@coralogix/browser 2.8.6 → 2.8.8

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/index.esm2.js CHANGED
@@ -1,150 +1,15 @@
1
+ import { __assign, __extends, __awaiter, __generator, __read as __read$1, __spreadArray, __rest, __values as __values$1 } from 'tslib';
1
2
  import { SamplingDecision, AlwaysOnSampler, BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
2
3
  import { getElementXPath, WebTracerProvider } from '@opentelemetry/sdk-trace-web';
3
4
  import { InstrumentationBase, registerInstrumentations } from '@opentelemetry/instrumentation';
5
+ import ErrorStackParser from 'error-stack-parser';
4
6
  import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
5
7
  import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';
6
8
  import { onFID, onCLS, onLCP, onFCP, onINP, onTTFB } from 'web-vitals/attribution';
7
- import { ExportResultCode, W3CBaggagePropagator, W3CTraceContextPropagator, CompositePropagator } from '@opentelemetry/core';
8
- import { trace, context } from '@opentelemetry/api';
9
+ import { createContextKey, baggageEntryMetadataFromString, propagation, diag, trace, isSpanContextValid, TraceFlags, context } from '@opentelemetry/api';
9
10
  import { B3Propagator, B3InjectEncoding } from '@opentelemetry/propagator-b3';
10
11
  import { AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray';
11
12
 
12
- /******************************************************************************
13
- Copyright (c) Microsoft Corporation.
14
-
15
- Permission to use, copy, modify, and/or distribute this software for any
16
- purpose with or without fee is hereby granted.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
19
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
20
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
21
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
- PERFORMANCE OF THIS SOFTWARE.
25
- ***************************************************************************** */
26
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
27
-
28
- var extendStatics = function(d, b) {
29
- extendStatics = Object.setPrototypeOf ||
30
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
32
- return extendStatics(d, b);
33
- };
34
-
35
- function __extends(d, b) {
36
- if (typeof b !== "function" && b !== null)
37
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
38
- extendStatics(d, b);
39
- function __() { this.constructor = d; }
40
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
41
- }
42
-
43
- var __assign = function() {
44
- __assign = Object.assign || function __assign(t) {
45
- for (var s, i = 1, n = arguments.length; i < n; i++) {
46
- s = arguments[i];
47
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
48
- }
49
- return t;
50
- };
51
- return __assign.apply(this, arguments);
52
- };
53
-
54
- function __rest(s, e) {
55
- var t = {};
56
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
57
- t[p] = s[p];
58
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
59
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
60
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
61
- t[p[i]] = s[p[i]];
62
- }
63
- return t;
64
- }
65
-
66
- function __awaiter(thisArg, _arguments, P, generator) {
67
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
68
- return new (P || (P = Promise))(function (resolve, reject) {
69
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
70
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
71
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
72
- step((generator = generator.apply(thisArg, _arguments || [])).next());
73
- });
74
- }
75
-
76
- function __generator(thisArg, body) {
77
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
78
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
79
- function verb(n) { return function (v) { return step([n, v]); }; }
80
- function step(op) {
81
- if (f) throw new TypeError("Generator is already executing.");
82
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
83
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
84
- if (y = 0, t) op = [op[0] & 2, t.value];
85
- switch (op[0]) {
86
- case 0: case 1: t = op; break;
87
- case 4: _.label++; return { value: op[1], done: false };
88
- case 5: _.label++; y = op[1]; op = [0]; continue;
89
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
90
- default:
91
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
92
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
93
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
94
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
95
- if (t[2]) _.ops.pop();
96
- _.trys.pop(); continue;
97
- }
98
- op = body.call(thisArg, _);
99
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
100
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
101
- }
102
- }
103
-
104
- function __values(o) {
105
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
106
- if (m) return m.call(o);
107
- if (o && typeof o.length === "number") return {
108
- next: function () {
109
- if (o && i >= o.length) o = void 0;
110
- return { value: o && o[i++], done: !o };
111
- }
112
- };
113
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
114
- }
115
-
116
- function __read(o, n) {
117
- var m = typeof Symbol === "function" && o[Symbol.iterator];
118
- if (!m) return o;
119
- var i = m.call(o), r, ar = [], e;
120
- try {
121
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
122
- }
123
- catch (error) { e = { error: error }; }
124
- finally {
125
- try {
126
- if (r && !r.done && (m = i["return"])) m.call(i);
127
- }
128
- finally { if (e) throw e.error; }
129
- }
130
- return ar;
131
- }
132
-
133
- function __spreadArray(to, from, pack) {
134
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
135
- if (ar || !(i in from)) {
136
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
137
- ar[i] = from[i];
138
- }
139
- }
140
- return to.concat(ar || Array.prototype.slice.call(from));
141
- }
142
-
143
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
144
- var e = new Error(message);
145
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
146
- };
147
-
148
13
  function isString(value) {
149
14
  return typeof value === 'string';
150
15
  }
@@ -219,8 +84,6 @@ var UrlType;
219
84
  UrlType["NETWORK_REQUEST"] = "network_request";
220
85
  })(UrlType || (UrlType = {}));
221
86
 
222
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
223
-
224
87
  function getDefaultExportFromCjs (x) {
225
88
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
226
89
  }
@@ -332,290 +195,6 @@ var CoralogixLogSeverity;
332
195
  CoralogixLogSeverity[CoralogixLogSeverity["Critical"] = 6] = "Critical";
333
196
  })(CoralogixLogSeverity || (CoralogixLogSeverity = {}));
334
197
 
335
- var errorStackParser = {exports: {}};
336
-
337
- var stackframe = {exports: {}};
338
-
339
- var hasRequiredStackframe;
340
- function requireStackframe() {
341
- if (hasRequiredStackframe) return stackframe.exports;
342
- hasRequiredStackframe = 1;
343
- (function (module, exports) {
344
- (function (root, factory) {
345
- {
346
- module.exports = factory();
347
- }
348
- })(commonjsGlobal, function () {
349
-
350
- function _isNumber(n) {
351
- return !isNaN(parseFloat(n)) && isFinite(n);
352
- }
353
- function _capitalize(str) {
354
- return str.charAt(0).toUpperCase() + str.substring(1);
355
- }
356
- function _getter(p) {
357
- return function () {
358
- return this[p];
359
- };
360
- }
361
- var booleanProps = ['isConstructor', 'isEval', 'isNative', 'isToplevel'];
362
- var numericProps = ['columnNumber', 'lineNumber'];
363
- var stringProps = ['fileName', 'functionName', 'source'];
364
- var arrayProps = ['args'];
365
- var objectProps = ['evalOrigin'];
366
- var props = booleanProps.concat(numericProps, stringProps, arrayProps, objectProps);
367
- function StackFrame(obj) {
368
- if (!obj) return;
369
- for (var i = 0; i < props.length; i++) {
370
- if (obj[props[i]] !== undefined) {
371
- this['set' + _capitalize(props[i])](obj[props[i]]);
372
- }
373
- }
374
- }
375
- StackFrame.prototype = {
376
- getArgs: function getArgs() {
377
- return this.args;
378
- },
379
- setArgs: function setArgs(v) {
380
- if (Object.prototype.toString.call(v) !== '[object Array]') {
381
- throw new TypeError('Args must be an Array');
382
- }
383
- this.args = v;
384
- },
385
- getEvalOrigin: function getEvalOrigin() {
386
- return this.evalOrigin;
387
- },
388
- setEvalOrigin: function setEvalOrigin(v) {
389
- if (v instanceof StackFrame) {
390
- this.evalOrigin = v;
391
- } else if (v instanceof Object) {
392
- this.evalOrigin = new StackFrame(v);
393
- } else {
394
- throw new TypeError('Eval Origin must be an Object or StackFrame');
395
- }
396
- },
397
- toString: function toString() {
398
- var fileName = this.getFileName() || '';
399
- var lineNumber = this.getLineNumber() || '';
400
- var columnNumber = this.getColumnNumber() || '';
401
- var functionName = this.getFunctionName() || '';
402
- if (this.getIsEval()) {
403
- if (fileName) {
404
- return '[eval] (' + fileName + ':' + lineNumber + ':' + columnNumber + ')';
405
- }
406
- return '[eval]:' + lineNumber + ':' + columnNumber;
407
- }
408
- if (functionName) {
409
- return functionName + ' (' + fileName + ':' + lineNumber + ':' + columnNumber + ')';
410
- }
411
- return fileName + ':' + lineNumber + ':' + columnNumber;
412
- }
413
- };
414
- StackFrame.fromString = function StackFrame$$fromString(str) {
415
- var argsStartIndex = str.indexOf('(');
416
- var argsEndIndex = str.lastIndexOf(')');
417
- var functionName = str.substring(0, argsStartIndex);
418
- var args = str.substring(argsStartIndex + 1, argsEndIndex).split(',');
419
- var locationString = str.substring(argsEndIndex + 1);
420
- if (locationString.indexOf('@') === 0) {
421
- var parts = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(locationString, '');
422
- var fileName = parts[1];
423
- var lineNumber = parts[2];
424
- var columnNumber = parts[3];
425
- }
426
- return new StackFrame({
427
- functionName: functionName,
428
- args: args || undefined,
429
- fileName: fileName,
430
- lineNumber: lineNumber || undefined,
431
- columnNumber: columnNumber || undefined
432
- });
433
- };
434
- for (var i = 0; i < booleanProps.length; i++) {
435
- StackFrame.prototype['get' + _capitalize(booleanProps[i])] = _getter(booleanProps[i]);
436
- StackFrame.prototype['set' + _capitalize(booleanProps[i])] = function (p) {
437
- return function (v) {
438
- this[p] = Boolean(v);
439
- };
440
- }(booleanProps[i]);
441
- }
442
- for (var j = 0; j < numericProps.length; j++) {
443
- StackFrame.prototype['get' + _capitalize(numericProps[j])] = _getter(numericProps[j]);
444
- StackFrame.prototype['set' + _capitalize(numericProps[j])] = function (p) {
445
- return function (v) {
446
- if (!_isNumber(v)) {
447
- throw new TypeError(p + ' must be a Number');
448
- }
449
- this[p] = Number(v);
450
- };
451
- }(numericProps[j]);
452
- }
453
- for (var k = 0; k < stringProps.length; k++) {
454
- StackFrame.prototype['get' + _capitalize(stringProps[k])] = _getter(stringProps[k]);
455
- StackFrame.prototype['set' + _capitalize(stringProps[k])] = function (p) {
456
- return function (v) {
457
- this[p] = String(v);
458
- };
459
- }(stringProps[k]);
460
- }
461
- return StackFrame;
462
- });
463
- })(stackframe);
464
- return stackframe.exports;
465
- }
466
-
467
- (function (module, exports) {
468
- (function (root, factory) {
469
- {
470
- module.exports = factory(requireStackframe());
471
- }
472
- })(commonjsGlobal, function ErrorStackParser(StackFrame) {
473
-
474
- var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
475
- var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
476
- var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
477
- return {
478
- parse: function ErrorStackParser$$parse(error) {
479
- if (typeof error.stacktrace !== 'undefined' || typeof error['opera#sourceloc'] !== 'undefined') {
480
- return this.parseOpera(error);
481
- } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
482
- return this.parseV8OrIE(error);
483
- } else if (error.stack) {
484
- return this.parseFFOrSafari(error);
485
- } else {
486
- throw new Error('Cannot parse given Error object');
487
- }
488
- },
489
- extractLocation: function ErrorStackParser$$extractLocation(urlLike) {
490
- if (urlLike.indexOf(':') === -1) {
491
- return [urlLike];
492
- }
493
- var regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
494
- var parts = regExp.exec(urlLike.replace(/[()]/g, ''));
495
- return [parts[1], parts[2] || undefined, parts[3] || undefined];
496
- },
497
- parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
498
- var filtered = error.stack.split('\n').filter(function (line) {
499
- return !!line.match(CHROME_IE_STACK_REGEXP);
500
- }, this);
501
- return filtered.map(function (line) {
502
- if (line.indexOf('(eval ') > -1) {
503
- line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(,.*$)/g, '');
504
- }
505
- var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').replace(/^.*?\s+/, '');
506
- var location = sanitizedLine.match(/ (\(.+\)$)/);
507
- sanitizedLine = location ? sanitizedLine.replace(location[0], '') : sanitizedLine;
508
- var locationParts = this.extractLocation(location ? location[1] : sanitizedLine);
509
- var functionName = location && sanitizedLine || undefined;
510
- var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
511
- return new StackFrame({
512
- functionName: functionName,
513
- fileName: fileName,
514
- lineNumber: locationParts[1],
515
- columnNumber: locationParts[2],
516
- source: line
517
- });
518
- }, this);
519
- },
520
- parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
521
- var filtered = error.stack.split('\n').filter(function (line) {
522
- return !line.match(SAFARI_NATIVE_CODE_REGEXP);
523
- }, this);
524
- return filtered.map(function (line) {
525
- if (line.indexOf(' > eval') > -1) {
526
- line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ':$1');
527
- }
528
- if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
529
- return new StackFrame({
530
- functionName: line
531
- });
532
- } else {
533
- var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
534
- var matches = line.match(functionNameRegex);
535
- var functionName = matches && matches[1] ? matches[1] : undefined;
536
- var locationParts = this.extractLocation(line.replace(functionNameRegex, ''));
537
- return new StackFrame({
538
- functionName: functionName,
539
- fileName: locationParts[0],
540
- lineNumber: locationParts[1],
541
- columnNumber: locationParts[2],
542
- source: line
543
- });
544
- }
545
- }, this);
546
- },
547
- parseOpera: function ErrorStackParser$$parseOpera(e) {
548
- if (!e.stacktrace || e.message.indexOf('\n') > -1 && e.message.split('\n').length > e.stacktrace.split('\n').length) {
549
- return this.parseOpera9(e);
550
- } else if (!e.stack) {
551
- return this.parseOpera10(e);
552
- } else {
553
- return this.parseOpera11(e);
554
- }
555
- },
556
- parseOpera9: function ErrorStackParser$$parseOpera9(e) {
557
- var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
558
- var lines = e.message.split('\n');
559
- var result = [];
560
- for (var i = 2, len = lines.length; i < len; i += 2) {
561
- var match = lineRE.exec(lines[i]);
562
- if (match) {
563
- result.push(new StackFrame({
564
- fileName: match[2],
565
- lineNumber: match[1],
566
- source: lines[i]
567
- }));
568
- }
569
- }
570
- return result;
571
- },
572
- parseOpera10: function ErrorStackParser$$parseOpera10(e) {
573
- var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
574
- var lines = e.stacktrace.split('\n');
575
- var result = [];
576
- for (var i = 0, len = lines.length; i < len; i += 2) {
577
- var match = lineRE.exec(lines[i]);
578
- if (match) {
579
- result.push(new StackFrame({
580
- functionName: match[3] || undefined,
581
- fileName: match[2],
582
- lineNumber: match[1],
583
- source: lines[i]
584
- }));
585
- }
586
- }
587
- return result;
588
- },
589
- parseOpera11: function ErrorStackParser$$parseOpera11(error) {
590
- var filtered = error.stack.split('\n').filter(function (line) {
591
- return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
592
- }, this);
593
- return filtered.map(function (line) {
594
- var tokens = line.split('@');
595
- var locationParts = this.extractLocation(tokens.pop());
596
- var functionCall = tokens.shift() || '';
597
- var functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, '$2').replace(/\([^)]*\)/g, '') || undefined;
598
- var argsRaw;
599
- if (functionCall.match(/\(([^)]*)\)/)) {
600
- argsRaw = functionCall.replace(/^[^(]+\(([^)]*)\)$/, '$1');
601
- }
602
- var args = argsRaw === undefined || argsRaw === '[arguments not available]' ? undefined : argsRaw.split(',');
603
- return new StackFrame({
604
- functionName: functionName,
605
- args: args,
606
- fileName: locationParts[0],
607
- lineNumber: locationParts[1],
608
- columnNumber: locationParts[2],
609
- source: line
610
- });
611
- }, this);
612
- }
613
- };
614
- });
615
- })(errorStackParser);
616
- var errorStackParserExports = errorStackParser.exports;
617
- var ErrorStackParser = getDefaultExportFromCjs(errorStackParserExports);
618
-
619
198
  var millisecondsPerSecond = 1000;
620
199
  var millisecondsPerMinute = millisecondsPerSecond * 60;
621
200
  var MILLISECONDS_PER_HOUR = millisecondsPerMinute * 60;
@@ -699,9 +278,26 @@ function getUserAgentData() {
699
278
  }
700
279
 
701
280
  var GLOBAL_SPAN_KEY = '__globalSpan__';
281
+ var GLOBAL_SPAN_MAP_KEY = '__globalSpanMap__';
702
282
  var CUSTOM_TRACER_KEY = '__customTracer__';
703
283
  var CUSTOM_TRACER_IGNORED_INSTRUMENTS = '__customTracerIgnoredInstruments__';
704
284
 
285
+ function addGlobalSpanByTraceId(traceId, globalSpan) {
286
+ var _a;
287
+ CxGlobal[GLOBAL_SPAN_MAP_KEY] = __assign(__assign({}, (CxGlobal[GLOBAL_SPAN_MAP_KEY] || {})), (_a = {}, _a[traceId] = globalSpan, _a));
288
+ }
289
+ function getGlobalSpanByTraceId(traceId) {
290
+ var _a;
291
+ return (_a = CxGlobal[GLOBAL_SPAN_MAP_KEY]) === null || _a === void 0 ? void 0 : _a[traceId];
292
+ }
293
+ function clearGlobalSpanMap() {
294
+ var globalSpanMap = CxGlobal[GLOBAL_SPAN_MAP_KEY];
295
+ Object.keys(globalSpanMap || {}).forEach(function (traceId) {
296
+ var globalSpan = globalSpanMap[traceId];
297
+ globalSpan === null || globalSpan === void 0 ? void 0 : globalSpan.endSpan();
298
+ });
299
+ delete CxGlobal[GLOBAL_SPAN_MAP_KEY];
300
+ }
705
301
  function setGlobalSpan(globalSpan) {
706
302
  CxGlobal[GLOBAL_SPAN_KEY] = globalSpan;
707
303
  }
@@ -724,9 +320,11 @@ function getCustomTracerIgnoredInstruments() {
724
320
  return CxGlobal[CUSTOM_TRACER_IGNORED_INSTRUMENTS];
725
321
  }
726
322
  function shouldAttachSpanToGlobalSpan(instrumentationType) {
323
+ return getGlobalSpan() && !isInstrumentationIgnored(instrumentationType);
324
+ }
325
+ function isInstrumentationIgnored(instrumentationType) {
727
326
  var _a;
728
- return (getGlobalSpan() &&
729
- !((_a = getCustomTracerIgnoredInstruments()) === null || _a === void 0 ? void 0 : _a.includes(instrumentationType)));
327
+ return !!((_a = getCustomTracerIgnoredInstruments()) === null || _a === void 0 ? void 0 : _a.includes(instrumentationType));
730
328
  }
731
329
  function attachChildSpanToGlobalSpan(name) {
732
330
  var globalSpan = getGlobalSpan();
@@ -842,7 +440,7 @@ function handleMFE(stackFrames, span) {
842
440
  i++;
843
441
  return [3, 1];
844
442
  case 4:
845
- _a = __read(stackFrames, 1), lastFrame = _a[0];
443
+ _a = __read$1(stackFrames, 1), lastFrame = _a[0];
846
444
  addLabelForMFE(span, lastFrame);
847
445
  return [2];
848
446
  }
@@ -864,7 +462,7 @@ function extractMetadataFromMfeStacktrace() {
864
462
  case 0:
865
463
  cachedMetadata = CxGlobal[CACHED_METADATA_KEY];
866
464
  MFE_METADATA_KEY = 'cx-metadata.json';
867
- _a = __read(fileName.match(/https?:\/\/.*\//), 1), mfePath = _a[0];
465
+ _a = __read$1(fileName.match(/https?:\/\/.*\//), 1), mfePath = _a[0];
868
466
  if (!mfePath) return [3, 7];
869
467
  response = void 0;
870
468
  if (!!(cachedMetadata === null || cachedMetadata === void 0 ? void 0 : cachedMetadata.has(mfePath))) return [3, 6];
@@ -1296,7 +894,7 @@ var HeadersManager = (function () {
1296
894
  }
1297
895
  var lines = headersString.trim().split(/\r\n/);
1298
896
  lines.forEach(function (line) {
1299
- var _a = __read(line.split(': ', 2), 2), key = _a[0], value = _a[1];
897
+ var _a = __read$1(line.split(': ', 2), 2), key = _a[0], value = _a[1];
1300
898
  if (key && value) {
1301
899
  headerMap.set(key.trim().toLowerCase(), value.trim());
1302
900
  }
@@ -1314,9 +912,10 @@ var NetworkInstrumentationAttributes = {
1314
912
  };
1315
913
 
1316
914
  function checkAttachingNetworkSpanToGlobalSpan(span) {
1317
- if (shouldAttachSpanToGlobalSpan(CoralogixEventType.NETWORK_REQUEST)) {
1318
- var globalSpan = getGlobalSpan();
1319
- var _a = globalSpan.span.spanContext(), traceId = _a.traceId, globalSpanId = _a.spanId;
915
+ var activeGlobalSpan = getGlobalSpanByTraceId(span.spanContext().traceId);
916
+ if (activeGlobalSpan &&
917
+ !isInstrumentationIgnored(CoralogixEventType.NETWORK_REQUEST)) {
918
+ var _a = activeGlobalSpan.span.spanContext(), traceId = _a.traceId, globalSpanId = _a.spanId;
1320
919
  span['_spanContext'].traceId = traceId;
1321
920
  span['parentSpanId'] = globalSpanId;
1322
921
  }
@@ -1561,7 +1160,7 @@ function coerceArray(value) {
1561
1160
  if (isNil(value))
1562
1161
  return [];
1563
1162
  if (value instanceof Set)
1564
- return __spreadArray([], __read(value), false);
1163
+ return __spreadArray([], __read$1(value), false);
1565
1164
  return Array.isArray(value) ? value : [value];
1566
1165
  }
1567
1166
 
@@ -1578,7 +1177,7 @@ function omit(object) {
1578
1177
  return {};
1579
1178
  var omitter = function (source, pathArray) {
1580
1179
  var _a;
1581
- var _b = __read(pathArray), firstKey = _b[0], remainingKeys = _b.slice(1);
1180
+ var _b = __read$1(pathArray), firstKey = _b[0], remainingKeys = _b.slice(1);
1582
1181
  if (!source.hasOwnProperty(firstKey))
1583
1182
  return source;
1584
1183
  if (!remainingKeys.length) {
@@ -2434,7 +2033,7 @@ var CoralogixUserInteractionInstrumentation = (function (_super) {
2434
2033
  ],
2435
2034
  [CoralogixAttributes.TARGET_ELEMENT, nodeName],
2436
2035
  ].forEach(function (_a) {
2437
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
2036
+ var _b = __read$1(_a, 2), key = _b[0], value = _b[1];
2438
2037
  span.setAttribute(key, value);
2439
2038
  });
2440
2039
  }
@@ -2443,11 +2042,11 @@ var CoralogixUserInteractionInstrumentation = (function (_super) {
2443
2042
  var eventsMap = __assign(__assign({}, DEFAULT_INSTRUMENTED_EVENTS), (_a = this._config) === null || _a === void 0 ? void 0 : _a['events']);
2444
2043
  var eventNames = Object.entries(eventsMap)
2445
2044
  .filter(function (_a) {
2446
- var _b = __read(_a, 2); _b[0]; var enabled = _b[1];
2045
+ var _b = __read$1(_a, 2); _b[0]; var enabled = _b[1];
2447
2046
  return enabled;
2448
2047
  })
2449
2048
  .map(function (_a) {
2450
- var _b = __read(_a, 1), eventName = _b[0];
2049
+ var _b = __read$1(_a, 1), eventName = _b[0];
2451
2050
  return eventName;
2452
2051
  });
2453
2052
  this.stop = addEventListeners(document, eventNames, this.handler, {
@@ -2487,7 +2086,7 @@ function mapMemoryUsageEntries(memoryUsage) {
2487
2086
  };
2488
2087
  var breakdownEntries = [];
2489
2088
  try {
2490
- for (var _b = __values(memoryUsage.breakdown), _c = _b.next(); !_c.done; _c = _b.next()) {
2089
+ for (var _b = __values$1(memoryUsage.breakdown), _c = _b.next(); !_c.done; _c = _b.next()) {
2491
2090
  var entry = _c.value;
2492
2091
  if (entry.bytes > 0) {
2493
2092
  breakdownEntries.push({
@@ -2506,7 +2105,7 @@ function mapMemoryUsageEntries(memoryUsage) {
2506
2105
  }
2507
2106
  finally { if (e_1) throw e_1.error; }
2508
2107
  }
2509
- return __spreadArray([parentEntry], __read(breakdownEntries), false);
2108
+ return __spreadArray([parentEntry], __read$1(breakdownEntries), false);
2510
2109
  }
2511
2110
 
2512
2111
  var CoralogixMemoryUsageInstrumentation = (function (_super) {
@@ -2541,7 +2140,7 @@ var CoralogixMemoryUsageInstrumentation = (function (_super) {
2541
2140
  memoryUsage = _b.sent();
2542
2141
  memoryUsageEntries = mapMemoryUsageEntries(memoryUsage);
2543
2142
  try {
2544
- for (memoryUsageEntries_1 = __values(memoryUsageEntries), memoryUsageEntries_1_1 = memoryUsageEntries_1.next(); !memoryUsageEntries_1_1.done; memoryUsageEntries_1_1 = memoryUsageEntries_1.next()) {
2143
+ for (memoryUsageEntries_1 = __values$1(memoryUsageEntries), memoryUsageEntries_1_1 = memoryUsageEntries_1.next(); !memoryUsageEntries_1_1.done; memoryUsageEntries_1_1 = memoryUsageEntries_1.next()) {
2545
2144
  entry = memoryUsageEntries_1_1.value;
2546
2145
  memoryUsageSpan = this.tracer.startSpan(MEMORY_USAGE_INSTRUMENTATION_NAME);
2547
2146
  memoryUsageSpan[CoralogixAttributes.EVENT_TYPE] =
@@ -2793,16 +2392,14 @@ var CoralogixWorkerInstrumentation = (function (_super) {
2793
2392
  };
2794
2393
  CoralogixWorkerInstrumentation.prototype.createCxWorker = function (OriginalWorker) {
2795
2394
  var self = this;
2796
- var CxWorker = (function (_super) {
2797
- __extends(CxWorker, _super);
2798
- function CxWorker(scriptURL, options) {
2799
- var _this = _super.call(this, scriptURL, options) || this;
2800
- _this.CoralogixRum = self.coralogixRum;
2801
- self.attachWorkerErrorHandlers(_this, scriptURL);
2802
- return _this;
2803
- }
2804
- return CxWorker;
2805
- }(OriginalWorker));
2395
+ function CxWorker(scriptURL, options) {
2396
+ var worker = new OriginalWorker(scriptURL, options);
2397
+ worker.CoralogixRum = self.coralogixRum;
2398
+ self.attachWorkerErrorHandlers(worker, scriptURL);
2399
+ return worker;
2400
+ }
2401
+ CxWorker.prototype = OriginalWorker.prototype;
2402
+ Object.defineProperties(CxWorker, Object.getOwnPropertyDescriptors(OriginalWorker));
2806
2403
  return CxWorker;
2807
2404
  };
2808
2405
  CoralogixWorkerInstrumentation.prototype.attachWorkerErrorHandlers = function (worker, scriptURL) {
@@ -3030,7 +2627,7 @@ function getInstrumentationConfig(value, defaults, defaultDisable) {
3030
2627
  return Object.assign({}, defaults, value);
3031
2628
  }
3032
2629
  var hrTimeToMilliseconds = function (_a) {
3033
- var _b = __read(_a, 2), seconds = _b[0], nanoseconds = _b[1];
2630
+ var _b = __read$1(_a, 2), seconds = _b[0], nanoseconds = _b[1];
3034
2631
  return seconds * 1000 + Math.round(nanoseconds / 1e6);
3035
2632
  };
3036
2633
  var isNetworkError = function (status) {
@@ -3099,8 +2696,8 @@ function parseUserAgent(userAgent) {
3099
2696
  var osVersion = 'Unknown';
3100
2697
  var device = 'Desktop';
3101
2698
  try {
3102
- for (var _g = __values(Object.entries(browsers)), _h = _g.next(); !_h.done; _h = _g.next()) {
3103
- var _j = __read(_h.value, 2), name_1 = _j[0], regex = _j[1];
2699
+ for (var _g = __values$1(Object.entries(browsers)), _h = _g.next(); !_h.done; _h = _g.next()) {
2700
+ var _j = __read$1(_h.value, 2), name_1 = _j[0], regex = _j[1];
3104
2701
  var match = userAgent.match(regex);
3105
2702
  if (match) {
3106
2703
  browser = name_1;
@@ -3117,8 +2714,8 @@ function parseUserAgent(userAgent) {
3117
2714
  finally { if (e_1) throw e_1.error; }
3118
2715
  }
3119
2716
  try {
3120
- for (var _k = __values(Object.entries(operatingSystems)), _l = _k.next(); !_l.done; _l = _k.next()) {
3121
- var _m = __read(_l.value, 2), name_2 = _m[0], regex = _m[1];
2717
+ for (var _k = __values$1(Object.entries(operatingSystems)), _l = _k.next(); !_l.done; _l = _k.next()) {
2718
+ var _m = __read$1(_l.value, 2), name_2 = _m[0], regex = _m[1];
3122
2719
  var match = userAgent.match(regex);
3123
2720
  if (match) {
3124
2721
  os = name_2;
@@ -3135,8 +2732,8 @@ function parseUserAgent(userAgent) {
3135
2732
  finally { if (e_2) throw e_2.error; }
3136
2733
  }
3137
2734
  try {
3138
- for (var _o = __values(Object.entries(devices)), _p = _o.next(); !_p.done; _p = _o.next()) {
3139
- var _q = __read(_p.value, 2), name_3 = _q[0], regex = _q[1];
2735
+ for (var _o = __values$1(Object.entries(devices)), _p = _o.next(); !_p.done; _p = _o.next()) {
2736
+ var _q = __read$1(_p.value, 2), name_3 = _q[0], regex = _q[1];
3140
2737
  var match = userAgent.match(regex);
3141
2738
  if (match) {
3142
2739
  device = name_3;
@@ -3177,8 +2774,8 @@ function flattenAttributes(attributes) {
3177
2774
  var customLabels = JSON.parse(attributes[CoralogixAttributes.CUSTOM_LABELS]);
3178
2775
  var flatAttributes = omit(attributes, CoralogixAttributes.CUSTOM_LABELS);
3179
2776
  try {
3180
- for (var _b = __values(Object.entries(customLabels)), _c = _b.next(); !_c.done; _c = _b.next()) {
3181
- var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
2777
+ for (var _b = __values$1(Object.entries(customLabels)), _c = _b.next(); !_c.done; _c = _b.next()) {
2778
+ var _d = __read$1(_c.value, 2), key = _d[0], value = _d[1];
3182
2779
  flatAttributes[key] =
3183
2780
  typeof value !== 'string' ? JSON.stringify(value) : value;
3184
2781
  }
@@ -3209,7 +2806,7 @@ function replacePatternsInUrl(_a) {
3209
2806
  var patterns = _a.patterns, url = _a.url;
3210
2807
  var modifiedUrl = url;
3211
2808
  try {
3212
- for (var patterns_1 = __values(patterns), patterns_1_1 = patterns_1.next(); !patterns_1_1.done; patterns_1_1 = patterns_1.next()) {
2809
+ for (var patterns_1 = __values$1(patterns), patterns_1_1 = patterns_1.next(); !patterns_1_1.done; patterns_1_1 = patterns_1.next()) {
3213
2810
  var _c = patterns_1_1.value, pattern = _c.pattern, replacement = _c.replacement;
3214
2811
  modifiedUrl = modifiedUrl.replace(pattern, replacement);
3215
2812
  }
@@ -3251,7 +2848,7 @@ function partition(array, predicate) {
3251
2848
  var truthyValues = [];
3252
2849
  var falsyValues = [];
3253
2850
  try {
3254
- for (var array_1 = __values(array), array_1_1 = array_1.next(); !array_1_1.done; array_1_1 = array_1.next()) {
2851
+ for (var array_1 = __values$1(array), array_1_1 = array_1.next(); !array_1_1.done; array_1_1 = array_1.next()) {
3255
2852
  var element = array_1_1.value;
3256
2853
  if (predicate(element)) {
3257
2854
  truthyValues.push(element);
@@ -3327,6 +2924,322 @@ var CoralogixSpanAttributesProcessor = (function () {
3327
2924
  return CoralogixSpanAttributesProcessor;
3328
2925
  }());
3329
2926
 
2927
+ var SUPPRESS_TRACING_KEY = createContextKey('OpenTelemetry SDK Context Key SUPPRESS_TRACING');
2928
+ function isTracingSuppressed(context) {
2929
+ return context.getValue(SUPPRESS_TRACING_KEY) === true;
2930
+ }
2931
+
2932
+ var BAGGAGE_KEY_PAIR_SEPARATOR = '=';
2933
+ var BAGGAGE_PROPERTIES_SEPARATOR = ';';
2934
+ var BAGGAGE_ITEMS_SEPARATOR = ',';
2935
+ var BAGGAGE_HEADER = 'baggage';
2936
+ var BAGGAGE_MAX_NAME_VALUE_PAIRS = 180;
2937
+ var BAGGAGE_MAX_PER_NAME_VALUE_PAIRS = 4096;
2938
+ var BAGGAGE_MAX_TOTAL_LENGTH = 8192;
2939
+
2940
+ var __read = undefined && undefined.__read || function (o, n) {
2941
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
2942
+ if (!m) return o;
2943
+ var i = m.call(o),
2944
+ r,
2945
+ ar = [],
2946
+ e;
2947
+ try {
2948
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
2949
+ } catch (error) {
2950
+ e = {
2951
+ error: error
2952
+ };
2953
+ } finally {
2954
+ try {
2955
+ if (r && !r.done && (m = i["return"])) m.call(i);
2956
+ } finally {
2957
+ if (e) throw e.error;
2958
+ }
2959
+ }
2960
+ return ar;
2961
+ };
2962
+ function serializeKeyPairs(keyPairs) {
2963
+ return keyPairs.reduce(function (hValue, current) {
2964
+ var value = "" + hValue + (hValue !== '' ? BAGGAGE_ITEMS_SEPARATOR : '') + current;
2965
+ return value.length > BAGGAGE_MAX_TOTAL_LENGTH ? hValue : value;
2966
+ }, '');
2967
+ }
2968
+ function getKeyPairs(baggage) {
2969
+ return baggage.getAllEntries().map(function (_a) {
2970
+ var _b = __read(_a, 2),
2971
+ key = _b[0],
2972
+ value = _b[1];
2973
+ var entry = encodeURIComponent(key) + "=" + encodeURIComponent(value.value);
2974
+ if (value.metadata !== undefined) {
2975
+ entry += BAGGAGE_PROPERTIES_SEPARATOR + value.metadata.toString();
2976
+ }
2977
+ return entry;
2978
+ });
2979
+ }
2980
+ function parsePairKeyValue(entry) {
2981
+ var valueProps = entry.split(BAGGAGE_PROPERTIES_SEPARATOR);
2982
+ if (valueProps.length <= 0) return;
2983
+ var keyPairPart = valueProps.shift();
2984
+ if (!keyPairPart) return;
2985
+ var separatorIndex = keyPairPart.indexOf(BAGGAGE_KEY_PAIR_SEPARATOR);
2986
+ if (separatorIndex <= 0) return;
2987
+ var key = decodeURIComponent(keyPairPart.substring(0, separatorIndex).trim());
2988
+ var value = decodeURIComponent(keyPairPart.substring(separatorIndex + 1).trim());
2989
+ var metadata;
2990
+ if (valueProps.length > 0) {
2991
+ metadata = baggageEntryMetadataFromString(valueProps.join(BAGGAGE_PROPERTIES_SEPARATOR));
2992
+ }
2993
+ return {
2994
+ key: key,
2995
+ value: value,
2996
+ metadata: metadata
2997
+ };
2998
+ }
2999
+
3000
+ var W3CBaggagePropagator = function () {
3001
+ function W3CBaggagePropagator() {}
3002
+ W3CBaggagePropagator.prototype.inject = function (context, carrier, setter) {
3003
+ var baggage = propagation.getBaggage(context);
3004
+ if (!baggage || isTracingSuppressed(context)) return;
3005
+ var keyPairs = getKeyPairs(baggage).filter(function (pair) {
3006
+ return pair.length <= BAGGAGE_MAX_PER_NAME_VALUE_PAIRS;
3007
+ }).slice(0, BAGGAGE_MAX_NAME_VALUE_PAIRS);
3008
+ var headerValue = serializeKeyPairs(keyPairs);
3009
+ if (headerValue.length > 0) {
3010
+ setter.set(carrier, BAGGAGE_HEADER, headerValue);
3011
+ }
3012
+ };
3013
+ W3CBaggagePropagator.prototype.extract = function (context, carrier, getter) {
3014
+ var headerValue = getter.get(carrier, BAGGAGE_HEADER);
3015
+ var baggageString = Array.isArray(headerValue) ? headerValue.join(BAGGAGE_ITEMS_SEPARATOR) : headerValue;
3016
+ if (!baggageString) return context;
3017
+ var baggage = {};
3018
+ if (baggageString.length === 0) {
3019
+ return context;
3020
+ }
3021
+ var pairs = baggageString.split(BAGGAGE_ITEMS_SEPARATOR);
3022
+ pairs.forEach(function (entry) {
3023
+ var keyPair = parsePairKeyValue(entry);
3024
+ if (keyPair) {
3025
+ var baggageEntry = {
3026
+ value: keyPair.value
3027
+ };
3028
+ if (keyPair.metadata) {
3029
+ baggageEntry.metadata = keyPair.metadata;
3030
+ }
3031
+ baggage[keyPair.key] = baggageEntry;
3032
+ }
3033
+ });
3034
+ if (Object.entries(baggage).length === 0) {
3035
+ return context;
3036
+ }
3037
+ return propagation.setBaggage(context, propagation.createBaggage(baggage));
3038
+ };
3039
+ W3CBaggagePropagator.prototype.fields = function () {
3040
+ return [BAGGAGE_HEADER];
3041
+ };
3042
+ return W3CBaggagePropagator;
3043
+ }();
3044
+
3045
+ var ExportResultCode;
3046
+ (function (ExportResultCode) {
3047
+ ExportResultCode[ExportResultCode["SUCCESS"] = 0] = "SUCCESS";
3048
+ ExportResultCode[ExportResultCode["FAILED"] = 1] = "FAILED";
3049
+ })(ExportResultCode || (ExportResultCode = {}));
3050
+
3051
+ var __values = undefined && undefined.__values || function (o) {
3052
+ var s = typeof Symbol === "function" && Symbol.iterator,
3053
+ m = s && o[s],
3054
+ i = 0;
3055
+ if (m) return m.call(o);
3056
+ if (o && typeof o.length === "number") return {
3057
+ next: function next() {
3058
+ if (o && i >= o.length) o = void 0;
3059
+ return {
3060
+ value: o && o[i++],
3061
+ done: !o
3062
+ };
3063
+ }
3064
+ };
3065
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
3066
+ };
3067
+ var CompositePropagator = function () {
3068
+ function CompositePropagator(config) {
3069
+ if (config === void 0) {
3070
+ config = {};
3071
+ }
3072
+ var _a;
3073
+ this._propagators = (_a = config.propagators) !== null && _a !== void 0 ? _a : [];
3074
+ this._fields = Array.from(new Set(this._propagators.map(function (p) {
3075
+ return typeof p.fields === 'function' ? p.fields() : [];
3076
+ }).reduce(function (x, y) {
3077
+ return x.concat(y);
3078
+ }, [])));
3079
+ }
3080
+ CompositePropagator.prototype.inject = function (context, carrier, setter) {
3081
+ var e_1, _a;
3082
+ try {
3083
+ for (var _b = __values(this._propagators), _c = _b.next(); !_c.done; _c = _b.next()) {
3084
+ var propagator = _c.value;
3085
+ try {
3086
+ propagator.inject(context, carrier, setter);
3087
+ } catch (err) {
3088
+ diag.warn("Failed to inject with " + propagator.constructor.name + ". Err: " + err.message);
3089
+ }
3090
+ }
3091
+ } catch (e_1_1) {
3092
+ e_1 = {
3093
+ error: e_1_1
3094
+ };
3095
+ } finally {
3096
+ try {
3097
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
3098
+ } finally {
3099
+ if (e_1) throw e_1.error;
3100
+ }
3101
+ }
3102
+ };
3103
+ CompositePropagator.prototype.extract = function (context, carrier, getter) {
3104
+ return this._propagators.reduce(function (ctx, propagator) {
3105
+ try {
3106
+ return propagator.extract(ctx, carrier, getter);
3107
+ } catch (err) {
3108
+ diag.warn("Failed to inject with " + propagator.constructor.name + ". Err: " + err.message);
3109
+ }
3110
+ return ctx;
3111
+ }, context);
3112
+ };
3113
+ CompositePropagator.prototype.fields = function () {
3114
+ return this._fields.slice();
3115
+ };
3116
+ return CompositePropagator;
3117
+ }();
3118
+
3119
+ var VALID_KEY_CHAR_RANGE = '[_0-9a-z-*/]';
3120
+ var VALID_KEY = "[a-z]" + VALID_KEY_CHAR_RANGE + "{0,255}";
3121
+ var VALID_VENDOR_KEY = "[a-z0-9]" + VALID_KEY_CHAR_RANGE + "{0,240}@[a-z]" + VALID_KEY_CHAR_RANGE + "{0,13}";
3122
+ var VALID_KEY_REGEX = new RegExp("^(?:" + VALID_KEY + "|" + VALID_VENDOR_KEY + ")$");
3123
+ var VALID_VALUE_BASE_REGEX = /^[ -~]{0,255}[!-~]$/;
3124
+ var INVALID_VALUE_COMMA_EQUAL_REGEX = /,|=/;
3125
+ function validateKey(key) {
3126
+ return VALID_KEY_REGEX.test(key);
3127
+ }
3128
+ function validateValue(value) {
3129
+ return VALID_VALUE_BASE_REGEX.test(value) && !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value);
3130
+ }
3131
+
3132
+ var MAX_TRACE_STATE_ITEMS = 32;
3133
+ var MAX_TRACE_STATE_LEN = 512;
3134
+ var LIST_MEMBERS_SEPARATOR = ',';
3135
+ var LIST_MEMBER_KEY_VALUE_SPLITTER = '=';
3136
+ var TraceState = function () {
3137
+ function TraceState(rawTraceState) {
3138
+ this._internalState = new Map();
3139
+ if (rawTraceState) this._parse(rawTraceState);
3140
+ }
3141
+ TraceState.prototype.set = function (key, value) {
3142
+ var traceState = this._clone();
3143
+ if (traceState._internalState.has(key)) {
3144
+ traceState._internalState["delete"](key);
3145
+ }
3146
+ traceState._internalState.set(key, value);
3147
+ return traceState;
3148
+ };
3149
+ TraceState.prototype.unset = function (key) {
3150
+ var traceState = this._clone();
3151
+ traceState._internalState["delete"](key);
3152
+ return traceState;
3153
+ };
3154
+ TraceState.prototype.get = function (key) {
3155
+ return this._internalState.get(key);
3156
+ };
3157
+ TraceState.prototype.serialize = function () {
3158
+ var _this = this;
3159
+ return this._keys().reduce(function (agg, key) {
3160
+ agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + _this.get(key));
3161
+ return agg;
3162
+ }, []).join(LIST_MEMBERS_SEPARATOR);
3163
+ };
3164
+ TraceState.prototype._parse = function (rawTraceState) {
3165
+ if (rawTraceState.length > MAX_TRACE_STATE_LEN) return;
3166
+ this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reverse().reduce(function (agg, part) {
3167
+ var listMember = part.trim();
3168
+ var i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
3169
+ if (i !== -1) {
3170
+ var key = listMember.slice(0, i);
3171
+ var value = listMember.slice(i + 1, part.length);
3172
+ if (validateKey(key) && validateValue(value)) {
3173
+ agg.set(key, value);
3174
+ }
3175
+ }
3176
+ return agg;
3177
+ }, new Map());
3178
+ if (this._internalState.size > MAX_TRACE_STATE_ITEMS) {
3179
+ this._internalState = new Map(Array.from(this._internalState.entries()).reverse().slice(0, MAX_TRACE_STATE_ITEMS));
3180
+ }
3181
+ };
3182
+ TraceState.prototype._keys = function () {
3183
+ return Array.from(this._internalState.keys()).reverse();
3184
+ };
3185
+ TraceState.prototype._clone = function () {
3186
+ var traceState = new TraceState();
3187
+ traceState._internalState = new Map(this._internalState);
3188
+ return traceState;
3189
+ };
3190
+ return TraceState;
3191
+ }();
3192
+
3193
+ var TRACE_PARENT_HEADER = 'traceparent';
3194
+ var TRACE_STATE_HEADER = 'tracestate';
3195
+ var VERSION = '00';
3196
+ var VERSION_PART = '(?!ff)[\\da-f]{2}';
3197
+ var TRACE_ID_PART = '(?![0]{32})[\\da-f]{32}';
3198
+ var PARENT_ID_PART = '(?![0]{16})[\\da-f]{16}';
3199
+ var FLAGS_PART = '[\\da-f]{2}';
3200
+ var TRACE_PARENT_REGEX = new RegExp("^\\s?(" + VERSION_PART + ")-(" + TRACE_ID_PART + ")-(" + PARENT_ID_PART + ")-(" + FLAGS_PART + ")(-.*)?\\s?$");
3201
+ function parseTraceParent(traceParent) {
3202
+ var match = TRACE_PARENT_REGEX.exec(traceParent);
3203
+ if (!match) return null;
3204
+ if (match[1] === '00' && match[5]) return null;
3205
+ return {
3206
+ traceId: match[2],
3207
+ spanId: match[3],
3208
+ traceFlags: parseInt(match[4], 16)
3209
+ };
3210
+ }
3211
+ var W3CTraceContextPropagator = function () {
3212
+ function W3CTraceContextPropagator() {}
3213
+ W3CTraceContextPropagator.prototype.inject = function (context, carrier, setter) {
3214
+ var spanContext = trace.getSpanContext(context);
3215
+ if (!spanContext || isTracingSuppressed(context) || !isSpanContextValid(spanContext)) return;
3216
+ var traceParent = VERSION + "-" + spanContext.traceId + "-" + spanContext.spanId + "-0" + Number(spanContext.traceFlags || TraceFlags.NONE).toString(16);
3217
+ setter.set(carrier, TRACE_PARENT_HEADER, traceParent);
3218
+ if (spanContext.traceState) {
3219
+ setter.set(carrier, TRACE_STATE_HEADER, spanContext.traceState.serialize());
3220
+ }
3221
+ };
3222
+ W3CTraceContextPropagator.prototype.extract = function (context, carrier, getter) {
3223
+ var traceParentHeader = getter.get(carrier, TRACE_PARENT_HEADER);
3224
+ if (!traceParentHeader) return context;
3225
+ var traceParent = Array.isArray(traceParentHeader) ? traceParentHeader[0] : traceParentHeader;
3226
+ if (typeof traceParent !== 'string') return context;
3227
+ var spanContext = parseTraceParent(traceParent);
3228
+ if (!spanContext) return context;
3229
+ spanContext.isRemote = true;
3230
+ var traceStateHeader = getter.get(carrier, TRACE_STATE_HEADER);
3231
+ if (traceStateHeader) {
3232
+ var state = Array.isArray(traceStateHeader) ? traceStateHeader.join(',') : traceStateHeader;
3233
+ spanContext.traceState = new TraceState(typeof state === 'string' ? state : undefined);
3234
+ }
3235
+ return trace.setSpanContext(context, spanContext);
3236
+ };
3237
+ W3CTraceContextPropagator.prototype.fields = function () {
3238
+ return [TRACE_PARENT_HEADER, TRACE_STATE_HEADER];
3239
+ };
3240
+ return W3CTraceContextPropagator;
3241
+ }();
3242
+
3330
3243
  var _a$1;
3331
3244
  var MAX_RUM_EVENTS_PER_REQUEST = 500;
3332
3245
  var MAX_RUM_EVENTS = 20000;
@@ -3514,7 +3427,7 @@ var CoralogixExporter = (function () {
3514
3427
  return cxSpans;
3515
3428
  }, []);
3516
3429
  this.invokeLogRequest(instrumentationLogs);
3517
- var cachedLogs = (CxGlobal.cachedLogs = __spreadArray(__spreadArray([], __read((CxGlobal.cachedLogs || [])), false), __read(currentSpans), false));
3430
+ var cachedLogs = (CxGlobal.cachedLogs = __spreadArray(__spreadArray([], __read$1((CxGlobal.cachedLogs || [])), false), __read$1(currentSpans), false));
3518
3431
  var logsCounter = cachedLogs.length;
3519
3432
  if (logsCounter > maxRumEventsForSessionWithError && !sessionHasError) {
3520
3433
  this.clearCachedDataForSessionWithError();
@@ -3825,13 +3738,19 @@ var SessionManager = (function (_super) {
3825
3738
  console.debug('Coralogix Browser SDK - Session expired, clearing session');
3826
3739
  }
3827
3740
  (_a = CxGlobal.sessionStorage) === null || _a === void 0 ? void 0 : _a.setItem(PREV_SESSION_KEY, JSON.stringify(__assign(__assign({}, this.activeSession), { hasRecording: (_b = this.sessionRecorder) === null || _b === void 0 ? void 0 : _b.getSessionHasRecording(), hasScreenshot: (_c = this.sessionRecorder) === null || _c === void 0 ? void 0 : _c.getSessionHasScreenshot() })));
3828
- clearGlobalSpan();
3741
+ this.clearGlobalSpans();
3829
3742
  this.clearSessionWithErrorMode();
3830
3743
  (_d = getSnapshotManager()) === null || _d === void 0 ? void 0 : _d.resetSnapshot();
3831
3744
  this._currentPageFragment = undefined;
3832
3745
  (_e = this.sessionRecorder) === null || _e === void 0 ? void 0 : _e.stopRecording();
3833
3746
  (_f = CxGlobal.sessionStorage) === null || _f === void 0 ? void 0 : _f.removeItem(SESSION_KEY);
3834
3747
  };
3748
+ SessionManager.prototype.clearGlobalSpans = function () {
3749
+ var _a;
3750
+ (_a = getGlobalSpan()) === null || _a === void 0 ? void 0 : _a.endSpan();
3751
+ clearGlobalSpan();
3752
+ clearGlobalSpanMap();
3753
+ };
3835
3754
  SessionManager.prototype.clearSessionWithErrorMode = function () {
3836
3755
  this.sessionHasError = false;
3837
3756
  this.cachedLogsSent = false;
@@ -3875,7 +3794,7 @@ function handlePropagators(config, tracerProvider) {
3875
3794
  propagators = [];
3876
3795
  _a = ((_c = config.traceParentInHeader) === null || _c === void 0 ? void 0 : _c.options) || {}, propagateB3TraceHeader = _a.propagateB3TraceHeader, propagateAwsXrayTraceHeader = _a.propagateAwsXrayTraceHeader;
3877
3796
  if (!propagateAwsXrayTraceHeader && !propagateB3TraceHeader) {
3878
- propagators = __spreadArray(__spreadArray([], __read(propagators), false), [
3797
+ propagators = __spreadArray(__spreadArray([], __read$1(propagators), false), [
3879
3798
  new W3CBaggagePropagator(),
3880
3799
  new W3CTraceContextPropagator(),
3881
3800
  ], false);
@@ -3952,7 +3871,7 @@ function isInitialConfigValid(initConfig) {
3952
3871
  return;
3953
3872
  }
3954
3873
  try {
3955
- for (var REQUIRED_CONFIG_KEYS_1 = __values(REQUIRED_CONFIG_KEYS), REQUIRED_CONFIG_KEYS_1_1 = REQUIRED_CONFIG_KEYS_1.next(); !REQUIRED_CONFIG_KEYS_1_1.done; REQUIRED_CONFIG_KEYS_1_1 = REQUIRED_CONFIG_KEYS_1.next()) {
3874
+ for (var REQUIRED_CONFIG_KEYS_1 = __values$1(REQUIRED_CONFIG_KEYS), REQUIRED_CONFIG_KEYS_1_1 = REQUIRED_CONFIG_KEYS_1.next(); !REQUIRED_CONFIG_KEYS_1_1.done; REQUIRED_CONFIG_KEYS_1_1 = REQUIRED_CONFIG_KEYS_1.next()) {
3956
3875
  var requiredProp = REQUIRED_CONFIG_KEYS_1_1.value;
3957
3876
  if (isNil(initConfig[requiredProp])) {
3958
3877
  console.error("CoralogixRum: Initialization aborted. Please provide the required property \"".concat(requiredProp, "\"."));
@@ -3976,10 +3895,10 @@ function validateAndResolveInitConfig(config) {
3976
3895
  }
3977
3896
  var ignoreUrls = config.ignoreUrls, urlBlueprinters = config.urlBlueprinters, proxyUrl = config.proxyUrl;
3978
3897
  var resolvedIgnoreUrls = [];
3979
- ignoreUrls && resolvedIgnoreUrls.push.apply(resolvedIgnoreUrls, __spreadArray([], __read(ignoreUrls), false));
3898
+ ignoreUrls && resolvedIgnoreUrls.push.apply(resolvedIgnoreUrls, __spreadArray([], __read$1(ignoreUrls), false));
3980
3899
  if (proxyUrl)
3981
3900
  resolvedIgnoreUrls.push(new RegExp(proxyUrl));
3982
- OPTIONS_DEFAULTS.ignoreUrls && resolvedIgnoreUrls.push.apply(resolvedIgnoreUrls, __spreadArray([], __read(OPTIONS_DEFAULTS.ignoreUrls), false));
3901
+ OPTIONS_DEFAULTS.ignoreUrls && resolvedIgnoreUrls.push.apply(resolvedIgnoreUrls, __spreadArray([], __read$1(OPTIONS_DEFAULTS.ignoreUrls), false));
3983
3902
  return __assign(__assign(__assign({}, OPTIONS_DEFAULTS), config), { maskInputTypes: (_a = config.maskInputTypes) !== null && _a !== void 0 ? _a : MASK_INPUT_TYPES_DEFAULT, maskClass: (_b = config.maskClass) !== null && _b !== void 0 ? _b : MASK_CLASS_DEFAULT, ignoreUrls: resolvedIgnoreUrls, urlBlueprinters: resolveUrlBlueprinters(urlBlueprinters), sessionSampleRate: (_c = config.sessionSampleRate) !== null && _c !== void 0 ? _c : 100, sessionConfig: resolveSessionConfig(config.sessionConfig), sessionRecordingConfig: resolveSessionRecordingConfig(config.sessionRecordingConfig), memoryUsageConfig: resolveMemoryUsageConfig(config.memoryUsageConfig), trackSoftNavigations: !!config.trackSoftNavigations, supportMfe: !!config.supportMfe });
3984
3903
  }
3985
3904
  function resolveMemoryUsageConfig(memoryUsageConfig) {
@@ -4001,10 +3920,10 @@ function resolveUrlBlueprinters(urlBlueprinters) {
4001
3920
  var _a, _b;
4002
3921
  var _c = urlBlueprinters || {}, pageUrlBlueprinters = _c.pageUrlBlueprinters, networkUrlBlueprinters = _c.networkUrlBlueprinters;
4003
3922
  if (pageUrlBlueprinters) {
4004
- (_a = resolvedUrlBlueprinters.pageUrlBlueprinters).push.apply(_a, __spreadArray([], __read(pageUrlBlueprinters), false));
3923
+ (_a = resolvedUrlBlueprinters.pageUrlBlueprinters).push.apply(_a, __spreadArray([], __read$1(pageUrlBlueprinters), false));
4005
3924
  }
4006
3925
  if (networkUrlBlueprinters) {
4007
- (_b = resolvedUrlBlueprinters.networkUrlBlueprinters).push.apply(_b, __spreadArray([], __read(networkUrlBlueprinters), false));
3926
+ (_b = resolvedUrlBlueprinters.networkUrlBlueprinters).push.apply(_b, __spreadArray([], __read$1(networkUrlBlueprinters), false));
4008
3927
  }
4009
3928
  };
4010
3929
  concatBlueprinters(urlBlueprinters);
@@ -4014,7 +3933,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
4014
3933
  return resolvedUrlBlueprinters;
4015
3934
  }
4016
3935
 
4017
- var SDK_VERSION = '2.8.6';
3936
+ var SDK_VERSION = '2.8.8';
4018
3937
 
4019
3938
  function shouldDropEvent(cxRumEvent, options) {
4020
3939
  if (isDocumentErrorWithoutMessage(cxRumEvent)) {
@@ -4175,7 +4094,7 @@ var CoralogixSpanMapProcessor = (function () {
4175
4094
  traceId: traceId,
4176
4095
  parentSpanId: parentSpanId,
4177
4096
  name: name,
4178
- attributes: __assign(__assign({}, flattenAttributes(attributes)), this.resolveLabels(cxSpan.text.cx_rum)),
4097
+ attributes: __assign(__assign(__assign({}, flattenAttributes(attributes)), this.resolveLabels(cxSpan.text.cx_rum)), { sessionId: sessionId }),
4179
4098
  startTime: startTime,
4180
4099
  endTime: endTime,
4181
4100
  status: severity === CoralogixLogSeverity.Error
@@ -4334,7 +4253,7 @@ var CoralogixSpanMapProcessor = (function () {
4334
4253
  var allLabels = {};
4335
4254
  var cxRumEventClone = deepClone(cxRumEvent);
4336
4255
  try {
4337
- for (var labelProviders_1 = __values(labelProviders), labelProviders_1_1 = labelProviders_1.next(); !labelProviders_1_1.done; labelProviders_1_1 = labelProviders_1.next()) {
4256
+ for (var labelProviders_1 = __values$1(labelProviders), labelProviders_1_1 = labelProviders_1.next(); !labelProviders_1_1.done; labelProviders_1_1 = labelProviders_1.next()) {
4338
4257
  var labelProvider = labelProviders_1_1.value;
4339
4258
  allLabels = __assign(__assign({}, allLabels), labelProvider.providerFunc(url, cxRumEventClone));
4340
4259
  }
@@ -4656,7 +4575,7 @@ var CoralogixRum = {
4656
4575
  tracerProvider: tracerProvider,
4657
4576
  instrumentations: instrumentations,
4658
4577
  });
4659
- var _c = __read(partition(resolvedOptions_1.labelProviders || [], function (_a) {
4578
+ var _c = __read$1(partition(resolvedOptions_1.labelProviders || [], function (_a) {
4660
4579
  var urlType = _a.urlType;
4661
4580
  return urlType === UrlType.PAGE || !urlType;
4662
4581
  }), 2), pageUrlLabelProviders = _c[0], networkUrlLabelProviders = _c[1];
@@ -4731,6 +4650,7 @@ var CoralogixRum = {
4731
4650
  },
4732
4651
  };
4733
4652
  setGlobalSpan(globalSpanModel);
4653
+ addGlobalSpanByTraceId(globalSpan.spanContext().traceId, globalSpanModel);
4734
4654
  return globalSpanModel;
4735
4655
  },
4736
4656
  };
@@ -4898,8 +4818,8 @@ var UrlBasedLabelProvider = (function () {
4898
4818
  var e_1, _a;
4899
4819
  var providerLabels = {};
4900
4820
  try {
4901
- outerLoop: for (var _b = __values(compiledRegexps.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
4902
- var _d = __read(_c.value, 2), index = _d[0], compiledRegex = _d[1];
4821
+ outerLoop: for (var _b = __values$1(compiledRegexps.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
4822
+ var _d = __read$1(_c.value, 2), index = _d[0], compiledRegex = _d[1];
4903
4823
  var labels = urlPatterns[index].labels;
4904
4824
  if (compiledRegex.some(function (regexp) { return regexp.test(url); })) {
4905
4825
  providerLabels = __assign(__assign({}, providerLabels), labels);
@@ -4935,4 +4855,4 @@ var SessionRecordingEventType;
4935
4855
  SessionRecordingEventType[SessionRecordingEventType["Plugin"] = 6] = "Plugin";
4936
4856
  })(SessionRecordingEventType || (SessionRecordingEventType = {}));
4937
4857
 
4938
- 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, __awaiter as _, __generator as a, __assign as b, getNowTime as c, SESSION_RECORDING_NETWORK_ERR0R_MESSAGE as d, SESSION_RECORDING_DEFAULT_HEADERS as e, SESSION_RECORDING_POSTFIX_URL as f, getSdkConfig as g, SESSION_RECORDER_KEY as h, MAX_MUTATIONS_FOR_SESSION_RECORDING as i, SESSION_RECORDING_DEFAULT_ERROR_MESSAGE as j, CoralogixRum as k, CoralogixLogSeverity as l, SessionRecordingEventType as m, CoralogixEventType as n, UrlType as o, reportInternalEvent as r };
4858
+ 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, getNowTime as a, SESSION_RECORDING_NETWORK_ERR0R_MESSAGE as b, SESSION_RECORDING_DEFAULT_HEADERS as c, SESSION_RECORDING_POSTFIX_URL as d, SESSION_RECORDER_KEY as e, MAX_MUTATIONS_FOR_SESSION_RECORDING as f, getSdkConfig as g, SESSION_RECORDING_DEFAULT_ERROR_MESSAGE as h, CoralogixRum as i, CoralogixLogSeverity as j, SessionRecordingEventType as k, CoralogixEventType as l, UrlType as m, reportInternalEvent as r };