fix(desktop): bundle Sentry and add sourcemap uploads#875
Conversation
📝 WalkthroughWalkthroughAdds Sentry Vite plugin and sourcemap generation to the desktop build, increases Node memory for compilation, and exposes SENTRY_AUTH_TOKEN in the CI compile step for conditional sourcemap upload during builds. Changes
Sequence Diagram(s)sequenceDiagram
participant CI as CI runner
participant Build as Vite/Electron build
participant Sentry as Sentry API
CI->>Build: set env SENTRY_AUTH_TOKEN (from secrets) and start compile
Build->>Build: initialize `@sentry/vite-plugin` if token present
Build->>Build: generate sourcemaps for main & renderer bundles
Build->>Sentry: upload sourcemaps via Sentry plugin (when initialized)
Sentry-->>Build: upload response/status
Build-->>CI: finish compile (artifacts + status)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/desktop/package.json`:
- Line 134: The package dependency "@sentry/vite-plugin" in package.json is
pinned to "^4.7.0" which doesn't support Vite 7; update the dependency entry for
"@sentry/vite-plugin" to a version that supports Vite 7 (e.g., "^4.8.0" or
later), then reinstall/update the lockfile so the new version is applied and run
your normal build to verify no regressions; check the package.json entry and the
lockfile after updating to ensure the new version was resolved.
🧹 Nitpick comments (1)
apps/desktop/electron.vite.config.ts (1)
74-75: Consider stripping.mapfiles from packaged artifacts.
Enabling production sourcemaps can ship source with the desktop app. If that’s not desired, consider excluding.mapfiles during packaging or deleting them post-upload.Also applies to: 190-191
| "zustand": "^5.0.8" | ||
| }, | ||
| "devDependencies": { | ||
| "@sentry/vite-plugin": "^4.7.0", |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Find and read electron.vite.config.ts to see the Sentry plugin configuration
fd -t f "electron\.vite\.config\.ts" apps/desktop/Repository: superset-sh/superset
Length of output: 184
🏁 Script executed:
# Read the package.json to check Vite and electron-vite versions
cat -n apps/desktop/package.json | head -50Repository: superset-sh/superset
Length of output: 184
🏁 Script executed:
# Also check if there are any other Sentry-related configs or version constraints
rg "sentry|vite-plugin" apps/desktop/package.json -iRepository: superset-sh/superset
Length of output: 184
🌐 Web query:
@sentry/vite-plugin v4.7.0 Vite 7 compatibility requirements
💡 Result:
Do you want me to fetch the exact peerDependencies/package.json for @sentry/vite-plugin v4.7.0 (to confirm which Vite versions it supports)?
🌐 Web query:
@sentry/vite-plugin release option configuration electron-vite
💡 Result:
Summary — how to configure the plugin's release options when using @sentry/vite-plugin with electron-vite
Key facts
@sentry/vite-pluginexposes a release option object with most-used fields: name (or SENTRY_RELEASE env var), inject, create, finalize, dist, vcsRemote, setCommits, deploy, cleanArtifacts, etc. Use release.name to force a specific release identifier. [1][2]- For Electron (electron-vite) you normally build separate targets (main, preload, renderer). Use the Sentry plugin in each Vite config (renderer and, if you upload main sourcemaps, main/preload) and ensure all builds use the same release name so Sentry groups errors correctly. [3][1]
Minimal example (electron.vite.config.ts)
- ensure sourcemaps are enabled for the builds that upload maps
- set a shared release.name (or export SENTRY_RELEASE in CI)
- put sentryVitePlugin in the appropriate build plugin array
Example snippet:
import { defineConfig } from 'electron-vite'
import { sentryVitePlugin } from '@sentry/vite-plugin'
export default defineConfig({
main: {
build: { sourcemap: true },
plugins: [
sentryVitePlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: { include: './out/main' }, // adjust paths as needed
release: {
name: process.env.SENTRY_RELEASE || 'my-app@' + process.env.npm_package_version,
inject: true, // inject release into bundles (recommended)
create: true, // create release on Sentry during build
finalize: true,
dist: process.env.BUILD_NUMBER,
setCommits: { auto: true },
},
}),
],
},
renderer: {
build: { sourcemap: true },
plugins: [
sentryVitePlugin({
/* same org/project/authToken */
release: { name: process.env.SENTRY_RELEASE || 'my-app@' + process.env.npm_package_version, inject: true },
}),
],
},
})
Practical tips
- Prefer setting SENTRY_RELEASE in CI (same value for main + renderer bundles). The plugin will fall back to auto-detect (git SHA) if name is not provided. [1][2]
- Ensure sourcemap generation is enabled for the builds you want to upload. [2]
- If you upload native electron artifacts (e.g., main process), consider uploading those maps/artifacts from the main/build output and set include paths accordingly. [1][3]
Sources
@sentry/vite-pluginoptions (release.* docs). [1]- Sentry docs: Vite sourcemaps / release guidance. [2]
- electron-vite config / multi-target build guidance (where to add the plugin for main/preload/renderer). [3]
🌐 Web query:
@sentry/vite-plugin 4.7.0 peerDependencies Vite version support
💡 Result:
Short answer: @sentry/vite-plugin v4.7.0 supports Vite v4 and v5. See Sentry's Vite docs and the bundler-plugins repo/issues showing usage and compatibility with Vite 4/5. [1][2]
Sources:
- Sentry docs — Vite sourcemaps / Sentry Vite plugin. [1]
- getsentry/sentry-javascript-bundler-plugins (package / issues referencing Vite 4 and Vite 5). [2]
🌐 Web query:
@sentry/vite-plugin electron-vite 4.0 compatibility
💡 Result:
Short answer: generally yes — @sentry/vite-plugin can be used with electron-vite, but you must match versions and watch a few caveats.
Details and recommendations:
@sentry/vite-plugintargets Vite builds and the official docs show using it in Vite projects for sourcemap/release upload — use the latest@sentry/vite-pluginand enable sourcemaps in your Vite build. [1][2]- electron-vite is a Vite-based tool (requires recent Vite — electron-vite docs show Vite 5+ for current releases), so compatibility depends on the Vite version electron-vite uses in your project. Ensure your
@sentry/vite-pluginsupports that Vite major version. [3] - There are community-reported build issues when newer
@sentry/vite-pluginversions interact with some Vite setups/plugins (errors uploading/failing builds). Test your full electron-vite build (main/preload/renderer) and adjust sentry plugin config (assets/sourcemap paths, placement after other plugins) if you hit problems. See related issues for troubleshooting. [4]
If you want, tell me your electron-vite version, Vite version, and the @sentry/vite-plugin version you plan to use and I’ll give precise compatibility guidance and a minimal working config.
@sentry/vite-plugin v4.7.0 does not support Vite 7.x — it only supports Vite 4 and 5. If this project uses Vite 7, upgrade to a newer version of @sentry/vite-plugin (v4.8.0+) that supports Vite 7. The release option is fully supported with your configuration.
🤖 Prompt for AI Agents
In `@apps/desktop/package.json` at line 134, The package dependency
"@sentry/vite-plugin" in package.json is pinned to "^4.7.0" which doesn't
support Vite 7; update the dependency entry for "@sentry/vite-plugin" to a
version that supports Vite 7 (e.g., "^4.8.0" or later), then reinstall/update
the lockfile so the new version is applied and run your normal build to verify
no regressions; check the package.json entry and the lockfile after updating to
ensure the new version was resolved.
- Remove @sentry/electron from externals so it gets bundled properly (fixes "Failed to resolve module specifier" error in renderer and missing module in production main process) - Add @sentry/vite-plugin for automatic sourcemap uploads to Sentry - Enable sourcemaps for both main and renderer builds - Add SENTRY_AUTH_TOKEN to CI workflow for sourcemap uploads
522e0e8 to
0dfa30e
Compare
Summary
@sentry/electronfrom Vite externals so it gets bundled properly (fixes "Failed to resolve module specifier" error in renderer and missing module in production main process)@sentry/vite-pluginfor automatic sourcemap uploads to SentrySENTRY_AUTH_TOKENto CI workflow for sourcemap uploadsRoot Cause
When
@sentry/electronwas externalized:@sentry/electron/renderer- they need bundled code or URLsTest plan
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.