Skip to content

Commit 6a8ea13

Browse files
Raushan kumarclaude
andcommitted
Fix Sentry import causing build failure
Remove dynamic @sentry/react import that was causing Rollup build errors. Instead, provide setSentryInstance() for manual Sentry integration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1e602fc commit 6a8ea13

1 file changed

Lines changed: 11 additions & 35 deletions

File tree

src/utils/errorLogger.js

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,22 @@ let errorBuffer = [];
3939
const BUFFER_SIZE = 10;
4040
const FLUSH_INTERVAL = 30000; // 30 seconds
4141

42-
// Sentry instance (lazy loaded)
42+
// Sentry instance (set externally if needed)
4343
let sentryInstance = null;
4444

4545
/**
46-
* Initialize Sentry if DSN is provided
46+
* Set Sentry instance manually (call this from your app if Sentry is installed)
47+
*
48+
* Usage:
49+
* import * as Sentry from '@sentry/react';
50+
* import { setSentryInstance } from './utils/errorLogger';
51+
* Sentry.init({ dsn: '...' });
52+
* setSentryInstance(Sentry);
4753
*/
48-
async function initSentry() {
49-
if (sentryInstance || !SENTRY_DSN || isDevelopment) return null;
50-
51-
try {
52-
const Sentry = await import('@sentry/react');
53-
Sentry.init({
54-
dsn: SENTRY_DSN,
55-
environment: import.meta.env.MODE,
56-
tracesSampleRate: 0.1, // 10% of transactions for performance monitoring
57-
replaysSessionSampleRate: 0.1,
58-
replaysOnErrorSampleRate: 1.0,
59-
beforeSend(event) {
60-
// Don't send events in development
61-
if (isDevelopment) return null;
62-
63-
// Scrub sensitive data
64-
if (event.request?.headers) {
65-
delete event.request.headers['Authorization'];
66-
delete event.request.headers['Cookie'];
67-
}
68-
69-
return event;
70-
},
71-
});
72-
sentryInstance = Sentry;
73-
return Sentry;
74-
} catch {
75-
// Sentry not installed, continue without it
76-
return null;
77-
}
54+
export function setSentryInstance(sentry) {
55+
sentryInstance = sentry;
7856
}
7957

80-
// Initialize on module load (non-blocking)
81-
initSentry();
82-
8358
/**
8459
* Format error for logging
8560
*/
@@ -262,6 +237,7 @@ export default {
262237
createLogger,
263238
logComponentError,
264239
withErrorLogging,
240+
setSentryInstance,
265241
ErrorSeverity,
266242
ErrorCategory,
267243
};

0 commit comments

Comments
 (0)