From f9ad6be60a21788da031d08336029167a020d81e Mon Sep 17 00:00:00 2001 From: Nevo David Date: Wed, 30 Jul 2025 20:49:23 +0700 Subject: [PATCH] feat: logs --- .../components/layout/sentry.component.tsx | 8 +--- .../src/sentry/initialize.sentry.ts | 3 +- .../sentry/initialize.sentry.next.basic.ts | 38 ++++++++++--------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/apps/frontend/src/components/layout/sentry.component.tsx b/apps/frontend/src/components/layout/sentry.component.tsx index 3f5b3994..3835f267 100644 --- a/apps/frontend/src/components/layout/sentry.component.tsx +++ b/apps/frontend/src/components/layout/sentry.component.tsx @@ -9,14 +9,10 @@ export const SentryComponent: FC<{ children: ReactNode }> = ({ children }) => { useEffect(() => { if (!dsn) { - return ; + return; } - try { - initializeSentryClient(dsn); - } catch (error) { - console.error('[Sentry] Configuration error:', error); - } + initializeSentryClient(dsn); }, [dsn]); // Always render children - don't block the app diff --git a/libraries/nestjs-libraries/src/sentry/initialize.sentry.ts b/libraries/nestjs-libraries/src/sentry/initialize.sentry.ts index 0c5e7ffd..aa34dd9e 100644 --- a/libraries/nestjs-libraries/src/sentry/initialize.sentry.ts +++ b/libraries/nestjs-libraries/src/sentry/initialize.sentry.ts @@ -24,9 +24,10 @@ export const initializeSentry = (appName: string) => { integrations: [ // Add our Profiling integration nodeProfilingIntegration(), + Sentry.consoleLoggingIntegration({ levels: ['log', 'error', 'warn'] }), ], tracesSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.3, - profilesSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.1, + enableLogs: true, }); } catch (err) {} return true; diff --git a/libraries/react-shared-libraries/src/sentry/initialize.sentry.next.basic.ts b/libraries/react-shared-libraries/src/sentry/initialize.sentry.next.basic.ts index 38121051..beb91f84 100644 --- a/libraries/react-shared-libraries/src/sentry/initialize.sentry.next.basic.ts +++ b/libraries/react-shared-libraries/src/sentry/initialize.sentry.next.basic.ts @@ -5,24 +5,26 @@ export const initializeSentryBasic = (dsn: string, extension: any) => { return; } - Sentry.init({ - initialScope: { - tags: { - service: 'frontend', - component: 'nextjs', - replaysEnabled: 'true', - }, - contexts: { - app: { - name: 'Postiz Frontend', - version: process.env.NEXT_PUBLIC_APP_VERSION || '0.0.0', + try { + Sentry.init({ + initialScope: { + tags: { + service: 'frontend', + component: 'nextjs', + replaysEnabled: 'true', + }, + contexts: { + app: { + name: 'Postiz Frontend', + version: process.env.NEXT_PUBLIC_APP_VERSION || '0.0.0', + }, }, }, - }, - dsn, - sendDefaultPii: true, - ...extension, - debug: process.env.NODE_ENV === 'development', - tracesSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.3, - }); + dsn, + sendDefaultPii: true, + ...extension, + debug: process.env.NODE_ENV === 'development', + tracesSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.3, + }); + } catch (err) {} };