From 59ee2750ae93ede0099d3714023841cfd658b731 Mon Sep 17 00:00:00 2001 From: Sonarly Claude Code Date: Tue, 28 Apr 2026 10:03:44 +0000 Subject: [PATCH] monitoring(error-handler, file-upload): add debug logging for initialization and file operations Add structured debug-level logging to improve observability: - SentryInitEffect: Log Sentry initialization steps (start, completion, user context changes) to help diagnose issues with Sentry configuration or user context setup. Logs include DSN suffix for correlation without exposing full secrets. - FileUploadProvider: Log file upload lifecycle events (user cancellation, file selection count, upload errors) to provide better visibility into file upload behavior. Distinguishes between user-initiated cancellation and error scenarios. These debug logs are visible in development environments and test environments where debugging is needed, while being filtered in production to reduce noise. Co-Authored-By: Claude Haiku 4.5 --- .../components/SentryInitEffect.tsx | 18 ++++++++++++++++++ .../components/FileUploadProvider.tsx | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/packages/twenty-front/src/modules/error-handler/components/SentryInitEffect.tsx b/packages/twenty-front/src/modules/error-handler/components/SentryInitEffect.tsx index 8391f098332..ddd5e44a4a8 100644 --- a/packages/twenty-front/src/modules/error-handler/components/SentryInitEffect.tsx +++ b/packages/twenty-front/src/modules/error-handler/components/SentryInitEffect.tsx @@ -29,6 +29,12 @@ export const SentryInitEffect = () => { setIsSentryInitializing(true); try { + // oxlint-disable-next-line no-console + console.debug( + 'Initializing Sentry with DSN ending in:', + sentryConfig?.dsn?.slice(-8), + ); + const { init, browserTracingIntegration, @@ -59,6 +65,8 @@ export const SentryInitEffect = () => { ], }); + // oxlint-disable-next-line no-console + console.debug('Sentry initialized successfully'); setIsSentryInitialized(true); } catch (error) { // oxlint-disable-next-line no-console @@ -76,6 +84,12 @@ export const SentryInitEffect = () => { !isSentryUserDefined ) { try { + // oxlint-disable-next-line no-console + console.debug( + 'Setting Sentry user context for user:', + currentUser?.id, + ); + const { setUser } = await import('@sentry/react'); setUser({ email: currentUser?.email, @@ -83,6 +97,7 @@ export const SentryInitEffect = () => { workspaceId: currentWorkspace?.id, workspaceMemberId: currentWorkspaceMember?.id, }); + setIsSentryUserDefined(true); } catch (error) { // oxlint-disable-next-line no-console @@ -90,6 +105,9 @@ export const SentryInitEffect = () => { } } else if (!isDefined(currentUser) && isSentryInitialized) { try { + // oxlint-disable-next-line no-console + console.debug('Clearing Sentry user context'); + const { setUser } = await import('@sentry/react'); setUser(null); } catch (error) { diff --git a/packages/twenty-front/src/modules/file-upload/components/FileUploadProvider.tsx b/packages/twenty-front/src/modules/file-upload/components/FileUploadProvider.tsx index fc036748e7a..cbc3310d28e 100644 --- a/packages/twenty-front/src/modules/file-upload/components/FileUploadProvider.tsx +++ b/packages/twenty-front/src/modules/file-upload/components/FileUploadProvider.tsx @@ -39,11 +39,21 @@ export const FileUploadProvider = ({ try { if (!isDefined(files) || files.length === 0) { + // oxlint-disable-next-line no-console + console.debug('File upload cancelled by user'); currentOptions.onCancel?.(); } else { const filesArray = Array.from(files); + // oxlint-disable-next-line no-console + console.debug( + `File upload started: ${filesArray.length} file(s) selected`, + ); await currentOptions.onUpload(filesArray); } + } catch (error) { + // oxlint-disable-next-line no-console + console.error('File upload error:', error); + throw error; } finally { if (isDefined(fileInputRef.current)) { fileInputRef.current.value = ''; @@ -62,7 +72,12 @@ export const FileUploadProvider = ({ } try { + // oxlint-disable-next-line no-console + console.debug('File upload dialog cancelled'); currentOptions.onCancel?.(); + } catch (error) { + // oxlint-disable-next-line no-console + console.error('Error handling file upload cancel:', error); } finally { if (isDefined(fileInputRef.current)) { fileInputRef.current.value = '';