@coralogix/browser 3.2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 3.4.0 (2026-02-26)
2
+
3
+ ### 🚀 Features
4
+
5
+ - add numeric ID grouping to default URL blueprinter
6
+
7
+ ## 3.3.0 (2026-02-24)
8
+
9
+ ### 🚀 Features
10
+
11
+ - Enrich spans with RUM context (cx_rum) to improve RUM–Tracing correlation.
12
+
1
13
  ## 3.2.0 (2026-02-05)
2
14
 
3
15
  - Create new zoneless CDN for Angular consumers
package/index.esm2.js CHANGED
@@ -2490,9 +2490,25 @@ var idPatterns = [
2490
2490
  replacement: ID_MASK_KEY,
2491
2491
  },
2492
2492
  ];
2493
+ var PATH_ID_PLACEHOLDER = '/{id}';
2494
+ var NUMERIC_PATH_SEGMENT_REGEX = /\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g;
2495
+ function replaceNumericPathSegments(url) {
2496
+ var replacePath = function (s) { return s.replace(NUMERIC_PATH_SEGMENT_REGEX, PATH_ID_PLACEHOLDER); };
2497
+ try {
2498
+ var origin_1 = new URL(url).origin;
2499
+ if (origin_1 === 'null' || !url.startsWith(origin_1))
2500
+ return url;
2501
+ return origin_1 + replacePath(url.slice(origin_1.length));
2502
+ }
2503
+ catch (_a) {
2504
+ return replacePath(url);
2505
+ }
2506
+ }
2493
2507
  var defaultUrlBlueprinters = {
2494
2508
  pageUrlBlueprinters: [
2495
- function (url) { return replacePatternsInUrl({ patterns: idPatterns, url: url }); },
2509
+ function (url) {
2510
+ return replaceNumericPathSegments(replacePatternsInUrl({ patterns: idPatterns, url: url }));
2511
+ },
2496
2512
  ],
2497
2513
  };
2498
2514
  var OPTIONS_DEFAULTS = {
@@ -2794,26 +2810,6 @@ function rateForTBTMetricValue(value) {
2794
2810
  return 'good';
2795
2811
  }
2796
2812
  }
2797
- function flattenAttributes(attributes) {
2798
- var e_4, _a;
2799
- var customLabels = JSON.parse(attributes[CoralogixAttributes.CUSTOM_LABELS]);
2800
- var flatAttributes = omit(attributes, CoralogixAttributes.CUSTOM_LABELS);
2801
- try {
2802
- for (var _b = __values$1(Object.entries(customLabels)), _c = _b.next(); !_c.done; _c = _b.next()) {
2803
- var _d = __read$1(_c.value, 2), key = _d[0], value = _d[1];
2804
- flatAttributes[key] =
2805
- typeof value !== 'string' ? JSON.stringify(value) : value;
2806
- }
2807
- }
2808
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
2809
- finally {
2810
- try {
2811
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2812
- }
2813
- finally { if (e_4) throw e_4.error; }
2814
- }
2815
- return flatAttributes;
2816
- }
2817
2813
  var getCircularReplacer = function () {
2818
2814
  var seen = new WeakSet();
2819
2815
  return function (key, value) {
@@ -4152,7 +4148,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
4152
4148
  return resolvedUrlBlueprinters;
4153
4149
  }
4154
4150
 
4155
- var SDK_VERSION = '3.2.0';
4151
+ var SDK_VERSION = '3.4.0';
4156
4152
 
4157
4153
  function shouldDropEvent(cxRumEvent, options) {
4158
4154
  if (isDocumentErrorWithoutMessage(cxRumEvent)) {
@@ -4218,6 +4214,54 @@ function editableToCxRumEvent(editable, cxRumEvent) {
4218
4214
  return __assign(__assign(__assign({}, cxRumEvent), editable), { session_context: __assign(__assign({}, cxRumEvent.session_context), editable.session_context) });
4219
4215
  }
4220
4216
 
4217
+ function buildCxRumSpanAttributes(attrs) {
4218
+ var e_1, _a;
4219
+ var result = {};
4220
+ try {
4221
+ for (var _b = __values$1(Object.entries(attrs)), _c = _b.next(); !_c.done; _c = _b.next()) {
4222
+ var _d = __read$1(_c.value, 2), key = _d[0], value = _d[1];
4223
+ if (value !== undefined && value !== null) {
4224
+ result[key] = value;
4225
+ }
4226
+ }
4227
+ }
4228
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
4229
+ finally {
4230
+ try {
4231
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4232
+ }
4233
+ finally { if (e_1) throw e_1.error; }
4234
+ }
4235
+ return result;
4236
+ }
4237
+ function flattenToAttributes(obj, prefix) {
4238
+ var e_2, _a;
4239
+ var result = {};
4240
+ if (!obj)
4241
+ return result;
4242
+ try {
4243
+ for (var _b = __values$1(Object.entries(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
4244
+ var _d = __read$1(_c.value, 2), key = _d[0], value = _d[1];
4245
+ if (value != null) {
4246
+ result["".concat(prefix).concat(key)] = typeof value === 'string' ? value : JSON.stringify(value);
4247
+ }
4248
+ }
4249
+ }
4250
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
4251
+ finally {
4252
+ try {
4253
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4254
+ }
4255
+ finally { if (e_2) throw e_2.error; }
4256
+ }
4257
+ return result;
4258
+ }
4259
+ function buildRumContextAttributes(cxRumEvent, resolvedLabels) {
4260
+ var session_context = cxRumEvent.session_context, page_context = cxRumEvent.page_context, event_context = cxRumEvent.event_context, error_context = cxRumEvent.error_context, network_request_context = cxRumEvent.network_request_context;
4261
+ var prefixedLabels = flattenToAttributes(resolvedLabels, 'cx_rum.labels.');
4262
+ return buildCxRumSpanAttributes(__assign(__assign({ 'cx_rum.browser_sdk.version': cxRumEvent.browser_sdk.version, 'cx_rum.platform': cxRumEvent.platform, 'cx_rum.environment': cxRumEvent.environment, 'cx_rum.version_metadata.app_name': cxRumEvent.version_metadata.app_name, 'cx_rum.version_metadata.app_version': cxRumEvent.version_metadata.app_version }, prefixedLabels), { 'cx_rum.session_context.os': session_context === null || session_context === void 0 ? void 0 : session_context.os, 'cx_rum.session_context.osVersion': session_context === null || session_context === void 0 ? void 0 : session_context.osVersion, 'cx_rum.session_context.browser': session_context === null || session_context === void 0 ? void 0 : session_context.browser, 'cx_rum.session_context.browserVersion': session_context === null || session_context === void 0 ? void 0 : session_context.browserVersion, 'cx_rum.session_context.device': session_context === null || session_context === void 0 ? void 0 : session_context.device, 'cx_rum.session_context.user_agent': session_context === null || session_context === void 0 ? void 0 : session_context.user_agent, 'cx_rum.session_context.user_email': session_context === null || session_context === void 0 ? void 0 : session_context.user_email, 'cx_rum.session_context.user_id': session_context === null || session_context === void 0 ? void 0 : session_context.user_id, 'cx_rum.session_context.user_name': session_context === null || session_context === void 0 ? void 0 : session_context.user_name, 'cx_rum.page_context.page_fragments': page_context === null || page_context === void 0 ? void 0 : page_context.page_fragments, 'cx_rum.page_context.page_url_blueprint': page_context === null || page_context === void 0 ? void 0 : page_context.page_url_blueprint, 'cx_rum.event_context.type': event_context === null || event_context === void 0 ? void 0 : event_context.type, 'cx_rum.event_context.severity': event_context === null || event_context === void 0 ? void 0 : event_context.severity, 'cx_rum.error_context.error_type': error_context === null || error_context === void 0 ? void 0 : error_context.error_type, 'cx_rum.error_context.error_message': error_context === null || error_context === void 0 ? void 0 : error_context.error_message, 'cx_rum.network_request_context.fragments': network_request_context === null || network_request_context === void 0 ? void 0 : network_request_context.fragments, 'cx_rum.network_request_context.url': network_request_context === null || network_request_context === void 0 ? void 0 : network_request_context.url, 'cx_rum.network_request_context.status_code': network_request_context === null || network_request_context === void 0 ? void 0 : network_request_context.status_code, 'cx_rum.network_request_context.method': network_request_context === null || network_request_context === void 0 ? void 0 : network_request_context.method }));
4263
+ }
4264
+
4221
4265
  var CoralogixSpanMapProcessor = (function () {
4222
4266
  function CoralogixSpanMapProcessor() {
4223
4267
  this.sdkConfig = getSdkConfig();
@@ -4304,6 +4348,7 @@ var CoralogixSpanMapProcessor = (function () {
4304
4348
  }, labels: labels, environment: attributes[CoralogixAttributes.ENVIRONMENT] || '' }),
4305
4349
  },
4306
4350
  };
4351
+ var resolvedLabels = this.resolveLabels(cxSpan.text.cx_rum);
4307
4352
  if (shouldAddOtelAttr(span)) {
4308
4353
  cxSpan.text.cx_rum.spanId = spanId;
4309
4354
  cxSpan.text.cx_rum.traceId = traceId;
@@ -4313,8 +4358,6 @@ var CoralogixSpanMapProcessor = (function () {
4313
4358
  spanId: spanId,
4314
4359
  traceId: traceId,
4315
4360
  parentSpanId: parentSpanId,
4316
- name: name,
4317
- attributes: __assign(__assign(__assign({}, flattenAttributes(attributes)), this.resolveLabels(cxSpan.text.cx_rum)), { sessionId: sessionId }),
4318
4361
  startTime: startTime,
4319
4362
  endTime: endTime,
4320
4363
  status: severity === CoralogixLogSeverity.Error
@@ -4322,6 +4365,8 @@ var CoralogixSpanMapProcessor = (function () {
4322
4365
  kind: kind,
4323
4366
  duration: duration,
4324
4367
  sessionId: sessionId,
4368
+ name: name,
4369
+ attributes: buildRumContextAttributes(cxSpan.text.cx_rum, resolvedLabels),
4325
4370
  },
4326
4371
  otelResource: {
4327
4372
  attributes: resourceAttributes,
@@ -4329,7 +4374,7 @@ var CoralogixSpanMapProcessor = (function () {
4329
4374
  };
4330
4375
  }
4331
4376
  this.resolveContextFromSpan(cxSpan, span, eventType);
4332
- cxSpan.text.cx_rum.labels = this.resolveLabels(cxSpan.text.cx_rum);
4377
+ cxSpan.text.cx_rum.labels = resolvedLabels;
4333
4378
  return cxSpan;
4334
4379
  };
4335
4380
  CoralogixSpanMapProcessor.prototype.resolveContextFromSpan = function (cxSpan, span, eventType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/browser",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "Official Coralogix SDK for browsers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
@@ -0,0 +1,30 @@
1
+ import type { Attributes } from '@opentelemetry/api';
2
+ import type { CoralogixRumLabels, CxRumEvent } from '../types';
3
+ export interface CxRumSpanAttributes extends Attributes {
4
+ 'cx_rum.browser_sdk.version'?: string;
5
+ 'cx_rum.platform'?: string;
6
+ 'cx_rum.environment'?: string;
7
+ 'cx_rum.version_metadata.app_name'?: string;
8
+ 'cx_rum.version_metadata.app_version'?: string;
9
+ 'cx_rum.session_context.os'?: string;
10
+ 'cx_rum.session_context.osVersion'?: string;
11
+ 'cx_rum.session_context.browser'?: string;
12
+ 'cx_rum.session_context.browserVersion'?: string;
13
+ 'cx_rum.session_context.device'?: string;
14
+ 'cx_rum.session_context.user_agent'?: string;
15
+ 'cx_rum.session_context.user_email'?: string;
16
+ 'cx_rum.session_context.user_id'?: string;
17
+ 'cx_rum.session_context.user_name'?: string;
18
+ 'cx_rum.page_context.page_fragments'?: string;
19
+ 'cx_rum.page_context.page_url_blueprint'?: string;
20
+ 'cx_rum.event_context.type'?: string;
21
+ 'cx_rum.event_context.severity'?: number;
22
+ 'cx_rum.error_context.error_type'?: string;
23
+ 'cx_rum.error_context.error_message'?: string;
24
+ 'cx_rum.network_request_context.fragments'?: string;
25
+ 'cx_rum.network_request_context.url'?: string;
26
+ 'cx_rum.network_request_context.status_code'?: number;
27
+ 'cx_rum.network_request_context.method'?: string;
28
+ }
29
+ export declare function buildCxRumSpanAttributes(attrs: CxRumSpanAttributes): Attributes;
30
+ export declare function buildRumContextAttributes(cxRumEvent: CxRumEvent, resolvedLabels: CoralogixRumLabels): Attributes;
package/src/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.2.0";
1
+ export declare const SDK_VERSION = "3.4.0";