From 8a4dc44fbc3384c369f59269f0773db78c43329b Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Mon, 15 Dec 2025 10:22:05 +0200 Subject: [PATCH] Show build info --- backend/api/src/health.ts | 2 ++ common/src/api/schema.ts | 7 +++++- web/components/about-settings.tsx | 39 +++++++++++++++++++++++++++++++ web/next.config.js | 3 +++ web/pages/_app.tsx | 4 ++-- web/pages/settings.tsx | 2 ++ 6 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 web/components/about-settings.tsx diff --git a/backend/api/src/health.ts b/backend/api/src/health.ts index 33e9886..6a69db6 100644 --- a/backend/api/src/health.ts +++ b/backend/api/src/health.ts @@ -1,10 +1,12 @@ import { APIHandler } from './helpers/endpoint' import {git} from './../metadata.json' +import {version as pkgVersion} from './../package.json' export const health: APIHandler<'health'> = async (_, auth) => { return { message: 'Server is working.', uid: auth?.uid, git: git, + version: pkgVersion, } } diff --git a/common/src/api/schema.ts b/common/src/api/schema.ts index e91b392..b571169 100644 --- a/common/src/api/schema.ts +++ b/common/src/api/schema.ts @@ -45,7 +45,12 @@ export const API = (_apiTypeCheck = { authed: false, rateLimited: false, props: z.object({}), - returns: {} as { message: 'Server is working.'; uid?: string }, + returns: {} as { + message: 'Server is working.' + uid?: string + version?: string + git?: { revision?: string; commitDate?: string; author?: string } + }, summary: 'Check whether the API server is running', tag: 'General', }, diff --git a/web/components/about-settings.tsx b/web/components/about-settings.tsx new file mode 100644 index 0000000..467f42a --- /dev/null +++ b/web/components/about-settings.tsx @@ -0,0 +1,39 @@ +import {WithPrivateUser} from "web/components/user/with-user"; +import {PrivateUser} from "common/user"; +import {Col} from "web/components/layout/col"; +import {IS_VERCEL} from "common/hosting/constants"; +import Link from "next/link"; + +export const AboutSettings = () => ( + + {user => } + +) + +const LoadedAboutSettings = (props: { + privateUser: PrivateUser, +}) => { + const {privateUser} = props + + return + + +} + +const WebBuildInfo = () => { + if (!IS_VERCEL) return + const env = process.env.NEXT_PUBLIC_VERCEL_ENV + const msg = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE + const owner = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER + const repo = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG + const sha = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + const deploymentId = process.env.NEXT_PUBLIC_VERCEL_DEPLOYMENT_ID + const url = `https://github.com/${owner}/${repo}/commit/${sha}` + return +

Web build (Vercel)

+

Commit SHA: {sha}

+

Commit message: {msg}

+

Vercel deployment ID: {deploymentId}

+

Environment: {env}

+ +} diff --git a/web/next.config.js b/web/next.config.js index 2731880..6d636a8 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -23,6 +23,9 @@ module.exports = { experimental: { scrollRestoration: true, }, + env: { + NEXT_PUBLIC_VERCEL_DEPLOYMENT_ID: process.env.VERCEL_DEPLOYMENT_ID, + }, // Remove once confirmed that posthog.init works without it // rewrites: async () => { // if (isAppBuild) { diff --git a/web/pages/_app.tsx b/web/pages/_app.tsx index 2c7ff5f..2e9ffbf 100644 --- a/web/pages/_app.tsx +++ b/web/pages/_app.tsx @@ -19,6 +19,7 @@ import {App} from '@capacitor/app' import {useRouter} from "next/navigation" import {Keyboard} from "@capacitor/keyboard" import {LiveUpdate} from "@capawesome/capacitor-live-update" +import {IS_VERCEL} from "common/hosting/constants" if (Capacitor.isNativePlatform()) { // Only runs on iOS/Android native @@ -70,8 +71,7 @@ const logoFont = Major_Mono_Display({ // }) function printBuildInfo() { - // These are undefined if e.g. dev server - if (process.env.NEXT_PUBLIC_VERCEL_ENV) { + if (IS_VERCEL) { const env = process.env.NEXT_PUBLIC_VERCEL_ENV const msg = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE const owner = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER diff --git a/web/pages/settings.tsx b/web/pages/settings.tsx index c62394d..bfbca46 100644 --- a/web/pages/settings.tsx +++ b/web/pages/settings.tsx @@ -18,6 +18,7 @@ import {NotificationSettings} from "web/components/notifications"; import ThemeIcon from "web/components/theme-icon"; import {WithPrivateUser} from "web/components/user/with-user"; import {sendPasswordReset} from "web/lib/firebase/password"; +import {AboutSettings} from "web/components/about-settings"; export default function NotificationsPage() { useRedirectIfSignedOut() @@ -30,6 +31,7 @@ export default function NotificationsPage() { tabs={[ {title: 'General', content: }, {title: 'Notifications', content: }, + {title: 'About', content: }, ]} trackingName={'settings page'} />