Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Specify the release in Sentry.init instead of the webpack plugin

Manav Rathi8a769ea08b3b
diff --git a/packages/shared/next/next.config.base.js b/packages/shared/next/next.config.base.js
index 08559a6ddf..a560605818 100644
--- a/packages/shared/next/next.config.base.js
+++ b/packages/shared/next/next.config.base.js
@@ -52,26 +52,20 @@ const nextConfig = {
},
// Build time Sentry configuration
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
sentry: {
widenClientFileUpload: true,
disableServerWebpackPlugin: true,
},
};
-// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
-const sentryWebpackPluginOptions = {
- // Sentry supports automatically deducing this, and if running the
- // sentry-cli release propose-version command directly, it can indeed find
- // the git SHA, but I've been unable to get that to work here without
- // explicitly specifying the git SHA.
- release: gitSHA,
-};
-
-// withSentryConfig extends the default Next.js usage of webpack to
-// 1. Initialize the SDK on client page load (`sentry.client.config.ts`)
+// withSentryConfig extends the default Next.js usage of webpack to:
+//
+// 1. Initialize the SDK on client page load (See `sentry.client.config.ts`)
+//
// 2. Upload sourcemaps (using the settings defined in `sentry.properties`)
//
// 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.
-module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);
+module.exports = withSentryConfig(nextConfig, {});
diff --git a/packages/shared/sentry/config/sentry.config.base.ts b/packages/shared/sentry/config/sentry.config.base.ts
index 100a4b7778..d78ed4610c 100644
--- a/packages/shared/sentry/config/sentry.config.base.ts
+++ b/packages/shared/sentry/config/sentry.config.base.ts
@@ -7,9 +7,31 @@ export const initSentry = async (dsn: string) => {
const optedOut = runningInBrowser() && getHasOptedOutOfCrashReports();
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,
- environment: process.env.NODE_ENV,
+ release,
attachStacktrace: true,
autoSessionTracking: false,
tunnel: 'https://sentry-reporter.ente.io',