Skip to content

Commit 80bdca7

Browse files
committed
feat(remix): Add parameterized transaction naming for routes
1 parent a524022 commit 80bdca7

File tree

67 files changed

+3296
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3296
-152
lines changed

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/tests/client-transactions.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { waitForTransaction } from '@sentry-internal/test-utils';
33

44
test('Sends a pageload transaction to Sentry', async ({ page }) => {
55
const transactionPromise = waitForTransaction('create-remix-app-express-vite-dev', transactionEvent => {
6-
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === 'routes/_index';
6+
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/';
77
});
88

99
await page.goto('/');
@@ -15,7 +15,7 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
1515

1616
test('Sends a navigation transaction to Sentry', async ({ page }) => {
1717
const transactionPromise = waitForTransaction('create-remix-app-express-vite-dev', transactionEvent => {
18-
return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === 'routes/user.$id';
18+
return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === '/user/:id';
1919
});
2020

2121
await page.goto('/');
@@ -28,6 +28,22 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
2828
expect(transactionEvent).toBeDefined();
2929
});
3030

31+
test('Sends a navigation transaction with parameterized route to Sentry', async ({ page }) => {
32+
const transactionPromise = waitForTransaction('create-remix-app-express-vite-dev', transactionEvent => {
33+
return transactionEvent.contexts?.trace?.op === 'navigation';
34+
});
35+
36+
await page.goto('/');
37+
38+
const linkElement = page.locator('id=navigation');
39+
await linkElement.click();
40+
41+
const transactionEvent = await transactionPromise;
42+
43+
expect(transactionEvent).toBeDefined();
44+
expect(transactionEvent.transaction).toBeTruthy();
45+
});
46+
3147
test('Renders `sentry-trace` and `baggage` meta tags for the root route', async ({ page }) => {
3248
await page.goto('/');
3349

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/tests/server-transactions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test('Sends two linked transactions (server & client) to Sentry', async ({ page
4848
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;
4949

5050
expect(httpServerTransaction.transaction).toBe('GET http://localhost:3030/');
51-
expect(pageloadTransaction.transaction).toBe('routes/_index');
51+
expect(pageloadTransaction.transaction).toBe('/');
5252

5353
expect(httpServerTraceId).toBeDefined();
5454
expect(httpServerSpanId).toBeDefined();

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/vite.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import { installGlobals } from '@remix-run/node';
12
import { vitePlugin as remix } from '@remix-run/dev';
3+
import { sentryRemixVitePlugin } from '@sentry/remix';
24
import { defineConfig } from 'vite';
35
import tsconfigPaths from 'vite-tsconfig-paths';
46

5-
import { installGlobals } from '@remix-run/node';
6-
77
installGlobals();
88

99
export default defineConfig({
1010
plugins: [
1111
remix(),
12+
sentryRemixVitePlugin(),
1213
tsconfigPaths({
1314
// The dev server config errors are not relevant to this test app
1415
// https://github.com/aleclarson/vite-tsconfig-paths?tab=readme-ov-file#options

dev-packages/e2e-tests/test-applications/create-remix-app-express/tests/client-transactions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { waitForTransaction } from '@sentry-internal/test-utils';
33

44
test('Sends a pageload transaction to Sentry', async ({ page }) => {
55
const transactionPromise = waitForTransaction('create-remix-app-express', transactionEvent => {
6-
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === 'routes/_index';
6+
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/';
77
});
88

99
await page.goto('/');
@@ -15,7 +15,7 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
1515

1616
test('Sends a navigation transaction to Sentry', async ({ page }) => {
1717
const transactionPromise = waitForTransaction('create-remix-app-express', transactionEvent => {
18-
return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === 'routes/user.$id';
18+
return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === '/user/:id';
1919
});
2020

2121
await page.goto('/');

dev-packages/e2e-tests/test-applications/create-remix-app-express/tests/server-transactions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ test('Propagates trace when ErrorBoundary is triggered', async ({ page }) => {
9090
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;
9191

9292
expect(httpServerTransaction.transaction).toBe('GET client-error');
93-
expect(pageloadTransaction.transaction).toBe('routes/client-error');
93+
expect(pageloadTransaction.transaction).toBe('/client-error');
9494

9595
expect(httpServerTraceId).toBeDefined();
9696
expect(httpServerSpanId).toBeDefined();
@@ -132,7 +132,7 @@ test('Sends two linked transactions (server & client) to Sentry', async ({ page
132132
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;
133133

134134
expect(httpServerTransaction.transaction).toBe('GET http://localhost:3030/');
135-
expect(pageloadTransaction.transaction).toBe('routes/_index');
135+
expect(pageloadTransaction.transaction).toBe('/');
136136

137137
expect(httpServerTraceId).toBeDefined();
138138
expect(httpServerSpanId).toBeDefined();

dev-packages/e2e-tests/test-applications/create-remix-app-express/vite.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import { installGlobals } from '@remix-run/node';
12
import { vitePlugin as remix } from '@remix-run/dev';
3+
import { sentryRemixVitePlugin } from '@sentry/remix';
24
import { defineConfig } from 'vite';
35
import tsconfigPaths from 'vite-tsconfig-paths';
46

5-
import { installGlobals } from '@remix-run/node';
6-
77
installGlobals();
88

99
export default defineConfig({
1010
plugins: [
1111
remix(),
12+
sentryRemixVitePlugin(),
1213
tsconfigPaths({
1314
// The dev server config errors are not relevant to this test app
1415
// https://github.com/aleclarson/vite-tsconfig-paths?tab=readme-ov-file#options
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import('eslint').Linter.Config} */
2+
module.exports = {
3+
extends: ['@remix-run/eslint-config', '@remix-run/eslint-config/node'],
4+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
3+
/.cache
4+
/build
5+
/public/build
6+
.env
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sentry:registry=http://127.0.0.1:4873
2+
@sentry-internal:registry=http://127.0.0.1:4873
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* By default, Remix will handle hydrating your app on the client for you.
3+
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
4+
* For more information, see https://remix.run/file-conventions/entry.client
5+
*/
6+
7+
// Extend the Window interface to include ENV
8+
declare global {
9+
interface Window {
10+
ENV: {
11+
SENTRY_DSN: string;
12+
[key: string]: unknown;
13+
};
14+
}
15+
}
16+
17+
import { RemixBrowser, useLocation, useMatches } from '@remix-run/react';
18+
import * as Sentry from '@sentry/remix';
19+
import { StrictMode, startTransition, useEffect } from 'react';
20+
import { hydrateRoot } from 'react-dom/client';
21+
22+
Sentry.init({
23+
environment: 'qa', // dynamic sampling bias to keep transactions
24+
dsn: window.ENV.SENTRY_DSN,
25+
integrations: [
26+
Sentry.browserTracingIntegration({
27+
useEffect,
28+
useLocation,
29+
useMatches,
30+
}),
31+
Sentry.replayIntegration(),
32+
],
33+
// Performance Monitoring
34+
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
35+
// Session Replay
36+
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
37+
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
38+
tunnel: 'http://localhost:3032/', // proxy server
39+
});
40+
41+
startTransition(() => {
42+
hydrateRoot(
43+
document,
44+
<StrictMode>
45+
<RemixBrowser />
46+
</StrictMode>,
47+
);
48+
});

0 commit comments

Comments
 (0)