o11y 254.2.0 → 254.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/modules/o11y/client/client.js +77 -40
  2. package/dist/modules/o11y/client/client.js.map +1 -1
  3. package/dist/modules/o11y/client/library/ActivityImpl.d.ts +1 -0
  4. package/dist/modules/o11y/client/library/PerformanceObservability.d.ts +8 -2
  5. package/dist/modules/o11y/client/types/TypeDefinitions-Private.d.ts +1 -0
  6. package/dist/modules/o11y/client/version.d.ts +1 -1
  7. package/dist/modules/o11y/collectors/library/ActivityImpl.d.ts +1 -0
  8. package/dist/modules/o11y/collectors/library/PerformanceObservability.d.ts +8 -2
  9. package/dist/modules/o11y/collectors/types/TypeDefinitions-Private.d.ts +1 -0
  10. package/dist/modules/o11y/collectors/version.d.ts +1 -1
  11. package/dist/modules/o11y/core_envelope/core_envelope.js +1 -1
  12. package/dist/modules/o11y/core_envelope/core_envelope.js.map +1 -1
  13. package/dist/modules/o11y/core_envelope/library/ActivityImpl.d.ts +1 -0
  14. package/dist/modules/o11y/core_envelope/library/PerformanceObservability.d.ts +8 -2
  15. package/dist/modules/o11y/core_envelope/types/TypeDefinitions-Private.d.ts +1 -0
  16. package/dist/modules/o11y/core_envelope/version.d.ts +1 -1
  17. package/dist/modules/o11y/shared/library/ActivityImpl.d.ts +1 -0
  18. package/dist/modules/o11y/shared/library/PerformanceObservability.d.ts +8 -2
  19. package/dist/modules/o11y/shared/types/TypeDefinitions-Private.d.ts +1 -0
  20. package/dist/modules/o11y/shared/version.d.ts +1 -1
  21. package/dist/modules/o11y/simple_collector/library/ActivityImpl.d.ts +1 -0
  22. package/dist/modules/o11y/simple_collector/library/PerformanceObservability.d.ts +8 -2
  23. package/dist/modules/o11y/simple_collector/types/TypeDefinitions-Private.d.ts +1 -0
  24. package/dist/modules/o11y/simple_collector/version.d.ts +1 -1
  25. package/dist/modules/o11y/web_vitals/library/ActivityImpl.d.ts +1 -0
  26. package/dist/modules/o11y/web_vitals/library/PerformanceObservability.d.ts +8 -2
  27. package/dist/modules/o11y/web_vitals/types/TypeDefinitions-Private.d.ts +1 -0
  28. package/dist/modules/o11y/web_vitals/version.d.ts +1 -1
  29. package/dist/modules/o11y/web_vitals/web_vitals.js +1 -1
  30. package/dist/modules/o11y/web_vitals/web_vitals.js.map +1 -1
  31. package/package.json +2 -2
@@ -247,16 +247,18 @@ class IdleDetectorImpl {
247
247
  }
248
248
  }
249
249
 
250
- const navigation_timing={namespace:"sfcore.performance",name:"NavigationTiming",pbjsSchema:{"nested":{"sfcore":{"nested":{"performance":{"nested":{"NavigationTiming":{"oneofs":{"_xhrDelay":{"oneof":["xhrDelay"]},"_renderBlockingStatus":{"oneof":["renderBlockingStatus"]},"_firstInterimResponseStart":{"oneof":["firstInterimResponseStart"]},"_srvDuration":{"oneof":["srvDuration"]},"_isCdnCached":{"oneof":["isCdnCached"]},"_dbDuration":{"oneof":["dbDuration"]},"_reqBatchCount":{"oneof":["reqBatchCount"]}},
251
- "fields":{"redirectCount":{"id":37,"type":"uint32"},"encodedBodySize":{"id":21,"type":"uint32"},"reqActionNames":{"rule":"repeated","id":28,"type":"string"},"unloadEventEnd":{"id":40,"type":"double"},"responseEnd":{"id":19,"type":"double"},"domainLookupEnd":{"id":12,"type":"double"},"unloadEventStart":{"id":39,"type":"double"},"domContentLoadedEventStart":{"id":32,"type":"double"},"type":{"id":38,"type":"string"},"firstInterimResponseStart":{"options":{"proto3_optional":true},"id":18,"type":"double"},
252
- "duration":{"id":3,"type":"double"},"decodedBodySize":{"id":22,"type":"uint32"},"redirectStart":{"id":8,"type":"double"},"connectEnd":{"id":15,"type":"double"},"isCdnCached":{"options":{"proto3_optional":true},"id":24,"type":"bool"},"requestStart":{"id":16,"type":"double"},"startTime":{"id":2,"type":"double"},"fetchStart":{"id":10,"type":"double"},"domContentLoadedEventEnd":{"id":33,"type":"double"},"srvReqId":{"id":29,"type":"string"},"reqBatchCount":{"options":{"proto3_optional":true},"id":27,"type":"uint32"},
253
- "renderBlockingStatus":{"options":{"proto3_optional":true},"id":6,"type":"string"},"workerStart":{"id":7,"type":"double"},"responseStart":{"id":17,"type":"double"},"xhrDelay":{"options":{"proto3_optional":true},"id":30,"type":"double"},"domInteractive":{"id":34,"type":"double"},"domComplete":{"id":31,"type":"double"},"domainLookupStart":{"id":11,"type":"double"},"responseStatus":{"id":23,"type":"uint32"},"redirectEnd":{"id":9,"type":"double"},"transferSize":{"id":20,"type":"uint32"},"srvDuration":{"options":{"proto3_optional":true},
254
- "id":26,"type":"double"},"dbDuration":{"options":{"proto3_optional":true},"id":25,"type":"double"},"connectStart":{"id":13,"type":"double"},"loadEventStart":{"id":35,"type":"double"},"secureConnectionStart":{"id":14,"type":"double"},"name":{"id":1,"type":"string"},"nextHopProtocol":{"id":5,"type":"string"},"initiatorType":{"id":4,"type":"string"},"loadEventEnd":{"id":36,"type":"double"}}}}}}}}}};
250
+ const navigation_timing={namespace:"sfcore.performance",name:"NavigationTiming",pbjsSchema:{"nested":{"sfcore":{"nested":{"performance":{"nested":{"NavigationTiming":{"oneofs":{"_xhrDelay":{"oneof":["xhrDelay"]},"_renderBlockingStatus":{"oneof":["renderBlockingStatus"]},"_firstInterimResponseStart":{"oneof":["firstInterimResponseStart"]},"_srvDuration":{"oneof":["srvDuration"]},"_isCdnCached":{"oneof":["isCdnCached"]},"_responseStatus":{"oneof":["responseStatus"]},"_dbDuration":{"oneof":["dbDuration"]},
251
+ "_reqBatchCount":{"oneof":["reqBatchCount"]}},"fields":{"redirectCount":{"id":37,"type":"uint32"},"encodedBodySize":{"id":21,"type":"uint32"},"reqActionNames":{"rule":"repeated","id":28,"type":"string"},"unloadEventEnd":{"id":40,"type":"double"},"responseEnd":{"id":19,"type":"double"},"domainLookupEnd":{"id":12,"type":"double"},"unloadEventStart":{"id":39,"type":"double"},"domContentLoadedEventStart":{"id":32,"type":"double"},"type":{"id":38,"type":"string"},"firstInterimResponseStart":{"options":{"proto3_optional":true},
252
+ "id":18,"type":"double"},"duration":{"id":3,"type":"double"},"decodedBodySize":{"id":22,"type":"uint32"},"redirectStart":{"id":8,"type":"double"},"connectEnd":{"id":15,"type":"double"},"isCdnCached":{"options":{"proto3_optional":true},"id":24,"type":"bool"},"requestStart":{"id":16,"type":"double"},"startTime":{"id":2,"type":"double"},"fetchStart":{"id":10,"type":"double"},"domContentLoadedEventEnd":{"id":33,"type":"double"},"srvReqId":{"id":29,"type":"string"},"reqBatchCount":{"options":{"proto3_optional":true},
253
+ "id":27,"type":"uint32"},"renderBlockingStatus":{"options":{"proto3_optional":true},"id":6,"type":"string"},"workerStart":{"id":7,"type":"double"},"responseStart":{"id":17,"type":"double"},"xhrDelay":{"options":{"proto3_optional":true},"id":30,"type":"double"},"domInteractive":{"id":34,"type":"double"},"domComplete":{"id":31,"type":"double"},"domainLookupStart":{"id":11,"type":"double"},"responseStatus":{"options":{"proto3_optional":true},"id":23,"type":"uint32"},"redirectEnd":{"id":9,"type":"double"},
254
+ "logEvent":{"id":41,"type":"string"},"transferSize":{"id":20,"type":"uint32"},"srvDuration":{"options":{"proto3_optional":true},"id":26,"type":"double"},"dbDuration":{"options":{"proto3_optional":true},"id":25,"type":"double"},"connectStart":{"id":13,"type":"double"},"loadEventStart":{"id":35,"type":"double"},"secureConnectionStart":{"id":14,"type":"double"},"name":{"id":1,"type":"string"},"nextHopProtocol":{"id":5,"type":"string"},"initiatorType":{"id":4,"type":"string"},"loadEventEnd":{"id":36,
255
+ "type":"double"}}}}}}}}}};
255
256
 
256
- const resource_timing={namespace:"sfcore.performance",name:"ResourceTiming",pbjsSchema:{"nested":{"sfcore":{"nested":{"performance":{"nested":{"ResourceTiming":{"oneofs":{"_xhrDelay":{"oneof":["xhrDelay"]},"_renderBlockingStatus":{"oneof":["renderBlockingStatus"]},"_firstInterimResponseStart":{"oneof":["firstInterimResponseStart"]},"_srvDuration":{"oneof":["srvDuration"]},"_isCdnCached":{"oneof":["isCdnCached"]},"_dbDuration":{"oneof":["dbDuration"]},"_reqBatchCount":{"oneof":["reqBatchCount"]}},
257
- "fields":{"encodedBodySize":{"id":21,"type":"uint32"},"reqActionNames":{"rule":"repeated","id":28,"type":"string"},"responseEnd":{"id":19,"type":"double"},"domainLookupEnd":{"id":12,"type":"double"},"firstInterimResponseStart":{"options":{"proto3_optional":true},"id":18,"type":"double"},"duration":{"id":3,"type":"double"},"decodedBodySize":{"id":22,"type":"uint32"},"redirectStart":{"id":8,"type":"double"},"connectEnd":{"id":15,"type":"double"},"isCdnCached":{"options":{"proto3_optional":true},"id":24,
258
- "type":"bool"},"requestStart":{"id":16,"type":"double"},"startTime":{"id":2,"type":"double"},"fetchStart":{"id":10,"type":"double"},"srvReqId":{"id":29,"type":"string"},"reqBatchCount":{"options":{"proto3_optional":true},"id":27,"type":"uint32"},"renderBlockingStatus":{"options":{"proto3_optional":true},"id":6,"type":"string"},"workerStart":{"id":7,"type":"double"},"responseStart":{"id":17,"type":"double"},"xhrDelay":{"options":{"proto3_optional":true},"id":30,"type":"double"},"domainLookupStart":{"id":11,
259
- "type":"double"},"responseStatus":{"id":23,"type":"uint32"},"redirectEnd":{"id":9,"type":"double"},"transferSize":{"id":20,"type":"uint32"},"srvDuration":{"options":{"proto3_optional":true},"id":26,"type":"double"},"dbDuration":{"options":{"proto3_optional":true},"id":25,"type":"double"},"connectStart":{"id":13,"type":"double"},"secureConnectionStart":{"id":14,"type":"double"},"name":{"id":1,"type":"string"},"nextHopProtocol":{"id":5,"type":"string"},"initiatorType":{"id":4,"type":"string"}}}}}}}}}};
257
+ const resource_timing={namespace:"sfcore.performance",name:"ResourceTiming",pbjsSchema:{"nested":{"sfcore":{"nested":{"performance":{"nested":{"ResourceTiming":{"oneofs":{"_xhrDelay":{"oneof":["xhrDelay"]},"_renderBlockingStatus":{"oneof":["renderBlockingStatus"]},"_firstInterimResponseStart":{"oneof":["firstInterimResponseStart"]},"_srvDuration":{"oneof":["srvDuration"]},"_isCdnCached":{"oneof":["isCdnCached"]},"_responseStatus":{"oneof":["responseStatus"]},"_dbDuration":{"oneof":["dbDuration"]},
258
+ "_reqBatchCount":{"oneof":["reqBatchCount"]}},"fields":{"encodedBodySize":{"id":21,"type":"uint32"},"reqActionNames":{"rule":"repeated","id":28,"type":"string"},"responseEnd":{"id":19,"type":"double"},"domainLookupEnd":{"id":12,"type":"double"},"firstInterimResponseStart":{"options":{"proto3_optional":true},"id":18,"type":"double"},"duration":{"id":3,"type":"double"},"decodedBodySize":{"id":22,"type":"uint32"},"redirectStart":{"id":8,"type":"double"},"connectEnd":{"id":15,"type":"double"},"isCdnCached":{"options":{"proto3_optional":true},
259
+ "id":24,"type":"bool"},"requestStart":{"id":16,"type":"double"},"startTime":{"id":2,"type":"double"},"fetchStart":{"id":10,"type":"double"},"srvReqId":{"id":29,"type":"string"},"reqBatchCount":{"options":{"proto3_optional":true},"id":27,"type":"uint32"},"renderBlockingStatus":{"options":{"proto3_optional":true},"id":6,"type":"string"},"workerStart":{"id":7,"type":"double"},"responseStart":{"id":17,"type":"double"},"xhrDelay":{"options":{"proto3_optional":true},"id":30,"type":"double"},"domainLookupStart":{"id":11,
260
+ "type":"double"},"responseStatus":{"options":{"proto3_optional":true},"id":23,"type":"uint32"},"redirectEnd":{"id":9,"type":"double"},"transferSize":{"id":20,"type":"uint32"},"srvDuration":{"options":{"proto3_optional":true},"id":26,"type":"double"},"dbDuration":{"options":{"proto3_optional":true},"id":25,"type":"double"},"connectStart":{"id":13,"type":"double"},"secureConnectionStart":{"id":14,"type":"double"},"name":{"id":1,"type":"string"},"nextHopProtocol":{"id":5,"type":"string"},"initiatorType":{"id":4,
261
+ "type":"string"}}}}}}}}}};
260
262
 
261
263
  class FuzzyMapper {
262
264
  constructor(_fuzzyKeyRange) {
@@ -307,7 +309,22 @@ class PerformanceObservability {
307
309
  this._instr = _instr;
308
310
  this._skipUrls = _skipUrls;
309
311
  this._logPerformanceActivityName = _logPerformanceActivityName;
312
+ this._boundObserverCallback = this._logPerformanceEntries.bind(this);
313
+ this._boundNavigationTimingEventCallback = (event) => {
314
+ this._logNavigationEntries(event);
315
+ };
316
+ this._setTimeoutNavigationCallback = (event) => {
317
+ setTimeout(() => {
318
+ this._boundNavigationTimingEventCallback(event);
319
+ }, 0);
320
+ };
321
+ this._visibilityChangeNavigationCallback = (event) => {
322
+ if (document.visibilityState === 'hidden') {
323
+ this._boundNavigationTimingEventCallback(event);
324
+ }
325
+ };
310
326
  this._isStarted = false;
327
+ this._processedNavigationTiming = false;
311
328
  utility.requireArgument(_instr, '_instr', 'object');
312
329
  utility.requireArgument(fuzzyMapRange, 'fuzzyMapRange', 'number');
313
330
  utility.requireArgumentIfDefined(_skipUrls, '_skipUrls', Array);
@@ -315,7 +332,7 @@ class PerformanceObservability {
315
332
  utility.requireArgumentIfDefined(logLevel, 'logLevel', 'string');
316
333
  this._hasPerf =
317
334
  typeof performance !== 'undefined' && typeof PerformanceObserver === 'function';
318
- this._boundObserverCallback = this._logPerformanceEntries.bind(this);
335
+ this._hasWindow = typeof window !== 'undefined';
319
336
  if (!logLevel || logLevel.toLowerCase() === 'full') {
320
337
  this._logLevel = 1;
321
338
  }
@@ -339,10 +356,9 @@ class PerformanceObservability {
339
356
  }
340
357
  if (!this._isStarted) {
341
358
  this._isStarted = true;
342
- this._navigationObserver = new PerformanceObserver(this._boundObserverCallback);
343
- this._navigationObserver.observe({ type: 'navigation', buffered: true });
344
359
  this._resourceObserver = new PerformanceObserver(this._boundObserverCallback);
345
360
  this._resourceObserver.observe({ type: 'resource', buffered: true });
361
+ this._addNavigationListeners();
346
362
  }
347
363
  }
348
364
  stop() {
@@ -350,13 +366,26 @@ class PerformanceObservability {
350
366
  this._resourceObserver.disconnect();
351
367
  this._resourceObserver = undefined;
352
368
  }
353
- if (this._navigationObserver) {
354
- this._navigationObserver.disconnect();
355
- this._navigationObserver = undefined;
356
- }
369
+ this._removeNavigationListeners();
357
370
  this._fuzzyMapper.clear();
358
371
  this._isStarted = false;
359
372
  }
373
+ _addNavigationListeners() {
374
+ if (!this._hasWindow) {
375
+ return;
376
+ }
377
+ window.addEventListener('load', this._setTimeoutNavigationCallback);
378
+ window.addEventListener('pagehide', this._boundNavigationTimingEventCallback);
379
+ document.addEventListener('visibilitychange', this._visibilityChangeNavigationCallback);
380
+ }
381
+ _removeNavigationListeners() {
382
+ if (!this._hasWindow) {
383
+ return;
384
+ }
385
+ window.removeEventListener('load', this._setTimeoutNavigationCallback);
386
+ window.removeEventListener('pagehide', this._boundNavigationTimingEventCallback);
387
+ document.removeEventListener('visibilitychange', this._visibilityChangeNavigationCallback);
388
+ }
360
389
  addEntry(absoluteUrl, perfTime, data) {
361
390
  this._fuzzyMapper.add(absoluteUrl, perfTime, data);
362
391
  }
@@ -426,30 +455,34 @@ class PerformanceObservability {
426
455
  .startActivity(this._logPerformanceActivityName, startOptions)
427
456
  .stop(schema, payload, stopOptions);
428
457
  }
429
- _logPerformanceEntries(list) {
430
- for (const entry of list.getEntriesByType('navigation')) {
458
+ _logNavigationEntries(event) {
459
+ if (this._processedNavigationTiming) {
460
+ return;
461
+ }
462
+ for (const entry of performance.getEntriesByType('navigation')) {
431
463
  const nt = entry;
432
464
  if (this._shouldInclude(nt)) {
433
- if (nt !== this._navTiming) {
434
- this._navTiming = nt;
435
- const payload = this._resourceEntryToResourceTiming(nt);
436
- const navOnly = {
437
- domComplete: nt.domComplete,
438
- domContentLoadedEventStart: nt.domContentLoadedEventStart,
439
- domContentLoadedEventEnd: nt.domContentLoadedEventEnd,
440
- domInteractive: nt.domInteractive,
441
- loadEventStart: nt.loadEventStart,
442
- loadEventEnd: nt.loadEventEnd,
443
- redirectCount: nt.redirectCount,
444
- type: nt.type,
445
- unloadEventStart: nt.unloadEventStart,
446
- unloadEventEnd: nt.unloadEventEnd
447
- };
448
- this._logActivity(navigation_timing, Object.assign(payload, navOnly));
449
- }
450
- break;
465
+ this._processedNavigationTiming = true;
466
+ const payload = this._resourceEntryToResourceTiming(nt);
467
+ const navOnly = {
468
+ domComplete: nt.domComplete,
469
+ domContentLoadedEventStart: nt.domContentLoadedEventStart,
470
+ domContentLoadedEventEnd: nt.domContentLoadedEventEnd,
471
+ domInteractive: nt.domInteractive,
472
+ loadEventStart: nt.loadEventStart,
473
+ loadEventEnd: nt.loadEventEnd,
474
+ redirectCount: nt.redirectCount,
475
+ type: nt.type,
476
+ unloadEventStart: nt.unloadEventStart,
477
+ unloadEventEnd: nt.unloadEventEnd,
478
+ logEvent: event.type
479
+ };
480
+ this._logActivity(navigation_timing, Object.assign(payload, navOnly));
451
481
  }
482
+ break;
452
483
  }
484
+ }
485
+ _logPerformanceEntries(list) {
453
486
  for (const entry of list.getEntriesByType('resource')) {
454
487
  const rt = entry;
455
488
  const requestInfo = this._fuzzyMapper.pop(rt.name, rt.startTime);
@@ -520,9 +553,12 @@ class Tracing {
520
553
  return text;
521
554
  }
522
555
  static getHeaders(traceId, spanId, isSampled, options) {
523
- utility.requireArgument(traceId, 'traceId', 'string');
524
556
  utility.requireArgument(spanId, 'spanId', 'string');
525
557
  const useB3Headers = options === null || options === void 0 ? void 0 : options.useB3Headers;
558
+ const headers = {};
559
+ if (traceId === undefined) {
560
+ return headers;
561
+ }
526
562
  traceId = this._conformTextAsId(traceId, (options === null || options === void 0 ? void 0 : options.traceIdEffectiveLength) !== undefined
527
563
  ? options.traceIdEffectiveLength
528
564
  : useB3Headers
@@ -533,7 +569,6 @@ class Tracing {
533
569
  options.parentSpanId !== undefined &&
534
570
  this._conformTextAsId(options.parentSpanId, defaultSpanIdLength)) ||
535
571
  undefined;
536
- const headers = {};
537
572
  if (useB3Headers) {
538
573
  const isCompact = options === null || options === void 0 ? void 0 : options.useCompactHeader;
539
574
  if (isCompact) {
@@ -957,6 +992,7 @@ class ActivityImpl {
957
992
  this._onError = _onError;
958
993
  this._isSampled = _isSampled;
959
994
  this._noRerooting = _noRerooting;
995
+ this._isRoot = false;
960
996
  this._errorCount = 0;
961
997
  this._timerOverridden = TimerOverride.none;
962
998
  const { tsNow, perfNow } = utility.time();
@@ -1124,7 +1160,7 @@ class ActivityImpl {
1124
1160
  }
1125
1161
  getTraceHeaders(options) {
1126
1162
  const spanId = this.id;
1127
- const traceId = this._rootId || spanId;
1163
+ const traceId = this._isRoot ? this.id : this._rootId;
1128
1164
  return Tracing.getHeaders(traceId, spanId, this.getIsSampled(), options);
1129
1165
  }
1130
1166
  getStartTimestamp() {
@@ -1862,6 +1898,7 @@ class RootActivityHistoryImpl {
1862
1898
  class RootActivityImpl extends ActivityImpl {
1863
1899
  constructor(name, onStopped, onError, rootId, isSampled, startPerfTime, generatedRootIdLength) {
1864
1900
  super(name, undefined, onStopped, onError, undefined, rootId || utility.generateUniqueId(generatedRootIdLength !== null && generatedRootIdLength !== void 0 ? generatedRootIdLength : 32), isSampled, startPerfTime);
1901
+ this._isRoot = true;
1865
1902
  }
1866
1903
  get preRootId() {
1867
1904
  return this._preRootId;
@@ -2662,7 +2699,7 @@ class ConsoleCollector {
2662
2699
  }
2663
2700
  }
2664
2701
 
2665
- const version = '254.2.0';
2702
+ const version = '254.4.0';
2666
2703
 
2667
2704
  const idleDetector = new IdleDetectorImpl({
2668
2705
  logThreshold: 300,