@coralogix/browser 3.1.1 → 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,19 @@
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
+
13
+ ## 3.2.0 (2026-02-05)
14
+
15
+ - Create new zoneless CDN for Angular consumers
16
+
1
17
  ## 3.1.1 (2026-02-01)
2
18
 
3
19
  ### 🩹 Fixes
package/README.md CHANGED
@@ -1073,7 +1073,7 @@ window.CoralogixRum.init(...);
1073
1073
  // In case of warning from TSC
1074
1074
  declare global {
1075
1075
  interface Window {
1076
- CoralogixRum: CoralogixOtelWebType;
1076
+ CoralogixRum: any;
1077
1077
  }
1078
1078
  }
1079
1079
  ```
package/index.esm2.js CHANGED
@@ -593,9 +593,9 @@ var CoralogixErrorInstrumentation = (function (_super) {
593
593
  };
594
594
  CoralogixErrorInstrumentation.prototype.reportError = function (source, err, customData, labels) {
595
595
  return __awaiter(this, void 0, void 0, function () {
596
- var message, name, span, cleanMessage;
597
- return __generator(this, function (_a) {
598
- switch (_a.label) {
596
+ var message, name, span, cleanMessage, supportMfe;
597
+ return __generator(this, function (_b) {
598
+ switch (_b.label) {
599
599
  case 0:
600
600
  message = err.message, name = err.name;
601
601
  span = this.createSpan('error');
@@ -610,9 +610,16 @@ var CoralogixErrorInstrumentation = (function (_super) {
610
610
  if (labels) {
611
611
  setCustomLabelsForSpan(span, labels);
612
612
  }
613
+ supportMfe = getSdkConfig().supportMfe;
614
+ if (!supportMfe) return [3, 2];
613
615
  return [4, buildStacktrace(span, err)];
614
616
  case 1:
615
- _a.sent();
617
+ _b.sent();
618
+ return [3, 3];
619
+ case 2:
620
+ void buildStacktrace(span, err);
621
+ _b.label = 3;
622
+ case 3:
616
623
  span.end();
617
624
  return [2];
618
625
  }
@@ -2483,9 +2490,25 @@ var idPatterns = [
2483
2490
  replacement: ID_MASK_KEY,
2484
2491
  },
2485
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
+ }
2486
2507
  var defaultUrlBlueprinters = {
2487
2508
  pageUrlBlueprinters: [
2488
- function (url) { return replacePatternsInUrl({ patterns: idPatterns, url: url }); },
2509
+ function (url) {
2510
+ return replaceNumericPathSegments(replacePatternsInUrl({ patterns: idPatterns, url: url }));
2511
+ },
2489
2512
  ],
2490
2513
  };
2491
2514
  var OPTIONS_DEFAULTS = {
@@ -2787,26 +2810,6 @@ function rateForTBTMetricValue(value) {
2787
2810
  return 'good';
2788
2811
  }
2789
2812
  }
2790
- function flattenAttributes(attributes) {
2791
- var e_4, _a;
2792
- var customLabels = JSON.parse(attributes[CoralogixAttributes.CUSTOM_LABELS]);
2793
- var flatAttributes = omit(attributes, CoralogixAttributes.CUSTOM_LABELS);
2794
- try {
2795
- for (var _b = __values$1(Object.entries(customLabels)), _c = _b.next(); !_c.done; _c = _b.next()) {
2796
- var _d = __read$1(_c.value, 2), key = _d[0], value = _d[1];
2797
- flatAttributes[key] =
2798
- typeof value !== 'string' ? JSON.stringify(value) : value;
2799
- }
2800
- }
2801
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
2802
- finally {
2803
- try {
2804
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2805
- }
2806
- finally { if (e_4) throw e_4.error; }
2807
- }
2808
- return flatAttributes;
2809
- }
2810
2813
  var getCircularReplacer = function () {
2811
2814
  var seen = new WeakSet();
2812
2815
  return function (key, value) {
@@ -4145,7 +4148,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
4145
4148
  return resolvedUrlBlueprinters;
4146
4149
  }
4147
4150
 
4148
- var SDK_VERSION = '3.1.1';
4151
+ var SDK_VERSION = '3.4.0';
4149
4152
 
4150
4153
  function shouldDropEvent(cxRumEvent, options) {
4151
4154
  if (isDocumentErrorWithoutMessage(cxRumEvent)) {
@@ -4211,6 +4214,54 @@ function editableToCxRumEvent(editable, cxRumEvent) {
4211
4214
  return __assign(__assign(__assign({}, cxRumEvent), editable), { session_context: __assign(__assign({}, cxRumEvent.session_context), editable.session_context) });
4212
4215
  }
4213
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
+
4214
4265
  var CoralogixSpanMapProcessor = (function () {
4215
4266
  function CoralogixSpanMapProcessor() {
4216
4267
  this.sdkConfig = getSdkConfig();
@@ -4297,6 +4348,7 @@ var CoralogixSpanMapProcessor = (function () {
4297
4348
  }, labels: labels, environment: attributes[CoralogixAttributes.ENVIRONMENT] || '' }),
4298
4349
  },
4299
4350
  };
4351
+ var resolvedLabels = this.resolveLabels(cxSpan.text.cx_rum);
4300
4352
  if (shouldAddOtelAttr(span)) {
4301
4353
  cxSpan.text.cx_rum.spanId = spanId;
4302
4354
  cxSpan.text.cx_rum.traceId = traceId;
@@ -4306,8 +4358,6 @@ var CoralogixSpanMapProcessor = (function () {
4306
4358
  spanId: spanId,
4307
4359
  traceId: traceId,
4308
4360
  parentSpanId: parentSpanId,
4309
- name: name,
4310
- attributes: __assign(__assign(__assign({}, flattenAttributes(attributes)), this.resolveLabels(cxSpan.text.cx_rum)), { sessionId: sessionId }),
4311
4361
  startTime: startTime,
4312
4362
  endTime: endTime,
4313
4363
  status: severity === CoralogixLogSeverity.Error
@@ -4315,6 +4365,8 @@ var CoralogixSpanMapProcessor = (function () {
4315
4365
  kind: kind,
4316
4366
  duration: duration,
4317
4367
  sessionId: sessionId,
4368
+ name: name,
4369
+ attributes: buildRumContextAttributes(cxSpan.text.cx_rum, resolvedLabels),
4318
4370
  },
4319
4371
  otelResource: {
4320
4372
  attributes: resourceAttributes,
@@ -4322,7 +4374,7 @@ var CoralogixSpanMapProcessor = (function () {
4322
4374
  };
4323
4375
  }
4324
4376
  this.resolveContextFromSpan(cxSpan, span, eventType);
4325
- cxSpan.text.cx_rum.labels = this.resolveLabels(cxSpan.text.cx_rum);
4377
+ cxSpan.text.cx_rum.labels = resolvedLabels;
4326
4378
  return cxSpan;
4327
4379
  };
4328
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.1.1",
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;
@@ -1,6 +1 @@
1
- export interface BrowserWindowWithZoneJs extends Window {
2
- Zone?: {
3
- __symbol__?: (name: string) => string;
4
- };
5
- }
6
1
  export declare function getZoneJsOriginalDom<Target, Name extends keyof Target & string>(target: Target, name: Name): Target[Name];
@@ -0,0 +1,10 @@
1
+ export interface ZoneType {
2
+ root: ZoneType;
3
+ current: ZoneType;
4
+ __symbol__?: (name: string) => string;
5
+ run: <T>(fn: () => T) => T;
6
+ }
7
+ export declare function hasZoneJs(): boolean;
8
+ export declare function isInRootZone(): boolean;
9
+ export declare function runOutsideAngularZone<T>(fn: () => T): T;
10
+ export declare function patchAsyncApisForZone(): (() => void) | undefined;
package/src/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.1.1";
1
+ export declare const SDK_VERSION = "3.4.0";