Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/angular/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import { CODE_FUNCTION_NAME, SENTRY_OP, URL_FULL, URL_PATH, URL_TEMPLATE } from
import { FUNCTION } from '@sentry/conventions/op';
import type { Integration, Span } from '@sentry/core';
import {
createCachedRouteProvider,
debug,
parseStringToURLObject,
setRouteProvider,
stripUrlQueryAndFragment,
timestampInSeconds,
filterCollectedUrl,
Expand All @@ -40,6 +42,11 @@ import { runOutsideAngular } from './zone';

let instrumentationInitialized: boolean;

// The parameterized route only exists on Angular's `ResolveEnd` event, resolved from the router
// state snapshot, so there is no matcher the integration could call. `TraceService` records each
// route as it resolves and the provider answers from that.
const ROUTE_PROVIDER = createCachedRouteProvider();

/**
* A custom browser tracing integration for Angular.
*
Expand All @@ -54,10 +61,18 @@ export function browserTracingIntegration(
instrumentationInitialized = true;
}

return originalBrowserTracingIntegration({
const integration = originalBrowserTracingIntegration({
...options,
instrumentNavigation: false,
});

return {
...integration,
setup(client) {
setRouteProvider(ROUTE_PROVIDER, client);
integration.setup?.(client);
},
};
}

/**
Expand Down Expand Up @@ -171,6 +186,7 @@ export class TraceService implements OnDestroy {
);

if (route) {
ROUTE_PROVIDER.record(stripUrlQueryAndFragment(event.urlAfterRedirects), route);
getCurrentScope().setTransactionName(route);
}

Expand Down
Loading