Skip to content

armgit / ente

Public Imported from GitHub
0

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

Resurrect SENTRY_AUTH_TOKEN

Manav Rathid54ff83bbace
diff --git a/apps/auth/sentry.client.config.ts b/apps/auth/sentry.client.config.ts
index 73dcbe1bde..2377523032 100644
--- a/apps/auth/sentry.client.config.ts
+++ b/apps/auth/sentry.client.config.ts
@@ -1,3 +1,3 @@
-import { setupSentry } from '@ente/shared/sentry/config/sentry.config.base';
+import { initSentry } from '@ente/shared/sentry/config/sentry.config.base';
-setupSentry('https://[email protected]/8');
+initSentry('https://[email protected]/8');
diff --git a/apps/photos/.sentryclirc b/apps/photos/.sentryclirc
new file mode 100644
index 0000000000..16a107b0a9
--- /dev/null
+++ b/apps/photos/.sentryclirc
@@ -0,0 +1,7 @@
+# This file is used by sentry-cli and the SentryWebPack plugin to upload
+# sourcemaps. In addition to the configuration specified here, Sentry expects an
+# environment variable named SENTRY_AUTH_TOKEN.
+[defaults]
+url=https://sentry.ente.io/
+org=ente
+project=photos-web
diff --git a/apps/photos/sentry.client.config.ts b/apps/photos/sentry.client.config.ts
index ccf6ec5241..760b53d76d 100644
--- a/apps/photos/sentry.client.config.ts
+++ b/apps/photos/sentry.client.config.ts
@@ -1,3 +1,3 @@
-import { setupSentry } from '@ente/shared/sentry/config/sentry.config.base';
+import { initSentry } from '@ente/shared/sentry/config/sentry.config.base';
-setupSentry('https://[email protected]/2');
+initSentry('https://[email protected]/2');
diff --git a/apps/photos/sentry.properties b/apps/photos/sentry.properties
deleted file mode 100644
index 3bcfe48bc1..0000000000
--- a/apps/photos/sentry.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-defaults.url=https://sentry.ente.io/
-defaults.org=ente
-defaults.project=photos-web
diff --git a/apps/photos/sentry.server.config.ts b/apps/photos/sentry.server.config.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/shared/next/next.config.base.js b/packages/shared/next/next.config.base.js
index a54a406b72..305c7c58d9 100644
--- a/packages/shared/next/next.config.base.js
+++ b/packages/shared/next/next.config.base.js
@@ -1,6 +1,5 @@
const { withSentryConfig } = require('@sentry/nextjs');
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
-
const cp = require('child_process');
const gitSHA = cp.execSync('git rev-parse --short HEAD', {
@@ -8,56 +7,51 @@ const gitSHA = cp.execSync('git rev-parse --short HEAD', {
encoding: 'utf8',
});
-module.exports = (phase) =>
- withSentryConfig(
- {
- sentry: {
- widenClientFileUpload: true,
- disableServerWebpackPlugin: true,
- autoInstrumentServerFunctions: false,
- },
- compiler: {
- emotion: {
- importMap: {
- '@mui/material': {
- styled: {
- canonicalImport: ['@emotion/styled', 'default'],
- styledBaseImport: ['@mui/material', 'styled'],
- },
- },
- '@mui/material/styles': {
- styled: {
- canonicalImport: ['@emotion/styled', 'default'],
- styledBaseImport: [
- '@mui/material/styles',
- 'styled',
- ],
- },
- },
+const nextConfig = {
+ compiler: {
+ emotion: {
+ importMap: {
+ '@mui/material': {
+ styled: {
+ canonicalImport: ['@emotion/styled', 'default'],
+ styledBaseImport: ['@mui/material', 'styled'],
+ },
+ },
+ '@mui/material/styles': {
+ styled: {
+ canonicalImport: ['@emotion/styled', 'default'],
+ styledBaseImport: ['@mui/material/styles', 'styled'],
},
},
- },
- transpilePackages: [
- '@mui/material',
- '@mui/system',
- '@mui/icons-material',
- ],
- env: {
- // Sentry reads this env var to set the "release" value.
- // TODO(MR): We also set this below, are both places required?
- SENTRY_RELEASE: gitSHA,
- },
-
- // https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
- webpack: (config, { isServer }) => {
- if (!isServer) {
- config.resolve.fallback.fs = false;
- }
- return config;
},
},
- {
- dryRun: phase === PHASE_DEVELOPMENT_SERVER,
- release: gitSHA,
+ },
+ transpilePackages: ['@mui/material', '@mui/system', '@mui/icons-material'],
+
+ // https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
+ webpack: (config, { isServer }) => {
+ if (!isServer) {
+ config.resolve.fallback.fs = false;
}
- );
+ return config;
+ },
+
+ // Build time Sentry configuration
+ sentry: {
+ widenClientFileUpload: true,
+ },
+};
+
+// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
+const createSentryWebpackPluginOptions = (phase) => {
+ return {
+ dryRun: phase === PHASE_DEVELOPMENT_SERVER,
+ 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));
diff --git a/packages/shared/sentry/config/sentry.config.base.ts b/packages/shared/sentry/config/sentry.config.base.ts
index a4349ad444..100a4b7778 100644
--- a/packages/shared/sentry/config/sentry.config.base.ts
+++ b/packages/shared/sentry/config/sentry.config.base.ts
@@ -3,7 +3,7 @@ import { getSentryUserID } from '@ente/shared/sentry/utils';
import { runningInBrowser } from '@ente/shared/platform';
import { getHasOptedOutOfCrashReports } from '@ente/shared/storage/localStorage/helpers';
-export const setupSentry = async (dsn: string) => {
+export const initSentry = async (dsn: string) => {
const optedOut = runningInBrowser() && getHasOptedOutOfCrashReports();
if (optedOut) return;
diff --git a/turbo.json b/turbo.json
index 0932f39998..308c67f29a 100644
--- a/turbo.json
+++ b/turbo.json
@@ -25,6 +25,7 @@
"NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT",
"NEXT_PUBLIC_ENTE_FAMILY_PORTAL_ENDPOINT",
"NODE_ENV",
+ "SENTRY_AUTH_TOKEN",
"SENTRY_RELEASE"
]
}