11import { WithPrivateUser } from "web/components/user/with-user" ;
22import { PrivateUser } from "common/user" ;
33import { Col } from "web/components/layout/col" ;
4- import { IS_VERCEL } from "common/hosting/constants" ;
5- import Link from "next/link" ;
4+ import { HOSTING_ENV , IS_VERCEL } from "common/hosting/constants" ;
5+ import { Capacitor } from "@capacitor/core" ;
6+ import { LiveUpdate } from "@capawesome/capacitor-live-update" ;
7+ import { useEffect , useState } from "react" ;
8+ import { App } from "@capacitor/app" ;
9+ import { api } from "web/lib/api" ;
10+ import { githubRepo } from "common/constants" ;
11+ import { CustomLink } from "web/components/links" ;
612
713export const AboutSettings = ( ) => (
814 < WithPrivateUser >
@@ -13,27 +19,88 @@ export const AboutSettings = () => (
1319const LoadedAboutSettings = ( props : {
1420 privateUser : PrivateUser ,
1521} ) => {
16- const { privateUser } = props
22+ const { } = props
1723
18- return < Col >
24+ return < Col className = { 'custom-link' } >
1925 < WebBuildInfo />
26+ < AndroidInfo />
27+ < BackendInfo />
28+ < RuntimeInfo />
2029 </ Col >
2130}
2231
2332const WebBuildInfo = ( ) => {
2433 if ( ! IS_VERCEL ) return
2534 const env = process . env . NEXT_PUBLIC_VERCEL_ENV
2635 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
2936 const sha = process . env . NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
3037 const deploymentId = process . env . NEXT_PUBLIC_VERCEL_DEPLOYMENT_ID
31- const url = `https://github.com/ ${ owner } / ${ repo } /commit/${ sha } `
38+ const url = `${ githubRepo } /commit/${ sha } `
3239 return < Col >
3340 < h3 > Web build (Vercel)</ h3 >
34- < p > Commit SHA: < Link href = { url } > { sha } </ Link > </ p >
41+ < p > Commit SHA: < CustomLink href = { url } > { sha } </ CustomLink > </ p >
3542 < p > Commit message: { msg } </ p >
3643 < p > Vercel deployment ID: { deploymentId } </ p >
3744 < p > Environment: { env } </ p >
3845 </ Col >
3946}
47+
48+ const AndroidInfo = ( ) => {
49+ if ( ! Capacitor . isNativePlatform ( ) ) return
50+ const liveUpdateInfo = {
51+ commitSha : process . env . CAPAWESOME_BUILD_GIT_COMMIT_SHA || 'N/A' ,
52+ commitMessage : process . env . CAPAWESOME_BUILD_GIT_COMMIT_MESSAGE || 'N/A' ,
53+ gitRef : process . env . CAPAWESOME_BUILD_GIT_REF || 'N/A' ,
54+ } ;
55+ console . log ( `Current Commit SHA: ${ liveUpdateInfo . commitSha } ` ) ;
56+ const [ liveUpdateBundleId , setLiveUpdateBundleId ] = useState < string | null > ( null )
57+ const [ androidAppVersion , setAndroidAppVersion ] = useState < string | null > ( null )
58+ const [ androidBuildNumber , setAndroidBuildNumber ] = useState < string | null > ( null )
59+ useEffect ( ( ) => {
60+ const load = async ( ) => {
61+ const liveUpdateBundle = await LiveUpdate . getCurrentBundle ( )
62+ console . log ( 'liveUpdateBundle' , liveUpdateBundle )
63+ setLiveUpdateBundleId ( liveUpdateBundle . bundleId )
64+ alert ( liveUpdateBundle )
65+
66+ const info = await App . getInfo ( )
67+ setAndroidAppVersion ( info . version )
68+ setAndroidBuildNumber ( info . build )
69+ }
70+ load ( )
71+ } , [ ] )
72+ return < Col >
73+ < h3 > Android (Capacitor / Capawesome)</ h3 >
74+ < p > App version (Android): { androidAppVersion } </ p >
75+ < p > Native build number (Android): { androidBuildNumber } </ p >
76+ < p > Live update build ID (Capawesome): { liveUpdateBundleId } </ p >
77+ < p > Live update commit
78+ (Capawesome): { liveUpdateInfo . commitSha } , { liveUpdateInfo . commitMessage } , { liveUpdateInfo . gitRef } </ p >
79+ < p > Env: { JSON . stringify ( Object . fromEntries ( Object . entries ( process . env ) . sort ( ) ) , null , 2 ) } </ p >
80+ </ Col >
81+ }
82+
83+ const BackendInfo = ( ) => {
84+ const [ info , setInfo ] = useState < any > ( { } )
85+ useEffect ( ( ) => {
86+ api ( 'health' ) . then ( setInfo )
87+ } , [ ] )
88+ console . log ( 'Backend info' , info )
89+ const gitInfo = info . git || { }
90+ const sha = gitInfo . revision
91+ const commitDate = gitInfo . commitDate
92+ const url = `${ githubRepo } /commit/${ sha } `
93+ return < Col >
94+ < h3 > Backend</ h3 >
95+ < p > API version: { info . version } </ p >
96+ { sha && < p > API commit SHA: < CustomLink href = { url } > { sha } </ CustomLink > </ p > }
97+ { commitDate && < p > API commit date: { commitDate } </ p > }
98+ </ Col >
99+ }
100+
101+ const RuntimeInfo = ( ) => {
102+ return < Col >
103+ < h3 > Runtime</ h3 >
104+ < p > Platform: { IS_VERCEL ? 'Web' : Capacitor . isNativePlatform ( ) ? 'Android' : HOSTING_ENV } </ p >
105+ </ Col >
106+ }
0 commit comments