π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Include the git SHA in the logs
Manav Rathi39034474bab2
diff --git a/apps/auth/src/pages/_app.tsx b/apps/auth/src/pages/_app.tsxindex eca7e58366..a61b32e928 100644--- a/apps/auth/src/pages/_app.tsx+++ b/apps/auth/src/pages/_app.tsx@@ -5,7 +5,7 @@ import { t } from 'i18next';import { useRouter } from 'next/router';import { Overlay } from '@ente/shared/components/Container';import EnteSpinner from '@ente/shared/components/EnteSpinner';-import { getData, LS_KEYS } from '@ente/shared/storage/localStorage';+import { LS_KEYS } from '@ente/shared/storage/localStorage';import HTTPService from '@ente/shared/network/HTTPService';import Head from 'next/head';import LoadingBar from 'react-top-loading-bar';@@ -17,8 +17,10 @@ import {DialogBoxAttributesV2,SetDialogBoxAttributesV2,} from '@ente/shared/components/DialogBoxV2/types';-import { addLogLine } from '@ente/shared/logging';-import { clearLogsIfLocalStorageLimitExceeded } from '@ente/shared/logging/web';+import {+ clearLogsIfLocalStorageLimitExceeded,+ logStartupMessage,+} from '@ente/shared/logging/web';import { CacheProvider } from '@emotion/react';import {@@ -31,8 +33,6 @@ import createEmotionCache from '@ente/shared/themes/createEmotionCache';import { THEME_COLOR } from '@ente/shared/themes/constants';import { SetTheme } from '@ente/shared/themes/types';import { setupI18n } from '@ente/shared/i18n';-import { getSentryUserID } from '@ente/shared/sentry/utils';-import { User } from '@ente/shared/user/types';import { useLocalState } from '@ente/shared/hooks/useLocalState';import { PHOTOS_PAGES as PAGES } from '@ente/shared/constants/pages';import { getTheme } from '@ente/shared/themes';@@ -87,12 +87,7 @@ export default function App(props: EnteAppProps) {});// setup loggingclearLogsIfLocalStorageLimitExceeded();- const main = async () => {- addLogLine(`userID: ${(getData(LS_KEYS.USER) as User)?.id}`);- addLogLine(`sentryID: ${await getSentryUserID()}`);- addLogLine(`sentry release: ${process.env.SENTRY_RELEASE}`);- };- main();+ logStartupMessage();}, []);const setUserOnline = () => setOffline(false);diff --git a/apps/photos/src/pages/_app.tsx b/apps/photos/src/pages/_app.tsxindex 9fc31ab422..7c9b09b953 100644--- a/apps/photos/src/pages/_app.tsx+++ b/apps/photos/src/pages/_app.tsx@@ -39,7 +39,10 @@ import {} from 'services/userService';import { CustomError } from '@ente/shared/error';import { addLogLine } from '@ente/shared/logging';-import { clearLogsIfLocalStorageLimitExceeded } from '@ente/shared/logging/web';+import {+ clearLogsIfLocalStorageLimitExceeded,+ logStartupMessage,+} from '@ente/shared/logging/web';import isElectron from 'is-electron';import ElectronAPIs from '@ente/shared/electron';import {@@ -71,8 +74,6 @@ import createEmotionCache from '@ente/shared/themes/createEmotionCache';import { THEME_COLOR } from '@ente/shared/themes/constants';import { SetTheme } from '@ente/shared/themes/types';import { setupI18n } from '@ente/shared/i18n';-import { getSentryUserID } from '@ente/shared/sentry/utils';-import { User } from '@ente/shared/user/types';import { useLocalState } from '@ente/shared/hooks/useLocalState';import { PHOTOS_PAGES as PAGES } from '@ente/shared/constants/pages';import { getTheme } from '@ente/shared/themes';@@ -168,12 +169,7 @@ export default function App(props: EnteAppProps) {});// setup loggingclearLogsIfLocalStorageLimitExceeded();- const main = async () => {- addLogLine(`userID: ${(getData(LS_KEYS.USER) as User)?.id}`);- addLogLine(`sentryID: ${await getSentryUserID()}`);- addLogLine(`sentry release: ${process.env.SENTRY_RELEASE}`);- };- main();+ logStartupMessage();}, []);useEffect(() => {diff --git a/packages/shared/logging/index.ts b/packages/shared/logging/index.tsindex d5c25d2af3..5c22f781b1 100644--- a/packages/shared/logging/index.ts+++ b/packages/shared/logging/index.ts@@ -13,7 +13,7 @@ export function addLogLine() {try {const completeLog = [log, ...optionalParams].join(' ');- if (isDevBuild()) {+ if (isDevBuild) {console.log(completeLog);}if (isElectron()) {@@ -28,7 +28,7 @@ export function addLogLine(}export const addLocalLog = (getLog: () => string) => {- if (isDevBuild()) {+ if (isDevBuild) {console.log(formatLog({logLine: getLog(),diff --git a/packages/shared/logging/web.ts b/packages/shared/logging/web.tsindex 5a58a8ee8d..13cef14cd2 100644--- a/packages/shared/logging/web.ts+++ b/packages/shared/logging/web.ts@@ -8,6 +8,9 @@ import {setData,} from '@ente/shared/storage/localStorage';import { ElectronFile } from '../upload/types';+import { addLogLine } from '.';+import { getSentryUserID } from '../sentry/utils';+import type { User } from '../user/types';export const MAX_LOG_SIZE = 5 * 1024 * 1024; // 5MBexport const MAX_LOG_LINES = 1000;@@ -67,6 +70,12 @@ export const clearLogsIfLocalStorageLimitExceeded = () => {}};+export const logStartupMessage = async () => {+ addLogLine(`User ID: ${(getData(LS_KEYS.USER) as User)?.id}`);+ addLogLine(`Sentry ID: ${await getSentryUserID()}`);+ addLogLine(`Git commit: ${process.env.GIT_SHA}`);+};+function getLogs(): Log[] {return getData(LS_KEYS.LOGS)?.logs ?? [];}diff --git a/packages/shared/network/api.ts b/packages/shared/network/api.tsindex ca5f27f7ed..9b8c11b920 100644--- a/packages/shared/network/api.ts+++ b/packages/shared/network/api.ts@@ -85,6 +85,4 @@ export const getFamilyPortalURL = () => {* assigns development when running the `next dev` command, or production for* all other commands.*/-export const isDevBuild = () => {- return process.env.NODE_ENV === 'development';-};+export const isDevBuild = process.env.NODE_ENV === 'development';diff --git a/packages/shared/next/next.config.base.js b/packages/shared/next/next.config.base.jsindex 8200c2a3ce..08559a6ddf 100644--- a/packages/shared/next/next.config.base.js+++ b/packages/shared/next/next.config.base.js@@ -1,3 +1,13 @@+/**+ * @file Configure the Next.js build+ *+ * This file gets used by the Next.js build phase, and is not included in the+ * browser build. It will not be parsed by Webpack, Babel or TypeScript, so+ * don't use features that will not be available in our target node version.+ *+ * https://nextjs.org/docs/pages/api-reference/next-config-js+ */+const { withSentryConfig } = require('@sentry/nextjs');const cp = require('child_process');@@ -27,6 +37,12 @@ const nextConfig = {},transpilePackages: ['@mui/material', '@mui/system', '@mui/icons-material'],+ // Add environment variables to the JavaScript bundle. They will be+ // available as `process.env.VAR_NAME` to our code.+ env: {+ GIT_SHA: gitSHA,+ },+// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6jwebpack: (config, { isServer }) => {if (!isServer) {diff --git a/turbo.json b/turbo.jsonindex 308c67f29a..ea29b20af0 100644--- a/turbo.json+++ b/turbo.json@@ -25,7 +25,6 @@"NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT","NEXT_PUBLIC_ENTE_FAMILY_PORTAL_ENDPOINT","NODE_ENV",- "SENTRY_AUTH_TOKEN",- "SENTRY_RELEASE"+ "SENTRY_AUTH_TOKEN"]}