@coralogix/browser 3.23.5 → 3.23.6

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,11 @@
1
+ ## 3.23.6 (2026-09-09)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - Prevent the browser tab from freezing on Safari and on every browser on iOS/iPadOS when an error is reported while the page is navigating away — a redirect on first visit, a link, or a form submit. The tab could hang at 100% CPU and grow in memory until the browser killed it, and the page being navigated to never loaded. Applications that load zone.js, such as Angular, were affected
6
+ - Prevent a `pageUrlBlueprinters` callback that throws from freezing the tab in any browser. Such a callback is now contained and reported once instead of looping; it still surfaces to your own error handling as before
7
+ - Stop the SDK's own error reporting from surfacing in your application as unhandled promise rejections
8
+
1
9
  ## 3.23.5 (2026-09-02)
2
10
 
3
11
  ### 🩹 Fixes
package/README.md CHANGED
@@ -960,7 +960,7 @@ CoralogixRum.init({
960
960
  > The `priority` hint only works in Chromium browsers (Chrome/Edge 101+) and is a no-op elsewhere. We type this option with our own `SdkFetchPriority` alias instead of the DOM `RequestPriority` type, so it still compiles on older TypeScript versions (the SDK supports `>= 4.4.2`).
961
961
 
962
962
  <!-- /split -->
963
- <!-- split title="Custom instrumentation" path="features/custom-instrumentation.md" -->
963
+ <!-- split title="Timing and measurements" path="features/timing-and-measurements.md" -->
964
964
  ### Custom Measurement
965
965
 
966
966
  Custom measurement allows you to send numeric data to Coralogix for precise monitoring and analysis.
@@ -1017,6 +1017,8 @@ A few behaviours worth knowing:
1017
1017
  - Ending a measurement releases its key, so the same key can be measured again afterwards.
1018
1018
  - Open measurements are dropped the next time you start or end one while the session is idle. The check runs on those calls rather than on a timer, and activity clears the idle flag, so a measurement spanning a short idle gap may still report.
1019
1019
 
1020
+ <!-- /split -->
1021
+ <!-- split title="Microfrontend support" path="configuration/microfrontend.md" -->
1020
1022
  ### Microfrontend support
1021
1023
 
1022
1024
  This feature allows you to track multiple applications on the same page.<br>
@@ -1035,6 +1037,8 @@ CoralogixRum.init({
1035
1037
  });
1036
1038
  ```
1037
1039
 
1040
+ <!-- /split -->
1041
+ <!-- split title="Custom spans" path="features/custom-spans.md" -->
1038
1042
  ### Custom Spans
1039
1043
 
1040
1044
  Create your own custom spans to track specific operations in your application.<br>
@@ -1095,6 +1099,8 @@ A few more things worth knowing:
1095
1099
  - Open global spans are ended for you when the session resets, which happens after an
1096
1100
  hour of session time or 15 minutes of inactivity.
1097
1101
 
1102
+ <!-- /split -->
1103
+ <!-- split title="Traces exporter" path="configuration/traces-exporter.md" -->
1098
1104
  ### Traces Exporter
1099
1105
 
1100
1106
  The `tracesExporter` callback gives you full control over how collected trace events are handled.
@@ -1135,6 +1141,8 @@ CoralogixRum.init({
1135
1141
  });
1136
1142
  ```
1137
1143
 
1144
+ <!-- /split -->
1145
+ <!-- split title="OpenTelemetry batching" path="configuration/opentelemetry-batching.md" -->
1138
1146
  ### OpenTelemetry Batch Configuration
1139
1147
 
1140
1148
  The SDK batches logs and traces through an OpenTelemetry `BatchSpanProcessor` before sending them to Coralogix. Use `otelConfig` to tune that batching — for example, to flush less frequently and reduce the number of network requests your app makes.
@@ -1152,6 +1160,8 @@ CoralogixRum.init({
1152
1160
  });
1153
1161
  ```
1154
1162
 
1163
+ <!-- /split -->
1164
+ <!-- split title="Soft navigations" path="configuration/soft-navigations.md" -->
1155
1165
  ### Soft Navigations — Experimental
1156
1166
 
1157
1167
  Soft navigations are navigations that do not trigger a full page reload, such as SPA navigations. Defaults to false.
@@ -1169,6 +1179,8 @@ CoralogixRum.init({
1169
1179
  });
1170
1180
  ```
1171
1181
 
1182
+ <!-- /split -->
1183
+ <!-- split title="Memory usage" path="features/memory-usage.md" -->
1172
1184
  ### Memory Usage - Experimental
1173
1185
 
1174
1186
  Memory usage is a feature that allows you to track the memory usage of your application. It uses the [measureUserAgentSpecificMemory](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measureUserAgentSpecificMemory) API.<br>
package/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- export { s as CoralogixEventType, q as CoralogixLogSeverity, p as CoralogixRum, O as OtelNetworkAttrs, P as PerformanceTypes, r as SessionRecordingEventType, U as UrlBasedLabelProvider, t as UrlType } from './index.esm2.js';
1
+ export { t as CoralogixEventType, q as CoralogixLogSeverity, p as CoralogixRum, O as OtelNetworkAttrs, P as PerformanceTypes, r as SessionRecordingEventType, U as UrlBasedLabelProvider, u as UrlType } from './index.esm2.js';
2
2
  import 'tslib';
3
3
  import '@opentelemetry/sdk-trace-base';
4
4
  import '@opentelemetry/sdk-trace-web';
package/index.esm2.js CHANGED
@@ -268,32 +268,46 @@ function getCxGlobal() {
268
268
  }
269
269
  var CxGlobal = getCxGlobal();
270
270
 
271
+ var SDK_STORE_KEY = '__cx_store__';
272
+ var CACHED_LOGS_KEY = 'cachedLogs';
273
+ var globalWithStore = CxGlobal;
274
+ var sdkStore = globalWithStore[SDK_STORE_KEY] || (globalWithStore[SDK_STORE_KEY] = {});
275
+ var globalMirror = CxGlobal;
276
+ function setSdkState(key, value) {
277
+ sdkStore[key] = value;
278
+ globalMirror[key] = value;
279
+ }
280
+ function deleteSdkState(key) {
281
+ delete sdkStore[key];
282
+ delete globalMirror[key];
283
+ }
284
+
271
285
  var CLICK_SCREENSHOT_MANAGER_KEY = 'rumClickScreenshotManager';
272
286
 
273
287
  function getSnapshotManager() {
274
- return CxGlobal[SNAPSHOT_MANAGER_KEY];
288
+ return sdkStore[SNAPSHOT_MANAGER_KEY];
275
289
  }
276
290
  function getSessionManager() {
277
- return CxGlobal[SESSION_MANAGER_KEY];
291
+ return sdkStore[SESSION_MANAGER_KEY];
278
292
  }
279
293
  function getSessionRecorder() {
280
- return CxGlobal[SESSION_RECORDER_KEY];
294
+ return sdkStore[SESSION_RECORDER_KEY];
281
295
  }
282
296
  function getClickScreenshotManager() {
283
- return CxGlobal[CLICK_SCREENSHOT_MANAGER_KEY];
297
+ return sdkStore[CLICK_SCREENSHOT_MANAGER_KEY];
284
298
  }
285
299
  function getSdkConfig() {
286
- return CxGlobal[SDK_CONFIG_KEY];
300
+ return sdkStore[SDK_CONFIG_KEY];
287
301
  }
288
302
  function getUserAgentData() {
289
- return CxGlobal[USER_AGENT_KEY];
303
+ return sdkStore[USER_AGENT_KEY];
290
304
  }
291
305
  var TRACER_PROVIDER_KEY = '__cx_tracer_provider__';
292
306
  function setTracerProvider(provider) {
293
- CxGlobal[TRACER_PROVIDER_KEY] = provider;
307
+ setSdkState(TRACER_PROVIDER_KEY, provider);
294
308
  }
295
309
  function getTracerProvider() {
296
- return CxGlobal[TRACER_PROVIDER_KEY];
310
+ return sdkStore[TRACER_PROVIDER_KEY];
297
311
  }
298
312
  function flush() {
299
313
  var tracerProvider = getTracerProvider();
@@ -309,40 +323,40 @@ var CUSTOM_TRACER_IGNORED_INSTRUMENTS = '__customTracerIgnoredInstruments__';
309
323
 
310
324
  function addGlobalSpanByTraceId(traceId, globalSpan) {
311
325
  var _a;
312
- CxGlobal[GLOBAL_SPAN_MAP_KEY] = __assign(__assign({}, (CxGlobal[GLOBAL_SPAN_MAP_KEY] || {})), (_a = {}, _a[traceId] = globalSpan, _a));
326
+ setSdkState(GLOBAL_SPAN_MAP_KEY, __assign(__assign({}, (sdkStore[GLOBAL_SPAN_MAP_KEY] || {})), (_a = {}, _a[traceId] = globalSpan, _a)));
313
327
  }
314
328
  function getGlobalSpanByTraceId(traceId) {
315
329
  var _a;
316
- return (_a = CxGlobal[GLOBAL_SPAN_MAP_KEY]) === null || _a === void 0 ? void 0 : _a[traceId];
330
+ return (_a = sdkStore[GLOBAL_SPAN_MAP_KEY]) === null || _a === void 0 ? void 0 : _a[traceId];
317
331
  }
318
332
  function clearGlobalSpanMap() {
319
- var globalSpanMap = CxGlobal[GLOBAL_SPAN_MAP_KEY];
333
+ var globalSpanMap = sdkStore[GLOBAL_SPAN_MAP_KEY];
320
334
  Object.keys(globalSpanMap || {}).forEach(function (traceId) {
321
335
  var globalSpan = globalSpanMap[traceId];
322
336
  globalSpan === null || globalSpan === void 0 ? void 0 : globalSpan.endSpan();
323
337
  });
324
- delete CxGlobal[GLOBAL_SPAN_MAP_KEY];
338
+ deleteSdkState(GLOBAL_SPAN_MAP_KEY);
325
339
  }
326
340
  function setGlobalSpan(globalSpan) {
327
- CxGlobal[GLOBAL_SPAN_KEY] = globalSpan;
341
+ setSdkState(GLOBAL_SPAN_KEY, globalSpan);
328
342
  }
329
343
  function getGlobalSpan() {
330
- return CxGlobal[GLOBAL_SPAN_KEY];
344
+ return sdkStore[GLOBAL_SPAN_KEY];
331
345
  }
332
346
  function clearGlobalSpan() {
333
- delete CxGlobal[GLOBAL_SPAN_KEY];
347
+ deleteSdkState(GLOBAL_SPAN_KEY);
334
348
  }
335
349
  function setCustomTracer(customTracer) {
336
- CxGlobal[CUSTOM_TRACER_KEY] = customTracer;
350
+ setSdkState(CUSTOM_TRACER_KEY, customTracer);
337
351
  }
338
352
  function getActiveCustomTracer() {
339
- return CxGlobal[CUSTOM_TRACER_KEY];
353
+ return sdkStore[CUSTOM_TRACER_KEY];
340
354
  }
341
355
  function setCustomTracerIgnoredInstruments(ignoredInstruments) {
342
- CxGlobal[CUSTOM_TRACER_IGNORED_INSTRUMENTS] = ignoredInstruments;
356
+ setSdkState(CUSTOM_TRACER_IGNORED_INSTRUMENTS, ignoredInstruments);
343
357
  }
344
358
  function getCustomTracerIgnoredInstruments() {
345
- return CxGlobal[CUSTOM_TRACER_IGNORED_INSTRUMENTS];
359
+ return sdkStore[CUSTOM_TRACER_IGNORED_INSTRUMENTS];
346
360
  }
347
361
  function shouldAttachSpanToGlobalSpan(instrumentationType) {
348
362
  return getGlobalSpan() && !isInstrumentationIgnored(instrumentationType);
@@ -373,15 +387,15 @@ function shouldAddOtelAttr(span) {
373
387
  return !!span[IS_OTEL_READY];
374
388
  }
375
389
  function setAttrProcessor(processor) {
376
- CxGlobal[ATTR_PROCESSOR_KEY] = processor;
390
+ setSdkState(ATTR_PROCESSOR_KEY, processor);
377
391
  }
378
392
  function getAttrProcessor() {
379
- return CxGlobal[ATTR_PROCESSOR_KEY];
393
+ return sdkStore[ATTR_PROCESSOR_KEY];
380
394
  }
381
395
 
382
396
  function setCustomLabelsForSpan(span, labels) {
383
397
  if (labels === void 0) { labels = {}; }
384
- span.setAttribute(CoralogixAttributes.CUSTOM_LABELS, JSON.stringify(getCustomMergedLabels(labels)));
398
+ span.setAttribute(CoralogixAttributes.CUSTOM_LABELS, JSON.stringify(getCustomMergedLabels(labels), getCircularReplacer()));
385
399
  }
386
400
  function getCustomMergedLabels(labels) {
387
401
  var _a;
@@ -427,6 +441,12 @@ var STACK_FRAME_LIMIT = 50;
427
441
  var STACK_LINE_LIMIT = 1024;
428
442
  var MESSAGE_LIMIT = 1024;
429
443
  var MFE_PATH_PATTERN = /https?:\/\/.*\//;
444
+ function reportFailed(e) {
445
+ var _a;
446
+ if ((_a = getSdkConfig()) === null || _a === void 0 ? void 0 : _a.debug) {
447
+ console.warn('Coralogix Browser SDK - Error report failed', e);
448
+ }
449
+ }
430
450
  var V8_HEADER_PATTERN = /^Error\b/;
431
451
  function sanitizeConsoleErrorStack(stack) {
432
452
  var _a;
@@ -483,23 +503,29 @@ function parseStackFrames(err) {
483
503
  }
484
504
  function buildStacktrace(span, err) {
485
505
  return __awaiter(this, void 0, void 0, function () {
486
- var stackFrames, supportMfe;
487
- return __generator(this, function (_a) {
488
- switch (_a.label) {
506
+ var stackFrames, e_1;
507
+ var _a;
508
+ return __generator(this, function (_b) {
509
+ switch (_b.label) {
489
510
  case 0:
511
+ _b.trys.push([0, 3, , 4]);
490
512
  stackFrames = parseStackFrames(err);
491
513
  if (stackFrames.length === 0) {
492
514
  return [2];
493
515
  }
494
- supportMfe = getSdkConfig().supportMfe;
495
- if (!supportMfe) return [3, 2];
516
+ if (!((_a = getSdkConfig()) === null || _a === void 0 ? void 0 : _a.supportMfe)) return [3, 2];
496
517
  return [4, handleMFE(stackFrames, span)];
497
518
  case 1:
498
- _a.sent();
499
- _a.label = 2;
519
+ _b.sent();
520
+ _b.label = 2;
500
521
  case 2:
501
522
  span[ErrorAttributes.STACK] = stackFrames;
502
- return [2];
523
+ return [3, 4];
524
+ case 3:
525
+ e_1 = _b.sent();
526
+ reportFailed(e_1);
527
+ return [3, 4];
528
+ case 4: return [2];
503
529
  }
504
530
  });
505
531
  });
@@ -538,7 +564,7 @@ function addLabelForMFE(span, lastFrame) {
538
564
  }
539
565
  function fetchMfeMetadata(mfePath) {
540
566
  return __awaiter(this, void 0, void 0, function () {
541
- var response, _a, e_1;
567
+ var response, _a, e_2;
542
568
  var _b;
543
569
  return __generator(this, function (_c) {
544
570
  switch (_c.label) {
@@ -556,9 +582,9 @@ function fetchMfeMetadata(mfePath) {
556
582
  return [4, response.json()];
557
583
  case 2: return [2, __assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_c.sent())])), { mfePath: mfePath }])];
558
584
  case 3:
559
- e_1 = _c.sent();
585
+ e_2 = _c.sent();
560
586
  if ((_b = getSdkConfig()) === null || _b === void 0 ? void 0 : _b.debug) {
561
- console.warn('Coralogix Browser SDK - Error fetching metadata', e_1);
587
+ console.warn('Coralogix Browser SDK - Error fetching metadata', e_2);
562
588
  }
563
589
  return [2, undefined];
564
590
  case 4: return [2];
@@ -571,7 +597,7 @@ function extractMetadataFromMfeStacktrace() {
571
597
  var cachedMetadata, mfePath, pending;
572
598
  if (fileName === void 0) { fileName = ''; }
573
599
  return __generator(this, function (_a) {
574
- cachedMetadata = CxGlobal[CACHED_METADATA_KEY];
600
+ cachedMetadata = sdkStore[CACHED_METADATA_KEY];
575
601
  mfePath = extractMfePath(fileName);
576
602
  if (mfePath) {
577
603
  pending = cachedMetadata === null || cachedMetadata === void 0 ? void 0 : cachedMetadata.get(mfePath);
@@ -621,6 +647,7 @@ function addErrorDefaultAttributes(span) {
621
647
  var CoralogixErrorInstrumentation = (function (_super) {
622
648
  __extends(CoralogixErrorInstrumentation, _super);
623
649
  function CoralogixErrorInstrumentation(config) {
650
+ var _a;
624
651
  var _this = _super.call(this, ERROR_INSTRUMENTATION_NAME, ERROR_INSTRUMENTATION_VERSION, config) || this;
625
652
  _this.parseErrorObject = function (obj) {
626
653
  var _a;
@@ -631,14 +658,15 @@ var CoralogixErrorInstrumentation = (function (_super) {
631
658
  return obj === null || obj === void 0 ? void 0 : obj.toString();
632
659
  }
633
660
  };
634
- if (getSdkConfig().supportMfe) {
635
- CxGlobal[CACHED_METADATA_KEY] = new Map();
661
+ if ((_a = getSdkConfig()) === null || _a === void 0 ? void 0 : _a.supportMfe) {
662
+ setSdkState(CACHED_METADATA_KEY, new Map());
636
663
  }
637
664
  return _this;
638
665
  }
639
666
  CoralogixErrorInstrumentation.prototype.init = function () { };
640
667
  CoralogixErrorInstrumentation.prototype.enable = function () {
641
- var stackTraceLimit = getSdkConfig().stackTraceLimit;
668
+ var _a;
669
+ var stackTraceLimit = ((_a = getSdkConfig()) !== null && _a !== void 0 ? _a : {}).stackTraceLimit;
642
670
  if (stackTraceLimit) {
643
671
  Error.stackTraceLimit = stackTraceLimit;
644
672
  }
@@ -662,94 +690,115 @@ var CoralogixErrorInstrumentation = (function (_super) {
662
690
  return;
663
691
  }
664
692
  }
665
- switch (true) {
666
- case arg instanceof Error:
667
- this.reportError(source, arg);
668
- break;
669
- case arg instanceof ErrorEvent:
670
- this.reportErrorEvent(source, arg);
671
- break;
672
- case arg instanceof Event:
673
- this.reportEvent(source, arg);
674
- break;
675
- case typeof arg === 'string':
676
- this.reportString(source, arg, stackContextError);
677
- break;
678
- case arg instanceof Array: {
679
- var firstError = arg.find(function (x) { return x instanceof Error; });
680
- var message = arg
681
- .map(function (msg) {
682
- return typeof msg === 'string' ? msg : _this.parseErrorObject(msg);
683
- })
684
- .join(' ');
685
- var stackSourceError = firstError !== null && firstError !== void 0 ? firstError : stackContextError;
686
- this.reportString(source, message, stackSourceError);
687
- break;
693
+ try {
694
+ switch (true) {
695
+ case arg instanceof Error:
696
+ this.reportError(source, arg);
697
+ break;
698
+ case arg instanceof ErrorEvent:
699
+ this.reportErrorEvent(source, arg);
700
+ break;
701
+ case arg instanceof Event:
702
+ this.reportEvent(source, arg);
703
+ break;
704
+ case typeof arg === 'string':
705
+ this.reportString(source, arg, stackContextError);
706
+ break;
707
+ case arg instanceof Array: {
708
+ var firstError = arg.find(function (x) { return x instanceof Error; });
709
+ var message = arg
710
+ .map(function (msg) {
711
+ return typeof msg === 'string' ? msg : _this.parseErrorObject(msg);
712
+ })
713
+ .join(' ');
714
+ var stackSourceError = firstError !== null && firstError !== void 0 ? firstError : stackContextError;
715
+ this.reportString(source, message, stackSourceError);
716
+ break;
717
+ }
718
+ default:
719
+ this.reportString(source, typeof arg === 'string' ? arg : this.getPossibleEventMessage(arg));
688
720
  }
689
- default:
690
- this.reportString(source, typeof arg === 'string' ? arg : this.getPossibleEventMessage(arg));
721
+ }
722
+ catch (e) {
723
+ reportFailed(e);
691
724
  }
692
725
  };
693
726
  CoralogixErrorInstrumentation.prototype.reportError = function (source, err, customData, labels) {
694
727
  return __awaiter(this, void 0, void 0, function () {
695
- var message, name, span, cleanMessage, supportMfe;
696
- return __generator(this, function (_b) {
697
- switch (_b.label) {
728
+ var message, name_1, cleanMessage, data, span, e_3;
729
+ var _b;
730
+ return __generator(this, function (_c) {
731
+ switch (_c.label) {
698
732
  case 0:
699
- message = err.message, name = err.name;
700
- span = this.createSpan('error');
733
+ _c.trys.push([0, 4, , 5]);
734
+ message = err.message, name_1 = err.name;
701
735
  cleanMessage = message.split('\n')[0];
736
+ data = customData
737
+ ? JSON.stringify(customData, getCircularReplacer())
738
+ : undefined;
739
+ span = this.createSpan('error');
702
740
  addErrorDefaultAttributes(span);
703
741
  span.setAttribute(CoralogixAttributes.SOURCE, source);
704
- span.setAttribute(ErrorAttributes.TYPE, name);
742
+ span.setAttribute(ErrorAttributes.TYPE, name_1);
705
743
  span.setAttribute(ErrorAttributes.MESSAGE, cleanMessage);
706
- if (customData) {
707
- span[ErrorAttributes.DATA] = JSON.stringify(customData, getCircularReplacer());
744
+ if (data) {
745
+ span[ErrorAttributes.DATA] = data;
708
746
  }
709
747
  if (labels) {
710
748
  setCustomLabelsForSpan(span, labels);
711
749
  }
712
- supportMfe = getSdkConfig().supportMfe;
713
- if (!supportMfe) return [3, 2];
750
+ if (!((_b = getSdkConfig()) === null || _b === void 0 ? void 0 : _b.supportMfe)) return [3, 2];
714
751
  return [4, buildStacktrace(span, err)];
715
752
  case 1:
716
- _b.sent();
753
+ _c.sent();
717
754
  return [3, 3];
718
755
  case 2:
719
756
  void buildStacktrace(span, err);
720
- _b.label = 3;
757
+ _c.label = 3;
721
758
  case 3:
722
759
  span.end();
723
- return [2];
760
+ return [3, 5];
761
+ case 4:
762
+ e_3 = _c.sent();
763
+ reportFailed(e_3);
764
+ return [3, 5];
765
+ case 5: return [2];
724
766
  }
725
767
  });
726
768
  });
727
769
  };
728
770
  CoralogixErrorInstrumentation.prototype.reportString = function (source, message, stackError) {
729
771
  return __awaiter(this, void 0, void 0, function () {
730
- var span, supportMfe;
731
- return __generator(this, function (_b) {
732
- switch (_b.label) {
772
+ var cleanMessage, span, e_4;
773
+ var _b;
774
+ return __generator(this, function (_c) {
775
+ switch (_c.label) {
733
776
  case 0:
777
+ _c.trys.push([0, 5, , 6]);
778
+ cleanMessage = message === null || message === void 0 ? void 0 : message.substring(0, MESSAGE_LIMIT);
734
779
  span = this.createSpan(source);
735
780
  addErrorDefaultAttributes(span);
736
781
  span.setAttribute(CoralogixAttributes.SOURCE, source);
737
- span.setAttribute(ErrorAttributes.MESSAGE, message === null || message === void 0 ? void 0 : message.substring(0, MESSAGE_LIMIT));
738
- supportMfe = getSdkConfig().supportMfe;
782
+ span.setAttribute(ErrorAttributes.MESSAGE, cleanMessage);
739
783
  if (!stackError) return [3, 4];
740
- if (!supportMfe) return [3, 2];
784
+ if (!((_b = getSdkConfig()) === null || _b === void 0 ? void 0 : _b.supportMfe)) return [3, 2];
741
785
  return [4, buildStacktrace(span, stackError)];
742
786
  case 1:
743
- _b.sent();
787
+ _c.sent();
744
788
  return [3, 3];
745
789
  case 2:
746
790
  void buildStacktrace(span, stackError);
747
- _b.label = 3;
791
+ _c.label = 3;
748
792
  case 3:
749
- _b.label = 4;
793
+ _c.label = 4;
750
794
  case 4:
751
795
  span.end();
752
- return [2];
796
+ return [3, 6];
797
+ case 5:
798
+ e_4 = _c.sent();
799
+ reportFailed(e_4);
800
+ return [3, 6];
801
+ case 6: return [2];
753
802
  }
754
803
  });
755
804
  });
@@ -3363,14 +3412,14 @@ var PAGE_URL_PARTS_KEY = 'rum_page_url_parts';
3363
3412
  var REFERRER_URL_PARTS_KEY = 'rum_referrer_url_parts';
3364
3413
 
3365
3414
  function saveInternalRumData(key, value) {
3366
- if (!CxGlobal[RUM_INTERNAL_DATA_KEY]) {
3367
- CxGlobal[RUM_INTERNAL_DATA_KEY] = {};
3415
+ if (!sdkStore[RUM_INTERNAL_DATA_KEY]) {
3416
+ setSdkState(RUM_INTERNAL_DATA_KEY, {});
3368
3417
  }
3369
- CxGlobal[RUM_INTERNAL_DATA_KEY][key] = value;
3418
+ sdkStore[RUM_INTERNAL_DATA_KEY][key] = value;
3370
3419
  }
3371
3420
  function getInternalRumData(key) {
3372
3421
  var _a;
3373
- return (_a = CxGlobal[RUM_INTERNAL_DATA_KEY]) === null || _a === void 0 ? void 0 : _a[key];
3422
+ return (_a = sdkStore[RUM_INTERNAL_DATA_KEY]) === null || _a === void 0 ? void 0 : _a[key];
3374
3423
  }
3375
3424
 
3376
3425
  var _a$2;
@@ -3613,14 +3662,14 @@ function applyUrlBluePrinters(_a) {
3613
3662
  return blueprintedUrl;
3614
3663
  }
3615
3664
  function resolvePageContext(url) {
3616
- var _a;
3665
+ var _a, _b, _c, _d;
3617
3666
  var page_url_blueprint = applyUrlBluePrinters({
3618
3667
  url: url,
3619
- blueprinters: (_a = getSdkConfig().urlBlueprinters) === null || _a === void 0 ? void 0 : _a.pageUrlBlueprinters,
3668
+ blueprinters: (_b = (_a = getSdkConfig()) === null || _a === void 0 ? void 0 : _a.urlBlueprinters) === null || _b === void 0 ? void 0 : _b.pageUrlBlueprinters,
3620
3669
  });
3621
3670
  var page_fragments = getUrlFragments(page_url_blueprint);
3622
3671
  var urlParts = getCachedUrlParts(PAGE_URL_PARTS_KEY, url);
3623
- var referrerParts = getCachedUrlParts(REFERRER_URL_PARTS_KEY, document === null || document === void 0 ? void 0 : document.referrer);
3672
+ var referrerParts = getCachedUrlParts(REFERRER_URL_PARTS_KEY, (_c = CxGlobal.document) === null || _c === void 0 ? void 0 : _c.referrer);
3624
3673
  return {
3625
3674
  page_url: url.slice(0, MAX_CHARACTERS),
3626
3675
  page_url_blueprint: page_url_blueprint,
@@ -3629,7 +3678,7 @@ function resolvePageContext(url) {
3629
3678
  subdomain: urlParts === null || urlParts === void 0 ? void 0 : urlParts.subdomain,
3630
3679
  domain: urlParts === null || urlParts === void 0 ? void 0 : urlParts.domain,
3631
3680
  host: urlParts === null || urlParts === void 0 ? void 0 : urlParts.host,
3632
- referrer: document.referrer,
3681
+ referrer: (_d = CxGlobal.document) === null || _d === void 0 ? void 0 : _d.referrer,
3633
3682
  referrer_path: referrerParts === null || referrerParts === void 0 ? void 0 : referrerParts.path,
3634
3683
  referrer_schema: referrerParts === null || referrerParts === void 0 ? void 0 : referrerParts.schema,
3635
3684
  referrer_subdomain: referrerParts === null || referrerParts === void 0 ? void 0 : referrerParts.subdomain,
@@ -4449,7 +4498,8 @@ var CoralogixExporter = (function () {
4449
4498
  return cxSpans;
4450
4499
  }, []);
4451
4500
  this.invokeLogRequest(instrumentationLogs);
4452
- var cachedLogs = (CxGlobal.cachedLogs = __spreadArray(__spreadArray([], __read$1((CxGlobal.cachedLogs || [])), false), __read$1(currentSpans), false));
4501
+ var cachedLogs = __spreadArray(__spreadArray([], __read$1((sdkStore[CACHED_LOGS_KEY] || [])), false), __read$1(currentSpans), false);
4502
+ setSdkState(CACHED_LOGS_KEY, cachedLogs);
4453
4503
  var logsCounter = cachedLogs.length;
4454
4504
  if (logsCounter > maxRumEventsForSessionWithError && !sessionHasError) {
4455
4505
  this.clearCachedDataForSessionWithError();
@@ -4481,7 +4531,7 @@ var CoralogixExporter = (function () {
4481
4531
  return strippedLogs;
4482
4532
  };
4483
4533
  CoralogixExporter.prototype.clearCachedDataForSessionWithError = function () {
4484
- CxGlobal.cachedLogs = [];
4534
+ setSdkState(CACHED_LOGS_KEY, []);
4485
4535
  this.batchTimeDelay = BATCH_TIME_DELAY;
4486
4536
  };
4487
4537
  CoralogixExporter.prototype.shutdown = function () {
@@ -4575,7 +4625,7 @@ var SnapshotManager = (function () {
4575
4625
  _this._isSnapshotSentDueToRecording = false;
4576
4626
  clearStoredSnapshotState();
4577
4627
  };
4578
- CxGlobal[SNAPSHOT_MANAGER_KEY] = this;
4628
+ setSdkState(SNAPSHOT_MANAGER_KEY, this);
4579
4629
  if (!this.restoreSnapshot()) {
4580
4630
  this.resetSnapshot();
4581
4631
  }
@@ -4905,7 +4955,7 @@ var SessionManager = (function (_super) {
4905
4955
  return __generator(this, function (_a) {
4906
4956
  switch (_a.label) {
4907
4957
  case 0:
4908
- CxGlobal[SESSION_MANAGER_KEY] = this;
4958
+ setSdkState(SESSION_MANAGER_KEY, this);
4909
4959
  this.sessionRecorderConfig = recordConfig;
4910
4960
  if (!(recordConfig === null || recordConfig === void 0 ? void 0 : recordConfig.enable)) return [3, 3];
4911
4961
  recordingSamplingEnabled = isSamplingOn(recordConfig.sessionRecordingSampleRate);
@@ -5224,7 +5274,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
5224
5274
  return resolvedUrlBlueprinters;
5225
5275
  }
5226
5276
 
5227
- var SDK_VERSION = '3.23.5';
5277
+ var SDK_VERSION = '3.23.6';
5228
5278
 
5229
5279
  function shouldDropEvent(cxRumEvent, options) {
5230
5280
  if (isDocumentErrorWithoutMessage(cxRumEvent)) {
@@ -5754,17 +5804,18 @@ var CoralogixNavigationProcessor = (function () {
5754
5804
  this.isResolving = true;
5755
5805
  try {
5756
5806
  var pageContext = resolvePageContext(location.href);
5757
- if (pageContext) {
5807
+ var sessionManager = getSessionManager();
5808
+ if (pageContext && sessionManager) {
5758
5809
  span[CoralogixAttributes.PAGE_CONTEXT] = pageContext;
5759
- var previousPageFragment = getSessionManager().currentPageFragment;
5810
+ var previousPageFragment = sessionManager.currentPageFragment;
5760
5811
  var page_fragments = pageContext.page_fragments;
5761
5812
  if (previousPageFragment !== page_fragments) {
5762
- getSessionManager().updateCurrentPage(page_fragments);
5813
+ sessionManager.updateCurrentPage(page_fragments);
5763
5814
  span[CoralogixAttributes.IS_NAVIGATION_EVENT] = true;
5764
5815
  this.handlePageNavigation(previousPageFragment);
5765
5816
  (_a = getClickScreenshotManager()) === null || _a === void 0 ? void 0 : _a.onNavigation();
5766
5817
  }
5767
- span[CoralogixAttributes.VIEW_NUMBER] = getSessionManager().viewNumber;
5818
+ span[CoralogixAttributes.VIEW_NUMBER] = sessionManager.viewNumber;
5768
5819
  }
5769
5820
  }
5770
5821
  finally {
@@ -5772,8 +5823,9 @@ var CoralogixNavigationProcessor = (function () {
5772
5823
  }
5773
5824
  };
5774
5825
  CoralogixNavigationProcessor.prototype.handlePageNavigation = function (previousPageFragment) {
5826
+ var _a;
5775
5827
  if (previousPageFragment) {
5776
- getSessionManager().incrementViewNumber();
5828
+ (_a = getSessionManager()) === null || _a === void 0 ? void 0 : _a.incrementViewNumber();
5777
5829
  }
5778
5830
  };
5779
5831
  CoralogixNavigationProcessor.prototype.shutdown = function () {
@@ -5817,10 +5869,10 @@ var ClickScreenshotManager = (function () {
5817
5869
  CoralogixRum.screenshot(CX_PREFIX);
5818
5870
  }
5819
5871
  };
5820
- CxGlobal[CLICK_SCREENSHOT_MANAGER_KEY] = this;
5872
+ setSdkState(CLICK_SCREENSHOT_MANAGER_KEY, this);
5821
5873
  }
5822
5874
  ClickScreenshotManager.unregister = function () {
5823
- CxGlobal[CLICK_SCREENSHOT_MANAGER_KEY] = undefined;
5875
+ deleteSdkState(CLICK_SCREENSHOT_MANAGER_KEY);
5824
5876
  };
5825
5877
  return ClickScreenshotManager;
5826
5878
  }());
@@ -5900,8 +5952,8 @@ var CoralogixRum = {
5900
5952
  if (!resolvedOptions_1) {
5901
5953
  return;
5902
5954
  }
5903
- CxGlobal[USER_AGENT_KEY] = parseUserAgent(navigator.userAgent);
5904
- CxGlobal[SDK_CONFIG_KEY] = resolvedOptions_1;
5955
+ setSdkState(USER_AGENT_KEY, parseUserAgent(navigator.userAgent));
5956
+ setSdkState(SDK_CONFIG_KEY, resolvedOptions_1);
5905
5957
  var sampler = getResolvedSampler();
5906
5958
  if (!resolvedOptions_1.debug && !resolvedOptions_1.public_key) {
5907
5959
  console.warn('rumAuth will be required in the future');
@@ -6326,4 +6378,4 @@ var SessionRecordingEventType;
6326
6378
  SessionRecordingEventType[SessionRecordingEventType["Plugin"] = 6] = "Plugin";
6327
6379
  })(SessionRecordingEventType || (SessionRecordingEventType = {}));
6328
6380
 
6329
- export { BATCH_TIME_DELAY as B, CxGlobal as C, MAX_BATCH_TIME_MS as M, OtelNetworkAttrs as O, PerformanceTypes as P, Request as R, SESSION_RECORDER_SEGMENTS_MAP as S, UrlBasedLabelProvider as U, cxClearTimeout as a, createCxMutationObserver as b, cxSetTimeout as c, cxRequestAnimationFrame as d, cxCancelAnimationFrame as e, getSdkConfig as f, getZoneJsOriginalDom as g, cxClearInterval as h, getNowTime as i, SESSION_RECORDING_NETWORK_ERR0R_MESSAGE as j, cxSetInterval as k, SESSION_RECORDING_DEFAULT_HEADERS as l, SESSION_RECORDING_POSTFIX_URL as m, SESSION_RECORDER_KEY as n, SESSION_RECORDING_DEFAULT_ERROR_MESSAGE as o, CoralogixRum as p, CoralogixLogSeverity as q, SessionRecordingEventType as r, CoralogixEventType as s, UrlType as t };
6381
+ export { BATCH_TIME_DELAY as B, CxGlobal as C, MAX_BATCH_TIME_MS as M, OtelNetworkAttrs as O, PerformanceTypes as P, Request as R, SESSION_RECORDER_SEGMENTS_MAP as S, UrlBasedLabelProvider as U, cxClearTimeout as a, createCxMutationObserver as b, cxSetTimeout as c, cxRequestAnimationFrame as d, cxCancelAnimationFrame as e, getSdkConfig as f, getZoneJsOriginalDom as g, cxClearInterval as h, getNowTime as i, SESSION_RECORDING_NETWORK_ERR0R_MESSAGE as j, cxSetInterval as k, SESSION_RECORDING_DEFAULT_HEADERS as l, SESSION_RECORDING_POSTFIX_URL as m, SESSION_RECORDER_KEY as n, SESSION_RECORDING_DEFAULT_ERROR_MESSAGE as o, CoralogixRum as p, CoralogixLogSeverity as q, SessionRecordingEventType as r, setSdkState as s, CoralogixEventType as t, UrlType as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/browser",
3
- "version": "3.23.5",
3
+ "version": "3.23.6",
4
4
  "description": "Official Coralogix SDK for browsers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
@@ -1,5 +1,5 @@
1
1
  import { __values, __spreadArray, __read, __assign, __rest, __awaiter, __generator } from 'tslib';
2
- import { c as cxSetTimeout, a as cxClearTimeout, g as getZoneJsOriginalDom, b as createCxMutationObserver, d as cxRequestAnimationFrame, e as cxCancelAnimationFrame, C as CxGlobal, S as SESSION_RECORDER_SEGMENTS_MAP, f as getSdkConfig, h as cxClearInterval, i as getNowTime, j as SESSION_RECORDING_NETWORK_ERR0R_MESSAGE, k as cxSetInterval, R as Request, l as SESSION_RECORDING_DEFAULT_HEADERS, m as SESSION_RECORDING_POSTFIX_URL, B as BATCH_TIME_DELAY, n as SESSION_RECORDER_KEY, o as SESSION_RECORDING_DEFAULT_ERROR_MESSAGE, M as MAX_BATCH_TIME_MS } from './index.esm2.js';
2
+ import { c as cxSetTimeout, a as cxClearTimeout, g as getZoneJsOriginalDom, b as createCxMutationObserver, d as cxRequestAnimationFrame, e as cxCancelAnimationFrame, C as CxGlobal, S as SESSION_RECORDER_SEGMENTS_MAP, f as getSdkConfig, h as cxClearInterval, i as getNowTime, j as SESSION_RECORDING_NETWORK_ERR0R_MESSAGE, k as cxSetInterval, R as Request, l as SESSION_RECORDING_DEFAULT_HEADERS, m as SESSION_RECORDING_POSTFIX_URL, B as BATCH_TIME_DELAY, s as setSdkState, n as SESSION_RECORDER_KEY, o as SESSION_RECORDING_DEFAULT_ERROR_MESSAGE, M as MAX_BATCH_TIME_MS } from './index.esm2.js';
3
3
  import '@opentelemetry/sdk-trace-base';
4
4
  import '@opentelemetry/sdk-trace-web';
5
5
  import '@opentelemetry/instrumentation';
@@ -5793,7 +5793,7 @@ var SessionRecorder = (function () {
5793
5793
  _this.batchTimeDelay = BATCH_TIME_DELAY;
5794
5794
  }
5795
5795
  };
5796
- CxGlobal[SESSION_RECORDER_KEY] = this;
5796
+ setSdkState(SESSION_RECORDER_KEY, this);
5797
5797
  this.sessionManager = sessionManager;
5798
5798
  if ((_b = getSdkConfig().sessionConfig) === null || _b === void 0 ? void 0 : _b.keepSessionAfterReload) {
5799
5799
  this.restoreSegmentIndexCounter();
@@ -0,0 +1,6 @@
1
+ export declare const SDK_STORE_KEY = "__cx_store__";
2
+ export declare const CACHED_LOGS_KEY = "cachedLogs";
3
+ export type SdkStore = Record<string, any>;
4
+ export declare const sdkStore: SdkStore;
5
+ export declare function setSdkState(key: string, value: unknown): void;
6
+ export declare function deleteSdkState(key: string): void;
package/src/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.23.5";
1
+ export declare const SDK_VERSION = "3.23.6";