-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathsentry.client.config.ts
More file actions
35 lines (27 loc) · 1.16 KB
/
Copy pathsentry.client.config.ts
File metadata and controls
35 lines (27 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from "@sentry/nextjs";
const isCI = process.env.CI === "true";
// Check if we're on a Vercel preview deployment, we want to run only on prod domain
const isVercelPreview =
typeof window !== "undefined" &&
window.location.hostname.includes(".vercel.app");
// This is the client config, so we need to check the NEXT_PUBLIC_SENTRY_ENABLED environment variable
const isSentryEnabled =
process.env.NEXT_PUBLIC_SENTRY_ENABLED === "true" &&
!isCI &&
!isVercelPreview;
if (isSentryEnabled) {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
enabled: isSentryEnabled,
// Adjust sampling in production for better performance/cost balance
tracesSampleRate: 0.15, // Sample 15% of transactions
// Recommended production settings
debug: false,
// Performance settings
replaysSessionSampleRate: 0.1, // Sample 10% of sessions
replaysOnErrorSampleRate: 1.0, // But capture all sessions with errors
});
}