소스 검색

Don't initialize Sentry on dev builds

Manav Rathi 1 년 전
부모
커밋
bf70857a41
2개의 변경된 파일13개의 추가작업 그리고 6개의 파일을 삭제
  1. 4 4
      apps/photos/.env.development
  2. 9 2
      packages/shared/sentry/config/sentry.config.base.ts

+ 4 - 4
apps/photos/.env.development

@@ -20,10 +20,10 @@
 #
 #
 # A development build behaves differently in some aspects:
 # 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
 # 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
 # APIs by default (can be customized using the env vars below). This is usually

+ 9 - 2
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 { getSentryUserID } from '@ente/shared/sentry/utils';
 import { runningInBrowser } from '@ente/shared/platform';
 import { runningInBrowser } from '@ente/shared/platform';
 import { getHasOptedOutOfCrashReports } from '@ente/shared/storage/localStorage/helpers';
 import { getHasOptedOutOfCrashReports } from '@ente/shared/storage/localStorage/helpers';
+import { isDevBuild } from '@ente/shared/network/api';
 
 
 export const initSentry = async (dsn: string) => {
 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]
     // [Note: Specifying the Sentry release]
     //
     //
@@ -51,3 +55,6 @@ export const initSentry = async (dsn: string) => {
 
 
     Sentry.setUser({ id: await getSentryUserID() });
     Sentry.setUser({ id: await getSentryUserID() });
 };
 };
+
+/** Return true if the user has opted out of crash reporting */
+const optedOut = () => runningInBrowser() && getHasOptedOutOfCrashReports();