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
6 changes: 5 additions & 1 deletion src/components/MaintainersMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,11 @@ function GlobeAvatar({
export function MaintainersMap({ maintainers }: MaintainersMapProps) {
const { data: initialLocation } = useSuspenseQuery({
queryKey: ['maintainers-globe', 'visitor-location'],
queryFn: () => getVisitorLocation().catch(() => null),
queryFn: () =>
getVisitorLocation().then(
(location) => location ?? null,
() => null,
),
staleTime: Infinity,
})
const prefix = useId().replace(/[^a-zA-Z0-9_-]/g, '')
Expand Down
4 changes: 3 additions & 1 deletion src/instrument.server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ if (!Sentry.getClient())
process.env.SENTRY_DSN ??
'https://ac4bfc43ff4a892f8dc7053c4a50d92f@o4507236158537728.ingest.us.sentry.io/4507236163649536',
enabled:
process.env.NODE_ENV === 'production' || Boolean(process.env.SENTRY_DSN),
process.env.NODE_ENV !== 'test' &&
(process.env.NODE_ENV === 'production' ||
Boolean(process.env.SENTRY_DSN)),
integrations: [],
sendDefaultPii: true,
// Performance Monitoring
Expand Down
1 change: 1 addition & 0 deletions src/utils/sentry.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function initSentryServer(): void {
Sentry.init({
dsn: env.SENTRY_DSN ?? SENTRY_DSN,
enabled:
process.env.NODE_ENV !== 'test' &&
import.meta.env.MODE !== 'staging' &&
(process.env.NODE_ENV === 'production' || Boolean(env.SENTRY_DSN)),
tracesSampleRate: 1.0,
Expand Down
8 changes: 7 additions & 1 deletion tests/sentry-initialization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import assert from 'node:assert/strict'
import test from 'node:test'
import * as Sentry from '@sentry/tanstackstart-react'

test('server instrumentation reuses its client after a module reload', async () => {
test('server instrumentation stays disabled in tests and reuses its client after a reload', async (t) => {
t.mock.property(process, 'env', {
...process.env,
NODE_ENV: 'test',
SENTRY_DSN: 'https://fixture@example.invalid/1',
})
const listenerCounts = () =>
['beforeExit', 'uncaughtException', 'unhandledRejection'].map((event) =>
process.listenerCount(event),
Expand All @@ -15,6 +20,7 @@ test('server instrumentation reuses its client after a module reload', async ()
const client = Sentry.getClient()
const counts = listenerCounts()
assert.ok(client)
assert.equal(client.getOptions().enabled, false)

await import(
new URL('../src/instrument.server.mjs?reload=2', import.meta.url).href
Expand Down
Loading