Skip to content

Commit 383743a

Browse files
authored
fix(solidstart): Set proper sentry origin for solid router integration when used in solidstart sdk (#12919)
The `@sentry/solid/solidrouter` integration is used within the solid start sdk as well, so we need a way to update the `sentry.origin` for navigation spans to be for the correct framework. I opted to read this out of the sdk metadata instead of exposing extra api surface and passing it through several levels.
1 parent 1d3e208 commit 383743a

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

dev-packages/e2e-tests/test-applications/solidstart/tests/performance.client.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test('sends a navigation transaction', async ({ page }) => {
3636
contexts: {
3737
trace: {
3838
op: 'navigation',
39-
origin: 'auto.navigation.solid.solidrouter',
39+
origin: 'auto.navigation.solidstart.solidrouter',
4040
},
4141
},
4242
transaction: '/users/5',
@@ -62,7 +62,7 @@ test('updates the transaction when using the back button', async ({ page }) => {
6262
contexts: {
6363
trace: {
6464
op: 'navigation',
65-
origin: 'auto.navigation.solid.solidrouter',
65+
origin: 'auto.navigation.solidstart.solidrouter',
6666
},
6767
},
6868
transaction: '/users/6',
@@ -82,7 +82,7 @@ test('updates the transaction when using the back button', async ({ page }) => {
8282
contexts: {
8383
trace: {
8484
op: 'navigation',
85-
origin: 'auto.navigation.solid.solidrouter',
85+
origin: 'auto.navigation.solidstart.solidrouter',
8686
},
8787
},
8888
transaction: '/',

packages/solid/src/solidrouter.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,18 @@ function handleNavigation(location: string): void {
3333
return;
3434
}
3535

36+
// The solid router integration will be used for both solid and solid start.
37+
// To avoid increasing the api surface with internal properties, we look at
38+
// the sdk metadata.
39+
const metaData = client.getSdkMetadata();
40+
const { name } = (metaData && metaData.sdk) || {};
41+
const framework = name && name.includes('solidstart') ? 'solidstart' : 'solid';
42+
3643
startBrowserTracingNavigationSpan(client, {
3744
name: location,
3845
attributes: {
3946
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
40-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solid.solidrouter',
47+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.${framework}.solidrouter`,
4148
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
4249
},
4350
});

packages/solid/test/solidrouter.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ describe('solidRouterBrowserTracingIntegration', () => {
4444
tracesSampleRate: 1,
4545
transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => Promise.resolve({})),
4646
stackParser: () => [],
47+
_metadata: {
48+
sdk: {
49+
name: 'sentry.javascript.solid',
50+
},
51+
},
4752
});
4853
}
4954

packages/solidstart/test/client/solidrouter.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ describe('solidRouterBrowserTracingIntegration', () => {
4444
tracesSampleRate: 1,
4545
transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => Promise.resolve({})),
4646
stackParser: () => [],
47+
_metadata: {
48+
sdk: {
49+
name: 'sentry.javascript.solidstart',
50+
},
51+
},
4752
});
4853
}
4954

@@ -138,7 +143,7 @@ describe('solidRouterBrowserTracingIntegration', () => {
138143
data: expect.objectContaining({
139144
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
140145
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
141-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solid.solidrouter',
146+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solidstart.solidrouter',
142147
}),
143148
}),
144149
);
@@ -170,7 +175,7 @@ describe('solidRouterBrowserTracingIntegration', () => {
170175
data: expect.objectContaining({
171176
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
172177
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
173-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solid.solidrouter',
178+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solidstart.solidrouter',
174179
}),
175180
}),
176181
);

0 commit comments

Comments
 (0)