π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
New constant
Manav Rathid09a7b290bbd
diff --git a/web/packages/next/log-web.ts b/web/packages/next/log-web.tsindex bf24741b09..e0fb39e265 100644--- a/web/packages/next/log-web.ts+++ b/web/packages/next/log-web.ts@@ -1,6 +1,6 @@import { isDevBuild } from "@/next/env";import log from "@/next/log";-import type { AppName } from "./types/app";+import { appNames, type AppName } from "./types/app";/*** Log a standard startup banner.@@ -11,6 +11,14 @@ import type { AppName } from "./types/app";* @param userId The uid for the currently logged in user, if any.*/export const logStartupBanner = (appName: AppName, userId?: number) => {+ // Log a warning if appName isn't what it claims to be. See the+ // documentation of `appName` for why this is needed.+ if (!appNames.includes(appName)) {+ log.warn(+ `App name ${appName} is not one of the known app names: ${JSON.stringify(appNames)}`,+ );+ }+const sha = process.env.gitSHA;const buildId = isDevBuild ? "dev " : sha ? `git ${sha} ` : "";log.info(`Starting ente-${appName}-web ${buildId}uid ${userId ?? 0}`);diff --git a/web/packages/next/types/app.ts b/web/packages/next/types/app.tsindex 6ca14398ad..79d70be7d0 100644--- a/web/packages/next/types/app.ts+++ b/web/packages/next/types/app.ts@@ -1,10 +1,28 @@import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";+export const appNames = ["accounts", "auth", "photos"] as const;+/*** Arbitrary names that we used as keys for indexing various constants* corresponding to our apps that rely on this package.*/-export type AppName = "accounts" | "auth" | "photos";+export type AppName = (typeof appNames)[number];++/**+ * The name of the Ente app which we're currently running as.+ *+ * Parts of our code are shared across apps. Some parts of them also run in+ * non-main thread execution contexts like web workers. So there isn't always an+ * easy way to figure out what the current app is.+ *+ * To solve this, we inject the app name during the build process. This is+ * available to all our code (shared packages, web workers).+ *+ * This constant employs an `as` cast to avoid incurring a dynamic check, and as+ * such may be incorrect (e.g. when a new app gets added). So apps should+ * dynamically validate and log it once somewhere during init.+ */+export const appName: AppName = process.env.appName as AppName;/*** Static title for the app.