Skip to content
Draft
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
11 changes: 11 additions & 0 deletions packages/tanstackstart-react/src/client/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,16 @@ export function init(options: ReactBrowserOptions): Client | undefined {
applyTunnelRouteOption(sentryOptions);
applySdkMetadata(sentryOptions, 'tanstackstart-react', ['tanstackstart-react', 'react']);

sentryOptions.ignoreSpans = [
...(sentryOptions.ignoreSpans || []),
/\/node_modules\//,
/\/favicon\.ico/,
/\/@id\//,
/\/@react-refresh/,
/\/@tanstack-start\//,
/\/@fs\//,
Comment thread
nicohrubec marked this conversation as resolved.
/\/@vite\//,
];
Comment thread
nicohrubec marked this conversation as resolved.

return initReactSDK(sentryOptions);
}
8 changes: 8 additions & 0 deletions packages/tanstackstart-react/src/server/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@ export function init(options: NodeOptions): NodeClient | undefined {

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

sentryOptions.ignoreSpans = [
...(sentryOptions.ignoreSpans || []),
/\/node_modules\//,
/\/@id\//,
/\/@react-refresh/,
/\/@vite\//,
];
Comment thread
nicohrubec marked this conversation as resolved.

return initNodeSdk(sentryOptions);
}
31 changes: 31 additions & 0 deletions packages/tanstackstart-react/test/client/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,37 @@ describe('TanStack Start React Client SDK', () => {
expect(init({})).not.toBeUndefined();
});

it('sets ignoreSpans to filter low-quality spans', () => {
init({ dsn: 'https://public@dsn.ingest.sentry.io/1337' });

expect(reactInit).toHaveBeenCalledWith(
expect.objectContaining({
ignoreSpans: expect.arrayContaining([
/\/node_modules\//,
/\/favicon\.ico/,
/\/@id\//,
/\/@react-refresh/,
/\/@tanstack-start\//,
/\/@fs\//,
/\/@vite\//,
]),
}),
);
});

it('preserves user-defined ignoreSpans', () => {
init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
ignoreSpans: [/custom-pattern/],
});

expect(reactInit).toHaveBeenCalledWith(
expect.objectContaining({
ignoreSpans: expect.arrayContaining([/custom-pattern/, /\/favicon\.ico/]),
}),
);
});

it('applies the managed tunnel route when no runtime tunnel is provided', () => {
vi.stubGlobal('__SENTRY_TANSTACKSTART_TUNNEL_ROUTE__', '/managed-tunnel');

Expand Down
23 changes: 23 additions & 0 deletions packages/tanstackstart-react/test/server/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,28 @@ describe('TanStack Start React Server SDK', () => {
it('returns client from init', () => {
expect(init({})).not.toBeUndefined();
});

it('sets ignoreSpans to filter low-quality transactions', () => {
init({ dsn: 'https://public@dsn.ingest.sentry.io/1337' });

expect(nodeInit).toHaveBeenCalledWith(
expect.objectContaining({
ignoreSpans: expect.arrayContaining([/\/node_modules\//, /\/@id\//, /\/@react-refresh/, /\/@vite\//]),
}),
);
});

it('preserves user-defined ignoreSpans', () => {
init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
ignoreSpans: [/custom-pattern/],
});

expect(nodeInit).toHaveBeenCalledWith(
expect.objectContaining({
ignoreSpans: expect.arrayContaining([/custom-pattern/, /\/@vite\//]),
}),
);
});
Comment thread
nicohrubec marked this conversation as resolved.
Comment thread
nicohrubec marked this conversation as resolved.
});
});
Loading