Skip to content

Conversation

Copy link

Copilot AI commented Nov 24, 2025

What kind of change does this PR introduce?

Feature - Sentry user context integration for error tracking across frontend and backend.

Why was this change needed?

Associates user information with Sentry error reports to improve debugging and issue triage. When errors occur, Sentry will now show which user was affected along with relevant metadata (org, role, tier).

Changes:

  • Added setSentryUserContext and clearSentryUserContext utilities for both React (frontend) and NestJS (backend)
  • Created SentryUserInterceptor for automatic backend request context setting
  • Integrated user context in frontend ContextWrapper component via useEffect
  • Added try-catch error handling to prevent Sentry SDK failures from breaking the app
  • Use null for tag clearing in both frontend and backend
  • Documented NEXT_PUBLIC_SENTRY_DSN in .env.example

Usage (backend):

// Global interceptor
import { APP_INTERCEPTOR } from '@nestjs/core';
import { SentryUserInterceptor } from '@gitroom/nestjs-libraries/sentry/sentry.user.interceptor';

@Module({
  providers: [
    { provide: APP_INTERCEPTOR, useClass: SentryUserInterceptor },
  ],
})
export class AppModule {}

Other information:

The interceptor is provided but not globally registered - teams can choose their preferred integration level (global, controller, or method).

Checklist:

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

  • I have read the CONTRIBUTING guide.
  • 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.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link

vercel bot commented Nov 24, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
postiz Ignored Ignored Nov 24, 2025 9:46pm

Copilot AI changed the title [WIP] Implement user implementation for Sentry integration feat: Sentry user context integration with error handling Nov 24, 2025
Copilot AI requested a review from egelhaus November 24, 2025 21:44
Sentry.setTag('user.super_admin', null);
try {
Sentry.setUser(null);
Sentry.setTag('user.activated', '');
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot Please use null to clear the user context everywhere.
Frontend and Backend

Copy link
Author

Choose a reason for hiding this comment

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

Updated both frontend and backend to use null for clearing Sentry tags in commit b5bbf87.

Copilot AI requested a review from egelhaus November 24, 2025 21:49
@egelhaus egelhaus marked this pull request as ready for review November 24, 2025 21:50
@egelhaus egelhaus merged commit af0542b into sentry-user Nov 24, 2025
5 checks passed
@egelhaus egelhaus deleted the copilot/sub-pr-910 branch November 24, 2025 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants