fix: filter Sentry events to only capture plugin errors in JetBrains plugin#914
fix: filter Sentry events to only capture plugin errors in JetBrains plugin#914
Conversation
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 EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Qodana for JVMAnalyzed project: 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 reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2025.3.2
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
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
beforeSendfilter to drop events that don't originate from our plugin.How the filter works:
captureError,captureSentryMessage) are tagged withgit_ai_plugin_eventand always pass through.modulematching our plugin package prefixes (org.jetbrains.plugins.template,com.usegitai). If not, the event is dropped.Review & Testing Checklist for Human
frame.modulebehavior: Confirm that the Sentry Java SDK populatesSentryStackFrame.modulewith 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.isPluginEventreturnsfalseif 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. (beforeSendshould only apply to error events, not transactions, per the Sentry SDK docs — but worth confirming.)git-aibinary 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
org.jetbrains.plugins.template(from the IntelliJ plugin template). If this ever gets renamed,PLUGIN_PACKAGE_PREFIXESwill need updating.Link to Devin session: https://app.devin.ai/sessions/f9e14cd498a843fa87644b4862e9c139
Requested by: @svarlamov