@sentry/browser-utils 11.0.0-beta.2 → 11.0.0-rc.1

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 (44) hide show
  1. package/build/cjs/index.js +5 -0
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/instrumentation/performanceObserver.js +29 -16
  4. package/build/cjs/instrumentation/performanceObserver.js.map +1 -1
  5. package/build/cjs/instrumentation/xhr.js +2 -1
  6. package/build/cjs/instrumentation/xhr.js.map +1 -1
  7. package/build/cjs/performance/entries.js.map +1 -1
  8. package/build/cjs/web-vitals/emitSpan.js +80 -0
  9. package/build/cjs/web-vitals/emitSpan.js.map +1 -0
  10. package/build/cjs/web-vitals/inp.js +8 -1
  11. package/build/cjs/web-vitals/inp.js.map +1 -1
  12. package/build/cjs/web-vitals/softNavs.js +84 -0
  13. package/build/cjs/web-vitals/softNavs.js.map +1 -0
  14. package/build/cjs/web-vitals/spans.js +118 -104
  15. package/build/cjs/web-vitals/spans.js.map +1 -1
  16. package/build/esm/index.js +2 -1
  17. package/build/esm/index.js.map +1 -1
  18. package/build/esm/instrumentation/performanceObserver.js +28 -17
  19. package/build/esm/instrumentation/performanceObserver.js.map +1 -1
  20. package/build/esm/instrumentation/xhr.js +2 -1
  21. package/build/esm/instrumentation/xhr.js.map +1 -1
  22. package/build/esm/package.json +1 -1
  23. package/build/esm/performance/entries.js.map +1 -1
  24. package/build/esm/web-vitals/emitSpan.js +78 -0
  25. package/build/esm/web-vitals/emitSpan.js.map +1 -0
  26. package/build/esm/web-vitals/inp.js +8 -1
  27. package/build/esm/web-vitals/inp.js.map +1 -1
  28. package/build/esm/web-vitals/softNavs.js +80 -0
  29. package/build/esm/web-vitals/softNavs.js.map +1 -0
  30. package/build/esm/web-vitals/spans.js +118 -103
  31. package/build/esm/web-vitals/spans.js.map +1 -1
  32. package/build/types/index.d.ts +2 -1
  33. package/build/types/index.d.ts.map +1 -1
  34. package/build/types/instrumentation/performanceObserver.d.ts +64 -2
  35. package/build/types/instrumentation/performanceObserver.d.ts.map +1 -1
  36. package/build/types/instrumentation/xhr.d.ts.map +1 -1
  37. package/build/types/web-vitals/emitSpan.d.ts +49 -0
  38. package/build/types/web-vitals/emitSpan.d.ts.map +1 -0
  39. package/build/types/web-vitals/inp.d.ts.map +1 -1
  40. package/build/types/web-vitals/softNavs.d.ts +39 -0
  41. package/build/types/web-vitals/softNavs.d.ts.map +1 -0
  42. package/build/types/web-vitals/spans.d.ts +10 -47
  43. package/build/types/web-vitals/spans.d.ts.map +1 -1
  44. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- type InstrumentHandlerTypePerformanceObserver = 'longtask' | 'event' | 'navigation' | 'paint' | 'resource' | 'element' | 'first-input';
1
+ type InstrumentHandlerTypePerformanceObserver = 'longtask' | 'event' | 'navigation' | 'paint' | 'resource' | 'element' | 'soft-navigation' | 'first-input';
2
2
  interface PerformanceEntry {
3
3
  readonly duration: number;
4
4
  readonly entryType: string;
@@ -14,6 +14,15 @@ export interface PerformanceEventTiming extends PerformanceEntry {
14
14
  target?: unknown | null;
15
15
  interactionId?: number;
16
16
  }
17
+ /**
18
+ * A `soft-navigation` entry, minted by the browser once a history change is followed by a
19
+ * confirming paint. `interactionId` is the id of the `PerformanceEventTiming` entry for the
20
+ * interaction that drove the navigation, which is how we join it back to a Sentry navigation span.
21
+ */
22
+ export interface PerformanceSoftNavigation extends PerformanceEntry {
23
+ readonly interactionId: number;
24
+ readonly navigationId: number;
25
+ }
17
26
  interface PerformanceScriptTiming extends PerformanceEntry {
18
27
  sourceURL: string;
19
28
  sourceFunctionName: string;
@@ -24,6 +33,10 @@ interface PerformanceScriptTiming extends PerformanceEntry {
24
33
  export interface PerformanceLongAnimationFrameTiming extends PerformanceEntry {
25
34
  scripts: PerformanceScriptTiming[];
26
35
  }
36
+ /**
37
+ * The navigation types web-vitals reports a metric for, reported as-is on `browser.navigation.type`.
38
+ */
39
+ export type MetricNavigationType = 'navigate' | 'reload' | 'back-forward' | 'back-forward-cache' | 'prerender' | 'restore' | 'soft-navigation';
27
40
  interface Metric {
28
41
  /**
29
42
  * The name of the metric (in acronym form).
@@ -66,9 +79,58 @@ interface Metric {
66
79
  * support that API). For pages that are restored from the bfcache, this
67
80
  * value will be 'back-forward-cache'.
68
81
  */
69
- navigationType: 'navigate' | 'reload' | 'back-forward' | 'back-forward-cache' | 'prerender' | 'restore' | 'soft-navigation';
82
+ navigationType: MetricNavigationType;
83
+ /**
84
+ * The id of the navigation the metric belongs to. For soft navigations this is the
85
+ * `navigationId` of the `soft-navigation` entry, otherwise it's the id of the hard navigation.
86
+ */
87
+ navigationId: number;
88
+ /**
89
+ * For soft navigations, the `interactionId` of the interaction that triggered the navigation.
90
+ */
91
+ navigationInteractionId?: number;
92
+ /**
93
+ * The start time the metric value is relative to. Non-zero for soft navigations, where the
94
+ * time origin is the triggering interaction rather than the start of the document.
95
+ */
96
+ navigationStartTime?: number;
97
+ /**
98
+ * The URL the metric was recorded for. Relevant for soft navigations, where a metric can be
99
+ * reported long after the URL has moved on.
100
+ */
101
+ navigationURL?: string;
70
102
  }
71
103
  type CleanupHandlerCallback = () => void;
104
+ /**
105
+ * Opt the CLS, LCP and INP observers into reporting metrics for soft navigations.
106
+ *
107
+ * This also turns `reportAllChanges` off for CLS and LCP. web-vitals force-reports a metric when
108
+ * the navigation it belongs to is over, so without the intermediate updates every value a handler
109
+ * receives is already the final one for its navigation. That only holds because soft navigations
110
+ * are limited to span streaming, where CLS and LCP are sent as their own spans - the static
111
+ * lifecycle instead writes them onto the pageload span as it ends, which is what `reportAllChanges`
112
+ * was originally added for (#11934, #12360).
113
+ *
114
+ * Each observer is instrumented lazily, on its first handler, and web-vitals takes its options at
115
+ * that point only. So this has to be called before any of the `add*InstrumentationHandler`
116
+ * functions, otherwise it won't take effect for observers that are already running.
117
+ *
118
+ * On browsers without the Soft Navigation API this is a no-op: web-vitals feature-detects the API
119
+ * and keeps reporting hard-navigation metrics as usual.
120
+ */
121
+ export declare function enableSoftNavigationReporting(): void;
122
+ /**
123
+ * Opt the CLS, LCP and INP observers into reporting metrics for back/forward-cache restores.
124
+ *
125
+ * web-vitals re-reports each metric after a restore, tagged with a `back-forward-cache` navigation
126
+ * type. A restore is a new page view measured against a document that was never reloaded, so the
127
+ * values only mean anything if there is a fresh root span for them to belong to. Without one they
128
+ * would attach to the span the page had before it was frozen, which is why this is off by default.
129
+ *
130
+ * Like `enableSoftNavigationReporting`, this only affects observers instrumented after it is
131
+ * called.
132
+ */
133
+ export declare function enableBfcacheReporting(): void;
72
134
  /**
73
135
  * Add a callback that will be triggered when a CLS metric is available.
74
136
  * Returns a cleanup callback which can be called to remove the instrumentation handler.
@@ -1 +1 @@
1
- {"version":3,"file":"performanceObserver.d.ts","sourceRoot":"","sources":["../../../src/instrumentation/performanceObserver.ts"],"names":[],"mappings":"AAIA,KAAK,wCAAwC,GACzC,UAAU,GACV,OAAO,GACP,YAAY,GACZ,OAAO,GACP,UAAU,GACV,SAAS,GAET,aAAa,CAAC;AAMlB,UAAU,gBAAgB;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AACD,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,uBAAwB,SAAQ,gBAAgB;IACxD,SAAS,EAAE,MAAM,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E;IAClD,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG;QAChC,OAAO,EAAE,sBAAsB,EAAE,CAAC;KACnC,CAAC;CACH,KAAK,IAAI,CAAC;AAEX;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,8BAA8B,GAAG,sBAAsB,CAE7G;AAED,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,CAAC,CAAC,gBAAgB,GAAG;QAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,CAAC,GAAG,sBAAsB,CAAC,EAAE,CAAA;CAAE,KAAK,IAAI,GACnH,sBAAsB,CAAC;AAC1B,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,wCAAwC,EAC9C,QAAQ,EAAE,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAAE,KAAK,IAAI,GACxD,sBAAsB,CAAC;AA0M1B;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,sBAAsB,CAEjG"}
@@ -1 +1 @@
1
- {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../../src/instrumentation/xhr.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAA+B,MAAM,UAAU,CAAC;AAG5E,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAIvD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI,CAI1F;AAED,+BAA+B;AAC/B,wBAAgB,aAAa,IAAI,IAAI,CA0IpC"}
1
+ {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../../src/instrumentation/xhr.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAA+B,MAAM,UAAU,CAAC;AAG5E,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAIvD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI,CAI1F;AAED,+BAA+B;AAC/B,wBAAgB,aAAa,IAAI,IAAI,CA2IpC"}
@@ -0,0 +1,49 @@
1
+ import type { Span, SpanAttributes } from '@sentry/core';
2
+ import type { MetricNavigationType } from '../instrumentation/performanceObserver';
3
+ import type { WebVitalReportEvent } from './reportEvents';
4
+ export interface LayoutShift extends PerformanceEntry {
5
+ value: number;
6
+ sources: Array<{
7
+ node: Node | null;
8
+ }>;
9
+ hadRecentInput: boolean;
10
+ }
11
+ export interface LargestContentfulPaint extends PerformanceEntry {
12
+ readonly renderTime: DOMHighResTimeStamp;
13
+ readonly loadTime: DOMHighResTimeStamp;
14
+ readonly size: number;
15
+ readonly id: string;
16
+ readonly url: string;
17
+ readonly element: Element | null;
18
+ }
19
+ interface WebVitalSpanOptions {
20
+ name: string;
21
+ op: string;
22
+ origin: string;
23
+ metricName: 'lcp' | 'cls' | 'inp';
24
+ value: number;
25
+ attributes?: SpanAttributes;
26
+ parentSpan?: Span;
27
+ reportEvent?: WebVitalReportEvent;
28
+ startTime: number;
29
+ endTime?: number;
30
+ /** Set when the vital was reported for a soft navigation rather than the initial page load. */
31
+ softNavigationId?: number;
32
+ /** The navigation the vital was measured on, as reported by web-vitals. */
33
+ navigationType?: MetricNavigationType;
34
+ /**
35
+ * When `true`, the span is sent on its own as a v2 streamed span instead of being folded into a
36
+ * transaction. Used for INP when span streaming is disabled (it reports late, so it can't ride
37
+ * the pageload transaction).
38
+ *
39
+ * TODO(standalone): remove once the static (transaction) trace lifecycle is dropped and INP always streams.
40
+ */
41
+ standalone?: boolean;
42
+ }
43
+ /**
44
+ * Emits a web vital span. When `standalone` is set it is sent on its own as a v2 streamed span;
45
+ * otherwise it flows through the span streaming pipeline as a child of `parentSpan`.
46
+ */
47
+ export declare function _emitWebVitalSpan(options: WebVitalSpanOptions): void;
48
+ export {};
49
+ //# sourceMappingURL=emitSpan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitSpan.d.ts","sourceRoot":"","sources":["../../../src/web-vitals/emitSpan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAoBtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAM1D,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACtC,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAClC;AAED,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+FAA+F;IAC/F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CA2EpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"inp.d.ts","sourceRoot":"","sources":["../../../src/web-vitals/inp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC,UAAU,kBAAkB;IAC1B,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAQD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CA2BzD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,kBAAkB,GAAG,SAAS,CAE7G;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,IAAI,CA6FrD"}
1
+ {"version":3,"file":"inp.d.ts","sourceRoot":"","sources":["../../../src/web-vitals/inp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC,UAAU,kBAAkB;IAC1B,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAWD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CA2BzD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,kBAAkB,GAAG,SAAS,CAE7G;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,IAAI,CA2GrD"}
@@ -0,0 +1,39 @@
1
+ import type { Client, Span } from '@sentry/core';
2
+ interface SoftNavMetric {
3
+ navigationType: string;
4
+ navigationId: number;
5
+ navigationInteractionId?: number;
6
+ }
7
+ /**
8
+ * Whether the browser can report web vitals for soft navigations.
9
+ *
10
+ * This mirrors web-vitals' own feature detection: passing `reportSoftNavs` on a browser that fails
11
+ * this check is a no-op there, so it has to be a no-op here too.
12
+ */
13
+ export declare function supportsSoftNavigations(): boolean;
14
+ /**
15
+ * Start correlating the browser's soft navigations with the SDK's navigation spans.
16
+ *
17
+ * A navigation span is created synchronously on the history change, but the browser only mints the
18
+ * `soft-navigation` entry (and with it the `navigationId` that web vitals are reported against)
19
+ * once the navigation has been confirmed by a paint. So the `navigationId` cannot be known at span
20
+ * creation time and the two have to be joined after the fact.
21
+ *
22
+ * The join key is the `interactionId` of the interaction that drove the navigation: per the Soft
23
+ * Navigations spec the `soft-navigation` entry carries the `interactionId` of the interaction that
24
+ * triggered it, which is the same id the interaction's own `PerformanceEventTiming` entry carries.
25
+ * So we bind a navigation span to the interaction it happened during, and the soft navigation
26
+ * joins back to that span through the shared id.
27
+ *
28
+ * This is inherently partial. Navigations that don't meet the browser's soft navigation heuristic
29
+ * (programmatic navigations, navigations that never paint, back/forward from the browser chrome)
30
+ * produce no entry at all, so those navigation spans simply have no web vitals.
31
+ */
32
+ export declare function startSoftNavigationCorrelation(client: Client): void;
33
+ /**
34
+ * The navigation span a soft navigation web vital belongs to, or `undefined` if the metric isn't
35
+ * for a soft navigation or we failed to correlate it.
36
+ */
37
+ export declare function getNavigationSpanForMetric(metric: SoftNavMetric): Span | undefined;
38
+ export {};
39
+ //# sourceMappingURL=softNavs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softNavs.d.ts","sourceRoot":"","sources":["../../../src/web-vitals/softNavs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAoBjD,UAAU,aAAa;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAkBD;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAejD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA8DnE;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,CAgBlF"}
@@ -1,71 +1,34 @@
1
- import type { Client, Span, SpanAttributes } from '@sentry/core';
1
+ import type { Client, Span } from '@sentry/core';
2
+ import type { InstrumentationHandlerCallback, MetricNavigationType } from '../instrumentation/performanceObserver';
3
+ import type { LargestContentfulPaint, LayoutShift } from './emitSpan';
2
4
  import type { WebVitalReportEvent } from './reportEvents';
3
5
  import type { PerformanceEventTiming } from '../instrumentation/performanceObserver';
4
- export interface LayoutShift extends PerformanceEntry {
5
- value: number;
6
- sources: Array<{
7
- node: Node | null;
8
- }>;
9
- hadRecentInput: boolean;
10
- }
11
- export interface LargestContentfulPaint extends PerformanceEntry {
12
- readonly renderTime: DOMHighResTimeStamp;
13
- readonly loadTime: DOMHighResTimeStamp;
14
- readonly size: number;
15
- readonly id: string;
16
- readonly url: string;
17
- readonly element: Element | null;
18
- }
19
- interface WebVitalSpanOptions {
20
- name: string;
21
- op: string;
22
- origin: string;
23
- metricName: 'lcp' | 'cls' | 'inp';
24
- value: number;
25
- attributes?: SpanAttributes;
26
- parentSpan?: Span;
27
- reportEvent?: WebVitalReportEvent;
28
- startTime: number;
29
- endTime?: number;
30
- /**
31
- * When `true`, the span is sent on its own as a v2 streamed span instead of being folded into a
32
- * transaction. Used for INP when span streaming is disabled (it reports late, so it can't ride
33
- * the pageload transaction).
34
- *
35
- * TODO(standalone): remove once the static (transaction) trace lifecycle is dropped and INP always streams.
36
- */
37
- standalone?: boolean;
38
- }
39
- /**
40
- * Emits a web vital span. When `standalone` is set it is sent on its own as a v2 streamed span;
41
- * otherwise it flows through the span streaming pipeline as a child of `parentSpan`.
42
- */
43
- export declare function _emitWebVitalSpan(options: WebVitalSpanOptions): void;
6
+ type InpMetric = Parameters<InstrumentationHandlerCallback>[0]['metric'];
44
7
  /**
45
8
  * Tracks LCP as a streamed span.
46
9
  */
47
- export declare function trackLcpAsSpan(client: Client): void;
10
+ export declare function trackLcpAsSpan(client: Client, perNavigation?: boolean): void;
48
11
  /**
49
12
  * Exported only for testing.
50
13
  */
51
- export declare function _sendLcpSpan(lcpValue: number, entry: LargestContentfulPaint | undefined, pageloadSpan?: Span, reportEvent?: WebVitalReportEvent): void;
14
+ export declare function _sendLcpSpan(lcpValue: number, entry: LargestContentfulPaint | undefined, pageloadSpan?: Span, reportEvent?: WebVitalReportEvent, softNavigationId?: number, navigationType?: MetricNavigationType, navigationStartTime?: number): void;
52
15
  /**
53
16
  * Tracks CLS as a streamed span.
54
17
  */
55
- export declare function trackClsAsSpan(client: Client): void;
18
+ export declare function trackClsAsSpan(client: Client, perNavigation?: boolean): void;
56
19
  /**
57
20
  * Exported only for testing.
58
21
  */
59
- export declare function _sendClsSpan(clsValue: number, entry: LayoutShift | undefined, pageloadSpan?: Span, reportEvent?: WebVitalReportEvent): void;
22
+ export declare function _sendClsSpan(clsValue: number, entry: LayoutShift | undefined, pageloadSpan?: Span, reportEvent?: WebVitalReportEvent, softNavigationId?: number, navigationType?: MetricNavigationType, navigationStartTime?: number): void;
60
23
  /**
61
24
  * Tracks INP and emits it as a web vital span, as a child of the interaction's root span.
62
25
  * Requires `registerInpInteractionListener()` to be called separately for cached element names and
63
26
  * root spans per interaction.
64
27
  */
65
- export declare function trackInpAsSpan(client: Client): void;
28
+ export declare function trackInpAsSpan(client: Client, perNavigation?: boolean): void;
66
29
  /**
67
30
  * Exported only for testing.
68
31
  */
69
- export declare function _sendInpSpan(inpValue: number, entry: PerformanceEventTiming, standalone?: boolean): void;
32
+ export declare function _sendInpSpan(inpValue: number, entry: PerformanceEventTiming | undefined, standalone?: boolean, attributedSpan?: Span, softNavigationId?: number, metric?: InpMetric): void;
70
33
  export {};
71
34
  //# sourceMappingURL=spans.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spans.d.ts","sourceRoot":"","sources":["../../../src/web-vitals/spans.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA4B9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAsBrF,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACtC,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAA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M,GAC3B,IAAI,CAgCN;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,UAAQ,GAAG,IAAI,CAgC1E;AAkBD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,sBAAsB,GAAG,SAAS,EACzC,UAAU,UAAQ,EAClB,cAAc,CAAC,EAAE,IAAI,EACrB,gBAAgB,CAAC,EAAE,MAAM,EACzB,MAAM,CAAC,EAAE,SAAS,GACjB,IAAI,CAyCN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/browser-utils",
3
- "version": "11.0.0-beta.2",
3
+ "version": "11.0.0-rc.1",
4
4
  "description": "Browser Utilities for all Sentry JavaScript SDKs",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser-utils",
@@ -33,9 +33,9 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@sentry/core": "11.0.0-beta.2",
37
- "@sentry/conventions": "^0.20.0",
38
- "web-vitals": "^6.0.1"
36
+ "@sentry/core": "11.0.0-rc.1",
37
+ "@sentry/conventions": "^0.23.0",
38
+ "web-vitals": "^6.1.1"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "run-p build:transpile build:types",