diff --git a/web/packages/base/app.ts b/web/packages/base/app.ts index 74b891a9c0..e330e41a83 100644 --- a/web/packages/base/app.ts +++ b/web/packages/base/app.ts @@ -62,8 +62,7 @@ export const staticAppTitle = { /** * Client "package names" for our app. * - * The package name is used as the (a) "X-Client-Package" header in API - * requests, and (b) as the identifier in inline user agent strings in payloads. + * The package name is used as the "X-Client-Package" header in API requests. * * In cases where this code works for both a web and a desktop app for the same * app (currently only photos), this will be the platform specific package name. @@ -72,9 +71,7 @@ export const clientPackageName = (() => { if (isDesktop) { if (appName != "photos") throw new Error(`Unsupported desktop appName ${appName}`); - if (!desktopAppVersion) - throw new Error(`desktopAppVersion is not defined`); - return `io.ente.photos.desktop/${desktopAppVersion}`; + return "io.ente.photos.desktop"; } return { accounts: "io.ente.accounts.web", @@ -83,3 +80,23 @@ export const clientPackageName = (() => { photos: "io.ente.photos.web", }[appName]; })(); + +/** + * The client package name, augmented with the client version where applicable. + * + * This string is used as the "client identifier" in payloads (e.g. ML data + * generated by a client). + * + * For the desktop app, it will be client package name and version. Otherwise, + * it'll just be the same as {@link clientPackageName}. + */ +export const clientIdentifier = (() => { + if (isDesktop) { + if (appName != "photos") + throw new Error(`Unsupported desktop appName ${appName}`); + if (!desktopAppVersion) + throw new Error(`desktopAppVersion is not defined`); + return `io.ente.photos.desktop/${desktopAppVersion}`; + } + return clientPackageName; +})(); diff --git a/web/packages/base/http.ts b/web/packages/base/http.ts index 38bb447608..e21b6f97c6 100644 --- a/web/packages/base/http.ts +++ b/web/packages/base/http.ts @@ -1,3 +1,4 @@ +import { desktopAppVersion, isDesktop } from "ente-base/app"; import { wait } from "ente-utils/promise"; import { z } from "zod"; import { clientPackageName } from "./app"; @@ -14,6 +15,7 @@ import log from "./log"; export const authenticatedRequestHeaders = async () => ({ "X-Auth-Token": await ensureAuthToken(), "X-Client-Package": clientPackageName, + ...(isDesktop ? { "X-Client-Version": desktopAppVersion } : {}), }); /** @@ -25,6 +27,7 @@ export const authenticatedRequestHeaders = async () => ({ */ export const publicRequestHeaders = () => ({ "X-Client-Package": clientPackageName, + ...(isDesktop ? { "X-Client-Version": desktopAppVersion } : {}), }); /** diff --git a/web/packages/base/next.config.base.js b/web/packages/base/next.config.base.js index 5bb855f792..8afb699564 100644 --- a/web/packages/base/next.config.base.js +++ b/web/packages/base/next.config.base.js @@ -64,7 +64,7 @@ const isDesktop = process.env._ENTE_IS_DESKTOP ? "1" : ""; /** * When we're running within the desktop app, also extract the version of the - * desktop app for use in our "X-Client-Package" string. + * desktop app for use in our "X-Client-Version" string. * * > The web app has continuous deployments, and doesn't have versions. */ diff --git a/web/packages/new/photos/services/ml/worker.ts b/web/packages/new/photos/services/ml/worker.ts index 7ddaeeb659..28ecbd09a8 100644 --- a/web/packages/new/photos/services/ml/worker.ts +++ b/web/packages/new/photos/services/ml/worker.ts @@ -1,5 +1,5 @@ import { expose, wrap } from "comlink"; -import { clientPackageName } from "ente-base/app"; +import { clientIdentifier } from "ente-base/app"; import { assertionFailed } from "ente-base/assert"; import { isHTTP4xxError, isHTTPErrorWithStatus } from "ente-base/http"; import log from "ente-base/log"; @@ -590,13 +590,13 @@ const index = async ( const remoteFaceIndex = existingRemoteFaceIndex ?? { version: faceIndexingVersion, - client: clientPackageName, + client: clientIdentifier, ...faceIndex, }; const remoteCLIPIndex = existingRemoteCLIPIndex ?? { version: clipIndexingVersion, - client: clientPackageName, + client: clientIdentifier, ...clipIndex, };