Skip to content

Commit 3d0a770

Browse files
authored
Merge pull request #18 from hackclub/staging
Add sentry
2 parents d6a99cf + f5cd889 commit 3d0a770

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-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

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ COPY package*.json ./
44
ENV DATABASE_HOST=localhost
55
RUN npm ci
66
COPY . .
7+
ENV PUBLIC_ENV=production
78
RUN npm run build
89
RUN npm prune --production
910

@@ -17,6 +18,7 @@ COPY drizzle ./drizzle
1718
COPY server.js .
1819
ENV DATABASE_HOST=localhost
1920
ENV BODY_SIZE_LIMIT=80M
21+
ENV PUBLIC_ENV=production
2022
EXPOSE 3000
2123
ENV NODE_ENV=production
2224
CMD ["sh","-c","mkdir -p /uploads/images && mkdir -p /uploads/models && npm run db:migrate && node server.js"]

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)