Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(solidstart): Set proper sentry origin for solid router integration when used in solidstart sdk #12919

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test('sends a navigation transaction', async ({ page }) => {
contexts: {
trace: {
op: 'navigation',
origin: 'auto.navigation.solid.solidrouter',
origin: 'auto.navigation.solidstart.solidrouter',
},
},
transaction: '/users/5',
Expand All @@ -62,7 +62,7 @@ test('updates the transaction when using the back button', async ({ page }) => {
contexts: {
trace: {
op: 'navigation',
origin: 'auto.navigation.solid.solidrouter',
origin: 'auto.navigation.solidstart.solidrouter',
},
},
transaction: '/users/6',
Expand All @@ -82,7 +82,7 @@ test('updates the transaction when using the back button', async ({ page }) => {
contexts: {
trace: {
op: 'navigation',
origin: 'auto.navigation.solid.solidrouter',
origin: 'auto.navigation.solidstart.solidrouter',
},
},
transaction: '/',
Expand Down
9 changes: 8 additions & 1 deletion packages/solid/src/solidrouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,18 @@ function handleNavigation(location: string): void {
return;
}

// The solid router integration will be used for both solid and solid start.
// To avoid increasing the api surface with internal properties, we look at
// the sdk metadata.
const metaData = client.getSdkMetadata();
const { name } = (metaData && metaData.sdk) || {};
const framework = name && name.includes('solidstart') ? 'solidstart' : 'solid';

startBrowserTracingNavigationSpan(client, {
name: location,
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solid.solidrouter',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.${framework}.solidrouter`,
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
},
});
Expand Down
5 changes: 5 additions & 0 deletions packages/solid/test/solidrouter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ describe('solidRouterBrowserTracingIntegration', () => {
tracesSampleRate: 1,
transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => Promise.resolve({})),
stackParser: () => [],
_metadata: {
sdk: {
name: 'sentry.javascript.solid',
},
},
});
}

Expand Down
9 changes: 7 additions & 2 deletions packages/solidstart/test/client/solidrouter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ describe('solidRouterBrowserTracingIntegration', () => {
tracesSampleRate: 1,
transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => Promise.resolve({})),
stackParser: () => [],
_metadata: {
sdk: {
name: 'sentry.javascript.solidstart',
},
},
});
}

Expand Down Expand Up @@ -138,7 +143,7 @@ describe('solidRouterBrowserTracingIntegration', () => {
data: expect.objectContaining({
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solid.solidrouter',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solidstart.solidrouter',
}),
}),
);
Expand Down Expand Up @@ -170,7 +175,7 @@ describe('solidRouterBrowserTracingIntegration', () => {
data: expect.objectContaining({
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solid.solidrouter',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.solidstart.solidrouter',
}),
}),
);
Expand Down
Loading