ソースを参照

patch up config related refactoring issues

Abhinav 1 年間 前
コミット
4b48e99b69

+ 4 - 1
apps/auth/sentry.client.config.ts

@@ -1,3 +1,6 @@
 import { setupSentry } from '@ente/shared/sentry/config/sentry.config.base';
 
-setupSentry();
+const DEFAULT_SENTRY_DSN =
+    'https://9466dbb7dc1e45f7865f16571d5320a9@sentry.ente.io/13';
+
+setupSentry(DEFAULT_SENTRY_DSN);

+ 6 - 2
packages/shared/apps/env.ts

@@ -3,6 +3,10 @@ import { APP_ENV } from './constants';
 export const getAppEnv = () =>
     process.env.NEXT_PUBLIC_APP_ENV ?? APP_ENV.DEVELOPMENT;
 
-export const isEnableSentryFlagSet = () => {
-    return process.env.NEXT_PUBLIC_ENABLE_SENTRY === 'true';
+export const isDisableSentryFlagSet = () => {
+    return process.env.NEXT_PUBLIC_DISABLE_SENTRY === 'true';
 };
+
+export const getSentryDSN = () => process.env.NEXT_PUBLIC_SENTRY_DSN;
+
+export const getSentryRelease = () => process.env.SENTRY_RELEASE;

+ 2 - 2
packages/shared/next/env.js

@@ -12,6 +12,6 @@ module.exports.getAppEnv = () => {
     return process.env.NEXT_PUBLIC_APP_ENV ?? ENV_DEVELOPMENT;
 };
 
-module.exports.isEnableSentryFlagSet = () => {
-    return process.env.NEXT_PUBLIC_ENABLE_SENTRY === 'true';
+module.exports.isDisableSentryFlagSet = () => {
+    return process.env.NEXT_PUBLIC_DISABLE_SENTRY === 'true';
 };

+ 2 - 0
packages/shared/next/next.config.base.js

@@ -46,6 +46,8 @@ module.exports = (phase) =>
                 SENTRY_RELEASE: GIT_SHA,
                 NEXT_PUBLIC_IS_TEST_APP: process.env.IS_TEST_RELEASE || 'false',
             },
+
+            // 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;

+ 1 - 1
packages/shared/next/pages/_document.tsx

@@ -13,7 +13,7 @@ import { AppType } from 'next/app';
 import createEmotionCache from '@ente/shared/themes/createEmotionCache';
 import { EnteAppProps } from '@ente/shared/apps/types';
 
-interface EnteDocumentProps extends DocumentProps {
+export interface EnteDocumentProps extends DocumentProps {
     emotionStyleTags: JSX.Element[];
 }
 

+ 3 - 3
packages/shared/next/utils/sentry.js

@@ -1,14 +1,14 @@
 const {
     getAppEnv,
     ENV_DEVELOPMENT,
-    isEnableSentryFlagSet,
+    isDisableSentryFlagSet,
 } = require('../env.js');
 const cp = require('child_process');
 
 module.exports.getIsSentryEnabled = () => {
     const isAppENVDevelopment = getAppEnv() === ENV_DEVELOPMENT;
-    const isSentryEnabled = isEnableSentryFlagSet();
-    return !isAppENVDevelopment || isSentryEnabled;
+    const isSentryDisabled = isDisableSentryFlagSet();
+    return !isAppENVDevelopment || !isSentryDisabled;
 };
 
 module.exports.getGitSha = () =>

+ 10 - 2
packages/shared/sentry/config/sentry.config.base.ts

@@ -4,19 +4,27 @@ import { getSentryUserID } from '@ente/shared/sentry/utils';
 import { runningInBrowser } from '@ente/shared/platform';
 import { getHasOptedOutOfCrashReports } from '@ente/shared/storage/localStorage/helpers';
 import { getIsSentryEnabled } from '@ente/shared/sentry/utils';
-import { getAppEnv } from '@ente/shared/apps/env';
+import {
+    getAppEnv,
+    getSentryDSN,
+    getSentryRelease,
+} from '@ente/shared/apps/env';
 
-export const setupSentry = async () => {
+export const setupSentry = async (DEFAULT_SENTRY_DSN: string) => {
     const HAS_OPTED_OUT_OF_CRASH_REPORTING =
         runningInBrowser() && getHasOptedOutOfCrashReports();
 
     if (!HAS_OPTED_OUT_OF_CRASH_REPORTING) {
+        const SENTRY_DSN = getSentryDSN() ?? DEFAULT_SENTRY_DSN;
         const APP_ENV = getAppEnv();
         const IS_ENABLED = getIsSentryEnabled();
+        const SENTRY_RELEASE = getSentryRelease();
 
         Sentry.init({
+            dsn: SENTRY_DSN,
             enabled: IS_ENABLED,
             environment: APP_ENV,
+            release: SENTRY_RELEASE,
             attachStacktrace: true,
             autoSessionTracking: false,
             tunnel: getSentryTunnelURL(),

+ 3 - 3
packages/shared/sentry/utils.ts

@@ -6,7 +6,7 @@ import {
 import isElectron from 'is-electron';
 import { getAppEnv } from '@ente/shared/apps/env';
 import { APP_ENV } from '@ente/shared/apps/constants';
-import { isEnableSentryFlagSet } from '@ente/shared/apps/env';
+import { isDisableSentryFlagSet } from '@ente/shared/apps/env';
 
 export async function getSentryUserID() {
     if (isElectron()) {
@@ -45,6 +45,6 @@ export function isErrorUnnecessaryForSentry(error: any) {
 
 export const getIsSentryEnabled = () => {
     const isAppENVDevelopment = getAppEnv() === APP_ENV.DEVELOPMENT;
-    const isSentryEnabled = isEnableSentryFlagSet();
-    return !isAppENVDevelopment || isSentryEnabled;
+    const isSentryDisabled = isDisableSentryFlagSet();
+    return !isAppENVDevelopment || !isSentryDisabled;
 };