Skip to content

Commit e806864

Browse files
Stabilize CI mocks Sentry init
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
1 parent 3d178e8 commit e806864

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

server/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,17 @@ const getHost = (req: { get: (key: string) => string | undefined }) =>
8787

8888
const MODE = process.env.NODE_ENV
8989

90-
if (MODE === 'production' && process.env.SENTRY_DSN) {
90+
const SHOULD_INIT_SENTRY =
91+
MODE === 'production' &&
92+
Boolean(process.env.SENTRY_DSN) &&
93+
// `start:mocks` (used in CI + local e2e) runs with `MOCKS=true`.
94+
process.env.MOCKS !== 'true'
95+
96+
if (SHOULD_INIT_SENTRY) {
9197
void import('./utils/monitoring.js').then(({ init }) => init())
9298
}
9399

94-
if (MODE === 'production') {
100+
if (SHOULD_INIT_SENTRY) {
95101
sentryInit({
96102
dsn: process.env.SENTRY_DSN,
97103
tracesSampleRate: 0.3,

vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ if (SENTRY_UPLOAD && MODE === 'production') {
1515
const authToken = process.env.SENTRY_AUTH_TOKEN
1616
const project = process.env.SENTRY_PROJECT
1717
const org = process.env.SENTRY_ORG
18+
// New-style Sentry auth tokens (prefix "sntrys_") embed the org, so SENTRY_ORG
19+
// is not required when using one.
1820
const tokenImpliesOrg = Boolean(authToken?.startsWith('sntrys_'))
1921

2022
// If upload is "on" but required settings are missing, the Sentry plugin will
@@ -66,6 +68,10 @@ export default defineConfig(async () => {
6668
: null,
6769
],
6870
build: {
71+
// This is an OSS project, so it's fine to generate "regular" sourcemaps.
72+
// If we ever want sourcemaps upload without exposing them publicly, switch
73+
// to `sourcemap: 'hidden'` (and keep uploading to Sentry).
74+
sourcemap: true,
6975
cssMinify: MODE === 'production',
7076
rollupOptions: {
7177
external: [/node:.*/, 'stream', 'crypto'],

0 commit comments

Comments
 (0)