diff --git a/frontend/sync-client/src/utils/create-client-id.ts b/frontend/sync-client/src/utils/create-client-id.ts index cfa132da..804efa9f 100644 --- a/frontend/sync-client/src/utils/create-client-id.ts +++ b/frontend/sync-client/src/utils/create-client-id.ts @@ -1,15 +1,13 @@ import { v4 as uuidv4 } from "uuid"; +import { packageVersion } from "./package-version"; export function createClientId(): string { - // @ts-expect-error, injected by webpack - const packageVersion = __CURRENT_VERSION__; // eslint-disable-line - const platform = typeof navigator !== "undefined" ? navigator.platform // eslint-disable-line @typescript-eslint/no-deprecated : typeof process !== "undefined" - ? process.platform - : "unknown"; + ? process.platform + : "unknown"; return `vault-link/${packageVersion} (${uuidv4()}; ${platform})`; } diff --git a/frontend/sync-client/src/utils/package-version.ts b/frontend/sync-client/src/utils/package-version.ts new file mode 100644 index 00000000..92d8c0b4 --- /dev/null +++ b/frontend/sync-client/src/utils/package-version.ts @@ -0,0 +1,7 @@ +declare const __CURRENT_VERSION__: string; + +/** Webpack replaces this identifier in bundles; source imports use a stable fallback. */ +export const packageVersion = + typeof __CURRENT_VERSION__ === "undefined" + ? "development" + : __CURRENT_VERSION__; diff --git a/frontend/sync-client/src/utils/set-up-telemetry.ts b/frontend/sync-client/src/utils/set-up-telemetry.ts index d3704ee1..bcd81dc2 100644 --- a/frontend/sync-client/src/utils/set-up-telemetry.ts +++ b/frontend/sync-client/src/utils/set-up-telemetry.ts @@ -1,7 +1,5 @@ import * as Sentry from "@sentry/browser"; - -// @ts-expect-error, injected by webpack -const packageVersion = __CURRENT_VERSION__; // eslint-disable-line +import { packageVersion } from "./package-version"; export const setUpTelemetry = (): (() => void) => { Sentry.init({