Skip to content

fix: filter Sentry events to only capture plugin errors in JetBrains plugin#914

Open
svarlamov wants to merge 1 commit intomainfrom
devin/1775068693-sentry-filter-plugin-errors
Open

fix: filter Sentry events to only capture plugin errors in JetBrains plugin#914
svarlamov wants to merge 1 commit intomainfrom
devin/1775068693-sentry-filter-plugin-errors

Conversation

@svarlamov
Copy link
Copy Markdown
Member

@svarlamov svarlamov commented Apr 1, 2026

Summary

Since the JetBrains plugin runs in the same JVM as the IDE, our Sentry instance was capturing all uncaught JVM exceptions — including JetBrains internal errors. This adds a beforeSend filter to drop events that don't originate from our plugin.

How the filter works:

  • Events we send explicitly (captureError, captureSentryMessage) are tagged with git_ai_plugin_event and always pass through.
  • For uncaught exceptions, the filter checks whether any exception stack frame has a module matching our plugin package prefixes (org.jetbrains.plugins.template, com.usegitai). If not, the event is dropped.

Review & Testing Checklist for Human

  • Verify frame.module behavior: Confirm that the Sentry Java SDK populates SentryStackFrame.module with the Java package/class name for JVM stack traces. If it uses a different field (e.g., filename, absPath), the filter would silently drop all uncaught exceptions including our own.
  • Events with no exceptions and no tag are dropped: isPluginEvent returns false if there are no exceptions and no tag. Verify this won't accidentally filter out Sentry performance transactions or other non-error event types we care about. (beforeSend should only apply to error events, not transactions, per the Sentry SDK docs — but worth confirming.)
  • Test plan: Install the plugin in a JetBrains IDE, trigger a known plugin error (e.g., point to a bad git-ai binary path), and confirm it appears in Sentry. Then cause an unrelated IDE exception and confirm it does not appear. Monitor Sentry for a day after deploy to verify legitimate errors still come through and noise has dropped.

Notes

  • The plugin package is still org.jetbrains.plugins.template (from the IntelliJ plugin template). If this ever gets renamed, PLUGIN_PACKAGE_PREFIXES will need updating.

Link to Devin session: https://app.devin.ai/sessions/f9e14cd498a843fa87644b4862e9c139
Requested by: @svarlamov


Open with Devin

Add beforeSend callback that drops events not originating from our
plugin. Since the JetBrains plugin runs in the same JVM as the IDE,
Sentry was capturing internal JetBrains errors alongside our own.

The filter works in two ways:
1. Events explicitly sent by our code (captureError, captureSentryMessage)
   are tagged with git_ai_plugin_event and always pass through.
2. Uncaught exceptions are checked for stack frames matching our plugin
   package prefixes (org.jetbrains.plugins.template, com.usegitai).

Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Qodana for JVM

Analyzed project: agent-support/intellij/

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2025.3.2
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

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