Skip to content

armgit / ente

Public Imported from GitHub
0

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

patch up config related refactoring issues

Abhinav4b48e99b69b4
diff --git a/apps/auth/sentry.client.config.ts b/apps/auth/sentry.client.config.ts
index bc0f9dae36..88a9a854b3 100644
--- a/apps/auth/sentry.client.config.ts
+++ b/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://[email protected]/13';
+
+setupSentry(DEFAULT_SENTRY_DSN);
diff --git a/packages/shared/apps/env.ts b/packages/shared/apps/env.ts
index 73b5aa6082..5046ccbafb 100644
--- a/packages/shared/apps/env.ts
+++ b/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;
diff --git a/packages/shared/next/env.js b/packages/shared/next/env.js
index 6cf1178b7d..161ed3d74a 100644
--- a/packages/shared/next/env.js
+++ b/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';
};
diff --git a/packages/shared/next/next.config.base.js b/packages/shared/next/next.config.base.js
index 44a0171da7..ad2f10536a 100644
--- a/packages/shared/next/next.config.base.js
+++ b/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;
diff --git a/packages/shared/next/pages/_document.tsx b/packages/shared/next/pages/_document.tsx
index d33dca37c5..d95f7b4255 100644
--- a/packages/shared/next/pages/_document.tsx
+++ b/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[];
}
diff --git a/packages/shared/next/utils/sentry.js b/packages/shared/next/utils/sentry.js
index c1c1ca5fdb..66c09e11a2 100644
--- a/packages/shared/next/utils/sentry.js
+++ b/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 = () =>
diff --git a/packages/shared/sentry/config/sentry.config.base.ts b/packages/shared/sentry/config/sentry.config.base.ts
index 22b50d3ffc..de8200d79e 100644
--- a/packages/shared/sentry/config/sentry.config.base.ts
+++ b/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(),
diff --git a/packages/shared/sentry/utils.ts b/packages/shared/sentry/utils.ts
index 0b6209ab48..a8574f5089 100644
--- a/packages/shared/sentry/utils.ts
+++ b/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;
};