Mimic an approach that also works with the desktop app build

This commit is contained in:
Manav Rathi 2024-02-13 12:50:49 +05:30
parent 07faec7851
commit c2523c695d
2 changed files with 5 additions and 27 deletions

View file

@ -65,9 +65,9 @@ const sentryWebpackPluginOptions = {};
//
// 1. Initialize the SDK on client page load (See `sentry.client.config.ts`)
//
// 2. Upload sourcemaps (using the settings defined in `sentry.properties`)
// 2. Upload sourcemaps, using the settings defined in `sentry.properties`.
// Sourcemaps are only uploaded if SENTRY_AUTH_TOKEN is defined.
//
// Irritatingly, it insists that we also provide it (empty)
// sentry.server.config.ts and sentry.edge.config.ts files too, even though we
// are not using those parts.
// Irritatingly, Sentry insists that we create empty sentry.server.config.ts and
// sentry.edge.config.ts files, even though we are not using those parts.
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);

View file

@ -11,31 +11,9 @@ export const initSentry = async (dsn: string) => {
// Don't initialize Sentry if the user has opted out of crash reporting
if (optedOut()) return;
// [Note: Specifying the Sentry release]
//
// Sentry supports automatically deducing the release, and if running the
// `sentry-cli release propose-version` command directly, it can indeed find
// and use the git SHA as the release, but I've been unable to get that
// automated detection to work with the Sentry webpack plugin.
//
// The other recommended approach, and what we were using earlier, is
// specify the release param in the `sentryWebpackPluginOptions` (second)
// argument to `withSentryConfig`. However, we selectively turn off Sentry
// to disable sourcemap uploads when the auth token is not available, and
// Sentry's documentation states that
//
// > Disable SentryWebPackPlugin... Note that [when doing so] you'll also
// > have to explicitly set a `release` value in your `Sentry.init()`.
//
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#disable-sentrywebpackplugin
//
// So we just keep things simple and always specify the release here (and
// only here).
const release = process.env.GIT_SHA;
Sentry.init({
dsn,
release,
release: process.env.GIT_SHA,
attachStacktrace: true,
autoSessionTracking: false,
tunnel: 'https://sentry-reporter.ente.io',