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
3 changes: 0 additions & 3 deletions apps/sim/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ next-env.d.ts
# cursorrules
.cursorrules

# Sentry Config File
.env.sentry-build-plugin

# Uploads
/uploads

Expand Down
6 changes: 0 additions & 6 deletions apps/sim/app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
'use client'

import { useEffect } from 'react'
import * as Sentry from '@sentry/nextjs'
import NextError from 'next/error'

export default function GlobalError({ error }: { error: Error & { digest?: string } }) {
useEffect(() => {
Sentry.captureException(error)
}, [error])

return (
<html lang='en'>
<body>
Expand Down
38 changes: 1 addition & 37 deletions apps/sim/instrumentation-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,7 @@
* It respects the user's telemetry preferences stored in localStorage.
*
*/
// This file configures the initialization of Sentry on the client.
// The added config here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import {
BrowserClient,
breadcrumbsIntegration,
captureRouterTransitionStart,
dedupeIntegration,
defaultStackParser,
getCurrentScope,
linkedErrorsIntegration,
makeFetchTransport,
} from '@sentry/nextjs'
import { env, getEnv } from './lib/env'
import { isProd } from './lib/environment'

// Only in production
if (typeof window !== 'undefined' && isProd) {
const client = new BrowserClient({
dsn: getEnv('NEXT_PUBLIC_SENTRY_DSN') || undefined,
environment: env.NODE_ENV || 'development',
transport: makeFetchTransport,
stackParser: defaultStackParser,
integrations: [breadcrumbsIntegration(), dedupeIntegration(), linkedErrorsIntegration()],
beforeSend(event) {
if (event.request && typeof event.request === 'object') {
;(event.request as any).ip = null
}
return event
},
})

getCurrentScope().setClient(client)
client.init()
}

export const onRouterTransitionStart = isProd ? captureRouterTransitionStart : () => {}
import { env } from './lib/env'

if (typeof window !== 'undefined') {
const TELEMETRY_STATUS_KEY = 'simstudio-telemetry-status'
Expand Down
37 changes: 0 additions & 37 deletions apps/sim/instrumentation-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
*/

import { env } from './lib/env'
import { isProd } from './lib/environment'
import { createLogger } from './lib/logs/console/logger.ts'

const Sentry = isProd ? require('@sentry/nextjs') : { captureRequestError: () => {} }

const logger = createLogger('OtelInstrumentation')

const DEFAULT_TELEMETRY_CONFIG = {
Expand Down Expand Up @@ -85,40 +82,6 @@ async function initializeOpenTelemetry() {
}
}

async function initializeSentry() {
if (!isProd) return

try {
// Skip initialization if Sentry appears to be already configured
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore accessing internal API
if ((Sentry as any).Hub?.current?.getClient()) {
logger.debug('Sentry already initialized, skipping duplicate init')
return
}

Sentry.init({
dsn: env.NEXT_PUBLIC_SENTRY_DSN || undefined,
enabled: true,
environment: env.NODE_ENV || 'development',
tracesSampleRate: 0.2,
beforeSend(event: any) {
if (event.request && typeof event.request === 'object') {
;(event.request as any).ip = null
}
return event
},
})

logger.info('Sentry initialized (server-side)')
} catch (error) {
logger.error('Failed to initialize Sentry', error as Error)
}
}

export async function register() {
await initializeSentry()
await initializeOpenTelemetry()
}

export const onRequestError = Sentry.captureRequestError
5 changes: 0 additions & 5 deletions apps/sim/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ export const env = createEnv({
// Monitoring & Analytics
TELEMETRY_ENDPOINT: z.string().url().optional(), // Custom telemetry/analytics endpoint
COST_MULTIPLIER: z.number().optional(), // Multiplier for cost calculations
SENTRY_ORG: z.string().optional(), // Sentry organization for error tracking
SENTRY_PROJECT: z.string().optional(), // Sentry project for error tracking
SENTRY_AUTH_TOKEN: z.string().optional(), // Sentry authentication token
LOG_LEVEL: z.enum(['DEBUG', 'INFO', 'WARN', 'ERROR']).optional(), // Minimum log level to display (defaults to ERROR in production, DEBUG in development)

// External Services
Expand Down Expand Up @@ -209,7 +206,6 @@ export const env = createEnv({
NEXT_PUBLIC_VERCEL_URL: z.string().optional(), // Vercel deployment URL for preview/production

// Client-side Services
NEXT_PUBLIC_SENTRY_DSN: z.string().url().optional(), // Sentry DSN for client-side error tracking
NEXT_PUBLIC_SOCKET_URL: z.string().url().optional(), // WebSocket server URL for real-time features

// Asset Storage
Expand Down Expand Up @@ -257,7 +253,6 @@ export const env = createEnv({
experimental__runtimeEnv: {
NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
NEXT_PUBLIC_VERCEL_URL: process.env.NEXT_PUBLIC_VERCEL_URL,
NEXT_PUBLIC_SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN,
NEXT_PUBLIC_BLOB_BASE_URL: process.env.NEXT_PUBLIC_BLOB_BASE_URL,
NEXT_PUBLIC_BILLING_ENABLED: process.env.NEXT_PUBLIC_BILLING_ENABLED,
NEXT_PUBLIC_GOOGLE_CLIENT_ID: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
Expand Down
21 changes: 2 additions & 19 deletions apps/sim/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { withSentryConfig } from '@sentry/nextjs'
import type { NextConfig } from 'next'
import { env, isTruthy } from './lib/env'
import { isDev, isHosted, isProd } from './lib/environment'
import { isDev, isHosted } from './lib/environment'
import { getMainCSPPolicy, getWorkflowExecutionCSPPolicy } from './lib/security/csp'

const nextConfig: NextConfig = {
Expand Down Expand Up @@ -241,20 +240,4 @@ const nextConfig: NextConfig = {
},
}

const sentryConfig = {
silent: true,
org: env.SENTRY_ORG || '',
project: env.SENTRY_PROJECT || '',
authToken: env.SENTRY_AUTH_TOKEN || undefined,
disableSourceMapUpload: !isProd,
autoInstrumentServerFunctions: isProd,
bundleSizeOptimizations: {
excludeDebugStatements: true,
excludePerformanceMonitoring: true,
excludeReplayIframe: true,
excludeReplayShadowDom: true,
excludeReplayWorker: true,
},
}

export default isDev ? nextConfig : withSentryConfig(nextConfig, sentryConfig)
export default nextConfig
1 change: 0 additions & 1 deletion apps/sim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"@radix-ui/react-toggle": "^1.1.2",
"@radix-ui/react-tooltip": "1.2.8",
"@react-email/components": "^0.0.34",
"@sentry/nextjs": "^9.15.0",
"@trigger.dev/sdk": "4.0.4",
"@types/pdf-parse": "1.1.5",
"@types/three": "0.177.0",
Expand Down
Loading