Skip to content
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 @@ -11,6 +11,16 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
'sentry.origin': 'auto.pageload.remix',
'sentry.source': 'url',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/$/),
'url.path': '/',
}),
);
// no url.template because the route isn't parameterized (sentry.source: 'url')
expect(transactionEvent.contexts?.trace?.data).not.toHaveProperty('url.template');
});

test('Sends a navigation transaction to Sentry', async ({ page }) => {
Expand All @@ -26,6 +36,14 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
'sentry.source': 'route',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/user\/5$/),
'url.path': '/user/5',
'url.template': '/user/:id',
}),
);
});

test('Sends a navigation transaction with parameterized route to Sentry', async ({ page }) => {
Expand All @@ -41,7 +59,15 @@ test('Sends a navigation transaction with parameterized route to Sentry', async
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.transaction).toBeTruthy();
expect(transactionEvent.transaction).toBe('/user/:id');
expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
'sentry.source': 'route',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/user\/5$/),
'url.path': '/user/5',
'url.template': '/user/:id',
}),
);
});

test('Renders `sentry-trace` and `baggage` meta tags for the root route', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
'sentry.origin': 'auto.pageload.remix',
'sentry.source': 'url',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/$/),
'url.path': '/',
}),
);
// no url.template because the route isn't parameterized (sentry.source: 'url')
expect(transactionEvent.contexts?.trace?.data).not.toHaveProperty('url.template');
});

test('Sends a navigation transaction to Sentry', async ({ page }) => {
Expand All @@ -26,6 +36,14 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
'sentry.source': 'route',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/user\/5$/),
'url.path': '/user/5',
'url.template': '/user/:id',
}),
);
});

test('Renders `sentry-trace` and `baggage` meta tags for the root route', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
// No manifest available (legacy app without the Sentry Vite plugin), so source falls back to 'route'
// and url.template uses the route id instead of a parameterized URL path.
'sentry.source': 'route',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/$/),
'url.path': '/',
'url.template': 'routes/_index',
}),
);
});

test('Sends a navigation transaction to Sentry', async ({ page }) => {
Expand All @@ -26,6 +36,14 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
'sentry.source': 'route',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/user\/5$/),
'url.path': '/user/5',
'url.template': 'routes/user.$id',
}),
);
});

test('Renders `sentry-trace` and `baggage` meta tags for the root route', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
'sentry.source': 'url',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/$/),
'url.path': '/',
}),
);
// no url.template because the route isn't parameterized (sentry.source: 'url')
expect(transactionEvent.contexts?.trace?.data).not.toHaveProperty('url.template');
});

test('Sends a navigation transaction to Sentry', async ({ page }) => {
Expand All @@ -26,6 +35,14 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
'sentry.source': 'route',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/user\/5$/),
'url.path': '/user/5',
'url.template': '/user/:id',
}),
);
});

test('Renders `sentry-trace` and `baggage` meta tags for the root route', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
const transactionEvent = await transactionPromise;

expect(transactionEvent).toBeDefined();
expect(transactionEvent).toMatchObject({
transaction: '/',
contexts: {
trace: {
data: {
'sentry.source': 'url',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/$/),
'url.path': '/',
},
},
},
});
// no url.template because the route isn't parameterized (sentry.source: 'url')
expect(transactionEvent.contexts?.trace?.data).not.toHaveProperty('url.template');
});

test('Sends a navigation transaction to Sentry', async ({ page }) => {
Expand Down Expand Up @@ -39,6 +53,16 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
expect(transactionEvent).toBeDefined();
expect(transactionEvent).toMatchObject({
transaction: '/user/:id',
contexts: {
trace: {
data: {
'sentry.source': 'route',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/user\/5$/),
'url.path': '/user/5',
'url.template': '/user/:id',
},
},
},
});
});

Expand Down
6 changes: 6 additions & 0 deletions packages/remix/src/client/performance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getClient, startBrowserTracingNavigationSpan, startBrowserTracingPageLo
import * as React from 'react';
import { DEBUG_BUILD } from '../utils/debug-build';
import { hasManifest, maybeParameterizeRemixRoute } from './remixRouteParameterization';
import { URL_TEMPLATE } from '@sentry/conventions/attributes';

export type Params<Key extends string = string> = {
readonly [key in Key]: string | undefined;
Expand Down Expand Up @@ -103,6 +104,7 @@ export function startPageloadSpan(client: Client): void {
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.remix',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
...(source === 'route' && { [URL_TEMPLATE]: spanName }),
},
};

Expand All @@ -126,6 +128,7 @@ function startNavigationSpan(matches: RouteMatch<string>[], location: ReturnType
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.remix',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
...(source === 'route' && { [URL_TEMPLATE]: name }),
},
};

Expand Down Expand Up @@ -182,6 +185,9 @@ export function withSentry<P extends Record<string, unknown>, R extends React.Co
if (transaction) {
transaction.updateName(name);
transaction.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
if (source === 'route') {
transaction.setAttribute(URL_TEMPLATE, name);
}
}
}
}
Expand Down
Loading