Fix the release string

This commit is contained in:
Manav Rathi 2024-02-10 22:59:04 +05:30
parent dc68659104
commit 54cbbfb722
2 changed files with 18 additions and 8 deletions

View file

View file

@ -1,4 +1,10 @@
const { withSentryConfig } = require('@sentry/nextjs');
const cp = require('child_process');
const gitSHA = cp.execSync('git rev-parse --short HEAD', {
cwd: __dirname,
encoding: 'utf8',
});
const nextConfig = {
compiler: {
@ -37,15 +43,19 @@ const nextConfig = {
};
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
const createSentryWebpackPluginOptions = () => {
return {
// dryRun: phase === PHASE_DEVELOPMENT_SERVER,
// release: gitSHA,
};
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`)
// 2. Upload sourcemaps (using the settings defined in `.sentryclirc`)
module.exports = (phase) =>
withSentryConfig(nextConfig, createSentryWebpackPluginOptions(phase));
// 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);