Skip to content
Open
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
4 changes: 2 additions & 2 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
container_name: postiz-pg-admin
restart: always
ports:
- 8081:80
- 8082:80
environment:
Comment thread
egelhaus marked this conversation as resolved.
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: admin
Expand Down Expand Up @@ -133,7 +133,7 @@ services:
networks:
- temporal-network
ports:
- "8080:8080"
- "8083:8080"
Comment thread
egelhaus marked this conversation as resolved.

volumes:
redisinsight:
Expand Down
8 changes: 8 additions & 0 deletions libraries/nestjs-libraries/src/sentry/initialize.sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ export const initializeSentry = (appName: string, allowLogs = false) => {
],
tracesSampleRate: 1.0,
enableLogs: true,
beforeSendLog: (log: any) => {
log.attributes = { ...(log.attributes || {}), service: appName, component: 'nestjs' };
return log;
Comment thread
egelhaus marked this conversation as resolved.
},
beforeSend(event: any) {
Comment thread
egelhaus marked this conversation as resolved.
event.tags = { ...(event.tags || {}), service: appName, component: 'nestjs' };
return event;
},

// Profiling
profileSessionSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.45,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export const initializeSentryBasic = (environment: string, dsn: string, extensio
debug: environment === 'development',
tracesSampleRate: 1.0,

beforeSend(event, hint) {
beforeSend(event: any, hint: any) {
event.tags = { ...(event.tags || {}), service: 'frontend', component: 'nextjs' };
Comment thread
egelhaus marked this conversation as resolved.

Comment thread
egelhaus marked this conversation as resolved.
if (event.exception && event.exception.values) {
for (const exception of event.exception.values) {
if (exception.value) {
Expand Down Expand Up @@ -77,6 +79,12 @@ export const initializeSentryBasic = (environment: string, dsn: string, extensio

return event; // Send the event to Sentry
},

beforeSendLog: (log: any) => {
log.attributes = { ...(log.attributes || {}), service: 'frontend', component: 'nextjs' };
return log;
},
Comment on lines +83 to +86
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The beforeSendLog hook in the Next.js Sentry config will not run because enableLogs: true is not set in the Sentry.init call.
Severity: MEDIUM

Suggested Fix

Add enableLogs: true to the Sentry.init configuration object within initialize.sentry.next.basic.ts to activate the log pipeline and ensure the beforeSendLog hook is executed for frontend log events.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
libraries/react-shared-libraries/src/sentry/initialize.sentry.next.basic.ts#L83-L86

Potential issue: The `beforeSendLog` hook is defined in
`initialize.sentry.next.basic.ts` to add `service` and `component` attributes to
frontend log events. However, this hook will never be triggered because the
`Sentry.init` call is missing the `enableLogs: true` option. The callers,
`initializeSentryServer` and `initializeSentryClient`, do not provide this option
through the `extension` parameter. Without `enableLogs: true`, Sentry's log pipeline is
disabled, rendering the `beforeSendLog` hook ineffective and preventing the enrichment
of frontend logs.

Did we get this right? 👍 / 👎 to inform future reviews.


});
} catch (err) {
// Log initialization errors
Expand Down
Loading