From 79a77bf3650cb204233672758f1681bca61ebf14 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Tue, 28 May 2024 17:44:02 +0200 Subject: [PATCH 1/6] feat(solidjs): Add solid router instrumentation --- packages/solidjs/package.json | 6 +- packages/solidjs/rollup.npm.config.mjs | 8 +- packages/solidjs/src/debug-build.ts | 8 ++ packages/solidjs/src/index.ts | 2 + packages/solidjs/src/solidrouter.ts | 165 +++++++++++++++++++++++++ yarn.lock | 9 ++ 6 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 packages/solidjs/src/debug-build.ts create mode 100644 packages/solidjs/src/solidrouter.ts diff --git a/packages/solidjs/package.json b/packages/solidjs/package.json index f3b91d7b706a..930da402f0be 100644 --- a/packages/solidjs/package.json +++ b/packages/solidjs/package.json @@ -44,7 +44,8 @@ "dependencies": { "@sentry/browser": "8.7.0", "@sentry/core": "8.7.0", - "@sentry/types": "8.7.0" + "@sentry/types": "8.7.0", + "@sentry/utils": "8.7.0" }, "peerDependencies": { "solid-js": "1.8.x" @@ -54,6 +55,9 @@ "solid-js": "1.8.11", "vite-plugin-solid": "^2.8.2" }, + "optionalDependencies": { + "@solidjs/router": "0.13.3" + }, "scripts": { "build": "run-p build:transpile build:types", "build:dev": "yarn build", diff --git a/packages/solidjs/rollup.npm.config.mjs b/packages/solidjs/rollup.npm.config.mjs index 84a06f2fb64a..3dddb100a442 100644 --- a/packages/solidjs/rollup.npm.config.mjs +++ b/packages/solidjs/rollup.npm.config.mjs @@ -1,3 +1,9 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils'; -export default makeNPMConfigVariants(makeBaseNPMConfig()); +export default makeNPMConfigVariants( + makeBaseNPMConfig({ + packageSpecificConfig: { + external: ['solid-js', 'solid-js/web', '@solidjs/router'], + }, + }), +); diff --git a/packages/solidjs/src/debug-build.ts b/packages/solidjs/src/debug-build.ts new file mode 100644 index 000000000000..60aa50940582 --- /dev/null +++ b/packages/solidjs/src/debug-build.ts @@ -0,0 +1,8 @@ +declare const __DEBUG_BUILD__: boolean; + +/** + * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code. + * + * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking. + */ +export const DEBUG_BUILD = __DEBUG_BUILD__; diff --git a/packages/solidjs/src/index.ts b/packages/solidjs/src/index.ts index 8e25b84c4a0c..77f17110f5e1 100644 --- a/packages/solidjs/src/index.ts +++ b/packages/solidjs/src/index.ts @@ -1,3 +1,5 @@ export * from '@sentry/browser'; export { init } from './sdk'; + +export * from './solidrouter'; diff --git a/packages/solidjs/src/solidrouter.ts b/packages/solidjs/src/solidrouter.ts new file mode 100644 index 000000000000..d7aa134920fd --- /dev/null +++ b/packages/solidjs/src/solidrouter.ts @@ -0,0 +1,165 @@ +import { + WINDOW, + browserTracingIntegration, + getActiveSpan, + getRootSpan, + spanToJSON, + startBrowserTracingNavigationSpan, + startBrowserTracingPageLoadSpan, +} from '@sentry/browser'; +import { + SEMANTIC_ATTRIBUTE_SENTRY_OP, + SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, + SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, + getClient, +} from '@sentry/core'; +import type { Client, Integration, Span } from '@sentry/types'; +import { logger } from '@sentry/utils'; +import type { BeforeLeaveEventArgs, Location, RouteSectionProps, RouterProps } from '@solidjs/router'; +import { createEffect, mergeProps, splitProps } from 'solid-js'; +import type { Component, JSX, ParentProps } from 'solid-js'; +import { createComponent } from 'solid-js/web'; +import { DEBUG_BUILD } from './debug-build'; + +const CLIENTS_WITH_INSTRUMENT_NAVIGATION: Client[] = []; + +type UserBeforeLeave = (listener: (e: BeforeLeaveEventArgs) => void) => void; +type UseLocation = () => Location; + +let _useBeforeLeave: UserBeforeLeave; +let _useLocation: UseLocation; + +interface SolidRouterOptions { + useBeforeLeave: UserBeforeLeave; + useLocation: UseLocation; +} + +function handleNavigation(location: string): void { + const client = getClient(); + if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.includes(client)) { + return; + } + + startBrowserTracingNavigationSpan(client, { + name: location, + attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation', + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solidjs.solidrouter', + [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url', + }, + }); +} + +function getActiveRootSpan(): Span | undefined { + const span = getActiveSpan(); + return span ? getRootSpan(span) : undefined; +} + +/** Pass-through component in case user didn't specify a root **/ +function SentryDefaultRoot(props: ParentProps): JSX.Element { + return props.children; +} + +/** + * Unfortunately, we cannot use router hooks directly in the Router, so we + * need to wrap the `root` prop to instrument navigation. + */ +function withSentryRouterRoot(Root: Component): Component { + const SentryRouterRoot = (props: RouteSectionProps): JSX.Element => { + // TODO: This is a rudimentary first version of handling navigation spans + // It does not + // - use query params + // - parameterize the route + + _useBeforeLeave(({ to }: BeforeLeaveEventArgs) => { + // `to` could be `-1` if the browser back-button was used + handleNavigation(to.toString()); + }); + + const location = _useLocation(); + createEffect(() => { + const name = location.pathname; + const rootSpan = getActiveRootSpan(); + + if (rootSpan) { + const { op, description } = spanToJSON(rootSpan); + + // We only need to update navigation spans that have been created by + // a browser back-button navigation (stored as `-1` by solid router) + // everything else was already instrumented correctly in `useBeforeLeave` + if (op === 'navigation' && description === '-1') { + rootSpan.updateName(name); + } + } + }); + + return createComponent(Root, props); + }; + + return SentryRouterRoot; +} + +/** + * A browser tracing integration that uses Solid Router to instrument navigations. + */ +export function solidRouterBrowserTracingIntegration( + options: Parameters[0] & SolidRouterOptions, +): Integration { + const integration = browserTracingIntegration({ + ...options, + instrumentPageLoad: false, + instrumentNavigation: false, + }); + + const { instrumentPageLoad = true, instrumentNavigation = true, useBeforeLeave, useLocation } = options; + + return { + ...integration, + setup() { + _useBeforeLeave = useBeforeLeave; + _useLocation = useLocation; + }, + afterAllSetup(client) { + integration.afterAllSetup(client); + + const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname; + if (instrumentPageLoad && initPathName) { + startBrowserTracingPageLoadSpan(client, { + name: initPathName, + attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url', + [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload', + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.solidjs.solidrouter', + }, + }); + } + + if (instrumentNavigation) { + CLIENTS_WITH_INSTRUMENT_NAVIGATION.push(client); + } + }, + }; +} + +/** + * A higher-order component to instrument Solid Router to create navigation spans. + */ +export function withSentryRouterRouting(Router: Component): Component { + if (!_useBeforeLeave || !_useLocation) { + DEBUG_BUILD && + logger.warn(`solidRouterBrowserTracingIntegration was unable to wrap Solid Router because of one or more missing hooks. + useBeforeLeave: ${_useBeforeLeave}. useLocation: ${_useLocation}.`); + + return Router; + } + + const SentryRouter = (props: RouterProps): JSX.Element => { + const [local, others] = splitProps(props, ['root']); + // We need to wrap root here in case the user passed in their own root + const Root = withSentryRouterRoot(local.root ? local.root : SentryDefaultRoot); + + return createComponent(Router, mergeProps({ root: Root }, others)); + }; + + return SentryRouter; +} diff --git a/yarn.lock b/yarn.lock index e0e07a2aefae..4f852d496b70 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7768,6 +7768,11 @@ resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz#96116f2a912e0c02817345b3c10751069920d553" integrity sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg== +"@solidjs/router@0.13.3": + version "0.13.3" + resolved "https://registry.yarnpkg.com/@solidjs/router/-/router-0.13.3.tgz#f520362d716a58c0416a33372ae9e5ed1a26be9a" + integrity sha512-p8zznlvnN3KySMXqT8irhubgDNTETNa/guaGHU/cZl7kuiPO3PmkWNYfoNCygtEpoxLmLpf62/ZKeyhFdZexsw== + "@solidjs/testing-library@0.8.5": version "0.8.5" resolved "https://registry.yarnpkg.com/@solidjs/testing-library/-/testing-library-0.8.5.tgz#97061b2286d8641bd43bf474e624c3bb47e486a6" @@ -8452,6 +8457,7 @@ "@types/unist" "*" "@types/history-4@npm:@types/history@4.7.8", "@types/history-5@npm:@types/history@4.7.8", "@types/history@*": + name "@types/history-4" version "4.7.8" resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.8.tgz#49348387983075705fe8f4e02fb67f7daaec4934" integrity sha512-S78QIYirQcUoo6UJZx9CSP0O2ix9IaeAXwQi26Rhr/+mg7qqPy8TzaxHSUut7eGjL8WmLccT7/MXf304WjqHcA== @@ -26109,6 +26115,7 @@ react-is@^18.0.0: "@remix-run/router" "1.0.2" "react-router-6@npm:react-router@6.3.0", react-router@6.3.0: + name react-router-6 version "6.3.0" resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.3.0.tgz#3970cc64b4cb4eae0c1ea5203a80334fdd175557" integrity sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ== @@ -28442,6 +28449,7 @@ string-template@~0.2.1: integrity sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0= "string-width-cjs@npm:string-width@^4.2.0", string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: + name string-width-cjs version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -31190,6 +31198,7 @@ workerpool@^6.4.0: integrity sha512-i3KR1mQMNwY2wx20ozq2EjISGtQWDIfV56We+yGJ5yDs8jTwQiLLaqHlkBHITlCuJnYlVRmXegxFxZg7gqI++A== "wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: + name wrap-ansi-cjs version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== From 752b61812061de77c491a70ea342b7b3c1b1c9a6 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Wed, 29 May 2024 10:14:47 +0200 Subject: [PATCH 2/6] feat(solidjs): Remove unnecessary external deps in rollup config --- packages/solidjs/rollup.npm.config.mjs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/solidjs/rollup.npm.config.mjs b/packages/solidjs/rollup.npm.config.mjs index 3dddb100a442..84a06f2fb64a 100644 --- a/packages/solidjs/rollup.npm.config.mjs +++ b/packages/solidjs/rollup.npm.config.mjs @@ -1,9 +1,3 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils'; -export default makeNPMConfigVariants( - makeBaseNPMConfig({ - packageSpecificConfig: { - external: ['solid-js', 'solid-js/web', '@solidjs/router'], - }, - }), -); +export default makeNPMConfigVariants(makeBaseNPMConfig()); From 88fad51252fd142b23ff1d9967e71afdcca3c462 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Wed, 29 May 2024 10:44:38 +0200 Subject: [PATCH 3/6] feat(solidjs): Use WeakSet to check for instrumented clients --- packages/solidjs/src/solidrouter.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/solidjs/src/solidrouter.ts b/packages/solidjs/src/solidrouter.ts index d7aa134920fd..f2477e2a9402 100644 --- a/packages/solidjs/src/solidrouter.ts +++ b/packages/solidjs/src/solidrouter.ts @@ -21,7 +21,7 @@ import type { Component, JSX, ParentProps } from 'solid-js'; import { createComponent } from 'solid-js/web'; import { DEBUG_BUILD } from './debug-build'; -const CLIENTS_WITH_INSTRUMENT_NAVIGATION: Client[] = []; +const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet(); type UserBeforeLeave = (listener: (e: BeforeLeaveEventArgs) => void) => void; type UseLocation = () => Location; @@ -36,7 +36,7 @@ interface SolidRouterOptions { function handleNavigation(location: string): void { const client = getClient(); - if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.includes(client)) { + if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) { return; } @@ -135,7 +135,7 @@ export function solidRouterBrowserTracingIntegration( } if (instrumentNavigation) { - CLIENTS_WITH_INSTRUMENT_NAVIGATION.push(client); + CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client); } }, }; From 523d9d5b7f2e338af582f469943fa4143b2eb121 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Wed, 29 May 2024 13:56:44 +0200 Subject: [PATCH 4/6] feat(solidjs): Drop solid router dep and vendor in types instead --- packages/solidjs/package.json | 7 ++--- packages/solidjs/src/solidrouter.ts | 41 ++++++++++++++++++++++++----- yarn.lock | 17 +++++------- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/packages/solidjs/package.json b/packages/solidjs/package.json index 930da402f0be..7b4317c79d60 100644 --- a/packages/solidjs/package.json +++ b/packages/solidjs/package.json @@ -48,16 +48,13 @@ "@sentry/utils": "8.7.0" }, "peerDependencies": { - "solid-js": "1.8.x" + "solid-js": "^1.8.4" }, "devDependencies": { "@solidjs/testing-library": "0.8.5", - "solid-js": "1.8.11", + "solid-js": "^1.8.11", "vite-plugin-solid": "^2.8.2" }, - "optionalDependencies": { - "@solidjs/router": "0.13.3" - }, "scripts": { "build": "run-p build:transpile build:types", "build:dev": "yarn build", diff --git a/packages/solidjs/src/solidrouter.ts b/packages/solidjs/src/solidrouter.ts index f2477e2a9402..fdd0cd20d949 100644 --- a/packages/solidjs/src/solidrouter.ts +++ b/packages/solidjs/src/solidrouter.ts @@ -15,25 +15,54 @@ import { } from '@sentry/core'; import type { Client, Integration, Span } from '@sentry/types'; import { logger } from '@sentry/utils'; -import type { BeforeLeaveEventArgs, Location, RouteSectionProps, RouterProps } from '@solidjs/router'; import { createEffect, mergeProps, splitProps } from 'solid-js'; import type { Component, JSX, ParentProps } from 'solid-js'; import { createComponent } from 'solid-js/web'; import { DEBUG_BUILD } from './debug-build'; -const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet(); +// Vendored solid router types so that we don't need to depend on solid router. +// These are not exhaustive and loose on purpose. +interface Location { + pathname: string; +} -type UserBeforeLeave = (listener: (e: BeforeLeaveEventArgs) => void) => void; -type UseLocation = () => Location; +interface BeforeLeaveEventArgs { + from: Location; + to: string | number; +} -let _useBeforeLeave: UserBeforeLeave; -let _useLocation: UseLocation; +interface RouteSectionProps { + location: Location; + data?: T; + children?: JSX.Element; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type RouteDefinition = { + path?: S; + children?: RouteDefinition | RouteDefinition[]; + component?: Component>; +}; + +interface RouterProps { + base?: string; + root?: Component; + children?: JSX.Element | RouteDefinition | RouteDefinition[]; +} interface SolidRouterOptions { useBeforeLeave: UserBeforeLeave; useLocation: UseLocation; } +type UserBeforeLeave = (listener: (e: BeforeLeaveEventArgs) => void) => void; +type UseLocation = () => Location; + +const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet(); + +let _useBeforeLeave: UserBeforeLeave; +let _useLocation: UseLocation; + function handleNavigation(location: string): void { const client = getClient(); if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) { diff --git a/yarn.lock b/yarn.lock index 4f852d496b70..e054994642fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7768,11 +7768,6 @@ resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz#96116f2a912e0c02817345b3c10751069920d553" integrity sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg== -"@solidjs/router@0.13.3": - version "0.13.3" - resolved "https://registry.yarnpkg.com/@solidjs/router/-/router-0.13.3.tgz#f520362d716a58c0416a33372ae9e5ed1a26be9a" - integrity sha512-p8zznlvnN3KySMXqT8irhubgDNTETNa/guaGHU/cZl7kuiPO3PmkWNYfoNCygtEpoxLmLpf62/ZKeyhFdZexsw== - "@solidjs/testing-library@0.8.5": version "0.8.5" resolved "https://registry.yarnpkg.com/@solidjs/testing-library/-/testing-library-0.8.5.tgz#97061b2286d8641bd43bf474e624c3bb47e486a6" @@ -27499,7 +27494,7 @@ seroval-plugins@^1.0.3: resolved "https://registry.yarnpkg.com/seroval-plugins/-/seroval-plugins-1.0.7.tgz#c02511a1807e9bc8f68a91fbec13474fa9cea670" integrity sha512-GO7TkWvodGp6buMEX9p7tNyIkbwlyuAWbI6G9Ec5bhcm7mQdu3JOK1IXbEUwb3FVzSc363GraG/wLW23NSavIw== -seroval@^1.0.3: +seroval@^1.0.4: version "1.0.7" resolved "https://registry.yarnpkg.com/seroval/-/seroval-1.0.7.tgz#ee48ad8ba69f1595bdd5c55d1a0d1da29dee7455" integrity sha512-n6ZMQX5q0Vn19Zq7CIKNIo7E75gPkGCFUEqDpa8jgwpYr/vScjqnQ6H09t1uIiZ0ZSK0ypEGvrYK2bhBGWsGdw== @@ -27941,13 +27936,13 @@ socks@^2.6.2: ip "^2.0.0" smart-buffer "^4.2.0" -solid-js@1.8.11: - version "1.8.11" - resolved "https://registry.yarnpkg.com/solid-js/-/solid-js-1.8.11.tgz#0e7496a9834720b10fe739eaac250221d3f72cd5" - integrity sha512-WdwmER+TwBJiN4rVQTVBxocg+9pKlOs41KzPYntrC86xO5sek8TzBYozPEZPL1IRWDouf2lMrvSbIs3CanlPvQ== +solid-js@^1.8.11: + version "1.8.17" + resolved "https://registry.yarnpkg.com/solid-js/-/solid-js-1.8.17.tgz#780ed6f0fd8633009d1b3c29d56bf6b6bb33bd50" + integrity sha512-E0FkUgv9sG/gEBWkHr/2XkBluHb1fkrHywUgA6o6XolPDCJ4g1HaLmQufcBBhiF36ee40q+HpG/vCZu7fLpI3Q== dependencies: csstype "^3.1.0" - seroval "^1.0.3" + seroval "^1.0.4" seroval-plugins "^1.0.3" solid-refresh@^0.6.3: From c326cecc7409105eaa8db10aaec34c1406a06733 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Wed, 29 May 2024 14:44:23 +0200 Subject: [PATCH 5/6] feat(solidjs): Update README with routing instrumentation instructions --- packages/solidjs/README.md | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/solidjs/README.md b/packages/solidjs/README.md index 3e37b30e7032..00d451763624 100644 --- a/packages/solidjs/README.md +++ b/packages/solidjs/README.md @@ -7,3 +7,44 @@ # Official Sentry SDK for SolidJS This SDK is work in progress, and should not be used before officially released. + +# Solid Router + +The Solid Router instrumentation uses the Solid Router library to create navigation spans to ensure you collect +meaningful performance data about the health of your page loads and associated requests. + +Add `Sentry.solidRouterBrowserTracingIntegration` instead of the regular `Sentry.browserTracingIntegration` and provide +the hooks it needs to enable performance tracing: + +`useBeforeLeave` from `@solidjs/router` +`useLocation` from `@solidjs/router` + +Make sure `Sentry.solidRouterBrowserTracingIntegration` is initialized by your `Sentry.init` call, before you wrap +`Router`. Otherwise, the routing instrumentation may not work properly. + +Wrap `Router`, `MemoryRouter` or `HashRouter` from `@solidjs/router` using `Sentry.withSentryRouterRouting`. This +creates a higher order component, which will enable Sentry to reach your router context. + +```js +import * as Sentry from '@sentry/solidjs'; +import { Route, Router, useBeforeLeave, useLocation } from '@solidjs/router'; + +Sentry.init({ + dsn: '__PUBLIC_DSN__', + integrations: [Sentry.solidRouterBrowserTracingIntegration({ useBeforeLeave, useLocation })], + tracesSampleRate: 1.0, // Capture 100% of the transactions + debug: true, +}); + +const SentryRouter = Sentry.withSentryRouterRouting(Router); + +render( + () => ( + + + ... + + ), + document.getElementById('root'), +); +``` From 5b74d498b62bedd9cd101a91e7f2b580d987a365 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Wed, 29 May 2024 16:33:25 +0200 Subject: [PATCH 6/6] feat(solidjs): Drop custom pageload navigation in favor of browserTracingIntegration's --- packages/solidjs/src/solidrouter.ts | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/packages/solidjs/src/solidrouter.ts b/packages/solidjs/src/solidrouter.ts index fdd0cd20d949..d38b21313570 100644 --- a/packages/solidjs/src/solidrouter.ts +++ b/packages/solidjs/src/solidrouter.ts @@ -1,11 +1,9 @@ import { - WINDOW, browserTracingIntegration, getActiveSpan, getRootSpan, spanToJSON, startBrowserTracingNavigationSpan, - startBrowserTracingPageLoadSpan, } from '@sentry/browser'; import { SEMANTIC_ATTRIBUTE_SENTRY_OP, @@ -136,11 +134,10 @@ export function solidRouterBrowserTracingIntegration( ): Integration { const integration = browserTracingIntegration({ ...options, - instrumentPageLoad: false, instrumentNavigation: false, }); - const { instrumentPageLoad = true, instrumentNavigation = true, useBeforeLeave, useLocation } = options; + const { instrumentNavigation = true, useBeforeLeave, useLocation } = options; return { ...integration, @@ -151,18 +148,6 @@ export function solidRouterBrowserTracingIntegration( afterAllSetup(client) { integration.afterAllSetup(client); - const initPathName = WINDOW && WINDOW.location && WINDOW.location.pathname; - if (instrumentPageLoad && initPathName) { - startBrowserTracingPageLoadSpan(client, { - name: initPathName, - attributes: { - [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url', - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload', - [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.solidjs.solidrouter', - }, - }); - } - if (instrumentNavigation) { CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client); }