@@ -253,9 +253,11 @@ async function tryReportStatus(statusReport, retryOnAppResume) {
253253 const label = statusReport . package . label ;
254254 if ( statusReport . status === "DeploymentSucceeded" ) {
255255 log ( `Reporting CodePush update success (${ label } )` ) ;
256+ sharedCodePushOptions ?. onUpdateSuccess ( label ) ;
256257 } else {
257258 log ( `Reporting CodePush update rollback (${ label } )` ) ;
258259 await NativeCodePush . setLatestRollbackInfo ( statusReport . package . packageHash ) ;
260+ sharedCodePushOptions ?. onUpdateRollback ( label ) ;
259261 }
260262 }
261263
@@ -584,6 +586,10 @@ let CodePush;
584586 * setReleaseHistoryFetcher(releaseHistoryFetcherFunction: releaseHistoryFetcher | undefined): void,
585587 * updateChecker: updateChecker | undefined,
586588 * 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,
587593 * }}
588594 */
589595const sharedCodePushOptions = {
@@ -598,6 +604,18 @@ const sharedCodePushOptions = {
598604 if ( typeof updateCheckerFunction !== 'function' ) throw new Error ( 'Please pass a function to updateChecker' ) ;
599605 this . updateChecker = updateCheckerFunction ;
600606 } ,
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+ } ,
601619}
602620
603621function codePushify ( options = { } ) {
@@ -627,6 +645,10 @@ function codePushify(options = {}) {
627645 sharedCodePushOptions . setReleaseHistoryFetcher ( options . releaseHistoryFetcher ) ;
628646 sharedCodePushOptions . setUpdateChecker ( options . updateChecker ) ;
629647
648+ // set telemetry callbacks
649+ sharedCodePushOptions . setOnUpdateSuccess ( options . onUpdateSuccess ) ;
650+ sharedCodePushOptions . setOnUpdateRollback ( options . onUpdateRollback ) ;
651+
630652 const decorator = ( RootComponent ) => {
631653 class CodePushComponent extends React . Component {
632654 constructor ( props ) {
0 commit comments