diff --git a/packages/solid/src/solidrouter.ts b/packages/solid/src/solidrouter.ts index 564e1e9b70ac..090a3cc62e84 100644 --- a/packages/solid/src/solidrouter.ts +++ b/packages/solid/src/solidrouter.ts @@ -15,11 +15,13 @@ import { } from '@sentry/conventions/attributes'; import type { Client, Integration, Span } from '@sentry/core'; import { + createCachedRouteProvider, getClient, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, filterCollectedUrl, + setRouteProvider, } from '@sentry/core'; import type { BeforeLeaveEventArgs, @@ -36,6 +38,11 @@ import { createComponent } from 'solid-js/web'; const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet(); +// Solid Router only exposes matches through `useCurrentMatches()` inside a component, so there is no +// matcher the integration could call. The provider answers from patterns the router root has already +// reported instead. +const ROUTE_PROVIDER = createCachedRouteProvider(); + function locationToSpanUrlAttributes(pathname: string, search: string = '', hash: string = ''): Record { const pathWithSearch = `${pathname}${search}${hash}`; @@ -129,6 +136,7 @@ function withSentryRouterRoot(Root: Component): Component