@sentry/browser-utils 11.2.0 → 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +7 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/routing.js +76 -0
- package/build/cjs/routing.js.map +1 -0
- package/build/cjs/web-vitals/emitSpan.js +1 -1
- package/build/cjs/web-vitals/emitSpan.js.map +1 -1
- package/build/cjs/web-vitals/spans.js +1 -1
- package/build/cjs/web-vitals/spans.js.map +1 -1
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/routing.js +69 -0
- package/build/esm/routing.js.map +1 -0
- package/build/esm/web-vitals/emitSpan.js +3 -3
- package/build/esm/web-vitals/emitSpan.js.map +1 -1
- package/build/esm/web-vitals/spans.js +3 -3
- package/build/esm/web-vitals/spans.js.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/routing.d.ts +87 -0
- package/build/types/routing.d.ts.map +1 -0
- package/build/types/web-vitals/spans.d.ts.map +1 -1
- package/package.json +3 -3
package/build/cjs/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const elementTiming = require('./performance/elementTiming.js');
|
|
|
8
8
|
const interactions = require('./performance/interactions.js');
|
|
9
9
|
const isBotUserAgent = require('./isBotUserAgent.js');
|
|
10
10
|
const getLocationHref = require('./getLocationHref.js');
|
|
11
|
+
const routing = require('./routing.js');
|
|
11
12
|
const userTiming = require('./performance/userTiming.js');
|
|
12
13
|
const utils = require('./performance/utils.js');
|
|
13
14
|
const spans = require('./web-vitals/spans.js');
|
|
@@ -46,6 +47,12 @@ exports.startTrackingElementTiming = elementTiming.startTrackingElementTiming;
|
|
|
46
47
|
exports.interactionsIntegration = interactions.interactionsIntegration;
|
|
47
48
|
exports.isBotUserAgent = isBotUserAgent.isBotUserAgent;
|
|
48
49
|
exports.getLocationHref = getLocationHref.getLocationHref;
|
|
50
|
+
exports.createCachedRouteProvider = routing.createCachedRouteProvider;
|
|
51
|
+
exports.createUrlRouteProvider = routing.createUrlRouteProvider;
|
|
52
|
+
exports.getRouteProvider = routing.getRouteProvider;
|
|
53
|
+
exports.resolveCurrentRoute = routing.resolveCurrentRoute;
|
|
54
|
+
exports.resolveRoute = routing.resolveRoute;
|
|
55
|
+
exports.setRouteProvider = routing.setRouteProvider;
|
|
49
56
|
exports.userTimingIntegration = userTiming.userTimingIntegration;
|
|
50
57
|
exports.extractNetworkProtocol = utils.extractNetworkProtocol;
|
|
51
58
|
exports.trackClsAsSpan = spans.trackClsAsSpan;
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const debugBuild = require('./debug-build.js');
|
|
5
|
+
const getLocationHref = require('./getLocationHref.js');
|
|
6
|
+
|
|
7
|
+
const CLIENT_ROUTE_PROVIDERS = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
function setRouteProvider(provider, client = core.getClient()) {
|
|
9
|
+
if (!client) {
|
|
10
|
+
debugBuild.DEBUG_BUILD && core.debug.warn("Cannot set a route provider without a client.");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (debugBuild.DEBUG_BUILD && getRouteProvider(client)) {
|
|
14
|
+
core.debug.warn(
|
|
15
|
+
"A route provider is already registered for this client and will be replaced. Routes only the previous provider knows about will no longer resolve."
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
CLIENT_ROUTE_PROVIDERS.set(client, provider);
|
|
19
|
+
}
|
|
20
|
+
function getRouteProvider(client = core.getClient()) {
|
|
21
|
+
return client && CLIENT_ROUTE_PROVIDERS.get(client);
|
|
22
|
+
}
|
|
23
|
+
function resolveRoute(url, client = core.getClient()) {
|
|
24
|
+
const provider = getRouteProvider(client);
|
|
25
|
+
if (!provider) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
const urlObject = typeof url === "string" ? parseLocation(url) : url;
|
|
29
|
+
if (!urlObject) {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
return core.safeCallback(
|
|
33
|
+
debugBuild.DEBUG_BUILD ? "Route provider threw while resolving a route:" : "",
|
|
34
|
+
() => provider.resolveRoute(urlObject) || void 0,
|
|
35
|
+
() => void 0
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function resolveCurrentRoute(client = core.getClient()) {
|
|
39
|
+
const provider = getRouteProvider(client);
|
|
40
|
+
return core.safeCallback(
|
|
41
|
+
debugBuild.DEBUG_BUILD ? "Route provider threw while resolving a route:" : "",
|
|
42
|
+
() => provider?.resolveCurrentRoute() || void 0,
|
|
43
|
+
() => void 0
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
function createUrlRouteProvider(resolveRouteFromUrl) {
|
|
47
|
+
return {
|
|
48
|
+
resolveRoute: resolveRouteFromUrl,
|
|
49
|
+
resolveCurrentRoute: () => {
|
|
50
|
+
const urlObject = parseLocation(getLocationHref.getLocationHref());
|
|
51
|
+
return urlObject && resolveRouteFromUrl(urlObject);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function createCachedRouteProvider(maxEntries = 50) {
|
|
56
|
+
const routeNames = new core.LRUMap(maxEntries);
|
|
57
|
+
return {
|
|
58
|
+
...createUrlRouteProvider((url) => routeNames.get(url.pathname)),
|
|
59
|
+
record(pathname, routeName) {
|
|
60
|
+
if (pathname && routeName) {
|
|
61
|
+
routeNames.set(pathname, routeName);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function parseLocation(url) {
|
|
67
|
+
return url ? core.parseStringToURLObject(url, getLocationHref.getLocationHref() || void 0) : void 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
exports.createCachedRouteProvider = createCachedRouteProvider;
|
|
71
|
+
exports.createUrlRouteProvider = createUrlRouteProvider;
|
|
72
|
+
exports.getRouteProvider = getRouteProvider;
|
|
73
|
+
exports.resolveCurrentRoute = resolveCurrentRoute;
|
|
74
|
+
exports.resolveRoute = resolveRoute;
|
|
75
|
+
exports.setRouteProvider = setRouteProvider;
|
|
76
|
+
//# sourceMappingURL=routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.js","sources":["../../src/routing.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport { debug, getClient, LRUMap, parseStringToURLObject, safeCallback } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\nimport { getLocationHref } from './getLocationHref';\n\n/** The parts of a URL a route depends on. A `URL` satisfies it. */\ntype RouteUrl = Pick<URL, 'pathname' | 'search' | 'hash'>;\n\n/**\n * Resolves URLs to low-cardinality route names.\n *\n * Framework SDKs register one so that everything the SDK names after a route (span names, the scope's\n * transaction name, metric and span segment attributes) gets the parameterized route instead of the raw\n * URL, without each integration having to reach into the framework's router itself.\n */\nexport interface RouteProvider {\n /**\n * Resolves a URL path template for a specific URL, e.g. `/users/42` -> `/users/:id`.\n *\n * Must return a path template, never a route identifier. Routers that name routes independently of\n * their path (Vue Router's `route.name`, Ember's `posts.show`) have to return the matched path\n * instead: callers set `url.template` from this, and an identifier is not a template. An SDK that\n * wants to name its span after the identifier still can, on the span itself.\n *\n * Returns `undefined` when the URL matches no known route. Must answer for the URL it is given rather\n * than for wherever the router currently is, so that callers can resolve a URL they captured earlier\n * (a web vital reported after a soft navigation, for example).\n */\n resolveRoute(url: RouteUrl): string | undefined;\n\n /**\n * Resolves the route the app is currently on.\n *\n * Routers whose location lives in the address bar can delegate to `resolveRoute`, which is what\n * {@link createUrlRouteProvider} does. Routers that keep their own location (memory and hash routers)\n * have to answer from that location instead: for those, `location.href` is the unchanging shell URL\n * and would bucket every route together.\n */\n resolveCurrentRoute(): string | undefined;\n}\n\nconst CLIENT_ROUTE_PROVIDERS = new WeakMap<Client, RouteProvider>();\n\n/**\n * Registers the route provider for a client, replacing any previously registered one. `BrowserClient`\n * calls this with its `routeProvider` option.\n *\n * Prefer the `routeProvider` option where the provider is known at `init`: the pageload span is named\n * while `browserTracingIntegration` sets up, so a provider registered after `init` can only rename it\n * after the fact.\n *\n * A client holds one provider. An app running two routers (a framework migration, or a shell plus an\n * island) registers twice and the last one wins, so the first router's routes stop resolving.\n */\nexport function setRouteProvider(provider: RouteProvider, client: Client | undefined = getClient()): void {\n if (!client) {\n DEBUG_BUILD && debug.warn('Cannot set a route provider without a client.');\n return;\n }\n\n if (DEBUG_BUILD && getRouteProvider(client)) {\n debug.warn(\n 'A route provider is already registered for this client and will be replaced. Routes only the previous provider knows about will no longer resolve.',\n );\n }\n\n CLIENT_ROUTE_PROVIDERS.set(client, provider);\n}\n\n/**\n * Returns the route provider registered for a client.\n */\nexport function getRouteProvider(client: Client | undefined = getClient()): RouteProvider | undefined {\n return client && CLIENT_ROUTE_PROVIDERS.get(client);\n}\n\n/**\n * Resolves a URL to a low-cardinality route name, e.g. `/users/42` -> `/users/:id`.\n *\n * Returns `undefined` when no route provider is registered or the URL matches no route. Callers pick\n * their own fallback, because the right one differs: a span name falls back to a low-cardinality\n * constant, the scope's transaction name to the raw path.\n */\nexport function resolveRoute(url: string | URL, client: Client | undefined = getClient()): string | undefined {\n const provider = getRouteProvider(client);\n if (!provider) {\n return undefined;\n }\n\n const urlObject = typeof url === 'string' ? parseLocation(url) : url;\n if (!urlObject) {\n return undefined;\n }\n\n return safeCallback(\n DEBUG_BUILD ? 'Route provider threw while resolving a route:' : '',\n () => provider.resolveRoute(urlObject) || undefined,\n () => undefined,\n );\n}\n\n/**\n * Resolves the route the app is currently on.\n *\n * Returns `undefined` when no route provider is registered or the current location matches no route.\n */\nexport function resolveCurrentRoute(client: Client | undefined = getClient()): string | undefined {\n const provider = getRouteProvider(client);\n\n return safeCallback(\n DEBUG_BUILD ? 'Route provider threw while resolving a route:' : '',\n () => provider?.resolveCurrentRoute() || undefined,\n () => undefined,\n );\n}\n\n/**\n * Builds a {@link RouteProvider} for a router whose location is the browser's, which covers every\n * router except memory and hash routers.\n */\nexport function createUrlRouteProvider(resolveRouteFromUrl: (url: RouteUrl) => string | undefined): RouteProvider {\n return {\n resolveRoute: resolveRouteFromUrl,\n resolveCurrentRoute: () => {\n const urlObject = parseLocation(getLocationHref());\n\n return urlObject && resolveRouteFromUrl(urlObject);\n },\n };\n}\n\n/**\n * A {@link RouteProvider} that answers from routes it has been told about, rather than by matching.\n */\nexport interface CachedRouteProvider extends RouteProvider {\n /** Records the route name a router reported for a path. Ignores empty values. */\n record(pathname: string | undefined, routeName: string | null | undefined): void;\n}\n\n/**\n * Builds a route provider for a router with no usable matcher, which can only report the route it is\n * on as it gets there (SvelteKit's `page.route.id`, Solid Router's current matches).\n *\n * A URL the app has not visited resolves to `undefined`, which includes the first pageload until the\n * router reports. Backed by an LRU so a long-lived app visiting many URLs can't grow it without end,\n * and so routes that keep being resolved outlive ones passed through once.\n */\nexport function createCachedRouteProvider(maxEntries: number = 50): CachedRouteProvider {\n const routeNames = new LRUMap<string, string>(maxEntries);\n\n return {\n ...createUrlRouteProvider(url => routeNames.get(url.pathname)),\n record(pathname, routeName) {\n if (pathname && routeName) {\n routeNames.set(pathname, routeName);\n }\n },\n };\n}\n\n/**\n * Parses up front so providers never have to, and resolves relative locations (which memory routers\n * hand around) against the document.\n */\nfunction parseLocation(url: string): RouteUrl | undefined {\n // Without a document `getLocationHref()` is empty, which would otherwise parse as `/`.\n return url ? parseStringToURLObject(url, getLocationHref() || undefined) : undefined;\n}\n"],"names":["getClient","DEBUG_BUILD","debug","safeCallback","getLocationHref","LRUMap","parseStringToURLObject"],"mappings":";;;;;;AAyCA,MAAM,sBAAA,uBAA6B,OAAA,EAA+B;AAa3D,SAAS,gBAAA,CAAiB,QAAA,EAAyB,MAAA,GAA6BA,cAAA,EAAU,EAAS;AACxG,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAAC,sBAAA,IAAeC,UAAA,CAAM,KAAK,+CAA+C,CAAA;AACzE,IAAA;AAAA,EACF;AAEA,EAAA,IAAID,sBAAA,IAAe,gBAAA,CAAiB,MAAM,CAAA,EAAG;AAC3C,IAAAC,UAAA,CAAM,IAAA;AAAA,MACJ;AAAA,KACF;AAAA,EACF;AAEA,EAAA,sBAAA,CAAuB,GAAA,CAAI,QAAQ,QAAQ,CAAA;AAC7C;AAKO,SAAS,gBAAA,CAAiB,MAAA,GAA6BF,cAAA,EAAU,EAA8B;AACpG,EAAA,OAAO,MAAA,IAAU,sBAAA,CAAuB,GAAA,CAAI,MAAM,CAAA;AACpD;AASO,SAAS,YAAA,CAAa,GAAA,EAAmB,MAAA,GAA6BA,cAAA,EAAU,EAAuB;AAC5G,EAAA,MAAM,QAAA,GAAW,iBAAiB,MAAM,CAAA;AACxC,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,YAAY,OAAO,GAAA,KAAQ,QAAA,GAAW,aAAA,CAAc,GAAG,CAAA,GAAI,GAAA;AACjE,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,OAAOG,iBAAA;AAAA,IACLF,yBAAc,+CAAA,GAAkD,EAAA;AAAA,IAChE,MAAM,QAAA,CAAS,YAAA,CAAa,SAAS,CAAA,IAAK,MAAA;AAAA,IAC1C,MAAM;AAAA,GACR;AACF;AAOO,SAAS,mBAAA,CAAoB,MAAA,GAA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|
28
|
+
[attributes.SENTRY_EXCLUSIVE_TIME]: 0,
|
|
29
29
|
[`browser.web_vital.${metricName}.value`]: value,
|
|
30
30
|
// oxlint-disable-next-line typescript-eslint/no-deprecated
|
|
31
31
|
[attributes.SENTRY_TRANSACTION]: segmentName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitSpan.js","sources":["../../../src/web-vitals/emitSpan.ts"],"sourcesContent":["import type { Integration, Span, SpanAttributes } from '@sentry/core';\nimport {\n getClient,\n getCurrentScope,\n getRootSpan,\n
|
|
1
|
+
{"version":3,"file":"emitSpan.js","sources":["../../../src/web-vitals/emitSpan.ts"],"sourcesContent":["import type { Integration, Span, SpanAttributes } from '@sentry/core';\nimport {\n getClient,\n getCurrentScope,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n} from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/core/browser';\nimport {\n SENTRY_EXCLUSIVE_TIME,\n BROWSER_NAVIGATION_ID,\n BROWSER_NAVIGATION_TYPE,\n SENTRY_REPLAY_ID,\n SENTRY_SEGMENT_NAME,\n SENTRY_TRANSACTION,\n USER_AGENT_ORIGINAL,\n} from '@sentry/conventions/attributes';\nimport { WINDOW } from '../types';\nimport type { MetricNavigationType } from '../instrumentation/performanceObserver';\n\n// Locally-defined interfaces to avoid leaking bare global type references into the\n// generated .d.ts. The `declare global` augmentations in web-vitals/types.ts make these\n// available during this package's compilation but are NOT carried to consumers.\n// This mirrors the pattern used for PerformanceEventTiming in instrument.ts.\nexport interface LayoutShift extends PerformanceEntry {\n value: number;\n sources: Array<{ node: Node | null }>;\n hadRecentInput: boolean;\n}\n\nexport interface LargestContentfulPaint extends PerformanceEntry {\n readonly renderTime: DOMHighResTimeStamp;\n readonly loadTime: DOMHighResTimeStamp;\n readonly size: number;\n readonly id: string;\n readonly url: string;\n readonly element: Element | null;\n}\n\ninterface WebVitalSpanOptions {\n name: string;\n op: string;\n origin: string;\n metricName: 'lcp' | 'cls' | 'inp';\n value: number;\n attributes?: SpanAttributes;\n parentSpan?: Span;\n startTime: number;\n endTime?: number;\n /** Set when the vital was reported for a soft navigation rather than the initial page load. */\n softNavigationId?: number;\n /** The navigation the vital was measured on, as reported by web-vitals. */\n navigationType?: MetricNavigationType;\n /**\n * When `true`, the span is sent on its own as a v2 streamed span instead of being folded into a\n * transaction. Used for INP when span streaming is disabled (it reports late, so it can't ride\n * the pageload transaction).\n *\n * TODO(standalone): remove once the static (transaction) trace lifecycle is dropped and INP always streams.\n */\n standalone?: boolean;\n}\n\n/**\n * Emits a web vital span. When `standalone` is set it is sent on its own as a v2 streamed span;\n * otherwise it flows through the span streaming pipeline as a child of `parentSpan`.\n */\nexport function _emitWebVitalSpan(options: WebVitalSpanOptions): void {\n const {\n name,\n op,\n origin,\n metricName,\n value,\n attributes: passedAttributes,\n parentSpan,\n startTime,\n endTime,\n standalone,\n softNavigationId,\n navigationType,\n } = options;\n\n // Taken off the segment span itself, so it can't diverge from it: a routing instrumentation may\n // rename that span (a pageload span is named `Pageload` until its route resolves), and the scope's\n // transaction name is deliberately not kept in sync with it. Only a standalone span, which is sent\n // without its segment span, has to fall back to the scope.\n const segmentSpan = parentSpan && getRootSpan(parentSpan);\n const segmentName = segmentSpan ? spanToJSON(segmentSpan).name : getCurrentScope().getScopeData().transactionName;\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,\n [SENTRY_EXCLUSIVE_TIME]: 0,\n [`browser.web_vital.${metricName}.value`]: value,\n // oxlint-disable-next-line typescript-eslint/no-deprecated\n [SENTRY_TRANSACTION]: segmentName,\n [SENTRY_SEGMENT_NAME]: segmentName,\n // Web vital score calculation relies on the user agent\n [USER_AGENT_ORIGINAL]: WINDOW.navigator?.userAgent,\n ...passedAttributes,\n };\n\n if (parentSpan && spanToJSON(parentSpan).attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'pageload') {\n // for LCP and CLS, we collect the pageload span id as an attribute\n attributes['sentry.pageload.span_id'] = parentSpan.spanContext().spanId;\n }\n\n if (softNavigationId != null) {\n attributes[BROWSER_NAVIGATION_ID] = softNavigationId;\n }\n\n if (navigationType) {\n attributes[BROWSER_NAVIGATION_TYPE] = navigationType;\n }\n\n // A standalone span is sent as a plain v2 span without running the `processSpan` hooks (see\n // `captureStandaloneSpanWithStaticCallback`), so Replay can't attach the replay id itself. Set it\n // here, mirroring Replay's `processSpan`, so INP keeps its replay association like it did on v1.\n // TODO(standalone): remove once the static (transaction) trace lifecycle is dropped and INP always\n // streams, at which point Replay's `processSpan` runs and attaches the replay id.\n if (standalone) {\n Object.assign(attributes, getReplayAttributes());\n }\n\n const span = startInactiveSpan({\n name,\n attributes,\n startTime,\n parentSpan,\n // oxlint-disable-next-line typescript/no-deprecated -- intentional during the v1/v2 transition; see the TODO(standalone) above\n experimental: standalone ? { standalone: true } : undefined,\n });\n\n if (span) {\n span.end(endTime ?? startTime);\n }\n}\n\ninterface ReplayIntegration extends Integration {\n getReplayId: (onlyIfSampled?: boolean) => string | undefined;\n getRecordingMode: () => 'session' | 'buffer' | undefined;\n}\n\n// TODO(standalone): remove once the static (transaction) trace lifecycle is dropped; Replay's\n// `processSpan` then attaches the replay id to the streamed INP span instead.\nfunction getReplayAttributes(): SpanAttributes {\n const replay = getClient()?.getIntegrationByName<ReplayIntegration>('Replay');\n const replayId = replay?.getReplayId(true);\n if (!replayId) {\n return {};\n }\n\n return {\n [SENTRY_REPLAY_ID]: replayId,\n // Not the `SENTRY_REPLAY_IS_BUFFERING` convention: that one has no `sentry._internal.` prefix, and\n // the rest of the SDK sets the prefixed key (see `logs/internal.ts`, `metrics/internal.ts`).\n 'sentry._internal.replay_is_buffering': replay!.getRecordingMode() === 'buffer' ? true : undefined,\n };\n}\n"],"names":["getRootSpan","spanToJSON","getCurrentScope","attributes","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","SENTRY_EXCLUSIVE_TIME","SENTRY_TRANSACTION","SENTRY_SEGMENT_NAME","USER_AGENT_ORIGINAL","WINDOW","BROWSER_NAVIGATION_ID","BROWSER_NAVIGATION_TYPE","startInactiveSpan","getClient","SENTRY_REPLAY_ID"],"mappings":";;;;;;;AAqEO,SAAS,kBAAkB,OAAA,EAAoC;AACpE,EAAA,MAAM;AAAA,IACJ,IAAA;AAAA,IACA,EAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA,EAAY,gBAAA;AAAA,IACZ,UAAA;AAAA,IACA,SAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAMJ,EAAA,MAAM,WAAA,GAAc,UAAA,IAAcA,gBAAA,CAAY,UAAU,CAAA;AACxD,EAAA,MAAM,WAAA,GAAc,cAAcC,eAAA,CAAW,WAAW,EAAE,IAAA,GAAOC,oBAAA,EAAgB,CAAE,YAAA,EAAa,CAAE,eAAA;AAElG,EAAA,MAAMC,YAAA,GAA6B;AAAA,IACjC,CAACC,qCAAgC,GAAG,MAAA;AAAA,IACpC,CAACC,iCAA4B,GAAG,EAAA;AAAA,IAChC,CAACC,gCAAqB,GAAG,CAAA;AAAA,IACzB,CAAC,CAAA,kBAAA,EAAqB,UAAU,CAAA,MAAA,CAAQ,GAAG,KAAA;AAAA;AAAA,IAE3C,CAACC,6BAAkB,GAAG,WAAA;AAAA,IACtB,CAACC,8BAAmB,GAAG,WAAA;AAAA;AAAA,IAEvB,CAACC,8BAAmB,GAAGC,YAAA,CAAO,SAAA,EAAW,SAAA;AAAA,IACzC,GAAG;AAAA,GACL;AAEA,EAAA,IAAI,cAAcT,eAAA,CAAW,UAAU,EAAE,UAAA,CAAWI,iCAA4B,MAAM,UAAA,EAAY;AAE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NAME_FALLBACK[interactionType];
|
|
244
244
|
const name = hasSpanStreaming ? componentName$1 || fallbackName : selector ?? "Interaction to next paint";
|
|
245
245
|
const attributes$1 = {
|
|
246
|
-
[
|
|
246
|
+
[attributes.SENTRY_EXCLUSIVE_TIME]: entry?.duration ?? inpValue
|
|
247
247
|
};
|
|
248
248
|
selector && selector !== inp.UNKNOWN_ELEMENT_NAME && (attributes$1[attributes.BROWSER_WEB_VITAL_INP_TARGET] = selector);
|
|
249
249
|
entryInteractionType && (attributes$1[attributes.BROWSER_WEB_VITAL_INP_INTERACTION_TYPE] = entryInteractionType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spans.js","sources":["../../../src/web-vitals/spans.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, Span, SpanAttributes } from '@sentry/core';\nimport {\n browserPerformanceTimeOrigin,\n debug,\n getActiveSpan,\n getClient,\n getRootSpan,\n hasSpanStreamingEnabled,\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n spanToJSON,\n timestampInSeconds,\n UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK,\n UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK,\n UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK,\n UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK,\n UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK,\n UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { htmlTreeAsString } from '../htmlTreeAsString';\nimport { getComponentName } from '../component-name';\nimport type { InteractionType } from './inp';\nimport { getCachedInteractionContext, INP_ENTRY_MAP, MAX_PLAUSIBLE_INP_DURATION, UNKNOWN_ELEMENT_NAME } from './inp';\nimport type { InstrumentationHandlerCallback, MetricNavigationType } from '../instrumentation/performanceObserver';\nimport {\n addClsInstrumentationHandler,\n addInpInstrumentationHandler,\n addLcpInstrumentationHandler,\n} from '../instrumentation/performanceObserver';\nimport type { LargestContentfulPaint, LayoutShift } from './emitSpan';\nimport {\n BROWSER_NAVIGATION_TYPE,\n BROWSER_WEB_VITAL_INP_INTERACTION_TYPE,\n BROWSER_WEB_VITAL_INP_TARGET,\n UI_COMPONENT_NAME,\n} from '@sentry/conventions/attributes';\nimport { _emitWebVitalSpan } from './emitSpan';\nimport { isValidLcpMetric } from './lcp';\nimport { listenForWebVitalReportEvents } from './reportEvents';\nimport { getNavigationSpanForMetric } from './softNavs';\nimport { getBrowserPerformanceAPI, msToSec, supportsWebVital } from '../performance/utils';\nimport type { PerformanceEventTiming } from '../instrumentation/performanceObserver';\nimport {\n NAVIGATION,\n UI_INTERACTION_CLICK,\n UI_INTERACTION_DRAG,\n UI_INTERACTION_HOVER,\n UI_INTERACTION_PRESS,\n UI_WEBVITAL_CLS,\n UI_WEBVITAL_LCP,\n} from '@sentry/conventions/op';\n\nconst INTERACTION_TYPE_TO_SPAN_OP: Record<InteractionType, string> = {\n click: UI_INTERACTION_CLICK,\n hover: UI_INTERACTION_HOVER,\n drag: UI_INTERACTION_DRAG,\n press: UI_INTERACTION_PRESS,\n};\n\nconst INTERACTION_TYPE_TO_SPAN_NAME_FALLBACK: Record<InteractionType, string> = {\n click: UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK,\n hover: UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK,\n drag: UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK,\n press: UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK,\n};\n\ntype WebVitalMetric = Parameters<Parameters<typeof addLcpInstrumentationHandler>[0]>[0]['metric'];\ntype InpMetric = Parameters<InstrumentationHandlerCallback>[0]['metric'];\n\n/**\n * Reports a web vital once per navigation, rather than once per page load.\n *\n * web-vitals restarts the metric on every soft navigation and force-reports the previous one just\n * before it does (and again on pagehide), and re-reports every metric after a bfcache restore.\n * Since `reportAllChanges` is off in this mode, every value we're handed is already the final one\n * for its navigation, so there is nothing to accumulate: each report is a span.\n */\nfunction trackWebVitalPerNavigation<M extends WebVitalMetric>(\n client: Client,\n addInstrumentationHandler: (callback: (data: { metric: M }) => void) => unknown,\n send: (metric: M, parentSpan: Span | undefined, softNavigationId: number | undefined) => void,\n): void {\n let pageloadSpan: Span | undefined;\n client.on('afterStartPageLoadSpan', span => {\n pageloadSpan = span;\n });\n\n // Remembered when the restore happens rather than read back at report time: the restore\n // navigation span is an idle span, and CLS and INP are only finalized on pagehide, by which point\n // it has long ended and is no longer what is active.\n let bfcacheNavigationSpan: Span | undefined;\n client.on('spanStart', span => {\n // The op has to be checked too: the web vital spans emitted for a restore carry the same\n // `back-forward-cache` navigation type, so matching on that alone lets the first of them replace the\n // navigation span, and every later vital then hangs off a sibling vital instead.\n const attributes = spanToJSON(span).attributes;\n if (\n attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] === NAVIGATION &&\n attributes[BROWSER_NAVIGATION_TYPE] === 'back-forward-cache'\n ) {\n bfcacheNavigationSpan = span;\n }\n });\n\n addInstrumentationHandler(({ metric }) => {\n const navigationSpan = getNavigationSpanForMetric(metric);\n if (metric.navigationType === 'soft-navigation') {\n // Reporting an uncorrelated soft navigation vital would attribute it to the wrong route, so\n // it's dropped instead.\n if (navigationSpan) {\n send(metric, navigationSpan, metric.navigationId);\n } else {\n DEBUG_BUILD &&\n debug.log(`[SoftNav] Dropping ${metric.name} for uncorrelated soft navigation ${metric.navigationId}`);\n }\n return;\n }\n\n if (metric.navigationType === 'back-forward-cache') {\n // A restore reuses the frozen document, so the pageload span above belongs to the page view\n // from before the freeze. The navigation span started for the restore is the page view these\n // values were actually measured on.\n send(metric, bfcacheNavigationSpan, undefined);\n return;\n }\n\n send(metric, pageloadSpan, undefined);\n });\n}\n\n/**\n * Tracks LCP as a streamed span.\n */\nexport function trackLcpAsSpan(client: Client, perNavigation = false): void {\n if (!supportsWebVital('largest-contentful-paint')) {\n return;\n }\n\n if (perNavigation) {\n trackWebVitalPerNavigation(client, addLcpInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n const entry = metric.entries[metric.entries.length - 1] as LargestContentfulPaint | undefined;\n _sendLcpSpan(\n metric.value,\n entry,\n parentSpan,\n softNavigationId,\n metric.navigationType,\n metric.navigationStartTime,\n );\n });\n return;\n }\n\n let lcpValue = 0;\n let lcpEntry: LargestContentfulPaint | undefined;\n let lcpNavigationType: MetricNavigationType | undefined;\n\n const cleanupLcpHandler = addLcpInstrumentationHandler(({ metric }) => {\n // The navigation type describes the page, not the entry, so it is worth keeping even for a\n // report we otherwise discard.\n lcpNavigationType = metric.navigationType;\n\n const entry = metric.entries[metric.entries.length - 1] as LargestContentfulPaint | undefined;\n if (!entry || !isValidLcpMetric(metric.value)) {\n return;\n }\n lcpValue = metric.value;\n lcpEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, pageloadSpan => {\n _sendLcpSpan(lcpValue, lcpEntry, pageloadSpan, undefined, lcpNavigationType);\n cleanupLcpHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendLcpSpan(\n lcpValue: number,\n entry: LargestContentfulPaint | undefined,\n pageloadSpan?: Span,\n softNavigationId?: number,\n navigationType?: MetricNavigationType,\n navigationStartTime?: number,\n): void {\n if (!isValidLcpMetric(lcpValue)) {\n return;\n }\n\n DEBUG_BUILD && debug.log(`Sending LCP span (${lcpValue})`);\n\n const performanceTimeOrigin = browserPerformanceTimeOrigin() || 0;\n // A soft navigation's LCP is measured from the triggering interaction, not the document time\n // origin. Starting the span there too keeps it inside the navigation span it is parented to and\n // keeps its duration equal to the value it reports.\n const startTime = msToSec(performanceTimeOrigin + (navigationStartTime || 0));\n // Without an entry there is no render time to end at, so the span lasts the value it reports,\n // like an entry-less INP does. Ending at the time origin instead would invert the span.\n const endTime = entry ? msToSec(performanceTimeOrigin + entry.startTime) : startTime + msToSec(lcpValue);\n const selector = entry ? htmlTreeAsString(entry.element) : undefined;\n const componentName = entry?.element ? getComponentName(entry.element) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming\n ? componentName || UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK\n : (selector ?? UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK);\n\n const attributes: SpanAttributes = {};\n\n if (selector) {\n attributes['browser.web_vital.lcp.element'] = selector;\n }\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n entry?.id && (attributes['browser.web_vital.lcp.id'] = entry.id);\n entry?.url && (attributes['browser.web_vital.lcp.url'] = entry.url);\n entry?.loadTime != null && (attributes['browser.web_vital.lcp.load_time'] = entry.loadTime);\n entry?.renderTime != null && (attributes['browser.web_vital.lcp.render_time'] = entry.renderTime);\n entry?.size != null && (attributes['browser.web_vital.lcp.size'] = entry.size);\n\n _emitWebVitalSpan({\n name,\n op: UI_WEBVITAL_LCP,\n origin: 'auto.http.browser.lcp',\n metricName: 'lcp',\n value: lcpValue,\n attributes,\n parentSpan: pageloadSpan,\n startTime,\n endTime,\n softNavigationId,\n navigationType,\n });\n}\n\n/**\n * Tracks CLS as a streamed span.\n */\nexport function trackClsAsSpan(client: Client, perNavigation = false): void {\n if (!supportsWebVital('layout-shift')) {\n return;\n }\n\n if (perNavigation) {\n trackWebVitalPerNavigation(client, addClsInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n const entry = metric.entries[metric.entries.length - 1] as LayoutShift | undefined;\n _sendClsSpan(\n metric.value,\n entry,\n parentSpan,\n softNavigationId,\n metric.navigationType,\n metric.navigationStartTime,\n );\n });\n return;\n }\n\n let clsValue = 0;\n let clsEntry: LayoutShift | undefined;\n let clsNavigationType: MetricNavigationType | undefined;\n\n const cleanupClsHandler = addClsInstrumentationHandler(({ metric }) => {\n // A CLS of 0 is reported with no entries and still emits a span, so the navigation type has to\n // be captured before the entry check rather than alongside the value.\n clsNavigationType = metric.navigationType;\n\n const entry = metric.entries[metric.entries.length - 1] as LayoutShift | undefined;\n if (!entry) {\n return;\n }\n clsValue = metric.value;\n clsEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, pageloadSpan => {\n _sendClsSpan(clsValue, clsEntry, pageloadSpan, undefined, clsNavigationType);\n cleanupClsHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendClsSpan(\n clsValue: number,\n entry: LayoutShift | undefined,\n pageloadSpan?: Span,\n softNavigationId?: number,\n navigationType?: MetricNavigationType,\n navigationStartTime?: number,\n): void {\n DEBUG_BUILD && debug.log(`Sending CLS span (${clsValue})`);\n\n const performanceTimeOrigin = browserPerformanceTimeOrigin();\n // A CLS of 0 has no shift to place the span at. It is reported when the navigation it was\n // measured on is already over - the next soft navigation, or pagehide - so the current time would\n // land it outside that navigation, on the route that follows it.\n const offset = entry?.startTime ?? navigationStartTime ?? 0;\n const startTime = performanceTimeOrigin ? msToSec(performanceTimeOrigin + offset) : timestampInSeconds();\n const firstSourceNode = entry?.sources[0]?.node;\n const selector = entry ? htmlTreeAsString(firstSourceNode) : undefined;\n const componentName = firstSourceNode ? getComponentName(firstSourceNode) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming\n ? componentName || UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK\n : (selector ?? UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK);\n\n const attributes: SpanAttributes = {};\n\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n\n if (entry?.sources) {\n entry.sources.forEach((source, index) => {\n attributes[`browser.web_vital.cls.source.${index + 1}`] = htmlTreeAsString(source.node);\n });\n }\n\n _emitWebVitalSpan({\n name,\n op: UI_WEBVITAL_CLS,\n origin: 'auto.http.browser.cls',\n metricName: 'cls',\n value: clsValue,\n attributes,\n parentSpan: pageloadSpan,\n startTime,\n softNavigationId,\n navigationType,\n });\n}\n\n/**\n * Tracks INP and emits it as a web vital span, as a child of the interaction's root span.\n * Requires `registerInpInteractionListener()` to be called separately for cached element names and\n * root spans per interaction.\n */\nexport function trackInpAsSpan(client: Client, perNavigation = false): void {\n const performance = getBrowserPerformanceAPI();\n if (!performance || !browserPerformanceTimeOrigin()) {\n return;\n }\n\n // INP reports late (on pagehide, after the pageload span has ended). With span streaming enabled\n // it rides the streaming pipeline. With streaming disabled it would be dropped as a late span, so\n // it is emitted as its own standalone v2 span instead (see `_emitWebVitalSpan`), overriding the\n // static trace lifecycle for INP only.\n // TODO(standalone): once the static trace lifecycle is dropped, INP always streams; drop this flag.\n const standalone = !hasSpanStreamingEnabled(client);\n\n if (perNavigation) {\n // INP restarts per navigation and reports once that navigation is over, by which point the\n // navigation span has ended and the interaction cache no longer knows about it. The metric\n // says which navigation it belongs to, so INP is attributed exactly like LCP and CLS.\n trackWebVitalPerNavigation(client, addInpInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n if (isPlausibleInp(metric)) {\n _sendInpSpan(metric.value, findInpEntry(metric), standalone, parentSpan, softNavigationId, metric);\n }\n });\n return;\n }\n\n const onInp: InstrumentationHandlerCallback = ({ metric }) => {\n if (isPlausibleInp(metric)) {\n _sendInpSpan(metric.value, findInpEntry(metric), standalone, undefined, undefined, metric);\n }\n };\n\n addInpInstrumentationHandler(onInp);\n}\n\nfunction isPlausibleInp(metric: InpMetric): boolean {\n return metric.value != null && msToSec(metric.value) <= MAX_PLAUSIBLE_INP_DURATION;\n}\n\n/**\n * The entry an INP span is built from: the one whose duration the reported value came from.\n *\n * There isn't always one. When every interaction of a soft navigation stayed below the Event Timing\n * threshold, web-vitals reports a synthetic value with no entries at all - see\n * `_estimateP98LongestInteraction`. The span still gets reported in that case, just without the\n * element and interaction type an entry would have supplied.\n */\nfunction findInpEntry(metric: InpMetric): PerformanceEventTiming | undefined {\n return metric.entries.find(e => e.duration === metric.value && INP_ENTRY_MAP[e.name]);\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendInpSpan(\n inpValue: number,\n entry: PerformanceEventTiming | undefined,\n standalone = false,\n attributedSpan?: Span,\n softNavigationId?: number,\n metric?: InpMetric,\n): void {\n DEBUG_BUILD && debug.log(`Sending INP span (${inpValue})`);\n\n // A web vital span carries the metric, not a real interaction timing, so an INP without an entry\n // is still worth reporting. It just has no element or interaction type to describe, and is placed\n // at the start of the navigation it belongs to rather than at the interaction.\n const startTime = msToSec(\n (browserPerformanceTimeOrigin() as number) + (entry?.startTime ?? metric?.navigationStartTime ?? 0),\n );\n const duration = msToSec(inpValue);\n // An INP without an entry has no interaction type to report. It still has to land inside the\n // `ui.interaction.*` family, because falling outside it would hide exactly the fast navigations\n // that web-vitals synthesizes these values for (GoogleChrome/web-vitals#724), reintroducing the\n // reporting bias they were added to remove.\n const entryInteractionType = entry && INP_ENTRY_MAP[entry.name];\n const interactionType = entryInteractionType || 'click';\n\n const cachedContext = entry && getCachedInteractionContext(entry.interactionId);\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined;\n\n // With soft navigations the caller knows exactly which navigation the metric belongs to. Without\n // them we fall back to the span that was active when the interaction was observed.\n const spanToUse = attributedSpan || cachedContext?.span || rootSpan;\n const selector = cachedContext?.elementName || (entry ? htmlTreeAsString(entry.target) : undefined);\n const componentName = entry?.target ? getComponentName(entry.target) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const fallbackName = INTERACTION_TYPE_TO_SPAN_NAME_FALLBACK[interactionType];\n const name = hasSpanStreaming ? componentName || fallbackName : (selector ?? 'Interaction to next paint');\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: entry?.duration ?? inpValue,\n };\n\n // The span's name and op always have a value, even for an INP without an entry, so they can't\n // say whether there was an interaction to describe. These attributes can: they are only set for\n // what was actually observed. The name no longer holds the selector either, now that it is the\n // component name or the op's fallback under span streaming.\n selector && selector !== UNKNOWN_ELEMENT_NAME && (attributes[BROWSER_WEB_VITAL_INP_TARGET] = selector);\n entryInteractionType && (attributes[BROWSER_WEB_VITAL_INP_INTERACTION_TYPE] = entryInteractionType);\n\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n\n _emitWebVitalSpan({\n name,\n op: INTERACTION_TYPE_TO_SPAN_OP[interactionType],\n origin: 'auto.http.browser.inp',\n metricName: 'inp',\n value: inpValue,\n attributes,\n startTime,\n endTime: startTime + duration,\n navigationType: metric?.navigationType,\n parentSpan: spanToUse,\n standalone,\n softNavigationId,\n });\n}\n"],"names":["UI_INTERACTION_CLICK","UI_INTERACTION_HOVER","UI_INTERACTION_DRAG","UI_INTERACTION_PRESS","UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK","UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK","UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK","UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK","attributes","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","NAVIGATION","BROWSER_NAVIGATION_TYPE","getNavigationSpanForMetric","DEBUG_BUILD","debug","supportsWebVital","addLcpInstrumentationHandler","isValidLcpMetric","listenForWebVitalReportEvents","browserPerformanceTimeOrigin","msToSec","htmlTreeAsString","componentName","getComponentName","getClient","hasSpanStreamingEnabled","UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK","UI_COMPONENT_NAME","_emitWebVitalSpan","UI_WEBVITAL_LCP","addClsInstrumentationHandler","timestampInSeconds","UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK","UI_WEBVITAL_CLS","getBrowserPerformanceAPI","addInpInstrumentationHandler","MAX_PLAUSIBLE_INP_DURATION","INP_ENTRY_MAP","getCachedInteractionContext","getActiveSpan","getRootSpan","SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME","UNKNOWN_ELEMENT_NAME","BROWSER_WEB_VITAL_INP_TARGET","BROWSER_WEB_VITAL_INP_INTERACTION_TYPE"],"mappings":";;;;;;;;;;;;;;;;AAsDA,MAAM,2BAAA,GAA+D;AAAA,E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,GAAe,uCAAuC,eAAe,CAAA;AAC3E,EAAA,MAAM,IAAA,GAAO,gBAAA,GAAmBH,eAAA,IAAiB,YAAA,GAAgB,QAAA,IAAY,2BAAA;AAE7E,EAAA,MAAMf,YAAA,GAA6B;AAAA,IACjC,CAACkC,sCAAiC,GAAG,KAAA,EAAO,QAAA,IAAY;AAAA,GAC1D;AAMA,EAAA,QAAA,IAAY,QAAA,KAAaC,wBAAA,KAAyBnC,YAAA,CAAWoC,uCAA4B,CAAA,GAAI,QAAA,CAAA;AAC7F,EAAA,oBAAA,KAAyBpC,YAAA,CAAWqC,iDAAsC,CAAA,GAAI,oBAAA,CAAA;AAE9E,EAAA,IAAItB,eAAA,EAAe;AACjB,IAAAf,YAAA,CAAWoB,4BAAiB,CAAA,GAAIL,eAAA;AAAA,EAClC;AAEA,EAAAM,0BAAA,CAAkB;AAAA,IAChB,IAAA;AAAA,IACA,EAAA,EAAI,4BAA4B,eAAe,CAAA;AAAA,IAC/C,MAAA,EAAQ,uBAAA;AAAA,IACR,UAAA,EAAY,KAAA;AAAA,IACZ,KAAA,EAAO,QAAA;AAAA,gBACPrB,YAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAS,SAAA,GAAY,QAAA;AAAA,IACrB,gBAAgB,MAAA,EAAQ,cAAA;AAAA,IACxB,UAAA,EAAY,SAAA;AAAA,IACZ,UAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"spans.js","sources":["../../../src/web-vitals/spans.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, Span, SpanAttributes } from '@sentry/core';\nimport {\n browserPerformanceTimeOrigin,\n debug,\n getActiveSpan,\n getClient,\n getRootSpan,\n hasSpanStreamingEnabled,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n spanToJSON,\n timestampInSeconds,\n UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK,\n UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK,\n UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK,\n UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK,\n UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK,\n UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { htmlTreeAsString } from '../htmlTreeAsString';\nimport { getComponentName } from '../component-name';\nimport type { InteractionType } from './inp';\nimport { getCachedInteractionContext, INP_ENTRY_MAP, MAX_PLAUSIBLE_INP_DURATION, UNKNOWN_ELEMENT_NAME } from './inp';\nimport type { InstrumentationHandlerCallback, MetricNavigationType } from '../instrumentation/performanceObserver';\nimport {\n addClsInstrumentationHandler,\n addInpInstrumentationHandler,\n addLcpInstrumentationHandler,\n} from '../instrumentation/performanceObserver';\nimport type { LargestContentfulPaint, LayoutShift } from './emitSpan';\nimport {\n SENTRY_EXCLUSIVE_TIME,\n BROWSER_NAVIGATION_TYPE,\n BROWSER_WEB_VITAL_INP_INTERACTION_TYPE,\n BROWSER_WEB_VITAL_INP_TARGET,\n UI_COMPONENT_NAME,\n} from '@sentry/conventions/attributes';\nimport { _emitWebVitalSpan } from './emitSpan';\nimport { isValidLcpMetric } from './lcp';\nimport { listenForWebVitalReportEvents } from './reportEvents';\nimport { getNavigationSpanForMetric } from './softNavs';\nimport { getBrowserPerformanceAPI, msToSec, supportsWebVital } from '../performance/utils';\nimport type { PerformanceEventTiming } from '../instrumentation/performanceObserver';\nimport {\n NAVIGATION,\n UI_INTERACTION_CLICK,\n UI_INTERACTION_DRAG,\n UI_INTERACTION_HOVER,\n UI_INTERACTION_PRESS,\n UI_WEBVITAL_CLS,\n UI_WEBVITAL_LCP,\n} from '@sentry/conventions/op';\n\nconst INTERACTION_TYPE_TO_SPAN_OP: Record<InteractionType, string> = {\n click: UI_INTERACTION_CLICK,\n hover: UI_INTERACTION_HOVER,\n drag: UI_INTERACTION_DRAG,\n press: UI_INTERACTION_PRESS,\n};\n\nconst INTERACTION_TYPE_TO_SPAN_NAME_FALLBACK: Record<InteractionType, string> = {\n click: UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK,\n hover: UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK,\n drag: UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK,\n press: UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK,\n};\n\ntype WebVitalMetric = Parameters<Parameters<typeof addLcpInstrumentationHandler>[0]>[0]['metric'];\ntype InpMetric = Parameters<InstrumentationHandlerCallback>[0]['metric'];\n\n/**\n * Reports a web vital once per navigation, rather than once per page load.\n *\n * web-vitals restarts the metric on every soft navigation and force-reports the previous one just\n * before it does (and again on pagehide), and re-reports every metric after a bfcache restore.\n * Since `reportAllChanges` is off in this mode, every value we're handed is already the final one\n * for its navigation, so there is nothing to accumulate: each report is a span.\n */\nfunction trackWebVitalPerNavigation<M extends WebVitalMetric>(\n client: Client,\n addInstrumentationHandler: (callback: (data: { metric: M }) => void) => unknown,\n send: (metric: M, parentSpan: Span | undefined, softNavigationId: number | undefined) => void,\n): void {\n let pageloadSpan: Span | undefined;\n client.on('afterStartPageLoadSpan', span => {\n pageloadSpan = span;\n });\n\n // Remembered when the restore happens rather than read back at report time: the restore\n // navigation span is an idle span, and CLS and INP are only finalized on pagehide, by which point\n // it has long ended and is no longer what is active.\n let bfcacheNavigationSpan: Span | undefined;\n client.on('spanStart', span => {\n // The op has to be checked too: the web vital spans emitted for a restore carry the same\n // `back-forward-cache` navigation type, so matching on that alone lets the first of them replace the\n // navigation span, and every later vital then hangs off a sibling vital instead.\n const attributes = spanToJSON(span).attributes;\n if (\n attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] === NAVIGATION &&\n attributes[BROWSER_NAVIGATION_TYPE] === 'back-forward-cache'\n ) {\n bfcacheNavigationSpan = span;\n }\n });\n\n addInstrumentationHandler(({ metric }) => {\n const navigationSpan = getNavigationSpanForMetric(metric);\n if (metric.navigationType === 'soft-navigation') {\n // Reporting an uncorrelated soft navigation vital would attribute it to the wrong route, so\n // it's dropped instead.\n if (navigationSpan) {\n send(metric, navigationSpan, metric.navigationId);\n } else {\n DEBUG_BUILD &&\n debug.log(`[SoftNav] Dropping ${metric.name} for uncorrelated soft navigation ${metric.navigationId}`);\n }\n return;\n }\n\n if (metric.navigationType === 'back-forward-cache') {\n // A restore reuses the frozen document, so the pageload span above belongs to the page view\n // from before the freeze. The navigation span started for the restore is the page view these\n // values were actually measured on.\n send(metric, bfcacheNavigationSpan, undefined);\n return;\n }\n\n send(metric, pageloadSpan, undefined);\n });\n}\n\n/**\n * Tracks LCP as a streamed span.\n */\nexport function trackLcpAsSpan(client: Client, perNavigation = false): void {\n if (!supportsWebVital('largest-contentful-paint')) {\n return;\n }\n\n if (perNavigation) {\n trackWebVitalPerNavigation(client, addLcpInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n const entry = metric.entries[metric.entries.length - 1] as LargestContentfulPaint | undefined;\n _sendLcpSpan(\n metric.value,\n entry,\n parentSpan,\n softNavigationId,\n metric.navigationType,\n metric.navigationStartTime,\n );\n });\n return;\n }\n\n let lcpValue = 0;\n let lcpEntry: LargestContentfulPaint | undefined;\n let lcpNavigationType: MetricNavigationType | undefined;\n\n const cleanupLcpHandler = addLcpInstrumentationHandler(({ metric }) => {\n // The navigation type describes the page, not the entry, so it is worth keeping even for a\n // report we otherwise discard.\n lcpNavigationType = metric.navigationType;\n\n const entry = metric.entries[metric.entries.length - 1] as LargestContentfulPaint | undefined;\n if (!entry || !isValidLcpMetric(metric.value)) {\n return;\n }\n lcpValue = metric.value;\n lcpEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, pageloadSpan => {\n _sendLcpSpan(lcpValue, lcpEntry, pageloadSpan, undefined, lcpNavigationType);\n cleanupLcpHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendLcpSpan(\n lcpValue: number,\n entry: LargestContentfulPaint | undefined,\n pageloadSpan?: Span,\n softNavigationId?: number,\n navigationType?: MetricNavigationType,\n navigationStartTime?: number,\n): void {\n if (!isValidLcpMetric(lcpValue)) {\n return;\n }\n\n DEBUG_BUILD && debug.log(`Sending LCP span (${lcpValue})`);\n\n const performanceTimeOrigin = browserPerformanceTimeOrigin() || 0;\n // A soft navigation's LCP is measured from the triggering interaction, not the document time\n // origin. Starting the span there too keeps it inside the navigation span it is parented to and\n // keeps its duration equal to the value it reports.\n const startTime = msToSec(performanceTimeOrigin + (navigationStartTime || 0));\n // Without an entry there is no render time to end at, so the span lasts the value it reports,\n // like an entry-less INP does. Ending at the time origin instead would invert the span.\n const endTime = entry ? msToSec(performanceTimeOrigin + entry.startTime) : startTime + msToSec(lcpValue);\n const selector = entry ? htmlTreeAsString(entry.element) : undefined;\n const componentName = entry?.element ? getComponentName(entry.element) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming\n ? componentName || UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK\n : (selector ?? UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK);\n\n const attributes: SpanAttributes = {};\n\n if (selector) {\n attributes['browser.web_vital.lcp.element'] = selector;\n }\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n entry?.id && (attributes['browser.web_vital.lcp.id'] = entry.id);\n entry?.url && (attributes['browser.web_vital.lcp.url'] = entry.url);\n entry?.loadTime != null && (attributes['browser.web_vital.lcp.load_time'] = entry.loadTime);\n entry?.renderTime != null && (attributes['browser.web_vital.lcp.render_time'] = entry.renderTime);\n entry?.size != null && (attributes['browser.web_vital.lcp.size'] = entry.size);\n\n _emitWebVitalSpan({\n name,\n op: UI_WEBVITAL_LCP,\n origin: 'auto.http.browser.lcp',\n metricName: 'lcp',\n value: lcpValue,\n attributes,\n parentSpan: pageloadSpan,\n startTime,\n endTime,\n softNavigationId,\n navigationType,\n });\n}\n\n/**\n * Tracks CLS as a streamed span.\n */\nexport function trackClsAsSpan(client: Client, perNavigation = false): void {\n if (!supportsWebVital('layout-shift')) {\n return;\n }\n\n if (perNavigation) {\n trackWebVitalPerNavigation(client, addClsInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n const entry = metric.entries[metric.entries.length - 1] as LayoutShift | undefined;\n _sendClsSpan(\n metric.value,\n entry,\n parentSpan,\n softNavigationId,\n metric.navigationType,\n metric.navigationStartTime,\n );\n });\n return;\n }\n\n let clsValue = 0;\n let clsEntry: LayoutShift | undefined;\n let clsNavigationType: MetricNavigationType | undefined;\n\n const cleanupClsHandler = addClsInstrumentationHandler(({ metric }) => {\n // A CLS of 0 is reported with no entries and still emits a span, so the navigation type has to\n // be captured before the entry check rather than alongside the value.\n clsNavigationType = metric.navigationType;\n\n const entry = metric.entries[metric.entries.length - 1] as LayoutShift | undefined;\n if (!entry) {\n return;\n }\n clsValue = metric.value;\n clsEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, pageloadSpan => {\n _sendClsSpan(clsValue, clsEntry, pageloadSpan, undefined, clsNavigationType);\n cleanupClsHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendClsSpan(\n clsValue: number,\n entry: LayoutShift | undefined,\n pageloadSpan?: Span,\n softNavigationId?: number,\n navigationType?: MetricNavigationType,\n navigationStartTime?: number,\n): void {\n DEBUG_BUILD && debug.log(`Sending CLS span (${clsValue})`);\n\n const performanceTimeOrigin = browserPerformanceTimeOrigin();\n // A CLS of 0 has no shift to place the span at. It is reported when the navigation it was\n // measured on is already over - the next soft navigation, or pagehide - so the current time would\n // land it outside that navigation, on the route that follows it.\n const offset = entry?.startTime ?? navigationStartTime ?? 0;\n const startTime = performanceTimeOrigin ? msToSec(performanceTimeOrigin + offset) : timestampInSeconds();\n const firstSourceNode = entry?.sources[0]?.node;\n const selector = entry ? htmlTreeAsString(firstSourceNode) : undefined;\n const componentName = firstSourceNode ? getComponentName(firstSourceNode) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming\n ? componentName || UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK\n : (selector ?? UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK);\n\n const attributes: SpanAttributes = {};\n\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n\n if (entry?.sources) {\n entry.sources.forEach((source, index) => {\n attributes[`browser.web_vital.cls.source.${index + 1}`] = htmlTreeAsString(source.node);\n });\n }\n\n _emitWebVitalSpan({\n name,\n op: UI_WEBVITAL_CLS,\n origin: 'auto.http.browser.cls',\n metricName: 'cls',\n value: clsValue,\n attributes,\n parentSpan: pageloadSpan,\n startTime,\n softNavigationId,\n navigationType,\n });\n}\n\n/**\n * Tracks INP and emits it as a web vital span, as a child of the interaction's root span.\n * Requires `registerInpInteractionListener()` to be called separately for cached element names and\n * root spans per interaction.\n */\nexport function trackInpAsSpan(client: Client, perNavigation = false): void {\n const performance = getBrowserPerformanceAPI();\n if (!performance || !browserPerformanceTimeOrigin()) {\n return;\n }\n\n // INP reports late (on pagehide, after the pageload span has ended). With span streaming enabled\n // it rides the streaming pipeline. With streaming disabled it would be dropped as a late span, so\n // it is emitted as its own standalone v2 span instead (see `_emitWebVitalSpan`), overriding the\n // static trace lifecycle for INP only.\n // TODO(standalone): once the static trace lifecycle is dropped, INP always streams; drop this flag.\n const standalone = !hasSpanStreamingEnabled(client);\n\n if (perNavigation) {\n // INP restarts per navigation and reports once that navigation is over, by which point the\n // navigation span has ended and the interaction cache no longer knows about it. The metric\n // says which navigation it belongs to, so INP is attributed exactly like LCP and CLS.\n trackWebVitalPerNavigation(client, addInpInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n if (isPlausibleInp(metric)) {\n _sendInpSpan(metric.value, findInpEntry(metric), standalone, parentSpan, softNavigationId, metric);\n }\n });\n return;\n }\n\n const onInp: InstrumentationHandlerCallback = ({ metric }) => {\n if (isPlausibleInp(metric)) {\n _sendInpSpan(metric.value, findInpEntry(metric), standalone, undefined, undefined, metric);\n }\n };\n\n addInpInstrumentationHandler(onInp);\n}\n\nfunction isPlausibleInp(metric: InpMetric): boolean {\n return metric.value != null && msToSec(metric.value) <= MAX_PLAUSIBLE_INP_DURATION;\n}\n\n/**\n * The entry an INP span is built from: the one whose duration the reported value came from.\n *\n * There isn't always one. When every interaction of a soft navigation stayed below the Event Timing\n * threshold, web-vitals reports a synthetic value with no entries at all - see\n * `_estimateP98LongestInteraction`. The span still gets reported in that case, just without the\n * element and interaction type an entry would have supplied.\n */\nfunction findInpEntry(metric: InpMetric): PerformanceEventTiming | undefined {\n return metric.entries.find(e => e.duration === metric.value && INP_ENTRY_MAP[e.name]);\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendInpSpan(\n inpValue: number,\n entry: PerformanceEventTiming | undefined,\n standalone = false,\n attributedSpan?: Span,\n softNavigationId?: number,\n metric?: InpMetric,\n): void {\n DEBUG_BUILD && debug.log(`Sending INP span (${inpValue})`);\n\n // A web vital span carries the metric, not a real interaction timing, so an INP without an entry\n // is still worth reporting. It just has no element or interaction type to describe, and is placed\n // at the start of the navigation it belongs to rather than at the interaction.\n const startTime = msToSec(\n (browserPerformanceTimeOrigin() as number) + (entry?.startTime ?? metric?.navigationStartTime ?? 0),\n );\n const duration = msToSec(inpValue);\n // An INP without an entry has no interaction type to report. It still has to land inside the\n // `ui.interaction.*` family, because falling outside it would hide exactly the fast navigations\n // that web-vitals synthesizes these values for (GoogleChrome/web-vitals#724), reintroducing the\n // reporting bias they were added to remove.\n const entryInteractionType = entry && INP_ENTRY_MAP[entry.name];\n const interactionType = entryInteractionType || 'click';\n\n const cachedContext = entry && getCachedInteractionContext(entry.interactionId);\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined;\n\n // With soft navigations the caller knows exactly which navigation the metric belongs to. Without\n // them we fall back to the span that was active when the interaction was observed.\n const spanToUse = attributedSpan || cachedContext?.span || rootSpan;\n const selector = cachedContext?.elementName || (entry ? htmlTreeAsString(entry.target) : undefined);\n const componentName = entry?.target ? getComponentName(entry.target) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const fallbackName = INTERACTION_TYPE_TO_SPAN_NAME_FALLBACK[interactionType];\n const name = hasSpanStreaming ? componentName || fallbackName : (selector ?? 'Interaction to next paint');\n\n const attributes: SpanAttributes = {\n [SENTRY_EXCLUSIVE_TIME]: entry?.duration ?? inpValue,\n };\n\n // The span's name and op always have a value, even for an INP without an entry, so they can't\n // say whether there was an interaction to describe. These attributes can: they are only set for\n // what was actually observed. The name no longer holds the selector either, now that it is the\n // component name or the op's fallback under span streaming.\n selector && selector !== UNKNOWN_ELEMENT_NAME && (attributes[BROWSER_WEB_VITAL_INP_TARGET] = selector);\n entryInteractionType && (attributes[BROWSER_WEB_VITAL_INP_INTERACTION_TYPE] = entryInteractionType);\n\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n\n _emitWebVitalSpan({\n name,\n op: INTERACTION_TYPE_TO_SPAN_OP[interactionType],\n origin: 'auto.http.browser.inp',\n metricName: 'inp',\n value: inpValue,\n attributes,\n startTime,\n endTime: startTime + duration,\n navigationType: metric?.navigationType,\n parentSpan: spanToUse,\n standalone,\n softNavigationId,\n });\n}\n"],"names":["UI_INTERACTION_CLICK","UI_INTERACTION_HOVER","UI_INTERACTION_DRAG","UI_INTERACTION_PRESS","UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK","UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK","UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK","UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK","attributes","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","NAVIGATION","BROWSER_NAVIGATION_TYPE","getNavigationSpanForMetric","DEBUG_BUILD","debug","supportsWebVital","addLcpInstrumentationHandler","isValidLcpMetric","listenForWebVitalReportEvents","browserPerformanceTimeOrigin","msToSec","htmlTreeAsString","componentName","getComponentName","getClient","hasSpanStreamingEnabled","UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK","UI_COMPONENT_NAME","_emitWebVitalSpan","UI_WEBVITAL_LCP","addClsInstrumentationHandler","timestampInSeconds","UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK","UI_WEBVITAL_CLS","getBrowserPerformanceAPI","addInpInstrumentationHandler","MAX_PLAUSIBLE_INP_DURATION","INP_ENTRY_MAP","getCachedInteractionContext","getActiveSpan","getRootSpan","SENTRY_EXCLUSIVE_TIME","UNKNOWN_ELEMENT_NAME","BROWSER_WEB_VITAL_INP_TARGET","BROWSER_WEB_VITAL_INP_INTERACTION_TYPE"],"mappings":";;;;;;;;;;;;;;;;AAsDA,MAAM,2BAAA,GAA+D;AAAA,EACnE,KAAA,EAAOA,uBAAA;AAAA,EACP,KAAA,EAAOC,uBAAA;AAAA,EACP,IAAA,EAAMC,sBAAA;AAAA,EACN,KAAA,EAAOC;AACT,CAAA;AAEA,MAAM,sCAAA,GAA0E;AAAA,EAC9E,KAAA,EAAOC,4CAAA;AAAA,EACP,KAAA,EAAOC,4CAAA;AAAA,EACP,IAAA,EAAMC,2CAAA;AAAA,EACN,KAAA,EAAOC;AACT,CAAA;AAaA,SAAS,0BAAA,CACP,MAAA,EACA,yBAAA,EACA,IAAA,EACM;AACN,EAAA,IAAI,YAAA;AACJ,EAAA,MAAA,CAAO,EAAA,CAAG,0BAA0B,CAAA,IAAA,KAAQ;AAC1C,IAAA,YAAA,GAAe,IAAA;AAAA,EACjB,CAAC,CAAA;AAKD,EAAA,IAAI,qBAAA;AACJ,EAAA,MAAA,CAAO,EAAA,CAAG,aAAa,CAAA,IAAA,KAAQ;AAI7B,IAAA,MAAMC,YAAA,GAAaC,eAAA,CAAW,IAAI,CAAA,CAAE,UAAA;AACpC,IAAA,IACED,eAAaE,iCAA4B,CAAA,KAAMC,iBAC/CH,YAAA,CAAWI,kCAAuB,MAAM,oBAAA,EACxC;AACA,MAAA,qBAAA,GAAwB,IAAA;AAAA,IAC1B;AA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AAA,EAAQ,cAAA;AAAA,IACxB,UAAA,EAAY,SAAA;AAAA,IACZ,UAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;;;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { elementTimingIntegration, startTrackingElementTiming } from './performa
|
|
|
6
6
|
export { interactionsIntegration } from './performance/interactions.js';
|
|
7
7
|
export { isBotUserAgent } from './isBotUserAgent.js';
|
|
8
8
|
export { getLocationHref } from './getLocationHref.js';
|
|
9
|
+
export { createCachedRouteProvider, createUrlRouteProvider, getRouteProvider, resolveCurrentRoute, resolveRoute, setRouteProvider } from './routing.js';
|
|
9
10
|
export { userTimingIntegration } from './performance/userTiming.js';
|
|
10
11
|
export { extractNetworkProtocol } from './performance/utils.js';
|
|
11
12
|
export { trackClsAsSpan, trackInpAsSpan, trackLcpAsSpan } from './web-vitals/spans.js';
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.
|
|
1
|
+
{"type":"module","version":"11.3.0","sideEffects":false}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { LRUMap, getClient, safeCallback, debug, parseStringToURLObject } from '@sentry/core';
|
|
2
|
+
import { DEBUG_BUILD } from './debug-build.js';
|
|
3
|
+
import { getLocationHref } from './getLocationHref.js';
|
|
4
|
+
|
|
5
|
+
const CLIENT_ROUTE_PROVIDERS = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
function setRouteProvider(provider, client = getClient()) {
|
|
7
|
+
if (!client) {
|
|
8
|
+
DEBUG_BUILD && debug.warn("Cannot set a route provider without a client.");
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (DEBUG_BUILD && getRouteProvider(client)) {
|
|
12
|
+
debug.warn(
|
|
13
|
+
"A route provider is already registered for this client and will be replaced. Routes only the previous provider knows about will no longer resolve."
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
CLIENT_ROUTE_PROVIDERS.set(client, provider);
|
|
17
|
+
}
|
|
18
|
+
function getRouteProvider(client = getClient()) {
|
|
19
|
+
return client && CLIENT_ROUTE_PROVIDERS.get(client);
|
|
20
|
+
}
|
|
21
|
+
function resolveRoute(url, client = getClient()) {
|
|
22
|
+
const provider = getRouteProvider(client);
|
|
23
|
+
if (!provider) {
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
const urlObject = typeof url === "string" ? parseLocation(url) : url;
|
|
27
|
+
if (!urlObject) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
return safeCallback(
|
|
31
|
+
DEBUG_BUILD ? "Route provider threw while resolving a route:" : "",
|
|
32
|
+
() => provider.resolveRoute(urlObject) || void 0,
|
|
33
|
+
() => void 0
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function resolveCurrentRoute(client = getClient()) {
|
|
37
|
+
const provider = getRouteProvider(client);
|
|
38
|
+
return safeCallback(
|
|
39
|
+
DEBUG_BUILD ? "Route provider threw while resolving a route:" : "",
|
|
40
|
+
() => provider?.resolveCurrentRoute() || void 0,
|
|
41
|
+
() => void 0
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
function createUrlRouteProvider(resolveRouteFromUrl) {
|
|
45
|
+
return {
|
|
46
|
+
resolveRoute: resolveRouteFromUrl,
|
|
47
|
+
resolveCurrentRoute: () => {
|
|
48
|
+
const urlObject = parseLocation(getLocationHref());
|
|
49
|
+
return urlObject && resolveRouteFromUrl(urlObject);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function createCachedRouteProvider(maxEntries = 50) {
|
|
54
|
+
const routeNames = new LRUMap(maxEntries);
|
|
55
|
+
return {
|
|
56
|
+
...createUrlRouteProvider((url) => routeNames.get(url.pathname)),
|
|
57
|
+
record(pathname, routeName) {
|
|
58
|
+
if (pathname && routeName) {
|
|
59
|
+
routeNames.set(pathname, routeName);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function parseLocation(url) {
|
|
65
|
+
return url ? parseStringToURLObject(url, getLocationHref() || void 0) : void 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { createCachedRouteProvider, createUrlRouteProvider, getRouteProvider, resolveCurrentRoute, resolveRoute, setRouteProvider };
|
|
69
|
+
//# sourceMappingURL=routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.js","sources":["../../src/routing.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport { debug, getClient, LRUMap, parseStringToURLObject, safeCallback } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\nimport { getLocationHref } from './getLocationHref';\n\n/** The parts of a URL a route depends on. A `URL` satisfies it. */\ntype RouteUrl = Pick<URL, 'pathname' | 'search' | 'hash'>;\n\n/**\n * Resolves URLs to low-cardinality route names.\n *\n * Framework SDKs register one so that everything the SDK names after a route (span names, the scope's\n * transaction name, metric and span segment attributes) gets the parameterized route instead of the raw\n * URL, without each integration having to reach into the framework's router itself.\n */\nexport interface RouteProvider {\n /**\n * Resolves a URL path template for a specific URL, e.g. `/users/42` -> `/users/:id`.\n *\n * Must return a path template, never a route identifier. Routers that name routes independently of\n * their path (Vue Router's `route.name`, Ember's `posts.show`) have to return the matched path\n * instead: callers set `url.template` from this, and an identifier is not a template. An SDK that\n * wants to name its span after the identifier still can, on the span itself.\n *\n * Returns `undefined` when the URL matches no known route. Must answer for the URL it is given rather\n * than for wherever the router currently is, so that callers can resolve a URL they captured earlier\n * (a web vital reported after a soft navigation, for example).\n */\n resolveRoute(url: RouteUrl): string | undefined;\n\n /**\n * Resolves the route the app is currently on.\n *\n * Routers whose location lives in the address bar can delegate to `resolveRoute`, which is what\n * {@link createUrlRouteProvider} does. Routers that keep their own location (memory and hash routers)\n * have to answer from that location instead: for those, `location.href` is the unchanging shell URL\n * and would bucket every route together.\n */\n resolveCurrentRoute(): string | undefined;\n}\n\nconst CLIENT_ROUTE_PROVIDERS = new WeakMap<Client, RouteProvider>();\n\n/**\n * Registers the route provider for a client, replacing any previously registered one. `BrowserClient`\n * calls this with its `routeProvider` option.\n *\n * Prefer the `routeProvider` option where the provider is known at `init`: the pageload span is named\n * while `browserTracingIntegration` sets up, so a provider registered after `init` can only rename it\n * after the fact.\n *\n * A client holds one provider. An app running two routers (a framework migration, or a shell plus an\n * island) registers twice and the last one wins, so the first router's routes stop resolving.\n */\nexport function setRouteProvider(provider: RouteProvider, client: Client | undefined = getClient()): void {\n if (!client) {\n DEBUG_BUILD && debug.warn('Cannot set a route provider without a client.');\n return;\n }\n\n if (DEBUG_BUILD && getRouteProvider(client)) {\n debug.warn(\n 'A route provider is already registered for this client and will be replaced. Routes only the previous provider knows about will no longer resolve.',\n );\n }\n\n CLIENT_ROUTE_PROVIDERS.set(client, provider);\n}\n\n/**\n * Returns the route provider registered for a client.\n */\nexport function getRouteProvider(client: Client | undefined = getClient()): RouteProvider | undefined {\n return client && CLIENT_ROUTE_PROVIDERS.get(client);\n}\n\n/**\n * Resolves a URL to a low-cardinality route name, e.g. `/users/42` -> `/users/:id`.\n *\n * Returns `undefined` when no route provider is registered or the URL matches no route. Callers pick\n * their own fallback, because the right one differs: a span name falls back to a low-cardinality\n * constant, the scope's transaction name to the raw path.\n */\nexport function resolveRoute(url: string | URL, client: Client | undefined = getClient()): string | undefined {\n const provider = getRouteProvider(client);\n if (!provider) {\n return undefined;\n }\n\n const urlObject = typeof url === 'string' ? parseLocation(url) : url;\n if (!urlObject) {\n return undefined;\n }\n\n return safeCallback(\n DEBUG_BUILD ? 'Route provider threw while resolving a route:' : '',\n () => provider.resolveRoute(urlObject) || undefined,\n () => undefined,\n );\n}\n\n/**\n * Resolves the route the app is currently on.\n *\n * Returns `undefined` when no route provider is registered or the current location matches no route.\n */\nexport function resolveCurrentRoute(client: Client | undefined = getClient()): string | undefined {\n const provider = getRouteProvider(client);\n\n return safeCallback(\n DEBUG_BUILD ? 'Route provider threw while resolving a route:' : '',\n () => provider?.resolveCurrentRoute() || undefined,\n () => undefined,\n );\n}\n\n/**\n * Builds a {@link RouteProvider} for a router whose location is the browser's, which covers every\n * router except memory and hash routers.\n */\nexport function createUrlRouteProvider(resolveRouteFromUrl: (url: RouteUrl) => string | undefined): RouteProvider {\n return {\n resolveRoute: resolveRouteFromUrl,\n resolveCurrentRoute: () => {\n const urlObject = parseLocation(getLocationHref());\n\n return urlObject && resolveRouteFromUrl(urlObject);\n },\n };\n}\n\n/**\n * A {@link RouteProvider} that answers from routes it has been told about, rather than by matching.\n */\nexport interface CachedRouteProvider extends RouteProvider {\n /** Records the route name a router reported for a path. Ignores empty values. */\n record(pathname: string | undefined, routeName: string | null | undefined): void;\n}\n\n/**\n * Builds a route provider for a router with no usable matcher, which can only report the route it is\n * on as it gets there (SvelteKit's `page.route.id`, Solid Router's current matches).\n *\n * A URL the app has not visited resolves to `undefined`, which includes the first pageload until the\n * router reports. Backed by an LRU so a long-lived app visiting many URLs can't grow it without end,\n * and so routes that keep being resolved outlive ones passed through once.\n */\nexport function createCachedRouteProvider(maxEntries: number = 50): CachedRouteProvider {\n const routeNames = new LRUMap<string, string>(maxEntries);\n\n return {\n ...createUrlRouteProvider(url => routeNames.get(url.pathname)),\n record(pathname, routeName) {\n if (pathname && routeName) {\n routeNames.set(pathname, routeName);\n }\n },\n };\n}\n\n/**\n * Parses up front so providers never have to, and resolves relative locations (which memory routers\n * hand around) against the document.\n */\nfunction parseLocation(url: string): RouteUrl | undefined {\n // Without a document `getLocationHref()` is empty, which would otherwise parse as `/`.\n return url ? parseStringToURLObject(url, getLocationHref() || undefined) : undefined;\n}\n"],"names":[],"mappings":";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GAAkD,EAAA;AAAA,IAChE,MAAM,QAAA,EAAU,mBAAA,EAAoB,IAAK,MAAA;AAAA,IACzC,MAAM;AAAA,GACR;AACF;AAMO,SAAS,uBAAuB,mBAAA,EAA2E;AAChH,EAAA,OAAO;AAAA,IACL,YAAA,EAAc,mBAAA;AAAA,IACd,qBAAqB,MAAM;AACzB,MAAA,MAAM,SAAA,GAAY,aAAA,CAAc,eAAA,EAAiB,CAAA;AAEjD,MAAA,OAAO,SAAA,IAAa,oBAAoB,SAAS,CAAA;AAAA,IACnD;AAAA,GACF;AACF;AAkBO,SAAS,yBAAA,CAA0B,aAAqB,EAAA,EAAyB;AACtF,EAAA,MAAM,UAAA,GAAa,IAAI,MAAA,CAAuB,UAAU,CAAA;AAExD,EAAA,OAAO;AAAA,IACL,GAAG,sBAAA,CAAuB,CAAA,GAAA,KAAO,WAAW,GAAA,CAAI,GAAA,CAAI,QAAQ,CAAC,CAAA;AAAA,IAC7D,MAAA,CAAO,UAAU,SAAA,EAAW;AAC1B,MAAA,IAAI,YAAY,SAAA,EAAW;AACzB,QAAA,UAAA,CAAW,GAAA,CAAI,UAAU,SAAS,CAAA;AAAA,MACpC;AAAA,IACF;AAAA,GACF;AACF;AAMA,SAAS,cAAc,GAAA,EAAmC;AAExD,EAAA,OAAO,MAAM,sBAAA,CAAuB,GAAA,EAAK,eAAA,EAAgB,IAAK,MAAS,CAAA,GAAI,MAAA;AAC7E;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getRootSpan, spanToJSON, getCurrentScope, SEMANTIC_ATTRIBUTE_SENTRY_OP,
|
|
1
|
+
import { getRootSpan, spanToJSON, getCurrentScope, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getClient } from '@sentry/core';
|
|
2
2
|
import { startInactiveSpan } from '@sentry/core/browser';
|
|
3
|
-
import { USER_AGENT_ORIGINAL, BROWSER_NAVIGATION_ID, BROWSER_NAVIGATION_TYPE, SENTRY_SEGMENT_NAME, SENTRY_TRANSACTION, SENTRY_REPLAY_ID } from '@sentry/conventions/attributes';
|
|
3
|
+
import { USER_AGENT_ORIGINAL, BROWSER_NAVIGATION_ID, BROWSER_NAVIGATION_TYPE, SENTRY_SEGMENT_NAME, SENTRY_TRANSACTION, SENTRY_EXCLUSIVE_TIME, SENTRY_REPLAY_ID } from '@sentry/conventions/attributes';
|
|
4
4
|
import { WINDOW } from '../types.js';
|
|
5
5
|
|
|
6
6
|
function _emitWebVitalSpan(options) {
|
|
@@ -23,7 +23,7 @@ function _emitWebVitalSpan(options) {
|
|
|
23
23
|
const attributes = {
|
|
24
24
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,
|
|
25
25
|
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
|
|
26
|
-
[
|
|
26
|
+
[SENTRY_EXCLUSIVE_TIME]: 0,
|
|
27
27
|
[`browser.web_vital.${metricName}.value`]: value,
|
|
28
28
|
// oxlint-disable-next-line typescript-eslint/no-deprecated
|
|
29
29
|
[SENTRY_TRANSACTION]: segmentName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitSpan.js","sources":["../../../src/web-vitals/emitSpan.ts"],"sourcesContent":["import type { Integration, Span, SpanAttributes } from '@sentry/core';\nimport {\n getClient,\n getCurrentScope,\n getRootSpan,\n
|
|
1
|
+
{"version":3,"file":"emitSpan.js","sources":["../../../src/web-vitals/emitSpan.ts"],"sourcesContent":["import type { Integration, Span, SpanAttributes } from '@sentry/core';\nimport {\n getClient,\n getCurrentScope,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n} from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/core/browser';\nimport {\n SENTRY_EXCLUSIVE_TIME,\n BROWSER_NAVIGATION_ID,\n BROWSER_NAVIGATION_TYPE,\n SENTRY_REPLAY_ID,\n SENTRY_SEGMENT_NAME,\n SENTRY_TRANSACTION,\n USER_AGENT_ORIGINAL,\n} from '@sentry/conventions/attributes';\nimport { WINDOW } from '../types';\nimport type { MetricNavigationType } from '../instrumentation/performanceObserver';\n\n// Locally-defined interfaces to avoid leaking bare global type references into the\n// generated .d.ts. The `declare global` augmentations in web-vitals/types.ts make these\n// available during this package's compilation but are NOT carried to consumers.\n// This mirrors the pattern used for PerformanceEventTiming in instrument.ts.\nexport interface LayoutShift extends PerformanceEntry {\n value: number;\n sources: Array<{ node: Node | null }>;\n hadRecentInput: boolean;\n}\n\nexport interface LargestContentfulPaint extends PerformanceEntry {\n readonly renderTime: DOMHighResTimeStamp;\n readonly loadTime: DOMHighResTimeStamp;\n readonly size: number;\n readonly id: string;\n readonly url: string;\n readonly element: Element | null;\n}\n\ninterface WebVitalSpanOptions {\n name: string;\n op: string;\n origin: string;\n metricName: 'lcp' | 'cls' | 'inp';\n value: number;\n attributes?: SpanAttributes;\n parentSpan?: Span;\n startTime: number;\n endTime?: number;\n /** Set when the vital was reported for a soft navigation rather than the initial page load. */\n softNavigationId?: number;\n /** The navigation the vital was measured on, as reported by web-vitals. */\n navigationType?: MetricNavigationType;\n /**\n * When `true`, the span is sent on its own as a v2 streamed span instead of being folded into a\n * transaction. Used for INP when span streaming is disabled (it reports late, so it can't ride\n * the pageload transaction).\n *\n * TODO(standalone): remove once the static (transaction) trace lifecycle is dropped and INP always streams.\n */\n standalone?: boolean;\n}\n\n/**\n * Emits a web vital span. When `standalone` is set it is sent on its own as a v2 streamed span;\n * otherwise it flows through the span streaming pipeline as a child of `parentSpan`.\n */\nexport function _emitWebVitalSpan(options: WebVitalSpanOptions): void {\n const {\n name,\n op,\n origin,\n metricName,\n value,\n attributes: passedAttributes,\n parentSpan,\n startTime,\n endTime,\n standalone,\n softNavigationId,\n navigationType,\n } = options;\n\n // Taken off the segment span itself, so it can't diverge from it: a routing instrumentation may\n // rename that span (a pageload span is named `Pageload` until its route resolves), and the scope's\n // transaction name is deliberately not kept in sync with it. Only a standalone span, which is sent\n // without its segment span, has to fall back to the scope.\n const segmentSpan = parentSpan && getRootSpan(parentSpan);\n const segmentName = segmentSpan ? spanToJSON(segmentSpan).name : getCurrentScope().getScopeData().transactionName;\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,\n [SENTRY_EXCLUSIVE_TIME]: 0,\n [`browser.web_vital.${metricName}.value`]: value,\n // oxlint-disable-next-line typescript-eslint/no-deprecated\n [SENTRY_TRANSACTION]: segmentName,\n [SENTRY_SEGMENT_NAME]: segmentName,\n // Web vital score calculation relies on the user agent\n [USER_AGENT_ORIGINAL]: WINDOW.navigator?.userAgent,\n ...passedAttributes,\n };\n\n if (parentSpan && spanToJSON(parentSpan).attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'pageload') {\n // for LCP and CLS, we collect the pageload span id as an attribute\n attributes['sentry.pageload.span_id'] = parentSpan.spanContext().spanId;\n }\n\n if (softNavigationId != null) {\n attributes[BROWSER_NAVIGATION_ID] = softNavigationId;\n }\n\n if (navigationType) {\n attributes[BROWSER_NAVIGATION_TYPE] = navigationType;\n }\n\n // A standalone span is sent as a plain v2 span without running the `processSpan` hooks (see\n // `captureStandaloneSpanWithStaticCallback`), so Replay can't attach the replay id itself. Set it\n // here, mirroring Replay's `processSpan`, so INP keeps its replay association like it did on v1.\n // TODO(standalone): remove once the static (transaction) trace lifecycle is dropped and INP always\n // streams, at which point Replay's `processSpan` runs and attaches the replay id.\n if (standalone) {\n Object.assign(attributes, getReplayAttributes());\n }\n\n const span = startInactiveSpan({\n name,\n attributes,\n startTime,\n parentSpan,\n // oxlint-disable-next-line typescript/no-deprecated -- intentional during the v1/v2 transition; see the TODO(standalone) above\n experimental: standalone ? { standalone: true } : undefined,\n });\n\n if (span) {\n span.end(endTime ?? startTime);\n }\n}\n\ninterface ReplayIntegration extends Integration {\n getReplayId: (onlyIfSampled?: boolean) => string | undefined;\n getRecordingMode: () => 'session' | 'buffer' | undefined;\n}\n\n// TODO(standalone): remove once the static (transaction) trace lifecycle is dropped; Replay's\n// `processSpan` then attaches the replay id to the streamed INP span instead.\nfunction getReplayAttributes(): SpanAttributes {\n const replay = getClient()?.getIntegrationByName<ReplayIntegration>('Replay');\n const replayId = replay?.getReplayId(true);\n if (!replayId) {\n return {};\n }\n\n return {\n [SENTRY_REPLAY_ID]: replayId,\n // Not the `SENTRY_REPLAY_IS_BUFFERING` convention: that one has no `sentry._internal.` prefix, and\n // the rest of the SDK sets the prefixed key (see `logs/internal.ts`, `metrics/internal.ts`).\n 'sentry._internal.replay_is_buffering': replay!.getRecordingMode() === 'buffer' ? true : undefined,\n };\n}\n"],"names":[],"mappings":";;;;;AAqEO,SAAS,kBAAkB,OAAA,EAAoC;AACpE,EAAA,MAAM;AAAA,IACJ,IAAA;AAAA,IACA,EAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA,EAAY,gBAAA;AAAA,IACZ,UAAA;AAAA,IACA,SAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAMJ,EAAA,MAAM,WAAA,GAAc,UAAA,IAAc,WAAA,CAAY,UAAU,CAAA;AACxD,EAAA,MAAM,WAAA,GAAc,cAAc,UAAA,CAAW,WAAW,EAAE,IAAA,GAAO,eAAA,EAAgB,CAAE,YAAA,EAAa,CAAE,eAAA;AAElG,EAAA,MAAM,UAAA,GAA6B;AAAA,IACjC,CAAC,gCAAgC,GAAG,MAAA;AAAA,IACpC,CAAC,4BAA4B,GAAG,EAAA;AAAA,IAChC,CAAC,qBAAqB,GAAG,CAAA;AAAA,IACzB,CAAC,CAAA,kBAAA,EAAqB,UAAU,CAAA,MAAA,CAAQ,GAAG,KAAA;AAAA;AAAA,IAE3C,CAAC,kBAAkB,GAAG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AAAA;AAAA,IAGpB,sCAAA,EAAwC,MAAA,CAAQ,gBAAA,EAAiB,KAAM,WAAW,IAAA,GAAO;AAAA,GAC3F;AACF;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { browserPerformanceTimeOrigin, hasSpanStreamingEnabled, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, debug, getClient, timestampInSeconds, getActiveSpan, getRootSpan,
|
|
1
|
+
import { browserPerformanceTimeOrigin, hasSpanStreamingEnabled, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, debug, getClient, timestampInSeconds, getActiveSpan, getRootSpan, UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK, UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK, UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK, UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK, UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK, UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK } from '@sentry/core';
|
|
2
2
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
3
3
|
import { htmlTreeAsString } from '../htmlTreeAsString.js';
|
|
4
4
|
import { getComponentName } from '../component-name.js';
|
|
5
5
|
import { MAX_PLAUSIBLE_INP_DURATION, INP_ENTRY_MAP, getCachedInteractionContext, UNKNOWN_ELEMENT_NAME } from './inp.js';
|
|
6
6
|
import { addClsInstrumentationHandler, addInpInstrumentationHandler, addLcpInstrumentationHandler } from '../instrumentation/performanceObserver.js';
|
|
7
|
-
import { BROWSER_NAVIGATION_TYPE, UI_COMPONENT_NAME, BROWSER_WEB_VITAL_INP_TARGET, BROWSER_WEB_VITAL_INP_INTERACTION_TYPE } from '@sentry/conventions/attributes';
|
|
7
|
+
import { BROWSER_NAVIGATION_TYPE, UI_COMPONENT_NAME, SENTRY_EXCLUSIVE_TIME, BROWSER_WEB_VITAL_INP_TARGET, BROWSER_WEB_VITAL_INP_INTERACTION_TYPE } from '@sentry/conventions/attributes';
|
|
8
8
|
import { _emitWebVitalSpan } from './emitSpan.js';
|
|
9
9
|
import { isValidLcpMetric } from './lcp.js';
|
|
10
10
|
import { listenForWebVitalReportEvents } from './reportEvents.js';
|
|
@@ -241,7 +241,7 @@ function _sendInpSpan(inpValue, entry, standalone = false, attributedSpan, softN
|
|
|
241
241
|
const fallbackName = INTERACTION_TYPE_TO_SPAN_NAME_FALLBACK[interactionType];
|
|
242
242
|
const name = hasSpanStreaming ? componentName || fallbackName : selector ?? "Interaction to next paint";
|
|
243
243
|
const attributes = {
|
|
244
|
-
[
|
|
244
|
+
[SENTRY_EXCLUSIVE_TIME]: entry?.duration ?? inpValue
|
|
245
245
|
};
|
|
246
246
|
selector && selector !== UNKNOWN_ELEMENT_NAME && (attributes[BROWSER_WEB_VITAL_INP_TARGET] = selector);
|
|
247
247
|
entryInteractionType && (attributes[BROWSER_WEB_VITAL_INP_INTERACTION_TYPE] = entryInteractionType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spans.js","sources":["../../../src/web-vitals/spans.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, Span, SpanAttributes } from '@sentry/core';\nimport {\n browserPerformanceTimeOrigin,\n debug,\n getActiveSpan,\n getClient,\n getRootSpan,\n hasSpanStreamingEnabled,\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n spanToJSON,\n timestampInSeconds,\n UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK,\n UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK,\n UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK,\n UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK,\n UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK,\n UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { htmlTreeAsString } from '../htmlTreeAsString';\nimport { getComponentName } from '../component-name';\nimport type { InteractionType } from './inp';\nimport { getCachedInteractionContext, INP_ENTRY_MAP, MAX_PLAUSIBLE_INP_DURATION, UNKNOWN_ELEMENT_NAME } from './inp';\nimport type { InstrumentationHandlerCallback, MetricNavigationType } from '../instrumentation/performanceObserver';\nimport {\n addClsInstrumentationHandler,\n addInpInstrumentationHandler,\n addLcpInstrumentationHandler,\n} from '../instrumentation/performanceObserver';\nimport type { LargestContentfulPaint, LayoutShift } from './emitSpan';\nimport {\n BROWSER_NAVIGATION_TYPE,\n BROWSER_WEB_VITAL_INP_INTERACTION_TYPE,\n BROWSER_WEB_VITAL_INP_TARGET,\n UI_COMPONENT_NAME,\n} from '@sentry/conventions/attributes';\nimport { _emitWebVitalSpan } from './emitSpan';\nimport { isValidLcpMetric } from './lcp';\nimport { listenForWebVitalReportEvents } from './reportEvents';\nimport { getNavigationSpanForMetric } from './softNavs';\nimport { getBrowserPerformanceAPI, msToSec, supportsWebVital } from '../performance/utils';\nimport type { PerformanceEventTiming } from '../instrumentation/performanceObserver';\nimport {\n NAVIGATION,\n UI_INTERACTION_CLICK,\n UI_INTERACTION_DRAG,\n UI_INTERACTION_HOVER,\n UI_INTERACTION_PRESS,\n UI_WEBVITAL_CLS,\n UI_WEBVITAL_LCP,\n} from '@sentry/conventions/op';\n\nconst INTERACTION_TYPE_TO_SPAN_OP: Record<InteractionType, string> = {\n click: UI_INTERACTION_CLICK,\n hover: UI_INTERACTION_HOVER,\n drag: UI_INTERACTION_DRAG,\n press: UI_INTERACTION_PRESS,\n};\n\nconst INTERACTION_TYPE_TO_SPAN_NAME_FALLBACK: Record<InteractionType, string> = {\n click: UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK,\n hover: UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK,\n drag: UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK,\n press: UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK,\n};\n\ntype WebVitalMetric = Parameters<Parameters<typeof addLcpInstrumentationHandler>[0]>[0]['metric'];\ntype InpMetric = Parameters<InstrumentationHandlerCallback>[0]['metric'];\n\n/**\n * Reports a web vital once per navigation, rather than once per page load.\n *\n * web-vitals restarts the metric on every soft navigation and force-reports the previous one just\n * before it does (and again on pagehide), and re-reports every metric after a bfcache restore.\n * Since `reportAllChanges` is off in this mode, every value we're handed is already the final one\n * for its navigation, so there is nothing to accumulate: each report is a span.\n */\nfunction trackWebVitalPerNavigation<M extends WebVitalMetric>(\n client: Client,\n addInstrumentationHandler: (callback: (data: { metric: M }) => void) => unknown,\n send: (metric: M, parentSpan: Span | undefined, softNavigationId: number | undefined) => void,\n): void {\n let pageloadSpan: Span | undefined;\n client.on('afterStartPageLoadSpan', span => {\n pageloadSpan = span;\n });\n\n // Remembered when the restore happens rather than read back at report time: the restore\n // navigation span is an idle span, and CLS and INP are only finalized on pagehide, by which point\n // it has long ended and is no longer what is active.\n let bfcacheNavigationSpan: Span | undefined;\n client.on('spanStart', span => {\n // The op has to be checked too: the web vital spans emitted for a restore carry the same\n // `back-forward-cache` navigation type, so matching on that alone lets the first of them replace the\n // navigation span, and every later vital then hangs off a sibling vital instead.\n const attributes = spanToJSON(span).attributes;\n if (\n attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] === NAVIGATION &&\n attributes[BROWSER_NAVIGATION_TYPE] === 'back-forward-cache'\n ) {\n bfcacheNavigationSpan = span;\n }\n });\n\n addInstrumentationHandler(({ metric }) => {\n const navigationSpan = getNavigationSpanForMetric(metric);\n if (metric.navigationType === 'soft-navigation') {\n // Reporting an uncorrelated soft navigation vital would attribute it to the wrong route, so\n // it's dropped instead.\n if (navigationSpan) {\n send(metric, navigationSpan, metric.navigationId);\n } else {\n DEBUG_BUILD &&\n debug.log(`[SoftNav] Dropping ${metric.name} for uncorrelated soft navigation ${metric.navigationId}`);\n }\n return;\n }\n\n if (metric.navigationType === 'back-forward-cache') {\n // A restore reuses the frozen document, so the pageload span above belongs to the page view\n // from before the freeze. The navigation span started for the restore is the page view these\n // values were actually measured on.\n send(metric, bfcacheNavigationSpan, undefined);\n return;\n }\n\n send(metric, pageloadSpan, undefined);\n });\n}\n\n/**\n * Tracks LCP as a streamed span.\n */\nexport function trackLcpAsSpan(client: Client, perNavigation = false): void {\n if (!supportsWebVital('largest-contentful-paint')) {\n return;\n }\n\n if (perNavigation) {\n trackWebVitalPerNavigation(client, addLcpInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n const entry = metric.entries[metric.entries.length - 1] as LargestContentfulPaint | undefined;\n _sendLcpSpan(\n metric.value,\n entry,\n parentSpan,\n softNavigationId,\n metric.navigationType,\n metric.navigationStartTime,\n );\n });\n return;\n }\n\n let lcpValue = 0;\n let lcpEntry: LargestContentfulPaint | undefined;\n let lcpNavigationType: MetricNavigationType | undefined;\n\n const cleanupLcpHandler = addLcpInstrumentationHandler(({ metric }) => {\n // The navigation type describes the page, not the entry, so it is worth keeping even for a\n // report we otherwise discard.\n lcpNavigationType = metric.navigationType;\n\n const entry = metric.entries[metric.entries.length - 1] as LargestContentfulPaint | undefined;\n if (!entry || !isValidLcpMetric(metric.value)) {\n return;\n }\n lcpValue = metric.value;\n lcpEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, pageloadSpan => {\n _sendLcpSpan(lcpValue, lcpEntry, pageloadSpan, undefined, lcpNavigationType);\n cleanupLcpHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendLcpSpan(\n lcpValue: number,\n entry: LargestContentfulPaint | undefined,\n pageloadSpan?: Span,\n softNavigationId?: number,\n navigationType?: MetricNavigationType,\n navigationStartTime?: number,\n): void {\n if (!isValidLcpMetric(lcpValue)) {\n return;\n }\n\n DEBUG_BUILD && debug.log(`Sending LCP span (${lcpValue})`);\n\n const performanceTimeOrigin = browserPerformanceTimeOrigin() || 0;\n // A soft navigation's LCP is measured from the triggering interaction, not the document time\n // origin. Starting the span there too keeps it inside the navigation span it is parented to and\n // keeps its duration equal to the value it reports.\n const startTime = msToSec(performanceTimeOrigin + (navigationStartTime || 0));\n // Without an entry there is no render time to end at, so the span lasts the value it reports,\n // like an entry-less INP does. Ending at the time origin instead would invert the span.\n const endTime = entry ? msToSec(performanceTimeOrigin + entry.startTime) : startTime + msToSec(lcpValue);\n const selector = entry ? htmlTreeAsString(entry.element) : undefined;\n const componentName = entry?.element ? getComponentName(entry.element) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming\n ? componentName || UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK\n : (selector ?? UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK);\n\n const attributes: SpanAttributes = {};\n\n if (selector) {\n attributes['browser.web_vital.lcp.element'] = selector;\n }\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n entry?.id && (attributes['browser.web_vital.lcp.id'] = entry.id);\n entry?.url && (attributes['browser.web_vital.lcp.url'] = entry.url);\n entry?.loadTime != null && (attributes['browser.web_vital.lcp.load_time'] = entry.loadTime);\n entry?.renderTime != null && (attributes['browser.web_vital.lcp.render_time'] = entry.renderTime);\n entry?.size != null && (attributes['browser.web_vital.lcp.size'] = entry.size);\n\n _emitWebVitalSpan({\n name,\n op: UI_WEBVITAL_LCP,\n origin: 'auto.http.browser.lcp',\n metricName: 'lcp',\n value: lcpValue,\n attributes,\n parentSpan: pageloadSpan,\n startTime,\n endTime,\n softNavigationId,\n navigationType,\n });\n}\n\n/**\n * Tracks CLS as a streamed span.\n */\nexport function trackClsAsSpan(client: Client, perNavigation = false): void {\n if (!supportsWebVital('layout-shift')) {\n return;\n }\n\n if (perNavigation) {\n trackWebVitalPerNavigation(client, addClsInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n const entry = metric.entries[metric.entries.length - 1] as LayoutShift | undefined;\n _sendClsSpan(\n metric.value,\n entry,\n parentSpan,\n softNavigationId,\n metric.navigationType,\n metric.navigationStartTime,\n );\n });\n return;\n }\n\n let clsValue = 0;\n let clsEntry: LayoutShift | undefined;\n let clsNavigationType: MetricNavigationType | undefined;\n\n const cleanupClsHandler = addClsInstrumentationHandler(({ metric }) => {\n // A CLS of 0 is reported with no entries and still emits a span, so the navigation type has to\n // be captured before the entry check rather than alongside the value.\n clsNavigationType = metric.navigationType;\n\n const entry = metric.entries[metric.entries.length - 1] as LayoutShift | undefined;\n if (!entry) {\n return;\n }\n clsValue = metric.value;\n clsEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, pageloadSpan => {\n _sendClsSpan(clsValue, clsEntry, pageloadSpan, undefined, clsNavigationType);\n cleanupClsHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendClsSpan(\n clsValue: number,\n entry: LayoutShift | undefined,\n pageloadSpan?: Span,\n softNavigationId?: number,\n navigationType?: MetricNavigationType,\n navigationStartTime?: number,\n): void {\n DEBUG_BUILD && debug.log(`Sending CLS span (${clsValue})`);\n\n const performanceTimeOrigin = browserPerformanceTimeOrigin();\n // A CLS of 0 has no shift to place the span at. It is reported when the navigation it was\n // measured on is already over - the next soft navigation, or pagehide - so the current time would\n // land it outside that navigation, on the route that follows it.\n const offset = entry?.startTime ?? navigationStartTime ?? 0;\n const startTime = performanceTimeOrigin ? msToSec(performanceTimeOrigin + offset) : timestampInSeconds();\n const firstSourceNode = entry?.sources[0]?.node;\n const selector = entry ? htmlTreeAsString(firstSourceNode) : undefined;\n const componentName = firstSourceNode ? getComponentName(firstSourceNode) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming\n ? componentName || UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK\n : (selector ?? UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK);\n\n const attributes: SpanAttributes = {};\n\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n\n if (entry?.sources) {\n entry.sources.forEach((source, index) => {\n attributes[`browser.web_vital.cls.source.${index + 1}`] = htmlTreeAsString(source.node);\n });\n }\n\n _emitWebVitalSpan({\n name,\n op: UI_WEBVITAL_CLS,\n origin: 'auto.http.browser.cls',\n metricName: 'cls',\n value: clsValue,\n attributes,\n parentSpan: pageloadSpan,\n startTime,\n softNavigationId,\n navigationType,\n });\n}\n\n/**\n * Tracks INP and emits it as a web vital span, as a child of the interaction's root span.\n * Requires `registerInpInteractionListener()` to be called separately for cached element names and\n * root spans per interaction.\n */\nexport function trackInpAsSpan(client: Client, perNavigation = false): void {\n const performance = getBrowserPerformanceAPI();\n if (!performance || !browserPerformanceTimeOrigin()) {\n return;\n }\n\n // INP reports late (on pagehide, after the pageload span has ended). With span streaming enabled\n // it rides the streaming pipeline. With streaming disabled it would be dropped as a late span, so\n // it is emitted as its own standalone v2 span instead (see `_emitWebVitalSpan`), overriding the\n // static trace lifecycle for INP only.\n // TODO(standalone): once the static trace lifecycle is dropped, INP always streams; drop this flag.\n const standalone = !hasSpanStreamingEnabled(client);\n\n if (perNavigation) {\n // INP restarts per navigation and reports once that navigation is over, by which point the\n // navigation span has ended and the interaction cache no longer knows about it. The metric\n // says which navigation it belongs to, so INP is attributed exactly like LCP and CLS.\n trackWebVitalPerNavigation(client, addInpInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n if (isPlausibleInp(metric)) {\n _sendInpSpan(metric.value, findInpEntry(metric), standalone, parentSpan, softNavigationId, metric);\n }\n });\n return;\n }\n\n const onInp: InstrumentationHandlerCallback = ({ metric }) => {\n if (isPlausibleInp(metric)) {\n _sendInpSpan(metric.value, findInpEntry(metric), standalone, undefined, undefined, metric);\n }\n };\n\n addInpInstrumentationHandler(onInp);\n}\n\nfunction isPlausibleInp(metric: InpMetric): boolean {\n return metric.value != null && msToSec(metric.value) <= MAX_PLAUSIBLE_INP_DURATION;\n}\n\n/**\n * The entry an INP span is built from: the one whose duration the reported value came from.\n *\n * There isn't always one. When every interaction of a soft navigation stayed below the Event Timing\n * threshold, web-vitals reports a synthetic value with no entries at all - see\n * `_estimateP98LongestInteraction`. The span still gets reported in that case, just without the\n * element and interaction type an entry would have supplied.\n */\nfunction findInpEntry(metric: InpMetric): PerformanceEventTiming | undefined {\n return metric.entries.find(e => e.duration === metric.value && INP_ENTRY_MAP[e.name]);\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendInpSpan(\n inpValue: number,\n entry: PerformanceEventTiming | undefined,\n standalone = false,\n attributedSpan?: Span,\n softNavigationId?: number,\n metric?: InpMetric,\n): void {\n DEBUG_BUILD && debug.log(`Sending INP span (${inpValue})`);\n\n // A web vital span carries the metric, not a real interaction timing, so an INP without an entry\n // is still worth reporting. It just has no element or interaction type to describe, and is placed\n // at the start of the navigation it belongs to rather than at the interaction.\n const startTime = msToSec(\n (browserPerformanceTimeOrigin() as number) + (entry?.startTime ?? metric?.navigationStartTime ?? 0),\n );\n const duration = msToSec(inpValue);\n // An INP without an entry has no interaction type to report. It still has to land inside the\n // `ui.interaction.*` family, because falling outside it would hide exactly the fast navigations\n // that web-vitals synthesizes these values for (GoogleChrome/web-vitals#724), reintroducing the\n // reporting bias they were added to remove.\n const entryInteractionType = entry && INP_ENTRY_MAP[entry.name];\n const interactionType = entryInteractionType || 'click';\n\n const cachedContext = entry && getCachedInteractionContext(entry.interactionId);\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined;\n\n // With soft navigations the caller knows exactly which navigation the metric belongs to. Without\n // them we fall back to the span that was active when the interaction was observed.\n const spanToUse = attributedSpan || cachedContext?.span || rootSpan;\n const selector = cachedContext?.elementName || (entry ? htmlTreeAsString(entry.target) : undefined);\n const componentName = entry?.target ? getComponentName(entry.target) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const fallbackName = INTERACTION_TYPE_TO_SPAN_NAME_FALLBACK[interactionType];\n const name = hasSpanStreaming ? componentName || fallbackName : (selector ?? 'Interaction to next paint');\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: entry?.duration ?? inpValue,\n };\n\n // The span's name and op always have a value, even for an INP without an entry, so they can't\n // say whether there was an interaction to describe. These attributes can: they are only set for\n // what was actually observed. The name no longer holds the selector either, now that it is the\n // component name or the op's fallback under span streaming.\n selector && selector !== UNKNOWN_ELEMENT_NAME && (attributes[BROWSER_WEB_VITAL_INP_TARGET] = selector);\n entryInteractionType && (attributes[BROWSER_WEB_VITAL_INP_INTERACTION_TYPE] = entryInteractionType);\n\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n\n _emitWebVitalSpan({\n name,\n op: INTERACTION_TYPE_TO_SPAN_OP[interactionType],\n origin: 'auto.http.browser.inp',\n metricName: 'inp',\n value: inpValue,\n attributes,\n startTime,\n endTime: startTime + duration,\n navigationType: metric?.navigationType,\n parentSpan: spanToUse,\n standalone,\n softNavigationId,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAsDA,MAAM,2BAAA,GAA+D;AAAA,EACnE,KAAA,EAAO,oBAAA;AAAA,EACP,KAAA,EAAO,oBAAA;AAAA,EACP,IAAA,EAAM,mBAAA;AAAA,EACN,KAAA,EAAO;AACT,CAAA;AAEA,MAAM,sCAAA,GAA0E;AAAA,EAC9E,KAAA,EAAO,uCAAA;AAAA,EACP,KAAA,EAAO,uCAAA;AAAA,EACP,IAAA,EAAM,sCAAA;AAAA,EACN,KAAA,EAAO;AACT,CAAA;AAaA,SAAS,0BAAA,CACP,MAAA,EACA,yBAAA,EACA,IAAA,EACM;AACN,EAAA,IAAI,YAAA;AACJ,EAAA,MAAA,CAAO,EAAA,CAAG,0BAA0B,CAAA,IAAA,KAAQ;AAC1C,IAAA,YAAA,GAAe,IAAA;AAAA,EACjB,CAAC,CAAA;AAKD,EAAA,IAAI,qBAAA;AACJ,EAAA,MAAA,CAAO,EAAA,CAAG,aAAa,CAAA,IAAA,KAAQ;AAI7B,IAAA,MAAM,UAAA,GAAa,UAAA,CAAW,IAAI,CAAA,CAAE,UAAA;AACpC,IAAA,IACE,aAAa,4B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AAA,IACxB,UAAA,EAAY,SAAA;AAAA,IACZ,UAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"spans.js","sources":["../../../src/web-vitals/spans.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, Span, SpanAttributes } from '@sentry/core';\nimport {\n browserPerformanceTimeOrigin,\n debug,\n getActiveSpan,\n getClient,\n getRootSpan,\n hasSpanStreamingEnabled,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n spanToJSON,\n timestampInSeconds,\n UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK,\n UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK,\n UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK,\n UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK,\n UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK,\n UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { htmlTreeAsString } from '../htmlTreeAsString';\nimport { getComponentName } from '../component-name';\nimport type { InteractionType } from './inp';\nimport { getCachedInteractionContext, INP_ENTRY_MAP, MAX_PLAUSIBLE_INP_DURATION, UNKNOWN_ELEMENT_NAME } from './inp';\nimport type { InstrumentationHandlerCallback, MetricNavigationType } from '../instrumentation/performanceObserver';\nimport {\n addClsInstrumentationHandler,\n addInpInstrumentationHandler,\n addLcpInstrumentationHandler,\n} from '../instrumentation/performanceObserver';\nimport type { LargestContentfulPaint, LayoutShift } from './emitSpan';\nimport {\n SENTRY_EXCLUSIVE_TIME,\n BROWSER_NAVIGATION_TYPE,\n BROWSER_WEB_VITAL_INP_INTERACTION_TYPE,\n BROWSER_WEB_VITAL_INP_TARGET,\n UI_COMPONENT_NAME,\n} from '@sentry/conventions/attributes';\nimport { _emitWebVitalSpan } from './emitSpan';\nimport { isValidLcpMetric } from './lcp';\nimport { listenForWebVitalReportEvents } from './reportEvents';\nimport { getNavigationSpanForMetric } from './softNavs';\nimport { getBrowserPerformanceAPI, msToSec, supportsWebVital } from '../performance/utils';\nimport type { PerformanceEventTiming } from '../instrumentation/performanceObserver';\nimport {\n NAVIGATION,\n UI_INTERACTION_CLICK,\n UI_INTERACTION_DRAG,\n UI_INTERACTION_HOVER,\n UI_INTERACTION_PRESS,\n UI_WEBVITAL_CLS,\n UI_WEBVITAL_LCP,\n} from '@sentry/conventions/op';\n\nconst INTERACTION_TYPE_TO_SPAN_OP: Record<InteractionType, string> = {\n click: UI_INTERACTION_CLICK,\n hover: UI_INTERACTION_HOVER,\n drag: UI_INTERACTION_DRAG,\n press: UI_INTERACTION_PRESS,\n};\n\nconst INTERACTION_TYPE_TO_SPAN_NAME_FALLBACK: Record<InteractionType, string> = {\n click: UI_INTERACTION_CLICK_SPAN_NAME_FALLBACK,\n hover: UI_INTERACTION_HOVER_SPAN_NAME_FALLBACK,\n drag: UI_INTERACTION_DRAG_SPAN_NAME_FALLBACK,\n press: UI_INTERACTION_PRESS_SPAN_NAME_FALLBACK,\n};\n\ntype WebVitalMetric = Parameters<Parameters<typeof addLcpInstrumentationHandler>[0]>[0]['metric'];\ntype InpMetric = Parameters<InstrumentationHandlerCallback>[0]['metric'];\n\n/**\n * Reports a web vital once per navigation, rather than once per page load.\n *\n * web-vitals restarts the metric on every soft navigation and force-reports the previous one just\n * before it does (and again on pagehide), and re-reports every metric after a bfcache restore.\n * Since `reportAllChanges` is off in this mode, every value we're handed is already the final one\n * for its navigation, so there is nothing to accumulate: each report is a span.\n */\nfunction trackWebVitalPerNavigation<M extends WebVitalMetric>(\n client: Client,\n addInstrumentationHandler: (callback: (data: { metric: M }) => void) => unknown,\n send: (metric: M, parentSpan: Span | undefined, softNavigationId: number | undefined) => void,\n): void {\n let pageloadSpan: Span | undefined;\n client.on('afterStartPageLoadSpan', span => {\n pageloadSpan = span;\n });\n\n // Remembered when the restore happens rather than read back at report time: the restore\n // navigation span is an idle span, and CLS and INP are only finalized on pagehide, by which point\n // it has long ended and is no longer what is active.\n let bfcacheNavigationSpan: Span | undefined;\n client.on('spanStart', span => {\n // The op has to be checked too: the web vital spans emitted for a restore carry the same\n // `back-forward-cache` navigation type, so matching on that alone lets the first of them replace the\n // navigation span, and every later vital then hangs off a sibling vital instead.\n const attributes = spanToJSON(span).attributes;\n if (\n attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] === NAVIGATION &&\n attributes[BROWSER_NAVIGATION_TYPE] === 'back-forward-cache'\n ) {\n bfcacheNavigationSpan = span;\n }\n });\n\n addInstrumentationHandler(({ metric }) => {\n const navigationSpan = getNavigationSpanForMetric(metric);\n if (metric.navigationType === 'soft-navigation') {\n // Reporting an uncorrelated soft navigation vital would attribute it to the wrong route, so\n // it's dropped instead.\n if (navigationSpan) {\n send(metric, navigationSpan, metric.navigationId);\n } else {\n DEBUG_BUILD &&\n debug.log(`[SoftNav] Dropping ${metric.name} for uncorrelated soft navigation ${metric.navigationId}`);\n }\n return;\n }\n\n if (metric.navigationType === 'back-forward-cache') {\n // A restore reuses the frozen document, so the pageload span above belongs to the page view\n // from before the freeze. The navigation span started for the restore is the page view these\n // values were actually measured on.\n send(metric, bfcacheNavigationSpan, undefined);\n return;\n }\n\n send(metric, pageloadSpan, undefined);\n });\n}\n\n/**\n * Tracks LCP as a streamed span.\n */\nexport function trackLcpAsSpan(client: Client, perNavigation = false): void {\n if (!supportsWebVital('largest-contentful-paint')) {\n return;\n }\n\n if (perNavigation) {\n trackWebVitalPerNavigation(client, addLcpInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n const entry = metric.entries[metric.entries.length - 1] as LargestContentfulPaint | undefined;\n _sendLcpSpan(\n metric.value,\n entry,\n parentSpan,\n softNavigationId,\n metric.navigationType,\n metric.navigationStartTime,\n );\n });\n return;\n }\n\n let lcpValue = 0;\n let lcpEntry: LargestContentfulPaint | undefined;\n let lcpNavigationType: MetricNavigationType | undefined;\n\n const cleanupLcpHandler = addLcpInstrumentationHandler(({ metric }) => {\n // The navigation type describes the page, not the entry, so it is worth keeping even for a\n // report we otherwise discard.\n lcpNavigationType = metric.navigationType;\n\n const entry = metric.entries[metric.entries.length - 1] as LargestContentfulPaint | undefined;\n if (!entry || !isValidLcpMetric(metric.value)) {\n return;\n }\n lcpValue = metric.value;\n lcpEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, pageloadSpan => {\n _sendLcpSpan(lcpValue, lcpEntry, pageloadSpan, undefined, lcpNavigationType);\n cleanupLcpHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendLcpSpan(\n lcpValue: number,\n entry: LargestContentfulPaint | undefined,\n pageloadSpan?: Span,\n softNavigationId?: number,\n navigationType?: MetricNavigationType,\n navigationStartTime?: number,\n): void {\n if (!isValidLcpMetric(lcpValue)) {\n return;\n }\n\n DEBUG_BUILD && debug.log(`Sending LCP span (${lcpValue})`);\n\n const performanceTimeOrigin = browserPerformanceTimeOrigin() || 0;\n // A soft navigation's LCP is measured from the triggering interaction, not the document time\n // origin. Starting the span there too keeps it inside the navigation span it is parented to and\n // keeps its duration equal to the value it reports.\n const startTime = msToSec(performanceTimeOrigin + (navigationStartTime || 0));\n // Without an entry there is no render time to end at, so the span lasts the value it reports,\n // like an entry-less INP does. Ending at the time origin instead would invert the span.\n const endTime = entry ? msToSec(performanceTimeOrigin + entry.startTime) : startTime + msToSec(lcpValue);\n const selector = entry ? htmlTreeAsString(entry.element) : undefined;\n const componentName = entry?.element ? getComponentName(entry.element) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming\n ? componentName || UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK\n : (selector ?? UI_WEBVITAL_LCP_SPAN_NAME_FALLBACK);\n\n const attributes: SpanAttributes = {};\n\n if (selector) {\n attributes['browser.web_vital.lcp.element'] = selector;\n }\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n entry?.id && (attributes['browser.web_vital.lcp.id'] = entry.id);\n entry?.url && (attributes['browser.web_vital.lcp.url'] = entry.url);\n entry?.loadTime != null && (attributes['browser.web_vital.lcp.load_time'] = entry.loadTime);\n entry?.renderTime != null && (attributes['browser.web_vital.lcp.render_time'] = entry.renderTime);\n entry?.size != null && (attributes['browser.web_vital.lcp.size'] = entry.size);\n\n _emitWebVitalSpan({\n name,\n op: UI_WEBVITAL_LCP,\n origin: 'auto.http.browser.lcp',\n metricName: 'lcp',\n value: lcpValue,\n attributes,\n parentSpan: pageloadSpan,\n startTime,\n endTime,\n softNavigationId,\n navigationType,\n });\n}\n\n/**\n * Tracks CLS as a streamed span.\n */\nexport function trackClsAsSpan(client: Client, perNavigation = false): void {\n if (!supportsWebVital('layout-shift')) {\n return;\n }\n\n if (perNavigation) {\n trackWebVitalPerNavigation(client, addClsInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n const entry = metric.entries[metric.entries.length - 1] as LayoutShift | undefined;\n _sendClsSpan(\n metric.value,\n entry,\n parentSpan,\n softNavigationId,\n metric.navigationType,\n metric.navigationStartTime,\n );\n });\n return;\n }\n\n let clsValue = 0;\n let clsEntry: LayoutShift | undefined;\n let clsNavigationType: MetricNavigationType | undefined;\n\n const cleanupClsHandler = addClsInstrumentationHandler(({ metric }) => {\n // A CLS of 0 is reported with no entries and still emits a span, so the navigation type has to\n // be captured before the entry check rather than alongside the value.\n clsNavigationType = metric.navigationType;\n\n const entry = metric.entries[metric.entries.length - 1] as LayoutShift | undefined;\n if (!entry) {\n return;\n }\n clsValue = metric.value;\n clsEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, pageloadSpan => {\n _sendClsSpan(clsValue, clsEntry, pageloadSpan, undefined, clsNavigationType);\n cleanupClsHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendClsSpan(\n clsValue: number,\n entry: LayoutShift | undefined,\n pageloadSpan?: Span,\n softNavigationId?: number,\n navigationType?: MetricNavigationType,\n navigationStartTime?: number,\n): void {\n DEBUG_BUILD && debug.log(`Sending CLS span (${clsValue})`);\n\n const performanceTimeOrigin = browserPerformanceTimeOrigin();\n // A CLS of 0 has no shift to place the span at. It is reported when the navigation it was\n // measured on is already over - the next soft navigation, or pagehide - so the current time would\n // land it outside that navigation, on the route that follows it.\n const offset = entry?.startTime ?? navigationStartTime ?? 0;\n const startTime = performanceTimeOrigin ? msToSec(performanceTimeOrigin + offset) : timestampInSeconds();\n const firstSourceNode = entry?.sources[0]?.node;\n const selector = entry ? htmlTreeAsString(firstSourceNode) : undefined;\n const componentName = firstSourceNode ? getComponentName(firstSourceNode) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming\n ? componentName || UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK\n : (selector ?? UI_WEBVITAL_CLS_SPAN_NAME_FALLBACK);\n\n const attributes: SpanAttributes = {};\n\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n\n if (entry?.sources) {\n entry.sources.forEach((source, index) => {\n attributes[`browser.web_vital.cls.source.${index + 1}`] = htmlTreeAsString(source.node);\n });\n }\n\n _emitWebVitalSpan({\n name,\n op: UI_WEBVITAL_CLS,\n origin: 'auto.http.browser.cls',\n metricName: 'cls',\n value: clsValue,\n attributes,\n parentSpan: pageloadSpan,\n startTime,\n softNavigationId,\n navigationType,\n });\n}\n\n/**\n * Tracks INP and emits it as a web vital span, as a child of the interaction's root span.\n * Requires `registerInpInteractionListener()` to be called separately for cached element names and\n * root spans per interaction.\n */\nexport function trackInpAsSpan(client: Client, perNavigation = false): void {\n const performance = getBrowserPerformanceAPI();\n if (!performance || !browserPerformanceTimeOrigin()) {\n return;\n }\n\n // INP reports late (on pagehide, after the pageload span has ended). With span streaming enabled\n // it rides the streaming pipeline. With streaming disabled it would be dropped as a late span, so\n // it is emitted as its own standalone v2 span instead (see `_emitWebVitalSpan`), overriding the\n // static trace lifecycle for INP only.\n // TODO(standalone): once the static trace lifecycle is dropped, INP always streams; drop this flag.\n const standalone = !hasSpanStreamingEnabled(client);\n\n if (perNavigation) {\n // INP restarts per navigation and reports once that navigation is over, by which point the\n // navigation span has ended and the interaction cache no longer knows about it. The metric\n // says which navigation it belongs to, so INP is attributed exactly like LCP and CLS.\n trackWebVitalPerNavigation(client, addInpInstrumentationHandler, (metric, parentSpan, softNavigationId) => {\n if (isPlausibleInp(metric)) {\n _sendInpSpan(metric.value, findInpEntry(metric), standalone, parentSpan, softNavigationId, metric);\n }\n });\n return;\n }\n\n const onInp: InstrumentationHandlerCallback = ({ metric }) => {\n if (isPlausibleInp(metric)) {\n _sendInpSpan(metric.value, findInpEntry(metric), standalone, undefined, undefined, metric);\n }\n };\n\n addInpInstrumentationHandler(onInp);\n}\n\nfunction isPlausibleInp(metric: InpMetric): boolean {\n return metric.value != null && msToSec(metric.value) <= MAX_PLAUSIBLE_INP_DURATION;\n}\n\n/**\n * The entry an INP span is built from: the one whose duration the reported value came from.\n *\n * There isn't always one. When every interaction of a soft navigation stayed below the Event Timing\n * threshold, web-vitals reports a synthetic value with no entries at all - see\n * `_estimateP98LongestInteraction`. The span still gets reported in that case, just without the\n * element and interaction type an entry would have supplied.\n */\nfunction findInpEntry(metric: InpMetric): PerformanceEventTiming | undefined {\n return metric.entries.find(e => e.duration === metric.value && INP_ENTRY_MAP[e.name]);\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendInpSpan(\n inpValue: number,\n entry: PerformanceEventTiming | undefined,\n standalone = false,\n attributedSpan?: Span,\n softNavigationId?: number,\n metric?: InpMetric,\n): void {\n DEBUG_BUILD && debug.log(`Sending INP span (${inpValue})`);\n\n // A web vital span carries the metric, not a real interaction timing, so an INP without an entry\n // is still worth reporting. It just has no element or interaction type to describe, and is placed\n // at the start of the navigation it belongs to rather than at the interaction.\n const startTime = msToSec(\n (browserPerformanceTimeOrigin() as number) + (entry?.startTime ?? metric?.navigationStartTime ?? 0),\n );\n const duration = msToSec(inpValue);\n // An INP without an entry has no interaction type to report. It still has to land inside the\n // `ui.interaction.*` family, because falling outside it would hide exactly the fast navigations\n // that web-vitals synthesizes these values for (GoogleChrome/web-vitals#724), reintroducing the\n // reporting bias they were added to remove.\n const entryInteractionType = entry && INP_ENTRY_MAP[entry.name];\n const interactionType = entryInteractionType || 'click';\n\n const cachedContext = entry && getCachedInteractionContext(entry.interactionId);\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined;\n\n // With soft navigations the caller knows exactly which navigation the metric belongs to. Without\n // them we fall back to the span that was active when the interaction was observed.\n const spanToUse = attributedSpan || cachedContext?.span || rootSpan;\n const selector = cachedContext?.elementName || (entry ? htmlTreeAsString(entry.target) : undefined);\n const componentName = entry?.target ? getComponentName(entry.target) : null;\n const client = getClient();\n const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);\n const fallbackName = INTERACTION_TYPE_TO_SPAN_NAME_FALLBACK[interactionType];\n const name = hasSpanStreaming ? componentName || fallbackName : (selector ?? 'Interaction to next paint');\n\n const attributes: SpanAttributes = {\n [SENTRY_EXCLUSIVE_TIME]: entry?.duration ?? inpValue,\n };\n\n // The span's name and op always have a value, even for an INP without an entry, so they can't\n // say whether there was an interaction to describe. These attributes can: they are only set for\n // what was actually observed. The name no longer holds the selector either, now that it is the\n // component name or the op's fallback under span streaming.\n selector && selector !== UNKNOWN_ELEMENT_NAME && (attributes[BROWSER_WEB_VITAL_INP_TARGET] = selector);\n entryInteractionType && (attributes[BROWSER_WEB_VITAL_INP_INTERACTION_TYPE] = entryInteractionType);\n\n if (componentName) {\n attributes[UI_COMPONENT_NAME] = componentName;\n }\n\n _emitWebVitalSpan({\n name,\n op: INTERACTION_TYPE_TO_SPAN_OP[interactionType],\n origin: 'auto.http.browser.inp',\n metricName: 'inp',\n value: inpValue,\n attributes,\n startTime,\n endTime: startTime + duration,\n navigationType: metric?.navigationType,\n parentSpan: spanToUse,\n standalone,\n softNavigationId,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;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AA,GAAgB,QAAA,IAAY,2BAAA;AAE7E,EAAA,MAAM,UAAA,GAA6B;AAAA,IACjC,CAAC,qBAAqB,GAAG,KAAA,EAAO,QAAA,IAAY;AAAA,GAC9C;AAMA,EAAA,QAAA,IAAY,QAAA,KAAa,oBAAA,KAAyB,UAAA,CAAW,4BAA4B,CAAA,GAAI,QAAA,CAAA;AAC7F,EAAA,oBAAA,KAAyB,UAAA,CAAW,sCAAsC,CAAA,GAAI,oBAAA,CAAA;AAE9E,EAAA,IAAI,aAAA,EAAe;AACjB,IAAA,UAAA,CAAW,iBAAiB,CAAA,GAAI,aAAA;AAAA,EAClC;AAEA,EAAA,iBAAA,CAAkB;AAAA,IAChB,IAAA;AAAA,IACA,EAAA,EAAI,4BAA4B,eAAe,CAAA;AAAA,IAC/C,MAAA,EAAQ,uBAAA;AAAA,IACR,UAAA,EAAY,KAAA;AAAA,IACZ,KAAA,EAAO,QAAA;AAAA,IACP,UAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAS,SAAA,GAAY,QAAA;AAAA,IACrB,gBAAgB,MAAA,EAAQ,cAAA;AAAA,IACxB,UAAA,EAAY,SAAA;AAAA,IACZ,UAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { elementTimingIntegration, startTrackingElementTiming } from './performa
|
|
|
6
6
|
export { interactionsIntegration } from './performance/interactions';
|
|
7
7
|
export { isBotUserAgent } from './isBotUserAgent';
|
|
8
8
|
export { getLocationHref } from './getLocationHref';
|
|
9
|
+
export { createCachedRouteProvider, createUrlRouteProvider, getRouteProvider, resolveCurrentRoute, resolveRoute, setRouteProvider, } from './routing';
|
|
10
|
+
export type { CachedRouteProvider, RouteProvider } from './routing';
|
|
9
11
|
export { userTimingIntegration } from './performance/userTiming';
|
|
10
12
|
export { extractNetworkProtocol } from './performance/utils';
|
|
11
13
|
export { trackClsAsSpan, trackInpAsSpan, trackLcpAsSpan } from './web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isfies it. */
|
|
3
|
+
type RouteUrl = Pick<URL, 'pathname' | 'search' | 'hash'>;
|
|
4
|
+
/**
|
|
5
|
+
* Resolves URLs to low-cardinality route names.
|
|
6
|
+
*
|
|
7
|
+
* Framework SDKs register one so that everything the SDK names after a route (span names, the scope's
|
|
8
|
+
* transaction name, metric and span segment attributes) gets the parameterized route instead of the raw
|
|
9
|
+
* URL, without each integration having to reach into the framework's router itself.
|
|
10
|
+
*/
|
|
11
|
+
export interface RouteProvider {
|
|
12
|
+
/**
|
|
13
|
+
* Resolves a URL path template for a specific URL, e.g. `/users/42` -> `/users/:id`.
|
|
14
|
+
*
|
|
15
|
+
* Must return a path template, never a route identifier. Routers that name routes independently of
|
|
16
|
+
* their path (Vue Router's `route.name`, Ember's `posts.show`) have to return the matched path
|
|
17
|
+
* instead: callers set `url.template` from this, and an identifier is not a template. An SDK that
|
|
18
|
+
* wants to name its span after the identifier still can, on the span itself.
|
|
19
|
+
*
|
|
20
|
+
* Returns `undefined` when the URL matches no known route. Must answer for the URL it is given rather
|
|
21
|
+
* than for wherever the router currently is, so that callers can resolve a URL they captured earlier
|
|
22
|
+
* (a web vital reported after a soft navigation, for example).
|
|
23
|
+
*/
|
|
24
|
+
resolveRoute(url: RouteUrl): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the route the app is currently on.
|
|
27
|
+
*
|
|
28
|
+
* Routers whose location lives in the address bar can delegate to `resolveRoute`, which is what
|
|
29
|
+
* {@link createUrlRouteProvider} does. Routers that keep their own location (memory and hash routers)
|
|
30
|
+
* have to answer from that location instead: for those, `location.href` is the unchanging shell URL
|
|
31
|
+
* and would bucket every route together.
|
|
32
|
+
*/
|
|
33
|
+
resolveCurrentRoute(): string | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Registers the route provider for a client, replacing any previously registered one. `BrowserClient`
|
|
37
|
+
* calls this with its `routeProvider` option.
|
|
38
|
+
*
|
|
39
|
+
* Prefer the `routeProvider` option where the provider is known at `init`: the pageload span is named
|
|
40
|
+
* while `browserTracingIntegration` sets up, so a provider registered after `init` can only rename it
|
|
41
|
+
* after the fact.
|
|
42
|
+
*
|
|
43
|
+
* A client holds one provider. An app running two routers (a framework migration, or a shell plus an
|
|
44
|
+
* island) registers twice and the last one wins, so the first router's routes stop resolving.
|
|
45
|
+
*/
|
|
46
|
+
export declare function setRouteProvider(provider: RouteProvider, client?: Client | undefined): void;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the route provider registered for a client.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getRouteProvider(client?: Client | undefined): RouteProvider | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Resolves a URL to a low-cardinality route name, e.g. `/users/42` -> `/users/:id`.
|
|
53
|
+
*
|
|
54
|
+
* Returns `undefined` when no route provider is registered or the URL matches no route. Callers pick
|
|
55
|
+
* their own fallback, because the right one differs: a span name falls back to a low-cardinality
|
|
56
|
+
* constant, the scope's transaction name to the raw path.
|
|
57
|
+
*/
|
|
58
|
+
export declare function resolveRoute(url: string | URL, client?: Client | undefined): string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Resolves the route the app is currently on.
|
|
61
|
+
*
|
|
62
|
+
* Returns `undefined` when no route provider is registered or the current location matches no route.
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveCurrentRoute(client?: Client | undefined): string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Builds a {@link RouteProvider} for a router whose location is the browser's, which covers every
|
|
67
|
+
* router except memory and hash routers.
|
|
68
|
+
*/
|
|
69
|
+
export declare function createUrlRouteProvider(resolveRouteFromUrl: (url: RouteUrl) => string | undefined): RouteProvider;
|
|
70
|
+
/**
|
|
71
|
+
* A {@link RouteProvider} that answers from routes it has been told about, rather than by matching.
|
|
72
|
+
*/
|
|
73
|
+
export interface CachedRouteProvider extends RouteProvider {
|
|
74
|
+
/** Records the route name a router reported for a path. Ignores empty values. */
|
|
75
|
+
record(pathname: string | undefined, routeName: string | null | undefined): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Builds a route provider for a router with no usable matcher, which can only report the route it is
|
|
79
|
+
* on as it gets there (SvelteKit's `page.route.id`, Solid Router's current matches).
|
|
80
|
+
*
|
|
81
|
+
* A URL the app has not visited resolves to `undefined`, which includes the first pageload until the
|
|
82
|
+
* router reports. Backed by an LRU so a long-lived app visiting many URLs can't grow it without end,
|
|
83
|
+
* and so routes that keep being resolved outlive ones passed through once.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createCachedRouteProvider(maxEntries?: number): CachedRouteProvider;
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,mEAAmE;AACnE,KAAK,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IAEhD;;;;;;;OAOG;IACH,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAAC;CAC3C;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAE,MAAM,GAAG,SAAuB,GAAG,IAAI,CAaxG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,MAAM,GAAG,SAAuB,GAAG,aAAa,GAAG,SAAS,CAEpG;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,MAAM,GAAE,MAAM,GAAG,SAAuB,GAAG,MAAM,GAAG,SAAS,CAgB5G;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,MAAM,GAAG,SAAuB,GAAG,MAAM,GAAG,SAAS,CAQhG;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,MAAM,GAAG,SAAS,GAAG,aAAa,CAShH;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,iFAAiF;IACjF,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;CAClF;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,GAAE,MAAW,GAAG,mBAAmB,CAWtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spans.d.ts","sourceRoot":"","sources":["../../../src/web-vitals/spans.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"spans.d.ts","sourceRoot":"","sources":["../../../src/web-vitals/spans.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AAuBjE,OAAO,KAAK,EAAE,8BAA8B,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAMnH,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAatE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AA0BrF,KAAK,SAAS,GAAG,UAAU,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AA+DzE;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,UAAQ,GAAG,IAAI,CAyC1E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,sBAAsB,GAAG,SAAS,EACzC,YAAY,CAAC,EAAE,IAAI,EACnB,gBAAgB,CAAC,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,oBAAoB,EACrC,mBAAmB,CAAC,EAAE,MAAM,GAC3B,IAAI,CAkDN;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,UAAQ,GAAG,IAAI,CAyC1E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,WAAW,GAAG,SAAS,EAC9B,YAAY,CAAC,EAAE,IAAI,EACnB,gBAAgB,CAAC,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,oBAAoB,EACrC,mBAAmB,CAAC,EAAE,MAAM,GAC3B,IAAI,CA0CN;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,CA4DN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/browser-utils",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
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,8 +33,8 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@sentry/core": "11.
|
|
37
|
-
"@sentry/conventions": "^0.
|
|
36
|
+
"@sentry/core": "11.3.0",
|
|
37
|
+
"@sentry/conventions": "^0.25.0",
|
|
38
38
|
"web-vitals": "^6.1.1"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|