Skip to content

armgit / ente

Public Imported from GitHub
0

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

Don't initialize Sentry on dev builds

Manav Rathibf70857a4147
diff --git a/apps/photos/.env.development b/apps/photos/.env.development
index a96392fe9a..64aec7da7a 100644
--- a/apps/photos/.env.development
+++ b/apps/photos/.env.development
@@ -20,10 +20,10 @@
#
# A development build behaves differently in some aspects:
#
-# 1. Logs go to the browser console (in addition to the log file), and there is
-# additional logging too.
-#
-# 2. Crash reports go to a separate "development" environment in Sentry.
+# - Logs go to the browser console (in addition to the log file)
+# - There is some additional logging
+# - Sentry is not initialized
+# - ... (search for isDevBuild to see all impacts)
#
# Note that even in development build, the app still connects to the production
# APIs by default (can be customized using the env vars below). This is usually
diff --git a/packages/shared/sentry/config/sentry.config.base.ts b/packages/shared/sentry/config/sentry.config.base.ts
index d78ed4610c..60a2d46236 100644
--- a/packages/shared/sentry/config/sentry.config.base.ts
+++ b/packages/shared/sentry/config/sentry.config.base.ts
@@ -2,10 +2,14 @@ import * as Sentry from '@sentry/nextjs';
import { getSentryUserID } from '@ente/shared/sentry/utils';
import { runningInBrowser } from '@ente/shared/platform';
import { getHasOptedOutOfCrashReports } from '@ente/shared/storage/localStorage/helpers';
+import { isDevBuild } from '@ente/shared/network/api';
export const initSentry = async (dsn: string) => {
- const optedOut = runningInBrowser() && getHasOptedOutOfCrashReports();
- if (optedOut) return;
+ // Don't initialize Sentry on dev builds
+ if (isDevBuild) return;
+
+ // Don't initialize Sentry if the user has opted out of crash reporting
+ if (optedOut()) return;
// [Note: Specifying the Sentry release]
//
@@ -51,3 +55,6 @@ export const initSentry = async (dsn: string) => {
Sentry.setUser({ id: await getSentryUserID() });
};
+
+/** Return true if the user has opted out of crash reporting */
+const optedOut = () => runningInBrowser() && getHasOptedOutOfCrashReports();