Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ CONFIG_PATH=${PWD}/config.json # Path to the sourcebot config file (if one exist
# NEXT_PUBLIC_SENTRY_WEBAPP_DSN=""
# SENTRY_ENVIRONMENT="dev"
# NEXT_PUBLIC_SENTRY_ENVIRONMENT="dev"
# SENTRY_TRACING_ENABLED="false" # Set to "true" to enable server and edge tracing.
# SENTRY_PROFILING_ENABLED="false" # Set to "true" to enable server-side profiling. Requires tracing.
# SENTRY_AUTH_TOKEN=

# Logtail
Expand Down
6 changes: 5 additions & 1 deletion packages/web/src/sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@

import * as Sentry from "@sentry/nextjs";

const isTracingEnabled = process.env.SENTRY_TRACING_ENABLED === 'true';

if (!!process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN && !!process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT) {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN,
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,

tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1,
...(isTracingEnabled ? {
tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1,
} : {}),

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
Expand Down
22 changes: 14 additions & 8 deletions packages/web/src/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@ import { nodeProfilingIntegration } from "@sentry/profiling-node";
import { createLogger } from "@sourcebot/shared";

const logger = createLogger('sentry-server-config');
const isTracingEnabled = process.env.SENTRY_TRACING_ENABLED === 'true';
const isProfilingEnabled = isTracingEnabled && process.env.SENTRY_PROFILING_ENABLED === 'true';

if (!!process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN && !!process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT) {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN,
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
integrations: [
nodeProfilingIntegration(),
],
tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1,
// Evaluated once per `Sentry.init()`, i.e. once per server process.
profileSessionSampleRate: 1.0,
// Profile only while a sampled root span is active, rather than continuously.
profileLifecycle: 'trace',
...(isTracingEnabled ? {
tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1,
} : {}),
...(isProfilingEnabled ? {
integrations: [
nodeProfilingIntegration(),
],
// Evaluated once per `Sentry.init()`, i.e. once per server process.
profileSessionSampleRate: 1.0,
// Profile only while a sampled root span is active, rather than continuously.
profileLifecycle: 'trace' as const,
} : {}),
});
} else {
logger.debug("[server] Sentry was not initialized");
Expand Down
Loading