o11y 260.4.0 → 260.8.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.
Files changed (47) hide show
  1. package/dist/modules/o11y/client/client.js +57 -8
  2. package/dist/modules/o11y/client/client.js.map +1 -1
  3. package/dist/modules/o11y/client/interfaces/Instrumentation.d.ts +1 -0
  4. package/dist/modules/o11y/client/interfaces/InstrumentationContext.d.ts +1 -0
  5. package/dist/modules/o11y/client/library/AppInstrumentationImpl.d.ts +2 -1
  6. package/dist/modules/o11y/client/library/InstrumentationImpl.d.ts +1 -0
  7. package/dist/modules/o11y/client/library/RootActivityImpl.d.ts +4 -1
  8. package/dist/modules/o11y/client/library/Tracing.d.ts +2 -0
  9. package/dist/modules/o11y/client/version.d.ts +2 -2
  10. package/dist/modules/o11y/collectors/interfaces/Instrumentation.d.ts +1 -0
  11. package/dist/modules/o11y/collectors/interfaces/InstrumentationContext.d.ts +1 -0
  12. package/dist/modules/o11y/collectors/library/AppInstrumentationImpl.d.ts +2 -1
  13. package/dist/modules/o11y/collectors/library/InstrumentationImpl.d.ts +1 -0
  14. package/dist/modules/o11y/collectors/library/RootActivityImpl.d.ts +4 -1
  15. package/dist/modules/o11y/collectors/library/Tracing.d.ts +2 -0
  16. package/dist/modules/o11y/collectors/version.d.ts +2 -2
  17. package/dist/modules/o11y/core_envelope/interfaces/Instrumentation.d.ts +1 -0
  18. package/dist/modules/o11y/core_envelope/interfaces/InstrumentationContext.d.ts +1 -0
  19. package/dist/modules/o11y/core_envelope/library/AppInstrumentationImpl.d.ts +2 -1
  20. package/dist/modules/o11y/core_envelope/library/InstrumentationImpl.d.ts +1 -0
  21. package/dist/modules/o11y/core_envelope/library/RootActivityImpl.d.ts +4 -1
  22. package/dist/modules/o11y/core_envelope/library/Tracing.d.ts +2 -0
  23. package/dist/modules/o11y/core_envelope/version.d.ts +2 -2
  24. package/dist/modules/o11y/shared/interfaces/Instrumentation.d.ts +1 -0
  25. package/dist/modules/o11y/shared/interfaces/InstrumentationContext.d.ts +1 -0
  26. package/dist/modules/o11y/shared/library/AppInstrumentationImpl.d.ts +2 -1
  27. package/dist/modules/o11y/shared/library/InstrumentationImpl.d.ts +1 -0
  28. package/dist/modules/o11y/shared/library/RootActivityImpl.d.ts +4 -1
  29. package/dist/modules/o11y/shared/library/Tracing.d.ts +2 -0
  30. package/dist/modules/o11y/shared/version.d.ts +2 -2
  31. package/dist/modules/o11y/simple_collector/interfaces/Instrumentation.d.ts +1 -0
  32. package/dist/modules/o11y/simple_collector/interfaces/InstrumentationContext.d.ts +1 -0
  33. package/dist/modules/o11y/simple_collector/library/AppInstrumentationImpl.d.ts +2 -1
  34. package/dist/modules/o11y/simple_collector/library/InstrumentationImpl.d.ts +1 -0
  35. package/dist/modules/o11y/simple_collector/library/RootActivityImpl.d.ts +4 -1
  36. package/dist/modules/o11y/simple_collector/library/Tracing.d.ts +2 -0
  37. package/dist/modules/o11y/simple_collector/version.d.ts +2 -2
  38. package/dist/modules/o11y/web_vitals/interfaces/Instrumentation.d.ts +1 -0
  39. package/dist/modules/o11y/web_vitals/interfaces/InstrumentationContext.d.ts +1 -0
  40. package/dist/modules/o11y/web_vitals/library/AppInstrumentationImpl.d.ts +2 -1
  41. package/dist/modules/o11y/web_vitals/library/InstrumentationImpl.d.ts +1 -0
  42. package/dist/modules/o11y/web_vitals/library/RootActivityImpl.d.ts +4 -1
  43. package/dist/modules/o11y/web_vitals/library/Tracing.d.ts +2 -0
  44. package/dist/modules/o11y/web_vitals/version.d.ts +2 -2
  45. package/dist/modules/o11y/web_vitals/web_vitals.js +63 -17
  46. package/dist/modules/o11y/web_vitals/web_vitals.js.map +1 -1
  47. package/package.json +2 -2
@@ -511,10 +511,18 @@ const headerSpanId = 'X-B3-SpanId';
511
511
  const headerSampled = 'X-B3-Sampled';
512
512
  const headerParentSpanId = 'X-B3-ParentSpanId';
513
513
  const headerRequestId = 'X-SFDC-Request-Id';
514
+ const headerBaggage = 'baggage';
514
515
  const defaultActivityNameForFetch = 'fetch';
515
516
  const defaultActivityNameForXhrSend = 'xhr_send';
516
517
  const defaultTimingActivityName = 'perf-timing';
517
518
  const defaultFuzzyMapRange = 50;
519
+ const userSettableHeaders = [
520
+ headerBaggage,
521
+ headerTraceId,
522
+ headerSpanId,
523
+ headerParentSpanId,
524
+ headerSampled
525
+ ];
518
526
  const o11yInfoForXHR = new WeakMap();
519
527
  class Tracing {
520
528
  constructor(_instr, _idleDetector) {
@@ -553,6 +561,18 @@ class Tracing {
553
561
  }
554
562
  return text;
555
563
  }
564
+ static setHeaders(headers) {
565
+ if (headers === undefined) {
566
+ Tracing._userHeaders = {};
567
+ return;
568
+ }
569
+ Object.entries(headers).forEach(([key]) => {
570
+ if (!userSettableHeaders.includes(key)) {
571
+ delete headers[key];
572
+ }
573
+ });
574
+ Tracing._userHeaders = headers;
575
+ }
556
576
  static getHeaders(traceId, spanId, isSampled, options) {
557
577
  utility.requireArgument(spanId, 'spanId', 'string');
558
578
  const useB3Headers = options === null || options === void 0 ? void 0 : options.useB3Headers;
@@ -668,6 +688,13 @@ class Tracing {
668
688
  traceHeaders = undefined;
669
689
  }
670
690
  }
691
+ if (Tracing._userHeaders && Object.keys(Tracing._userHeaders).length > 0) {
692
+ traceHeaders = { ...traceHeaders };
693
+ Object.entries(Tracing._userHeaders).forEach(([key, value]) => {
694
+ traceHeaders[key] = value;
695
+ });
696
+ Tracing._userHeaders = undefined;
697
+ }
671
698
  return traceHeaders || {};
672
699
  }
673
700
  static _extractHeader(headerName, input, init) {
@@ -1684,13 +1711,17 @@ class InstrumentationImpl {
1684
1711
  noRerooting = true;
1685
1712
  context = {
1686
1713
  rootId,
1687
- isRootActivitySampled: options.instrumentationContext.isRootActivitySampled
1714
+ isRootActivitySampled: options.instrumentationContext.isRootActivitySampled,
1715
+ isRootActivityExternalSampled: options.instrumentationContext.isRootActivityExternalSampled
1688
1716
  };
1689
1717
  }
1690
1718
  else {
1691
1719
  context = this._nextGen.getDefaultInstrumentationContext();
1692
1720
  }
1693
- const activity = new ActivityImpl(name, context.rootId, this._onActivityStoppedCallback, this._onActivityErrorCallback, maxActivityDurationMsecs, options === null || options === void 0 ? void 0 : options.id, context.isRootActivitySampled, options === null || options === void 0 ? void 0 : options.perfStartOverride, noRerooting, options === null || options === void 0 ? void 0 : options.isExternal, parentActivity);
1721
+ const isActivitySampled = (options === null || options === void 0 ? void 0 : options.isExternal)
1722
+ ? context.isRootActivityExternalSampled
1723
+ : context.isRootActivitySampled;
1724
+ const activity = new ActivityImpl(name, context.rootId, this._onActivityStoppedCallback, this._onActivityErrorCallback, maxActivityDurationMsecs, options === null || options === void 0 ? void 0 : options.id, isActivitySampled, options === null || options === void 0 ? void 0 : options.perfStartOverride, noRerooting, options === null || options === void 0 ? void 0 : options.isExternal, parentActivity);
1694
1725
  return activity;
1695
1726
  }, activityNoOp, { op: 'startActivity' });
1696
1727
  }
@@ -1884,6 +1915,10 @@ class InstrumentationImpl {
1884
1915
  act.stop((_c = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _c === void 0 ? void 0 : _c.schema, (_d = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _d === void 0 ? void 0 : _d.payload, options === null || options === void 0 ? void 0 : options.stopOptions);
1885
1916
  }
1886
1917
  }
1918
+ invokeNetworkCallWithHeaders(apiCall, params, headers) {
1919
+ Tracing.setHeaders(headers);
1920
+ return apiCall(...params);
1921
+ }
1887
1922
  }
1888
1923
  InstrumentationImpl.defaultAppName = 'APP_NOT_REGISTERED';
1889
1924
 
@@ -1939,9 +1974,17 @@ class RootActivityHistoryImpl {
1939
1974
  }
1940
1975
 
1941
1976
  class RootActivityImpl extends ActivityImpl {
1942
- constructor(name, onStopped, onError, rootId, isSampled, startPerfTime, generatedRootIdLength) {
1977
+ constructor(name, onStopped, onError, rootId, isSampled, startPerfTime, generatedRootIdLength, isExternalSampled) {
1943
1978
  super(name, undefined, onStopped, onError, undefined, rootId || utility.generateUniqueId(generatedRootIdLength !== null && generatedRootIdLength !== void 0 ? generatedRootIdLength : 32), isSampled, startPerfTime);
1944
1979
  this._isRoot = true;
1980
+ this._isExternalSampled = isExternalSampled;
1981
+ }
1982
+ get isExternalSampled() {
1983
+ var _a;
1984
+ return (_a = this._isExternalSampled) !== null && _a !== void 0 ? _a : false;
1985
+ }
1986
+ set isExternalSampled(value) {
1987
+ this._isExternalSampled = value;
1945
1988
  }
1946
1989
  get preRootId() {
1947
1990
  return this._preRootId;
@@ -2006,13 +2049,13 @@ class AppInstrumentationImpl extends InstrumentationImpl {
2006
2049
  this._rootActivityHistory = new RootActivityHistoryImpl();
2007
2050
  this._onRootActivityStoppedCallback = this._handleRootActivityStop.bind(this);
2008
2051
  }
2009
- startRootActivity(name, rootId, isSampled, options) {
2052
+ startRootActivity(name, rootId, isSampled, options, isExternalActivitySampled) {
2010
2053
  return this._safety.tryCatchReturn(() => {
2011
2054
  utility.requireArgument(name, 'name');
2012
2055
  if ((options === null || options === void 0 ? void 0 : options.id) !== undefined) {
2013
2056
  throw new Error('Cannot specify id for root activity, use rootId argument instead');
2014
2057
  }
2015
- const newRootActivity = new RootActivityImpl(name, this._onRootActivityStoppedCallback, this._onActivityErrorCallback, rootId, isSampled, options === null || options === void 0 ? void 0 : options.perfStartOverride, this._nextGen.preferredRootIdLength);
2058
+ const newRootActivity = new RootActivityImpl(name, this._onRootActivityStoppedCallback, this._onActivityErrorCallback, rootId, isSampled, options === null || options === void 0 ? void 0 : options.perfStartOverride, this._nextGen.preferredRootIdLength, isExternalActivitySampled);
2016
2059
  if (!this._allowMulti) {
2017
2060
  const entry = {
2018
2061
  id: newRootActivity.getId(),
@@ -2058,6 +2101,10 @@ class AppInstrumentationImpl extends InstrumentationImpl {
2058
2101
  var _a;
2059
2102
  return (_a = this._singleRootActivity) === null || _a === void 0 ? void 0 : _a.getIsSampled();
2060
2103
  }
2104
+ isSingleRootActivityExternalSampled() {
2105
+ var _a, _b;
2106
+ return (_b = (_a = this._singleRootActivity) === null || _a === void 0 ? void 0 : _a.isExternalSampled) !== null && _b !== void 0 ? _b : false;
2107
+ }
2061
2108
  _initMetrics() {
2062
2109
  return new MetricsImpl(this.name, () => this.name);
2063
2110
  }
@@ -2397,6 +2444,7 @@ class NextgenImpl {
2397
2444
  registerForLogPrompt: this._appInstr.registerForLogPrompt.bind(this._appInstr),
2398
2445
  activity: this._appInstr.activity.bind(this._appInstr),
2399
2446
  activityAsync: this._appInstr.activityAsync.bind(this._appInstr),
2447
+ invokeNetworkCallWithHeaders: this._appInstr.invokeNetworkCallWithHeaders.bind(this._appInstr),
2400
2448
  startRootActivity: this._appInstr.startRootActivity.bind(this._appInstr),
2401
2449
  registerLogCollector: this._isSender ? noOpFunc : this.registerLogCollector.bind(this),
2402
2450
  registerMetricsCollector: this._isSender
@@ -2532,10 +2580,11 @@ class NextgenImpl {
2532
2580
  return this._autoClickTracker;
2533
2581
  }
2534
2582
  getDefaultInstrumentationContext() {
2535
- var _a, _b;
2583
+ var _a, _b, _c;
2536
2584
  return {
2537
2585
  rootId: (_a = this._appInstr) === null || _a === void 0 ? void 0 : _a.getSingleRootActivityId(),
2538
- isRootActivitySampled: (_b = this._appInstr) === null || _b === void 0 ? void 0 : _b.isSingleRootActivitySampled()
2586
+ isRootActivitySampled: (_b = this._appInstr) === null || _b === void 0 ? void 0 : _b.isSingleRootActivitySampled(),
2587
+ isRootActivityExternalSampled: (_c = this._appInstr) === null || _c === void 0 ? void 0 : _c.isSingleRootActivityExternalSampled()
2539
2588
  };
2540
2589
  }
2541
2590
  activateClickTracker() {
@@ -2751,7 +2800,7 @@ class ConsoleCollector {
2751
2800
  }
2752
2801
  }
2753
2802
 
2754
- const version = '260.4.0';
2803
+ const version = '260.8.0';
2755
2804
 
2756
2805
  const idleDetector = new IdleDetectorImpl({
2757
2806
  logThreshold: 300,