Skip to content

Commit 883147e

Browse files
committed
Expose build metadata through vite
1 parent 0d0b946 commit 883147e

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/composables/usePostHog.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export function usePostHog() {
1515
cookieless_mode: "always",
1616
defaults: "2026-01-30",
1717
});
18+
posthog.register({
19+
build_date: __BUILD_DATE__,
20+
build_sha: __BUILD_SHA__,
21+
});
1822
}
1923
initialized = true;
2024
}

src/env.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
/// <reference types="vite/client" />
22
/// <reference types="vite-plugin-pwa/client" />
3+
4+
declare const __BUILD_DATE__: string;
5+
declare const __BUILD_SHA__: string;

vite.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ import vue from "@vitejs/plugin-vue";
33
import { viteStaticCopy } from "vite-plugin-static-copy";
44
import { VitePWA } from "vite-plugin-pwa";
55
import path from "path";
6+
import { execSync } from "child_process";
67

78
const cesiumEngineSource = "node_modules/@cesium/engine";
89
const cesiumWidgetsSource = "node_modules/@cesium/widgets";
910
const cesiumBaseUrl = "cesium";
1011

12+
const buildDate = new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
13+
const buildSha = execSync("git rev-parse --short HEAD").toString().trim();
14+
1115
export default defineConfig({
1216
base: "",
1317
build: {
@@ -50,6 +54,8 @@ export default defineConfig({
5054
define: {
5155
// Define relative base path in cesium for loading assets
5256
CESIUM_BASE_URL: JSON.stringify("./cesium"),
57+
__BUILD_DATE__: JSON.stringify(buildDate),
58+
__BUILD_SHA__: JSON.stringify(buildSha),
5359
},
5460
plugins: [
5561
vue(),

0 commit comments

Comments
 (0)