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 <noreply@anthropic.com>
This commit is contained in:
Sonarly Claude Code
2026-04-28 10:03:44 +00:00
co-authored by Claude Haiku 4.5
parent 2e4bcb6856
commit 59ee2750ae
2 changed files with 33 additions and 0 deletions
@@ -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) {
@@ -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 = '';