@coralogix/browser 2.0.0 → 2.2.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 +12 -0
- package/index.esm.js +128 -126
- package/package.json +1 -1
- package/src/coralogix-rum.d.ts +5 -1
- package/src/index.d.ts +1 -1
- package/src/instrumentations/helpers/performance-observer.helper.d.ts +3 -0
- package/src/processors/CoralogixExporter.d.ts +0 -5
- package/src/tools/getGlobalObject.d.ts +2 -5
- package/src/version.d.ts +1 -1
- /package/src/instrumentations/{instrumentation.helper.d.ts → helpers/instrumentation.helper.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 2.2.0 (2025-03-18)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- Update Coralogix configuration and improve performance observer handling
|
|
6
|
+
|
|
7
|
+
## 2.1.0 (2025-02-18)
|
|
8
|
+
|
|
9
|
+
### 🚀 Features
|
|
10
|
+
|
|
11
|
+
- Improved initialization for SSR applications.
|
|
12
|
+
|
|
1
13
|
# 2.0.0 (2025-01-29)
|
|
2
14
|
|
|
3
15
|
### 🚀 Features
|
package/index.esm.js
CHANGED
|
@@ -258,17 +258,44 @@ var INITIAL_SNAPSHOT_CONTEXT = {
|
|
|
258
258
|
hasScreenshot: false,
|
|
259
259
|
};
|
|
260
260
|
|
|
261
|
+
function getCxGlobal() {
|
|
262
|
+
if (typeof globalThis === 'object') {
|
|
263
|
+
return globalThis;
|
|
264
|
+
}
|
|
265
|
+
Object.defineProperty(Object.prototype, '__cx_global__', {
|
|
266
|
+
get: function () {
|
|
267
|
+
return this;
|
|
268
|
+
},
|
|
269
|
+
configurable: true,
|
|
270
|
+
});
|
|
271
|
+
var globalObject = __cx_global__;
|
|
272
|
+
delete Object.prototype.__cx_global__;
|
|
273
|
+
if (typeof globalObject !== 'object') {
|
|
274
|
+
if (typeof self === 'object') {
|
|
275
|
+
globalObject = self;
|
|
276
|
+
}
|
|
277
|
+
else if (typeof window === 'object') {
|
|
278
|
+
globalObject = window;
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
globalObject = {};
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return globalObject;
|
|
285
|
+
}
|
|
286
|
+
var CxGlobal = getCxGlobal();
|
|
287
|
+
|
|
261
288
|
function getSnapshotManager() {
|
|
262
|
-
return
|
|
289
|
+
return CxGlobal[SNAPSHOT_MANAGER_KEY];
|
|
263
290
|
}
|
|
264
291
|
function getSessionManager() {
|
|
265
|
-
return
|
|
292
|
+
return CxGlobal[SESSION_MANAGER_KEY];
|
|
266
293
|
}
|
|
267
294
|
function getSessionRecorder() {
|
|
268
|
-
return
|
|
295
|
+
return CxGlobal[SESSION_RECORDER_KEY];
|
|
269
296
|
}
|
|
270
297
|
function getSdkConfig() {
|
|
271
|
-
return
|
|
298
|
+
return CxGlobal[SDK_CONFIG_KEY];
|
|
272
299
|
}
|
|
273
300
|
|
|
274
301
|
var GLOBAL_SPAN_KEY = '__globalSpan__';
|
|
@@ -276,25 +303,25 @@ var CUSTOM_TRACER_KEY = '__customTracer__';
|
|
|
276
303
|
var CUSTOM_TRACER_IGNORED_INSTRUMENTS = '__customTracerIgnoredInstruments__';
|
|
277
304
|
|
|
278
305
|
function setGlobalSpan(globalSpan) {
|
|
279
|
-
|
|
306
|
+
CxGlobal[GLOBAL_SPAN_KEY] = globalSpan;
|
|
280
307
|
}
|
|
281
308
|
function getGlobalSpan() {
|
|
282
|
-
return
|
|
309
|
+
return CxGlobal[GLOBAL_SPAN_KEY];
|
|
283
310
|
}
|
|
284
311
|
function clearGlobalSpan() {
|
|
285
|
-
delete
|
|
312
|
+
delete CxGlobal[GLOBAL_SPAN_KEY];
|
|
286
313
|
}
|
|
287
314
|
function setCustomTracer(customTracer) {
|
|
288
|
-
|
|
315
|
+
CxGlobal[CUSTOM_TRACER_KEY] = customTracer;
|
|
289
316
|
}
|
|
290
317
|
function getCustomTracer() {
|
|
291
|
-
return
|
|
318
|
+
return CxGlobal[CUSTOM_TRACER_KEY];
|
|
292
319
|
}
|
|
293
320
|
function setCustomTracerIgnoredInstruments(ignoredInstruments) {
|
|
294
|
-
|
|
321
|
+
CxGlobal[CUSTOM_TRACER_IGNORED_INSTRUMENTS] = ignoredInstruments;
|
|
295
322
|
}
|
|
296
323
|
function getCustomTracerIgnoredInstruments() {
|
|
297
|
-
return
|
|
324
|
+
return CxGlobal[CUSTOM_TRACER_IGNORED_INSTRUMENTS];
|
|
298
325
|
}
|
|
299
326
|
function shouldAttachSpanToGlobalSpan(instrumentationType) {
|
|
300
327
|
var _a;
|
|
@@ -338,10 +365,10 @@ function shouldAddOtelAttr(span) {
|
|
|
338
365
|
return !!span[IS_OTEL_READY];
|
|
339
366
|
}
|
|
340
367
|
function setAttrProcessor(processor) {
|
|
341
|
-
|
|
368
|
+
CxGlobal[ATTR_PROCESSOR_KEY] = processor;
|
|
342
369
|
}
|
|
343
370
|
function getAttrProcessor() {
|
|
344
|
-
return
|
|
371
|
+
return CxGlobal[ATTR_PROCESSOR_KEY];
|
|
345
372
|
}
|
|
346
373
|
|
|
347
374
|
function setCustomLabelsForSpan(span, labels) {
|
|
@@ -450,7 +477,7 @@ function extractMetadataFromMfeStacktrace() {
|
|
|
450
477
|
return __generator(this, function (_c) {
|
|
451
478
|
switch (_c.label) {
|
|
452
479
|
case 0:
|
|
453
|
-
cachedMetadata =
|
|
480
|
+
cachedMetadata = CxGlobal[CACHED_METADATA_KEY];
|
|
454
481
|
MFE_METADATA_KEY = 'cx-metadata.json';
|
|
455
482
|
_a = __read$1(fileName.match(/https?:\/\/.*\//), 1), mfePath = _a[0];
|
|
456
483
|
if (!mfePath) return [3 /*break*/, 7];
|
|
@@ -477,7 +504,7 @@ function extractMetadataFromMfeStacktrace() {
|
|
|
477
504
|
}
|
|
478
505
|
return [3 /*break*/, 5];
|
|
479
506
|
case 5:
|
|
480
|
-
|
|
507
|
+
CxGlobal[CACHED_METADATA_KEY] = cachedMetadata.set(mfePath, metadata);
|
|
481
508
|
return [3 /*break*/, 7];
|
|
482
509
|
case 6:
|
|
483
510
|
metadata = cachedMetadata === null || cachedMetadata === undefined ? undefined : cachedMetadata.get(mfePath);
|
|
@@ -527,23 +554,23 @@ var CoralogixErrorInstrumentation = /** @class */ (function (_super) {
|
|
|
527
554
|
return (_a = obj === null || obj === undefined ? undefined : obj.message) !== null && _a !== undefined ? _a : JSON.stringify(obj, getCircularReplacer());
|
|
528
555
|
};
|
|
529
556
|
if (getSdkConfig().supportMfe) {
|
|
530
|
-
|
|
557
|
+
CxGlobal[CACHED_METADATA_KEY] = new Map();
|
|
531
558
|
}
|
|
532
559
|
return _this;
|
|
533
560
|
}
|
|
534
561
|
CoralogixErrorInstrumentation.prototype.init = function () { };
|
|
535
562
|
CoralogixErrorInstrumentation.prototype.enable = function () {
|
|
536
563
|
shimmer_1.wrap(console, 'error', _consoleErrorHandler(this));
|
|
537
|
-
|
|
538
|
-
|
|
564
|
+
CxGlobal.addEventListener('error', _errorListener(this));
|
|
565
|
+
CxGlobal.addEventListener('unhandledrejection', _unhandledRejectionListener(this));
|
|
539
566
|
document.documentElement.addEventListener('error', _documentErrorListener(this), {
|
|
540
567
|
capture: true,
|
|
541
568
|
});
|
|
542
569
|
};
|
|
543
570
|
CoralogixErrorInstrumentation.prototype.disable = function () {
|
|
544
571
|
shimmer_1.unwrap(console, 'error');
|
|
545
|
-
|
|
546
|
-
|
|
572
|
+
CxGlobal.removeEventListener('error', _errorListener(this));
|
|
573
|
+
CxGlobal.removeEventListener('unhandledrejection', _unhandledRejectionListener(this));
|
|
547
574
|
document.documentElement.removeEventListener('error', _documentErrorListener(this), { capture: true });
|
|
548
575
|
};
|
|
549
576
|
CoralogixErrorInstrumentation.prototype.report = function (source, arg) {
|
|
@@ -1298,7 +1325,8 @@ var IMG_EXTENSIONS = [
|
|
|
1298
1325
|
* because it's not maintained anymore, and we want to have control over the codebase.
|
|
1299
1326
|
* Also, we don't want to have a dependency on a package that is not maintained.
|
|
1300
1327
|
*/
|
|
1301
|
-
|
|
1328
|
+
|
|
1329
|
+
var h = 'undefined' != typeof CxGlobal ? CxGlobal : {},
|
|
1302
1330
|
k =
|
|
1303
1331
|
'function' == typeof Object.defineProperties
|
|
1304
1332
|
? Object.defineProperty
|
|
@@ -1450,8 +1478,8 @@ function C(a) {
|
|
|
1450
1478
|
a = a ? a : {};
|
|
1451
1479
|
this.w = !!a.useMutationObserver;
|
|
1452
1480
|
this.u = a.minValue || null;
|
|
1453
|
-
a =
|
|
1454
|
-
var b =
|
|
1481
|
+
a = CxGlobal.__tti && CxGlobal.__tti.e;
|
|
1482
|
+
var b = CxGlobal.__tti && CxGlobal.__tti.o;
|
|
1455
1483
|
this.a = a
|
|
1456
1484
|
? a.map(function (a) {
|
|
1457
1485
|
return { start: a.startTime, end: a.startTime + a.duration };
|
|
@@ -1475,7 +1503,7 @@ C.prototype.getFirstConsistentlyInteractive = function () {
|
|
|
1475
1503
|
a.s = b;
|
|
1476
1504
|
'complete' == document.readyState
|
|
1477
1505
|
? F(a)
|
|
1478
|
-
:
|
|
1506
|
+
: CxGlobal.addEventListener('load', function () {
|
|
1479
1507
|
F(a);
|
|
1480
1508
|
});
|
|
1481
1509
|
});
|
|
@@ -1494,7 +1522,7 @@ function G(a, b) {
|
|
|
1494
1522
|
var b = performance.timing.navigationStart,
|
|
1495
1523
|
d = B(a.g, a.b),
|
|
1496
1524
|
b =
|
|
1497
|
-
(
|
|
1525
|
+
(CxGlobal.a && CxGlobal.a.A ? 1e3 * CxGlobal.a.A().C - b : 0) ||
|
|
1498
1526
|
performance.timing.domContentLoadedEventEnd - b;
|
|
1499
1527
|
if (a.u) var f = a.u;
|
|
1500
1528
|
else
|
|
@@ -1556,14 +1584,34 @@ h.Object.defineProperties(C.prototype, {
|
|
|
1556
1584
|
},
|
|
1557
1585
|
});
|
|
1558
1586
|
var H = {
|
|
1559
|
-
getFirstConsistentlyInteractive: function (a) {
|
|
1587
|
+
getFirstConsistentlyInteractive: function (a = undefined) {
|
|
1560
1588
|
a = a ? a : {};
|
|
1561
|
-
return 'PerformanceLongTaskTiming' in
|
|
1589
|
+
return 'PerformanceLongTaskTiming' in CxGlobal
|
|
1562
1590
|
? new C(a).getFirstConsistentlyInteractive()
|
|
1563
1591
|
: Promise.resolve(null);
|
|
1564
1592
|
},
|
|
1565
1593
|
};
|
|
1566
1594
|
|
|
1595
|
+
function observeIfSupported(observer, entryType) {
|
|
1596
|
+
if (!isPerformanceObserverSupported()) {
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1599
|
+
try {
|
|
1600
|
+
observer.observe({ type: entryType, buffered: true });
|
|
1601
|
+
}
|
|
1602
|
+
catch (error) {
|
|
1603
|
+
observer.observe({ entryTypes: [entryType] });
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
function isPerformanceObserverSupported() {
|
|
1607
|
+
var _a;
|
|
1608
|
+
if (!((_a = CxGlobal === null || CxGlobal === undefined ? undefined : CxGlobal.PerformanceObserver) === null || _a === undefined ? undefined : _a.supportedEntryTypes)) {
|
|
1609
|
+
console.warn('Coralogix Browser SDK - browser does not support the required APIs ');
|
|
1610
|
+
return false;
|
|
1611
|
+
}
|
|
1612
|
+
return true;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1567
1615
|
var CoralogixWebVitalsInstrumentation = /** @class */ (function (_super) {
|
|
1568
1616
|
__extends(CoralogixWebVitalsInstrumentation, _super);
|
|
1569
1617
|
function CoralogixWebVitalsInstrumentation(config) {
|
|
@@ -1596,6 +1644,9 @@ var CoralogixWebVitalsInstrumentation = /** @class */ (function (_super) {
|
|
|
1596
1644
|
_this.metrics = isEmpty(config.metrics)
|
|
1597
1645
|
? ALL_WEB_VITALS_METRICS
|
|
1598
1646
|
: config.metrics;
|
|
1647
|
+
if (!isPerformanceObserverSupported()) {
|
|
1648
|
+
return _this;
|
|
1649
|
+
}
|
|
1599
1650
|
_this.registerToCoreWebVitalMetrics();
|
|
1600
1651
|
_this.registerToCalculatedWebVitalMetrics();
|
|
1601
1652
|
if (_this.isSoftNavsEnabled) {
|
|
@@ -1651,10 +1702,7 @@ var CoralogixWebVitalsInstrumentation = /** @class */ (function (_super) {
|
|
|
1651
1702
|
});
|
|
1652
1703
|
});
|
|
1653
1704
|
this.observers.push(softNavObserver);
|
|
1654
|
-
softNavObserver.
|
|
1655
|
-
type: PerformanceTypes.SoftNavigation,
|
|
1656
|
-
buffered: true,
|
|
1657
|
-
});
|
|
1705
|
+
observeIfSupported(softNavObserver, PerformanceTypes.SoftNavigation);
|
|
1658
1706
|
}
|
|
1659
1707
|
else {
|
|
1660
1708
|
console.warn('Coralogix Browser SDK - browser doesnt support soft navigation events');
|
|
@@ -1709,10 +1757,7 @@ var CoralogixWebVitalsInstrumentation = /** @class */ (function (_super) {
|
|
|
1709
1757
|
});
|
|
1710
1758
|
});
|
|
1711
1759
|
this.observers.push(loadingPageObserver);
|
|
1712
|
-
loadingPageObserver.
|
|
1713
|
-
type: PerformanceTypes.Navigation,
|
|
1714
|
-
buffered: true,
|
|
1715
|
-
});
|
|
1760
|
+
observeIfSupported(loadingPageObserver, PerformanceTypes.Navigation);
|
|
1716
1761
|
};
|
|
1717
1762
|
CoralogixWebVitalsInstrumentation.prototype.calculateAllTotalBlockingTime = function () {
|
|
1718
1763
|
var _this = this;
|
|
@@ -1728,10 +1773,7 @@ var CoralogixWebVitalsInstrumentation = /** @class */ (function (_super) {
|
|
|
1728
1773
|
};
|
|
1729
1774
|
});
|
|
1730
1775
|
this.observers.push(totalBLockingTimeObserver);
|
|
1731
|
-
totalBLockingTimeObserver.
|
|
1732
|
-
type: PerformanceTypes.LongTask,
|
|
1733
|
-
buffered: true,
|
|
1734
|
-
});
|
|
1776
|
+
observeIfSupported(totalBLockingTimeObserver, PerformanceTypes.LongTask);
|
|
1735
1777
|
H.getFirstConsistentlyInteractive().then(function (tti) {
|
|
1736
1778
|
var _a, _b;
|
|
1737
1779
|
if (tti) {
|
|
@@ -1742,7 +1784,7 @@ var CoralogixWebVitalsInstrumentation = /** @class */ (function (_super) {
|
|
|
1742
1784
|
id: generateWebVitalUniqueID(),
|
|
1743
1785
|
});
|
|
1744
1786
|
totalBLockingTimeObserver.disconnect();
|
|
1745
|
-
(_b = (_a =
|
|
1787
|
+
(_b = (_a = CxGlobal.__tti) === null || _a === undefined ? undefined : _a.o) === null || _b === undefined ? undefined : _b.disconnect();
|
|
1746
1788
|
}
|
|
1747
1789
|
});
|
|
1748
1790
|
};
|
|
@@ -1775,10 +1817,7 @@ var CoralogixLongTaskInstrumentation = /** @class */ (function (_super) {
|
|
|
1775
1817
|
return _this.createSpanFromLongTask(entry);
|
|
1776
1818
|
});
|
|
1777
1819
|
});
|
|
1778
|
-
this.longTaskObserver.
|
|
1779
|
-
type: PerformanceTypes.LongTask,
|
|
1780
|
-
buffered: true,
|
|
1781
|
-
});
|
|
1820
|
+
observeIfSupported(this.longTaskObserver, PerformanceTypes.LongTask);
|
|
1782
1821
|
};
|
|
1783
1822
|
CoralogixLongTaskInstrumentation.prototype.createSpanFromLongTask = function (entry) {
|
|
1784
1823
|
var longTaskSpan = this.tracer.startSpan(CoralogixEventType.LONG_TASK);
|
|
@@ -1864,10 +1903,7 @@ var CoralogixResourcesInstrumentation = /** @class */ (function (_super) {
|
|
|
1864
1903
|
}
|
|
1865
1904
|
});
|
|
1866
1905
|
});
|
|
1867
|
-
this.resourcesObserver.
|
|
1868
|
-
type: PerformanceTypes.Resource,
|
|
1869
|
-
buffered: true,
|
|
1870
|
-
});
|
|
1906
|
+
observeIfSupported(this.resourcesObserver, PerformanceTypes.Resource);
|
|
1871
1907
|
};
|
|
1872
1908
|
CoralogixResourcesInstrumentation.prototype.isProcessableResourceEntry = function (entry) {
|
|
1873
1909
|
var isAcceptedResourceType = ![
|
|
@@ -1941,47 +1977,11 @@ var CoralogixResourcesInstrumentation = /** @class */ (function (_super) {
|
|
|
1941
1977
|
return CoralogixResourcesInstrumentation;
|
|
1942
1978
|
}(InstrumentationBase));
|
|
1943
1979
|
|
|
1944
|
-
/**
|
|
1945
|
-
* access the global this consistently, making it suitable for various JavaScript contexts.
|
|
1946
|
-
* inspired by https://mathiasbynens.be/notes/globalthis
|
|
1947
|
-
*/
|
|
1948
|
-
function getGlobalObject() {
|
|
1949
|
-
if (typeof globalThis === 'object') {
|
|
1950
|
-
return globalThis;
|
|
1951
|
-
}
|
|
1952
|
-
Object.defineProperty(Object.prototype, '_dd_temp_', {
|
|
1953
|
-
get: function () {
|
|
1954
|
-
return this;
|
|
1955
|
-
},
|
|
1956
|
-
configurable: true,
|
|
1957
|
-
});
|
|
1958
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1959
|
-
// @ts-ignore _dd_temp is defined using defineProperty
|
|
1960
|
-
var globalObject = _dd_temp_;
|
|
1961
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1962
|
-
// @ts-ignore _dd_temp is defined using defineProperty
|
|
1963
|
-
delete Object.prototype._dd_temp_;
|
|
1964
|
-
if (typeof globalObject !== 'object') {
|
|
1965
|
-
// on safari _dd_temp_ is available on window but not globally
|
|
1966
|
-
// fallback on other browser globals check
|
|
1967
|
-
if (typeof self === 'object') {
|
|
1968
|
-
globalObject = self;
|
|
1969
|
-
}
|
|
1970
|
-
else if (typeof window === 'object') {
|
|
1971
|
-
globalObject = window;
|
|
1972
|
-
}
|
|
1973
|
-
else {
|
|
1974
|
-
globalObject = {};
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
return globalObject;
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
1980
|
/**
|
|
1981
1981
|
* Gets the original value for a DOM API that was potentially patched by Zone.js.
|
|
1982
1982
|
*/
|
|
1983
1983
|
function getZoneJsOriginalDom(target, name) {
|
|
1984
|
-
var browserWindow =
|
|
1984
|
+
var browserWindow = getCxGlobal();
|
|
1985
1985
|
var original;
|
|
1986
1986
|
if (browserWindow.Zone &&
|
|
1987
1987
|
typeof browserWindow.Zone.__symbol__ === 'function') {
|
|
@@ -2170,7 +2170,7 @@ var MEMORY_USAGE_INSTRUMENTATION_VERSION = '1.0.0';
|
|
|
2170
2170
|
var MEMORY_USAGE_DEFAULT_INTERVAL = 300000; // 5 minutes;
|
|
2171
2171
|
|
|
2172
2172
|
function isMeasureUserAgentSpecificMemoryAllowed() {
|
|
2173
|
-
if (!
|
|
2173
|
+
if (!CxGlobal.crossOriginIsolated) {
|
|
2174
2174
|
console.debug('Coralogix Browser SDK - measureUserAgentSpecificMemory() is only available in cross-origin-isolated pages.');
|
|
2175
2175
|
return false;
|
|
2176
2176
|
}
|
|
@@ -2630,20 +2630,20 @@ var PARAMS_SEPARATOR = '?';
|
|
|
2630
2630
|
var PROTOCOL_SEPARATOR = '://';
|
|
2631
2631
|
|
|
2632
2632
|
function saveInternalRumData(key, value) {
|
|
2633
|
-
if (!
|
|
2634
|
-
|
|
2633
|
+
if (!CxGlobal[RUM_INTERNAL_DATA_KEY]) {
|
|
2634
|
+
CxGlobal[RUM_INTERNAL_DATA_KEY] = {};
|
|
2635
2635
|
}
|
|
2636
|
-
|
|
2636
|
+
CxGlobal[RUM_INTERNAL_DATA_KEY][key] = value;
|
|
2637
2637
|
}
|
|
2638
2638
|
function getInternalRumData(key) {
|
|
2639
2639
|
var _a;
|
|
2640
|
-
return (_a =
|
|
2640
|
+
return (_a = CxGlobal[RUM_INTERNAL_DATA_KEY]) === null || _a === undefined ? undefined : _a[key];
|
|
2641
2641
|
}
|
|
2642
2642
|
|
|
2643
2643
|
var _a$1;
|
|
2644
|
-
var supportedPerformanceTypes = !((_a$1 =
|
|
2644
|
+
var supportedPerformanceTypes = !((_a$1 = CxGlobal === null || CxGlobal === undefined ? undefined : CxGlobal.PerformanceObserver) === null || _a$1 === undefined ? undefined : _a$1.supportedEntryTypes)
|
|
2645
2645
|
? new Set()
|
|
2646
|
-
: new Set(
|
|
2646
|
+
: new Set(CxGlobal.PerformanceObserver.supportedEntryTypes);
|
|
2647
2647
|
function valueEndWithOrInclude(value, extensions) {
|
|
2648
2648
|
return extensions.some(function (ex) { return value.endsWith(ex) || value.includes(ex); });
|
|
2649
2649
|
}
|
|
@@ -3677,7 +3677,7 @@ var CoralogixExporter = /** @class */ (function () {
|
|
|
3677
3677
|
return cxSpans;
|
|
3678
3678
|
}, []);
|
|
3679
3679
|
this.invokeLogRequest(instrumentationLogs);
|
|
3680
|
-
var cachedLogs = (
|
|
3680
|
+
var cachedLogs = (CxGlobal.cachedLogs = __spreadArray(__spreadArray([], __read$1((CxGlobal.cachedLogs || [])), false), __read$1(currentSpans), false));
|
|
3681
3681
|
var logsCounter = cachedLogs.length;
|
|
3682
3682
|
//check if we reached the limit of max rum events for session with error
|
|
3683
3683
|
if (logsCounter > maxRumEventsForSessionWithError && !sessionHasError) {
|
|
@@ -3703,7 +3703,7 @@ var CoralogixExporter = /** @class */ (function () {
|
|
|
3703
3703
|
}
|
|
3704
3704
|
};
|
|
3705
3705
|
CoralogixExporter.prototype.clearCachedDataForSessionWithError = function () {
|
|
3706
|
-
|
|
3706
|
+
CxGlobal.cachedLogs = [];
|
|
3707
3707
|
this.batchTimeDelay = BATCH_TIME_DELAY;
|
|
3708
3708
|
};
|
|
3709
3709
|
CoralogixExporter.prototype.shutdown = function () {
|
|
@@ -5035,7 +5035,7 @@ var WorkerManager = /** @class */ (function () {
|
|
|
5035
5035
|
if (workerUrl.startsWith('http://') || workerUrl.startsWith('https://')) {
|
|
5036
5036
|
return workerUrl;
|
|
5037
5037
|
}
|
|
5038
|
-
return "".concat(
|
|
5038
|
+
return "".concat(CxGlobal.location.origin).concat(workerUrl);
|
|
5039
5039
|
};
|
|
5040
5040
|
return WorkerManager;
|
|
5041
5041
|
}());
|
|
@@ -5119,7 +5119,7 @@ var SessionRecorder = /** @class */ (function () {
|
|
|
5119
5119
|
_this.batchTimeDelay = BATCH_TIME_DELAY;
|
|
5120
5120
|
}
|
|
5121
5121
|
};
|
|
5122
|
-
|
|
5122
|
+
CxGlobal[SESSION_RECORDER_KEY] = this;
|
|
5123
5123
|
this.sessionManager = sessionManager;
|
|
5124
5124
|
var onlySessionWithErrorMode = sessionManager.onlySessionWithErrorMode, maxRecordTimeForSessionWithError = sessionManager.maxRecordTimeForSessionWithError;
|
|
5125
5125
|
var maxMutations = recordConfig.maxMutations, autoStartSessionRecording = recordConfig.autoStartSessionRecording, workerUrl = recordConfig.workerUrl;
|
|
@@ -5128,7 +5128,7 @@ var SessionRecorder = /** @class */ (function () {
|
|
|
5128
5128
|
this.isAutoStartRecording = autoStartSessionRecording;
|
|
5129
5129
|
this.maxMutations = maxMutations !== null && maxMutations !== undefined ? maxMutations : MAX_MUTATIONS_FOR_SESSION_RECORDING;
|
|
5130
5130
|
this.recordConfig = this.prepareRecordConfig(recordConfig);
|
|
5131
|
-
if (
|
|
5131
|
+
if (CxGlobal.Worker) {
|
|
5132
5132
|
this.workerManager = new WorkerManager();
|
|
5133
5133
|
this.initializeSessionWorker(workerUrl);
|
|
5134
5134
|
}
|
|
@@ -5435,8 +5435,10 @@ var SessionIdle = /** @class */ (function () {
|
|
|
5435
5435
|
SessionIdle.prototype.trackActivity = function () {
|
|
5436
5436
|
var _a, _b;
|
|
5437
5437
|
(_b = (_a = this.stopCallbacks).removeActivityListeners) === null || _b === undefined ? undefined : _b.call(_a);
|
|
5438
|
-
|
|
5439
|
-
|
|
5438
|
+
if (typeof CxGlobal.addEventListener === 'function') {
|
|
5439
|
+
var stop_1 = addEventListeners(CxGlobal, ["touchstart" /* DOM_EVENT.TOUCH_START */, "keydown" /* DOM_EVENT.KEY_DOWN */, "mousemove" /* DOM_EVENT.MOUSE_MOVE */], this.idlenessEventsHandler, { capture: true, passive: true }).stop;
|
|
5440
|
+
this.stopCallbacks.removeActivityListeners = stop_1;
|
|
5441
|
+
}
|
|
5440
5442
|
};
|
|
5441
5443
|
return SessionIdle;
|
|
5442
5444
|
}());
|
|
@@ -5454,10 +5456,12 @@ var SessionManager = /** @class */ (function (_super) {
|
|
|
5454
5456
|
_this._cachedLogsSent = false;
|
|
5455
5457
|
_this._currentPageTimestamp = getNowTime();
|
|
5456
5458
|
_this.getPrevSession = function () {
|
|
5457
|
-
|
|
5459
|
+
var _a;
|
|
5460
|
+
return JSON.parse((_a = CxGlobal.sessionStorage) === null || _a === undefined ? undefined : _a.getItem(PREV_SESSION_KEY));
|
|
5458
5461
|
};
|
|
5459
5462
|
_this.getSession = function () {
|
|
5460
|
-
var
|
|
5463
|
+
var _a;
|
|
5464
|
+
var storedSession = JSON.parse((_a = CxGlobal.sessionStorage) === null || _a === undefined ? undefined : _a.getItem(SESSION_KEY));
|
|
5461
5465
|
var now = getNowTime();
|
|
5462
5466
|
var session;
|
|
5463
5467
|
if (storedSession) {
|
|
@@ -5472,7 +5476,7 @@ var SessionManager = /** @class */ (function (_super) {
|
|
|
5472
5476
|
return session;
|
|
5473
5477
|
};
|
|
5474
5478
|
_this.setSession = function (afterIdle) {
|
|
5475
|
-
var _a, _b, _c;
|
|
5479
|
+
var _a, _b, _c, _d;
|
|
5476
5480
|
if (afterIdle === undefined) { afterIdle = false; }
|
|
5477
5481
|
var shouldkeepSessionAfterReload = (_a = _this._sessionConfig) === null || _a === undefined ? undefined : _a.keepSessionAfterReload;
|
|
5478
5482
|
if (shouldkeepSessionAfterReload) {
|
|
@@ -5481,14 +5485,14 @@ var SessionManager = /** @class */ (function (_super) {
|
|
|
5481
5485
|
else {
|
|
5482
5486
|
_this.createNewSession();
|
|
5483
5487
|
}
|
|
5484
|
-
|
|
5488
|
+
(_b = CxGlobal.sessionStorage) === null || _b === undefined ? undefined : _b.setItem(SESSION_KEY, JSON.stringify(_this.activeSession));
|
|
5485
5489
|
var sessionRecorder = getSessionRecorder();
|
|
5486
5490
|
var shouldStartRecordingAfterIdle = afterIdle &&
|
|
5487
5491
|
!!(sessionRecorder === null || sessionRecorder === undefined ? undefined : sessionRecorder.recordingStopDueToTimeout) &&
|
|
5488
|
-
!!((
|
|
5492
|
+
!!((_c = _this.sessionRecorderConfig) === null || _c === undefined ? undefined : _c.enable);
|
|
5489
5493
|
if (shouldStartRecordingAfterIdle ||
|
|
5490
5494
|
(sessionRecorder === null || sessionRecorder === undefined ? undefined : sessionRecorder.getIsAutoStartRecording())) {
|
|
5491
|
-
(
|
|
5495
|
+
(_d = _this.sessionRecorder) === null || _d === undefined ? undefined : _d.startRecording();
|
|
5492
5496
|
}
|
|
5493
5497
|
return _this.activeSession;
|
|
5494
5498
|
};
|
|
@@ -5588,7 +5592,7 @@ var SessionManager = /** @class */ (function (_super) {
|
|
|
5588
5592
|
this.stopIdleListener();
|
|
5589
5593
|
};
|
|
5590
5594
|
SessionManager.prototype.initializeSession = function (recordConfig) {
|
|
5591
|
-
|
|
5595
|
+
CxGlobal[SESSION_MANAGER_KEY] = this;
|
|
5592
5596
|
this.sessionRecorderConfig = recordConfig;
|
|
5593
5597
|
if (recordConfig === null || recordConfig === undefined ? undefined : recordConfig.enable) {
|
|
5594
5598
|
var recordingSamplingEnabled = isSamplingOn(recordConfig.sessionRecordingSampleRate);
|
|
@@ -5610,28 +5614,29 @@ var SessionManager = /** @class */ (function (_super) {
|
|
|
5610
5614
|
this.clearSession();
|
|
5611
5615
|
};
|
|
5612
5616
|
SessionManager.prototype.clearPrevSession = function () {
|
|
5613
|
-
|
|
5617
|
+
var _a;
|
|
5618
|
+
(_a = CxGlobal.sessionStorage) === null || _a === undefined ? undefined : _a.removeItem(PREV_SESSION_KEY);
|
|
5614
5619
|
};
|
|
5615
5620
|
SessionManager.prototype.clearSession = function () {
|
|
5616
|
-
var _a, _b, _c, _d;
|
|
5617
|
-
|
|
5621
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5622
|
+
(_a = CxGlobal.sessionStorage) === null || _a === undefined ? undefined : _a.setItem(PREV_SESSION_KEY, JSON.stringify(__assign(__assign({}, this.activeSession), { hasRecording: (_b = this.sessionRecorder) === null || _b === undefined ? undefined : _b.getSessionHasRecording(), hasScreenshot: (_c = this.sessionRecorder) === null || _c === undefined ? undefined : _c.getSessionHasScreenshot() })));
|
|
5618
5623
|
clearGlobalSpan();
|
|
5619
5624
|
this.clearSessionWithErrorMode();
|
|
5620
|
-
(
|
|
5625
|
+
(_d = getSnapshotManager()) === null || _d === undefined ? undefined : _d.resetSnapshot();
|
|
5621
5626
|
this._currentPageFragment = undefined;
|
|
5622
|
-
(
|
|
5623
|
-
|
|
5627
|
+
(_e = this.sessionRecorder) === null || _e === undefined ? undefined : _e.stopRecording();
|
|
5628
|
+
(_f = CxGlobal.sessionStorage) === null || _f === undefined ? undefined : _f.removeItem(SESSION_KEY);
|
|
5624
5629
|
};
|
|
5625
5630
|
SessionManager.prototype.clearSessionWithErrorMode = function () {
|
|
5626
5631
|
this.sessionHasError = false;
|
|
5627
5632
|
this.cachedLogsSent = false;
|
|
5628
5633
|
};
|
|
5629
5634
|
SessionManager.prototype.handleRefreshedSessions = function () {
|
|
5630
|
-
var _a;
|
|
5635
|
+
var _a, _b;
|
|
5631
5636
|
this.activeSession = this.getSession();
|
|
5632
|
-
var recordingSegmentMapFromStorage = JSON.parse(
|
|
5637
|
+
var recordingSegmentMapFromStorage = JSON.parse(((_a = CxGlobal.sessionStorage) === null || _a === undefined ? undefined : _a.getItem(SESSION_RECORDER_SEGMENTS_MAP)) || '{}');
|
|
5633
5638
|
if (this.activeSession) {
|
|
5634
|
-
(
|
|
5639
|
+
(_b = getSessionRecorder()) === null || _b === undefined ? undefined : _b.updateSegmentIndexCounter(recordingSegmentMapFromStorage);
|
|
5635
5640
|
}
|
|
5636
5641
|
else {
|
|
5637
5642
|
this.createNewSession();
|
|
@@ -5786,7 +5791,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
|
|
|
5786
5791
|
return resolvedUrlBlueprinters;
|
|
5787
5792
|
}
|
|
5788
5793
|
|
|
5789
|
-
var SDK_VERSION = '2.
|
|
5794
|
+
var SDK_VERSION = '2.2.0';
|
|
5790
5795
|
|
|
5791
5796
|
function shouldDropEvent(cxRumEvent, options) {
|
|
5792
5797
|
if (isDocumentErrorWithoutMessage(cxRumEvent)) {
|
|
@@ -6211,7 +6216,7 @@ var SnapshotManager = /** @class */ (function () {
|
|
|
6211
6216
|
_this._fragmentsState = new Set();
|
|
6212
6217
|
_this._isSnapshotSentDueToRecording = false;
|
|
6213
6218
|
};
|
|
6214
|
-
|
|
6219
|
+
CxGlobal[SNAPSHOT_MANAGER_KEY] = this;
|
|
6215
6220
|
this.resetSnapshot();
|
|
6216
6221
|
}
|
|
6217
6222
|
Object.defineProperty(SnapshotManager.prototype, "fragmentsState", {
|
|
@@ -6274,16 +6279,13 @@ function getTiming(duration) {
|
|
|
6274
6279
|
}
|
|
6275
6280
|
|
|
6276
6281
|
if (supportedPerformanceTypes.has(PerformanceTypes.LongTask)) {
|
|
6277
|
-
var ttiHandler_1 = (
|
|
6282
|
+
var ttiHandler_1 = (CxGlobal.__tti = {
|
|
6278
6283
|
e: [],
|
|
6279
6284
|
});
|
|
6280
6285
|
ttiHandler_1.o = new PerformanceObserver(function (list) {
|
|
6281
6286
|
ttiHandler_1.e = ttiHandler_1.e.concat(list.getEntries());
|
|
6282
6287
|
});
|
|
6283
|
-
ttiHandler_1.o.
|
|
6284
|
-
type: PerformanceTypes.LongTask,
|
|
6285
|
-
buffered: true,
|
|
6286
|
-
});
|
|
6288
|
+
observeIfSupported(ttiHandler_1.o, PerformanceTypes.LongTask);
|
|
6287
6289
|
}
|
|
6288
6290
|
var isInited = false;
|
|
6289
6291
|
var _deregisterInstrumentations;
|
|
@@ -6310,8 +6312,8 @@ var CoralogixRum = {
|
|
|
6310
6312
|
console.warn('CoralogixRum already inited.');
|
|
6311
6313
|
return;
|
|
6312
6314
|
}
|
|
6313
|
-
// Abort if
|
|
6314
|
-
if (
|
|
6315
|
+
// Abort if not in browser environment.
|
|
6316
|
+
if (!CxGlobal.sessionStorage) {
|
|
6315
6317
|
console.warn('CoralogixRum: Non-browser environment detected, aborting');
|
|
6316
6318
|
return;
|
|
6317
6319
|
}
|
|
@@ -6324,7 +6326,7 @@ var CoralogixRum = {
|
|
|
6324
6326
|
if (!resolvedOptions) {
|
|
6325
6327
|
return;
|
|
6326
6328
|
}
|
|
6327
|
-
|
|
6329
|
+
CxGlobal[SDK_CONFIG_KEY] = resolvedOptions;
|
|
6328
6330
|
var sampler = getResolvedSampler(resolvedOptions);
|
|
6329
6331
|
// Check if not in debug mode & no auth token.
|
|
6330
6332
|
if (!resolvedOptions.debug && !resolvedOptions.public_key) {
|
|
@@ -6639,7 +6641,7 @@ var CoralogixRum = {
|
|
|
6639
6641
|
}
|
|
6640
6642
|
},
|
|
6641
6643
|
};
|
|
6642
|
-
|
|
6644
|
+
CxGlobal.CoralogixRum = CoralogixRum;
|
|
6643
6645
|
|
|
6644
6646
|
var UrlBasedLabelProvider = /** @class */ (function () {
|
|
6645
6647
|
function UrlBasedLabelProvider(config) {
|
package/package.json
CHANGED
package/src/coralogix-rum.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { CoralogixOtelWebType, CoralogixWindow } from './types';
|
|
1
|
+
import { CoralogixOtelWebType, CoralogixWindow, CxSpan } from './types';
|
|
2
2
|
import { MemoryUsageContext } from './instrumentations/memory-usage';
|
|
3
3
|
declare global {
|
|
4
|
+
interface Object {
|
|
5
|
+
__cx_global__: unknown;
|
|
6
|
+
}
|
|
4
7
|
interface Window extends CoralogixWindow {
|
|
8
|
+
cachedLogs: CxSpan[];
|
|
5
9
|
}
|
|
6
10
|
interface Performance {
|
|
7
11
|
measureUserAgentSpecificMemory(): Promise<MemoryUsageContext>;
|
package/src/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { CoralogixRum } from './coralogix-rum';
|
|
|
2
2
|
export { CoralogixLogSeverity } from './types-external';
|
|
3
3
|
export { UrlBasedLabelProvider } from './label-providers/url-based-label-provider';
|
|
4
4
|
export * from './types';
|
|
5
|
-
export { SessionRecordingEventType, RecordEvent, RecordPluginEvent, } from './session/session.model';
|
|
5
|
+
export { SessionRecordingEventType, type RecordEvent, type RecordPluginEvent, } from './session/session.model';
|
|
@@ -6,11 +6,6 @@ import { ExportResult } from '@opentelemetry/core';
|
|
|
6
6
|
interface CxReadableSpan extends ReadableSpan {
|
|
7
7
|
[CX_MAPPED_SPAN]?: CxSpan;
|
|
8
8
|
}
|
|
9
|
-
declare global {
|
|
10
|
-
interface Window {
|
|
11
|
-
cachedLogs: CxSpan[];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
9
|
export declare class CoralogixExporter implements SpanExporter, ProcessorBaseModel {
|
|
15
10
|
isActive: boolean;
|
|
16
11
|
private sdkConfig;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* inspired by https://mathiasbynens.be/notes/globalthis
|
|
4
|
-
*/
|
|
5
|
-
export declare function getGlobalObject<T = typeof globalThis>(): T;
|
|
1
|
+
export declare function getCxGlobal<T = typeof globalThis>(): T;
|
|
2
|
+
export declare const CxGlobal: typeof globalThis;
|
package/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.
|
|
1
|
+
export declare const SDK_VERSION = "2.2.0";
|
/package/src/instrumentations/{instrumentation.helper.d.ts → helpers/instrumentation.helper.d.ts}
RENAMED
|
File without changes
|