Skip to content

Commit 8a4dc44

Browse files
committed
Show build info
1 parent e231f01 commit 8a4dc44

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

backend/api/src/health.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { APIHandler } from './helpers/endpoint'
22
import {git} from './../metadata.json'
3+
import {version as pkgVersion} from './../package.json'
34

45
export const health: APIHandler<'health'> = async (_, auth) => {
56
return {
67
message: 'Server is working.',
78
uid: auth?.uid,
89
git: git,
10+
version: pkgVersion,
911
}
1012
}

common/src/api/schema.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ export const API = (_apiTypeCheck = {
4545
authed: false,
4646
rateLimited: false,
4747
props: z.object({}),
48-
returns: {} as { message: 'Server is working.'; uid?: string },
48+
returns: {} as {
49+
message: 'Server is working.'
50+
uid?: string
51+
version?: string
52+
git?: { revision?: string; commitDate?: string; author?: string }
53+
},
4954
summary: 'Check whether the API server is running',
5055
tag: 'General',
5156
},

web/components/about-settings.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {WithPrivateUser} from "web/components/user/with-user";
2+
import {PrivateUser} from "common/user";
3+
import {Col} from "web/components/layout/col";
4+
import {IS_VERCEL} from "common/hosting/constants";
5+
import Link from "next/link";
6+
7+
export const AboutSettings = () => (
8+
<WithPrivateUser>
9+
{user => <LoadedAboutSettings privateUser={user}/>}
10+
</WithPrivateUser>
11+
)
12+
13+
const LoadedAboutSettings = (props: {
14+
privateUser: PrivateUser,
15+
}) => {
16+
const {privateUser} = props
17+
18+
return <Col>
19+
<WebBuildInfo/>
20+
</Col>
21+
}
22+
23+
const WebBuildInfo = () => {
24+
if (!IS_VERCEL) return
25+
const env = process.env.NEXT_PUBLIC_VERCEL_ENV
26+
const msg = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE
27+
const owner = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER
28+
const repo = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG
29+
const sha = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
30+
const deploymentId = process.env.NEXT_PUBLIC_VERCEL_DEPLOYMENT_ID
31+
const url = `https://github.com/${owner}/${repo}/commit/${sha}`
32+
return <Col>
33+
<h3>Web build (Vercel)</h3>
34+
<p>Commit SHA: <Link href={url}>{sha}</Link></p>
35+
<p>Commit message: {msg}</p>
36+
<p>Vercel deployment ID: {deploymentId}</p>
37+
<p>Environment: {env}</p>
38+
</Col>
39+
}

web/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ module.exports = {
2323
experimental: {
2424
scrollRestoration: true,
2525
},
26+
env: {
27+
NEXT_PUBLIC_VERCEL_DEPLOYMENT_ID: process.env.VERCEL_DEPLOYMENT_ID,
28+
},
2629
// Remove once confirmed that posthog.init works without it
2730
// rewrites: async () => {
2831
// if (isAppBuild) {

web/pages/_app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {App} from '@capacitor/app'
1919
import {useRouter} from "next/navigation"
2020
import {Keyboard} from "@capacitor/keyboard"
2121
import {LiveUpdate} from "@capawesome/capacitor-live-update"
22+
import {IS_VERCEL} from "common/hosting/constants"
2223

2324
if (Capacitor.isNativePlatform()) {
2425
// Only runs on iOS/Android native
@@ -70,8 +71,7 @@ const logoFont = Major_Mono_Display({
7071
// })
7172

7273
function printBuildInfo() {
73-
// These are undefined if e.g. dev server
74-
if (process.env.NEXT_PUBLIC_VERCEL_ENV) {
74+
if (IS_VERCEL) {
7575
const env = process.env.NEXT_PUBLIC_VERCEL_ENV
7676
const msg = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE
7777
const owner = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER

web/pages/settings.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {NotificationSettings} from "web/components/notifications";
1818
import ThemeIcon from "web/components/theme-icon";
1919
import {WithPrivateUser} from "web/components/user/with-user";
2020
import {sendPasswordReset} from "web/lib/firebase/password";
21+
import {AboutSettings} from "web/components/about-settings";
2122

2223
export default function NotificationsPage() {
2324
useRedirectIfSignedOut()
@@ -30,6 +31,7 @@ export default function NotificationsPage() {
3031
tabs={[
3132
{title: 'General', content: <GeneralSettings/>},
3233
{title: 'Notifications', content: <NotificationSettings/>},
34+
{title: 'About', content: <AboutSettings/>},
3335
]}
3436
trackingName={'settings page'}
3537
/>

0 commit comments

Comments
 (0)