diff --git a/packages/embeds/embed-core/package.json b/packages/embeds/embed-core/package.json index d4c81bdcd40d33..a3b53d53e55bc5 100644 --- a/packages/embeds/embed-core/package.json +++ b/packages/embeds/embed-core/package.json @@ -15,7 +15,7 @@ "embed-web-start": "yarn workspace @calcom/web start", "__build": "yarn tailwind && vite build && tsc --emitDeclarationOnly --declarationDir dist && cp -r ../../../apps/web/public/embed ./dist/", "__dev": "yarn tailwind && vite build --mode development", - "build": "rm -rf dist && NEXT_PUBLIC_EMBED_FINGER_PRINT=$(git rev-parse --short HEAD) yarn __build", + "build": "rm -rf dist && NEXT_PUBLIC_EMBED_FINGER_PRINT=$(git rev-parse --short HEAD) NEXT_PUBLIC_EMBED_VERSION=$(node -p 'require(\"./package.json\").version') yarn __build", "build-preview": "PREVIEW_BUILD=1 yarn __build ", "vite": "vite", "tailwind": "yarn tailwindcss -i ./src/styles.css -o ./src/tailwind.generated.css", diff --git a/packages/embeds/embed-core/src/embed.ts b/packages/embeds/embed-core/src/embed.ts index ad17a1f2248533..b2bef057fe74ef 100644 --- a/packages/embeds/embed-core/src/embed.ts +++ b/packages/embeds/embed-core/src/embed.ts @@ -52,6 +52,7 @@ if (!globalCal || !globalCal.q) { // TODO: Ideally it should be the version as per package.json and then it can be renamed to version. // But because it is built on local machine right now, it is much more reliable to have the commit hash. globalCal.fingerprint = process.env.EMBED_PUBLIC_EMBED_FINGER_PRINT as string; +globalCal.version = process.env.EMBED_PUBLIC_EMBED_VERSION as string; globalCal.__css = allCss; document.head.appendChild(document.createElement("style")).innerHTML = css; @@ -810,6 +811,7 @@ export interface GlobalCalWithoutNs { instance?: Cal; __css?: string; fingerprint?: string; + version?: string; __logQueue?: unknown[]; } diff --git a/packages/embeds/embed-core/src/preview.ts b/packages/embeds/embed-core/src/preview.ts index d361342c76888d..3a1b0861a99a05 100644 --- a/packages/embeds/embed-core/src/preview.ts +++ b/packages/embeds/embed-core/src/preview.ts @@ -50,6 +50,7 @@ if (!bookerUrl || !embedLibUrl) { })(window, embedLibUrl, "init"); const previewWindow = window; previewWindow.Cal.fingerprint = process.env.EMBED_PUBLIC_EMBED_FINGER_PRINT as string; +previewWindow.Cal.version = process.env.EMBED_PUBLIC_EMBED_VERSION as string; previewWindow.Cal("init", { origin: bookerUrl, diff --git a/packages/embeds/embed-core/vite.config.js b/packages/embeds/embed-core/vite.config.js index 953d5282e291a7..2399cbbcb1bb38 100644 --- a/packages/embeds/embed-core/vite.config.js +++ b/packages/embeds/embed-core/vite.config.js @@ -13,6 +13,7 @@ module.exports = defineConfig((configEnv) => { plugins: [ EnvironmentPlugin({ EMBED_PUBLIC_EMBED_FINGER_PRINT: embedCoreEnvVars.EMBED_PUBLIC_EMBED_FINGER_PRINT, + EMBED_PUBLIC_EMBED_VERSION: embedCoreEnvVars.EMBED_PUBLIC_EMBED_VERSION, EMBED_PUBLIC_VERCEL_URL: embedCoreEnvVars.EMBED_PUBLIC_VERCEL_URL, EMBED_PUBLIC_WEBAPP_URL: embedCoreEnvVars.EMBED_PUBLIC_WEBAPP_URL, }), diff --git a/packages/embeds/vite.config.js b/packages/embeds/vite.config.js index f88e008ef27b1f..c074f0efaeec6e 100644 --- a/packages/embeds/vite.config.js +++ b/packages/embeds/vite.config.js @@ -6,6 +6,8 @@ process.env.EMBED_PUBLIC_WEBAPP_URL = process.env.NEXT_PUBLIC_WEBAPP_URL; process.env.EMBED_PUBLIC_EMBED_LIB_URL = process.env.NEXT_PUBLIC_EMBED_LIB_URL; // eslint-disable-next-line turbo/no-undeclared-env-vars process.env.EMBED_PUBLIC_EMBED_FINGER_PRINT = process.env.NEXT_PUBLIC_EMBED_FINGER_PRINT; +// eslint-disable-next-line turbo/no-undeclared-env-vars +process.env.EMBED_PUBLIC_EMBED_VERSION = process.env.NEXT_PUBLIC_EMBED_VERSION; // Problem: typeof process.env.EMBED_PUBLIC_EMBED_LIB_URL is "undefined"(truthy) if process.env.NEXT_PUBLIC_EMBED_LIB_URL is undefined(falsy) // This is probably because environment variables are always string, so this weird automatic conversion to string happens @@ -30,6 +32,7 @@ const viteBaseConfig = { export default viteBaseConfig; export const embedCoreEnvVars = { EMBED_PUBLIC_EMBED_FINGER_PRINT: process.env.EMBED_PUBLIC_EMBED_FINGER_PRINT ?? "", + EMBED_PUBLIC_EMBED_VERSION: process.env.EMBED_PUBLIC_EMBED_VERSION ?? "", EMBED_PUBLIC_VERCEL_URL: process.env.EMBED_PUBLIC_VERCEL_URL ?? "http://localhost:3000", EMBED_PUBLIC_WEBAPP_URL: process.env.EMBED_PUBLIC_WEBAPP_URL ?? diff --git a/turbo.json b/turbo.json index dc2a85b6d5b3f9..9e7e75d544aab2 100644 --- a/turbo.json +++ b/turbo.json @@ -188,7 +188,7 @@ "@calcom/embed-core#build": { "cache": false, "outputs": ["../../../apps/web/public/embed/**"], - "env": ["EMBED_PUBLIC_VERCEL_URL", "EMBED_PUBLIC_WEBAPP_URL", "EMBED_PUBLIC_EMBED_FINGER_PRINT"] + "env": ["EMBED_PUBLIC_VERCEL_URL", "EMBED_PUBLIC_WEBAPP_URL", "EMBED_PUBLIC_EMBED_FINGER_PRINT", "EMBED_PUBLIC_EMBED_VERSION"] }, "embed-tests-update-snapshots:ci": { "cache": false, @@ -418,6 +418,7 @@ "CLOUDFLARE_VERCEL_CNAME", "CLOUDFLARE_DNS", "EMBED_PUBLIC_EMBED_FINGER_PRINT", + "EMBED_PUBLIC_EMBED_VERSION", "EMBED_PUBLIC_WEBAPP_URL", "EMBED_PUBLIC_VERCEL_URL", "NEXT_PUBLIC_ENABLE_PROFILE_SWITCHER",