Skip to content

feat: fix logging tags for sentry#1365

Open
egelhaus wants to merge 2 commits into
mainfrom
feat/sentry-logging-tags
Open

feat: fix logging tags for sentry#1365
egelhaus wants to merge 2 commits into
mainfrom
feat/sentry-logging-tags

Conversation

@egelhaus
Copy link
Copy Markdown
Collaborator

@egelhaus egelhaus commented Apr 2, 2026

What kind of change does this PR introduce?

eg: Bug fix, feature, docs update, ...

Why was this change needed?

Please link to related issues when possible, and explain WHY you changed things, not WHAT you changed.

Other information:

eg: Did you discuss this change with anybody before working on it (not required, but can be a good idea for bigger changes). Any plans for the future, etc?

Checklist:

Put a "X" in the boxes below to indicate you have followed the checklist;

  • I have read the CONTRIBUTING guide.
  • I confirm I have not used AI to submit this PR or generate code for it.
  • I checked that there were not similar issues or PRs already open for this.
  • This PR fixes just ONE issue (do not include multiple issues or types of change in the same PR) For example, don't try and fix a UI issue and include new dependencies in the same PR.

Copilot AI review requested due to automatic review settings April 2, 2026 14:44
@egelhaus egelhaus requested review from nevo-david and removed request for Copilot April 2, 2026 14:44
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
postiz-app-test Ready Ready Preview, Comment Apr 2, 2026 2:46pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
postiz Ignored Ignored Apr 2, 2026 2:46pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Sentry initialization in both the Next.js (frontend) and NestJS (backend) shared libraries to ensure consistent service/component tagging for both events and logs.

Changes:

  • Add beforeSend hooks to stamp Sentry events with service/component tags.
  • Add beforeSendLog hooks to stamp Sentry logs with service/component attributes.
  • Update exposed ports in docker-compose.dev.yaml for pgAdmin and Temporal UI.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
libraries/react-shared-libraries/src/sentry/initialize.sentry.next.basic.ts Adds beforeSend and beforeSendLog hooks to enforce frontend/Next.js tags on events and logs.
libraries/nestjs-libraries/src/sentry/initialize.sentry.ts Adds beforeSend and beforeSendLog hooks to enforce app/service tags for NestJS events and logs.
docker-compose.dev.yaml Changes dev port mappings for pgAdmin and Temporal UI.

Comment thread libraries/nestjs-libraries/src/sentry/initialize.sentry.ts
Comment thread libraries/nestjs-libraries/src/sentry/initialize.sentry.ts
Comment thread docker-compose.dev.yaml
Comment thread docker-compose.dev.yaml
@egelhaus egelhaus added the contribution:evaluate Evaluate the PR again label May 4, 2026
@postiz-contribution postiz-contribution Bot added contribution:approved Approved contributor and removed contribution:evaluate Evaluate the PR again labels May 4, 2026
Comment on lines +83 to +86
beforeSendLog: (log: any) => {
log.attributes = { ...(log.attributes || {}), service: 'frontend', component: 'nextjs' };
return log;
},
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.

@egelhaus egelhaus added the contribution:evaluate Evaluate the PR again label May 30, 2026
@postiz-contribution postiz-contribution Bot removed the contribution:evaluate Evaluate the PR again label May 30, 2026
@egelhaus egelhaus added the contribution:evaluate Evaluate the PR again label May 30, 2026
@postiz-contribution postiz-contribution Bot removed the contribution:evaluate Evaluate the PR again label May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution:approved Approved contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants