11// Vendored from https://github.com/microsoft/code-push/blob/master/src/script/acquisition-sdk.ts (archived, MIT licensed)
22
3- import { UpdateCheckResponse , UpdateCheckRequest , DeploymentStatusReport , DownloadReport } from "./types" ;
3+ import { UpdateCheckResponse , UpdateCheckRequest , DeploymentStatusReport , DownloadReport , DownloadStatus } from "./types" ;
44import { CodePushHttpError , CodePushDeployStatusError , CodePushPackageError } from "./code-push-error"
55
66export namespace Http {
@@ -35,6 +35,11 @@ export interface RemotePackage extends Package {
3535 downloadUrl : string ;
3636}
3737
38+ export interface DownloadedPackage extends Package {
39+ downloadDurationMs ?: number ;
40+ status : DownloadStatus ;
41+ }
42+
3843export interface NativeUpdateNotification {
3944 updateAppVersion : boolean ; // Always true
4045 appVersion : string ;
@@ -59,6 +64,11 @@ export class AcquisitionStatus {
5964 public static DeploymentFailed = "DeploymentFailed" ;
6065}
6166
67+ export class DownloadAcquisitionStatus {
68+ public static Succeeded : DownloadStatus = "DownloadSucceeded" ;
69+ public static Failed : DownloadStatus = "DownloadFailed" ;
70+ }
71+
6272export class AcquisitionManager {
6373 private readonly BASE_URL_PART = "appcenter.ms" ;
6474 private _appVersion : string ;
@@ -235,7 +245,7 @@ export class AcquisitionManager {
235245 } ) ;
236246 }
237247
238- public reportStatusDownload ( downloadedPackage : Package , callback ?: Callback < void > ) : void {
248+ public reportStatusDownload ( downloadedPackage : DownloadedPackage , callback ?: Callback < void > ) : void {
239249 if ( AcquisitionManager . _apiCallsDisabled ) {
240250 console . log ( `[CodePush] Api calls are disabled, skipping API call` ) ;
241251 callback ( /*error*/ null , /*not used*/ null ) ;
@@ -246,7 +256,9 @@ export class AcquisitionManager {
246256 var body : DownloadReport = {
247257 client_unique_id : this . _clientUniqueId ,
248258 deployment_key : this . _deploymentKey ,
249- label : downloadedPackage . label
259+ label : downloadedPackage . label ,
260+ download_duration_ms : downloadedPackage . downloadDurationMs ,
261+ status : downloadedPackage . status
250262 } ;
251263
252264 this . _httpRequester . request ( Http . Verb . POST , url , JSON . stringify ( body ) , ( error : Error , response : Http . Response ) : void => {
0 commit comments