Skip to content

Commit baea134

Browse files
committed
feat: add tracking for client update download start event
1 parent 4932e44 commit baea134

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/backend/metrics/types.ts

+10
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,15 @@ export interface ClientUpdateNotified {
399399
sensitiveProperties?: never
400400
}
401401

402+
export interface ClientUpdateDownloading {
403+
event: 'Downloading Client Update'
404+
properties: {
405+
currentVersion: string
406+
newVersion: string
407+
}
408+
sensitiveProperties?: never
409+
}
410+
402411
export interface ClientUpdateError {
403412
event: 'Client Update Error'
404413
properties: {
@@ -460,6 +469,7 @@ export type PossibleMetricPayloads =
460469
| RewardClaimSuccess
461470
| RewardClaimError
462471
| ClientUpdateNotified
472+
| ClientUpdateDownloading
463473
| ClientUpdateError
464474
| ClientUpdateDownloaded
465475
| PatchingStarted

src/backend/updater/updater.ts

+15
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ autoUpdater.autoInstallOnAppQuit = true
2121

2222
let isAppUpdating = false
2323
let hasUpdated = false
24+
let hasReportedDownloadStart = false
2425

2526
let updateAttempts = 0
2627
const MAX_UPDATE_ATTEMPTS = 10
@@ -73,6 +74,19 @@ autoUpdater.on('update-available', async (info) => {
7374
// log download progress
7475
autoUpdater.on('download-progress', (progress) => {
7576
isAppUpdating = true
77+
78+
// Track download start only once
79+
if (!hasReportedDownloadStart) {
80+
trackEvent({
81+
event: 'Downloading Client Update',
82+
properties: {
83+
currentVersion: autoUpdater.currentVersion.version,
84+
newVersion
85+
}
86+
})
87+
hasReportedDownloadStart = true
88+
}
89+
7690
logInfo(
7791
'Downloading HyperPlay update...' +
7892
`Download speed: ${progress.bytesPerSecond}, ` +
@@ -88,6 +102,7 @@ autoUpdater.on('update-downloaded', async () => {
88102
logInfo('The App update was downloaded', LogPrefix.AutoUpdater)
89103
hasUpdated = true
90104
isAppUpdating = false
105+
hasReportedDownloadStart = false // Reset for potential future updates
91106

92107
trackEvent({
93108
event: 'Client Update Downloaded',

0 commit comments

Comments
 (0)