1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-07 19:05:13 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Add download duration and error reporting to Pushy class

This commit is contained in:
sunnylqm
2025-03-16 00:04:39 +08:00
parent 828740823d
commit 90f6b7bcb3

View File

@@ -353,6 +353,7 @@ export class Pushy {
if (Pushy.progressHandlers[hash]) { if (Pushy.progressHandlers[hash]) {
return; return;
} }
const patchStartTime = Date.now();
if (onDownloadProgress) { if (onDownloadProgress) {
// @ts-expect-error harmony not in existing platforms // @ts-expect-error harmony not in existing platforms
if (Platform.OS === 'harmony') { if (Platform.OS === 'harmony') {
@@ -458,9 +459,18 @@ export class Pushy {
} }
return; return;
} else { } else {
const duration = Date.now() - patchStartTime;
const data: Record<string, any> = {
newVersion: hash,
diff: succeeded,
duration,
};
if (errorMessages.length > 0) {
data.error = errorMessages.join(';');
}
this.report({ this.report({
type: 'downloadSuccess', type: 'downloadSuccess',
data: { newVersion: hash, diff: succeeded }, data,
}); });
} }
log(`downloaded ${succeeded} hash:`, hash); log(`downloaded ${succeeded} hash:`, hash);