Skip to content

Commit df03a41

Browse files
committed
Add sentry environment everywhere
1 parent 1db66e0 commit df03a41

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# POSTGRES_USER=postgres
44
# POSTGRES_PASSWORD=password
55
# DATABASE_URL=postgresql://postgres:password@db:5432/postgres
6+
# SENTRY_AUTH_TOKEN=
7+
# PUBLIC_ENV=production # or staging
8+
9+
PUBLIC_ENV=dev
610

711
DATABASE_URL=postgresql://postgres@localhost:5432/postgres
812

src/hooks.client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import { handleErrorWithSentry, replayIntegration } from '@sentry/sveltekit';
22
import * as Sentry from '@sentry/sveltekit';
3+
import { PUBLIC_ENV } from '$env/static/public';
34

45
Sentry.init({
5-
dsn: 'https://[email protected]/4510461147742208',
6+
dsn:
7+
PUBLIC_ENV == 'staging' || PUBLIC_ENV == 'production'
8+
? 'https://[email protected]/4510461147742208'
9+
: undefined,
610

711
tracesSampleRate: 1.0,
812

913
// Enable logs to be sent to Sentry
1014
enableLogs: true,
1115

16+
// Environment
17+
environment: PUBLIC_ENV,
18+
1219
// This sets the sample rate to be 10%. You may want this to be 100% while
1320
// in development and sample at a lower rate in production
1421
replaysSessionSampleRate: 0.1,

src/instrumentation.server.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
import { PUBLIC_ENV } from '$env/static/public';
12
import * as Sentry from '@sentry/sveltekit';
23

34
Sentry.init({
4-
dsn: 'https://[email protected]/4510461147742208',
5+
dsn:
6+
PUBLIC_ENV == 'staging' || PUBLIC_ENV == 'production'
7+
? 'https://[email protected]/4510461147742208'
8+
: undefined,
59

610
integrations: [Sentry.consoleLoggingIntegration({ levels: ['log', 'warn', 'error'] })],
711

812
tracesSampleRate: 1.0,
913

10-
environment: process.env.SENTRY_ENVIRONMENT,
14+
environment: PUBLIC_ENV,
1115

1216
// Enable logs to be sent to Sentry
1317
enableLogs: true

0 commit comments

Comments
 (0)