diff --git a/.env.example b/.env.example index 94bcb57..51222f3 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,10 @@ # POSTGRES_USER=postgres # POSTGRES_PASSWORD=password # DATABASE_URL=postgresql://postgres:password@db:5432/postgres +# SENTRY_AUTH_TOKEN= +# PUBLIC_ENV=production # or staging + +PUBLIC_ENV=dev DATABASE_URL=postgresql://postgres@localhost:5432/postgres diff --git a/Dockerfile b/Dockerfile index b84e5a8..9415e5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ COPY package*.json ./ ENV DATABASE_HOST=localhost RUN npm ci COPY . . +ENV PUBLIC_ENV=production RUN npm run build RUN npm prune --production @@ -17,6 +18,7 @@ COPY drizzle ./drizzle COPY server.js . ENV DATABASE_HOST=localhost ENV BODY_SIZE_LIMIT=80M +ENV PUBLIC_ENV=production EXPOSE 3000 ENV NODE_ENV=production CMD ["sh","-c","mkdir -p /uploads/images && mkdir -p /uploads/models && npm run db:migrate && node server.js"] \ No newline at end of file diff --git a/src/hooks.client.ts b/src/hooks.client.ts index 1ed86d2..43bcdf3 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -1,14 +1,21 @@ import { handleErrorWithSentry, replayIntegration } from '@sentry/sveltekit'; import * as Sentry from '@sentry/sveltekit'; +import { PUBLIC_ENV } from '$env/static/public'; Sentry.init({ - dsn: 'https://7caab434460a1585f4c87baa1a692427@o40609.ingest.us.sentry.io/4510461147742208', + dsn: + PUBLIC_ENV == 'staging' || PUBLIC_ENV == 'production' + ? 'https://7caab434460a1585f4c87baa1a692427@o40609.ingest.us.sentry.io/4510461147742208' + : undefined, tracesSampleRate: 1.0, // Enable logs to be sent to Sentry enableLogs: true, + // Environment + environment: PUBLIC_ENV, + // This sets the sample rate to be 10%. You may want this to be 100% while // in development and sample at a lower rate in production replaysSessionSampleRate: 0.1, diff --git a/src/instrumentation.server.ts b/src/instrumentation.server.ts index 4c96612..1429dae 100644 --- a/src/instrumentation.server.ts +++ b/src/instrumentation.server.ts @@ -1,13 +1,17 @@ +import { PUBLIC_ENV } from '$env/static/public'; import * as Sentry from '@sentry/sveltekit'; Sentry.init({ - dsn: 'https://7caab434460a1585f4c87baa1a692427@o40609.ingest.us.sentry.io/4510461147742208', + dsn: + PUBLIC_ENV == 'staging' || PUBLIC_ENV == 'production' + ? 'https://7caab434460a1585f4c87baa1a692427@o40609.ingest.us.sentry.io/4510461147742208' + : undefined, integrations: [Sentry.consoleLoggingIntegration({ levels: ['log', 'warn', 'error'] })], tracesSampleRate: 1.0, - environment: process.env.SENTRY_ENVIRONMENT, + environment: PUBLIC_ENV, // Enable logs to be sent to Sentry enableLogs: true