소스 검색

Fix the release string

Manav Rathi 1 년 전
부모
커밋
54cbbfb722
2개의 변경된 파일18개의 추가작업 그리고 8개의 파일을 삭제
  1. 0 0
      apps/photos/sentry.edge.config.ts
  2. 18 8
      packages/shared/next/next.config.base.js

+ 0 - 0
apps/photos/sentry.edge.config.ts


+ 18 - 8
packages/shared/next/next.config.base.js

@@ -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);