@@ -3,6 +3,7 @@ import { format as formatDate } from 'date-fns';
33
44import { serverVersion , desktopVersion , UI_VERSION } from './services/service-versions' ;
55import { delay } from './util/promise' ;
6+ import { DesktopApi } from './services/desktop-api' ;
67
78const POSTHOG_KEY = process . env . POSTHOG_KEY ;
89const enabled = ! ! POSTHOG_KEY && navigator . doNotTrack !== "1" ;
@@ -36,7 +37,10 @@ export function initMetrics() {
3637 // every single page separately, who cares. Try to wait for initialization first though,
3738 // so we can see the server version etc. We might not track <10s sessions - again who cares.
3839 Promise . race ( [
39- serverVersion ,
40+ Promise . all ( [
41+ DesktopApi . waitUntilDesktopApiReady ?.( ) ,
42+ serverVersion
43+ ] ) ,
4044 delay ( 10_000 )
4145 ] ) . then ( ( ) => {
4246 posthog . capture ( '$pageview' , {
@@ -69,13 +73,34 @@ if (isFirstRunToday) localStorage.setItem('last-run-date', today);
6973// This is passed via $set_once on all Posthog events, and the session collects metadata once it's
7074// available. These values never change as all metrics are anonymous - there's no connection between
7175// sessions, so the desktop/server version is always fixed.
72- const sessionData = ( ) => ( {
73- 'first-run' : isFirstRun ,
74- 'first-run-today' : isFirstRunToday ,
75- 'ui-version' : UI_VERSION ,
76- 'server-version' : serverVersion . state === 'fulfilled' ? serverVersion . value : undefined ,
77- 'desktop-version' : desktopVersion . state === 'fulfilled' ? desktopVersion . value : undefined ,
78- } ) ;
76+ const sessionData = ( ) => {
77+ const desktopDetails = DesktopApi . getDeviceInfo ?.( ) ;
78+
79+ // We collect some data here, but we do our best to make sure it's anonymous and we couldn't
80+ // track users by the data here even if we wanted to. We're looking for very general patterns
81+ // (there's still lots of Windows 10 users, most Mac users are on ARM now) and we don't want
82+ // any particularly unique values in here.
83+
84+ return {
85+ // These are booleans - not dates, just used to work out a rough daily new/existing user count.
86+ 'first-run' : isFirstRun ,
87+ 'first-run-today' : isFirstRunToday ,
88+
89+ // Current app versions - not a fingerprinting vector since they change very frequently and
90+ // in concert across the whole userbase.
91+ 'ui-version' : UI_VERSION ,
92+ 'server-version' : serverVersion . state === 'fulfilled' ? serverVersion . value : undefined ,
93+ 'desktop-version' : desktopVersion . state === 'fulfilled' ? desktopVersion . value : undefined ,
94+
95+ // Various platform details we use to judge which platforms to support/drop. These should
96+ // not be a significant fingerprinting vector - there's relatively few values in practice,
97+ // and we actively simplify them (to drop patch versions etc) in the desktop app.
98+ 'platform' : desktopDetails ?. platform , // E.g. Windows
99+ 'platform-release' : desktopDetails ?. release , // E.g. Windows 10
100+ 'runtime-arch' : desktopDetails ?. runtimeArch , // E.g. x64
101+ 'real-arch' : desktopDetails ?. realArch // E.g. actually ARM64 (on Mac with Rosetta)
102+ } ;
103+ } ;
79104
80105const normalizeUrl = ( url : string ) =>
81106 url
0 commit comments