From b1ca9027e7c492c29b4aed387dc1a94d927656f8 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 26 Jun 2024 12:45:00 +0200 Subject: [PATCH] fix: enable sentry only in build --- .env.example | 1 + src/hooks.client.ts | 5 +++-- src/hooks.server.ts | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 291e856ae..ccf399ed5 100644 --- a/.env.example +++ b/.env.example @@ -9,3 +9,4 @@ PUBLIC_GROWTH_ENDPOINT= APPWRITE_DB_INIT_ID= APPWRITE_COL_INIT_ID= APPWRITE_API_KEY_INIT= +SENTRY_AUTH_TOKEN= \ No newline at end of file diff --git a/src/hooks.client.ts b/src/hooks.client.ts index dfc8de119..edf8629b2 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -1,10 +1,11 @@ -import { dev } from '$app/environment'; +import { building } from '$app/environment'; +import { SENTRY_AUTH_TOKEN } from '$env/static/private'; import { SENTRY_DSN } from '$lib/constants'; import { handleErrorWithSentry, replayIntegration } from '@sentry/sveltekit'; import * as Sentry from '@sentry/sveltekit'; Sentry.init({ - enabled: !dev, + enabled: !!SENTRY_AUTH_TOKEN && building, dsn: SENTRY_DSN, tracesSampleRate: 1.0, diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 8d671be05..566f96613 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -3,10 +3,11 @@ import type { Handle } from '@sveltejs/kit'; import redirects from './redirects.json'; import { sequence } from '@sveltejs/kit/hooks'; import { BANNER_KEY, SENTRY_DSN } from '$lib/constants'; -import { dev } from '$app/environment'; +import { SENTRY_AUTH_TOKEN } from '$env/static/private'; +import { building } from '$app/environment'; Sentry.init({ - enabled: !dev, + enabled: !!SENTRY_AUTH_TOKEN && building, dsn: SENTRY_DSN, tracesSampleRate: 1 })