@@ -253,9 +253,11 @@ async function tryReportStatus(statusReport, retryOnAppResume) {
253
253
const label = statusReport . package . label ;
254
254
if ( statusReport . status === "DeploymentSucceeded" ) {
255
255
log ( `Reporting CodePush update success (${ label } )` ) ;
256
+ sharedCodePushOptions ?. onUpdateSuccess ( label ) ;
256
257
} else {
257
258
log ( `Reporting CodePush update rollback (${ label } )` ) ;
258
259
await NativeCodePush . setLatestRollbackInfo ( statusReport . package . packageHash ) ;
260
+ sharedCodePushOptions ?. onUpdateRollback ( label ) ;
259
261
}
260
262
}
261
263
@@ -584,6 +586,10 @@ let CodePush;
584
586
* setReleaseHistoryFetcher(releaseHistoryFetcherFunction: releaseHistoryFetcher | undefined): void,
585
587
* updateChecker: updateChecker | undefined,
586
588
* setUpdateChecker(updateCheckerFunction: updateChecker | undefined): void,
589
+ * onUpdateSuccess: (label: string) => void | undefined,
590
+ * setOnUpdateSuccess(onUpdateSuccessFunction: (label: string) => void | undefined): void,
591
+ * onUpdateRollback: (label: string) => void | undefined,
592
+ * setOnUpdateRollback(onUpdateRollbackFunction: (label: string) => void | undefined): void,
587
593
* }}
588
594
*/
589
595
const sharedCodePushOptions = {
@@ -598,6 +604,18 @@ const sharedCodePushOptions = {
598
604
if ( typeof updateCheckerFunction !== 'function' ) throw new Error ( 'Please pass a function to updateChecker' ) ;
599
605
this . updateChecker = updateCheckerFunction ;
600
606
} ,
607
+ onUpdateSuccess : undefined ,
608
+ setOnUpdateSuccess ( onUpdateSuccessFunction ) {
609
+ if ( ! onUpdateSuccessFunction ) return ;
610
+ if ( typeof onUpdateSuccessFunction !== 'function' ) throw new Error ( 'Please pass a function to onUpdateSuccess' ) ;
611
+ this . onUpdateSuccess = onUpdateSuccessFunction ;
612
+ } ,
613
+ onUpdateRollback : undefined ,
614
+ setOnUpdateRollback ( onUpdateRollbackFunction ) {
615
+ if ( ! onUpdateRollbackFunction ) return ;
616
+ if ( typeof onUpdateRollbackFunction !== 'function' ) throw new Error ( 'Please pass a function to onUpdateRollback' ) ;
617
+ this . onUpdateRollback = onUpdateRollbackFunction ;
618
+ } ,
601
619
}
602
620
603
621
function codePushify ( options = { } ) {
@@ -627,6 +645,10 @@ function codePushify(options = {}) {
627
645
sharedCodePushOptions . setReleaseHistoryFetcher ( options . releaseHistoryFetcher ) ;
628
646
sharedCodePushOptions . setUpdateChecker ( options . updateChecker ) ;
629
647
648
+ // set telemetry callbacks
649
+ sharedCodePushOptions . setOnUpdateSuccess ( options . onUpdateSuccess ) ;
650
+ sharedCodePushOptions . setOnUpdateRollback ( options . onUpdateRollback ) ;
651
+
630
652
const decorator = ( RootComponent ) => {
631
653
class CodePushComponent extends React . Component {
632
654
constructor ( props ) {
0 commit comments