Skip to content

Commit fb83c9b

Browse files
nicohrubecclaude
andauthored
feat(tanstackstart-react): Filter noisy dev transactions (#21145)
Vite dev server requests (`/node_modules/`, `/@id/`, `/@react-refresh`, `/@tanstack-start/`) and `/favicon.ico` generate noise. Filters them via `ignoreSpans` in `init()` so this works for both transactions and streamed spans. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5c75be7 commit fb83c9b

4 files changed

Lines changed: 73 additions & 0 deletions

File tree

packages/tanstackstart-react/src/client/sdk.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,16 @@ export function init(options: ReactBrowserOptions): Client | undefined {
1818
applyTunnelRouteOption(sentryOptions);
1919
applySdkMetadata(sentryOptions, 'tanstackstart-react', ['tanstackstart-react', 'react']);
2020

21+
sentryOptions.ignoreSpans = [
22+
...(sentryOptions.ignoreSpans || []),
23+
/\/node_modules\//,
24+
/\/favicon\.ico/,
25+
/\/@id\//,
26+
/\/@react-refresh/,
27+
/\/@tanstack-start\//,
28+
/\/@fs\//,
29+
/\/@vite\//,
30+
];
31+
2132
return initReactSDK(sentryOptions);
2233
}

packages/tanstackstart-react/src/server/sdk.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,13 @@ export function init(options: NodeOptions): NodeClient | undefined {
1313

1414
applySdkMetadata(sentryOptions, 'tanstackstart-react', ['tanstackstart-react', 'node']);
1515

16+
sentryOptions.ignoreSpans = [
17+
...(sentryOptions.ignoreSpans || []),
18+
/\/node_modules\//,
19+
/\/@id\//,
20+
/\/@react-refresh/,
21+
/\/@vite\//,
22+
];
23+
1624
return initNodeSdk(sentryOptions);
1725
}

packages/tanstackstart-react/test/client/sdk.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,37 @@ describe('TanStack Start React Client SDK', () => {
4343
expect(init({})).not.toBeUndefined();
4444
});
4545

46+
it('sets ignoreSpans to filter low-quality spans', () => {
47+
init({ dsn: 'https://public@dsn.ingest.sentry.io/1337' });
48+
49+
expect(reactInit).toHaveBeenCalledWith(
50+
expect.objectContaining({
51+
ignoreSpans: expect.arrayContaining([
52+
/\/node_modules\//,
53+
/\/favicon\.ico/,
54+
/\/@id\//,
55+
/\/@react-refresh/,
56+
/\/@tanstack-start\//,
57+
/\/@fs\//,
58+
/\/@vite\//,
59+
]),
60+
}),
61+
);
62+
});
63+
64+
it('preserves user-defined ignoreSpans', () => {
65+
init({
66+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
67+
ignoreSpans: [/custom-pattern/],
68+
});
69+
70+
expect(reactInit).toHaveBeenCalledWith(
71+
expect.objectContaining({
72+
ignoreSpans: expect.arrayContaining([/custom-pattern/, /\/favicon\.ico/]),
73+
}),
74+
);
75+
});
76+
4677
it('applies the managed tunnel route when no runtime tunnel is provided', () => {
4778
vi.stubGlobal('__SENTRY_TANSTACKSTART_TUNNEL_ROUTE__', '/managed-tunnel');
4879

packages/tanstackstart-react/test/server/sdk.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,28 @@ describe('TanStack Start React Server SDK', () => {
3838
it('returns client from init', () => {
3939
expect(init({})).not.toBeUndefined();
4040
});
41+
42+
it('sets ignoreSpans to filter low-quality transactions', () => {
43+
init({ dsn: 'https://public@dsn.ingest.sentry.io/1337' });
44+
45+
expect(nodeInit).toHaveBeenCalledWith(
46+
expect.objectContaining({
47+
ignoreSpans: expect.arrayContaining([/\/node_modules\//, /\/@id\//, /\/@react-refresh/, /\/@vite\//]),
48+
}),
49+
);
50+
});
51+
52+
it('preserves user-defined ignoreSpans', () => {
53+
init({
54+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
55+
ignoreSpans: [/custom-pattern/],
56+
});
57+
58+
expect(nodeInit).toHaveBeenCalledWith(
59+
expect.objectContaining({
60+
ignoreSpans: expect.arrayContaining([/custom-pattern/, /\/@vite\//]),
61+
}),
62+
);
63+
});
4164
});
4265
});

0 commit comments

Comments
 (0)