From 90f6b7bcb3dcd6699fbbc87207ff9f758ac46f00 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Sun, 16 Mar 2025 00:04:39 +0800 Subject: [PATCH] Add download duration and error reporting to Pushy class --- src/client.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index fd84c4b..b11b5d4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -353,6 +353,7 @@ export class Pushy { if (Pushy.progressHandlers[hash]) { return; } + const patchStartTime = Date.now(); if (onDownloadProgress) { // @ts-expect-error harmony not in existing platforms if (Platform.OS === 'harmony') { @@ -458,9 +459,18 @@ export class Pushy { } return; } else { + const duration = Date.now() - patchStartTime; + const data: Record = { + newVersion: hash, + diff: succeeded, + duration, + }; + if (errorMessages.length > 0) { + data.error = errorMessages.join(';'); + } this.report({ type: 'downloadSuccess', - data: { newVersion: hash, diff: succeeded }, + data, }); } log(`downloaded ${succeeded} hash:`, hash);