Skip to content

Commit

Permalink
Add try/catch to explats connection
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsreberski committed Aug 5, 2024
1 parent e5fd873 commit baf4292
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,30 @@ const ConnectionStep = ( {

recordEvent( 'jetpack_myjetpack_welcome_banner_connect_site_success' );

await sideloadTracks();
try {
await sideloadTracks();

initializeExPlat();
initializeExPlat();

const { variationName } = await loadExperimentAssignment(
'jetpack_my_jetpack_post_connection_flow_202408'
);
const { variationName } = await loadExperimentAssignment(
'jetpack_my_jetpack_post_connection_flow_202408'
);

if ( variationName !== 'treatment' ) {
// For control or default, we redirect to the connection page as described in the experiment.
window.location.href = 'admin.php?page=my-jetpack#/connection';
}

onUpdateWelcomeFlowExperiment( state => ( {
...state,
variation: variationName as WelcomeFlowExperiment[ 'variation' ], // casting to 'control' or 'treatment'
} ) );
if ( variationName !== 'treatment' ) {
// For control or default, we redirect to the connection page as described in the experiment.
window.location.href = 'admin.php?page=my-jetpack#/connection';
}

resetNotice();
setNotice( NOTICE_SITE_CONNECTED, resetNotice );
onUpdateWelcomeFlowExperiment( state => ( {
...state,
variation: variationName as WelcomeFlowExperiment[ 'variation' ], // casting to 'control' or 'treatment'
} ) );
} finally {
resetNotice();
setNotice( NOTICE_SITE_CONNECTED, resetNotice );

onUpdateWelcomeFlowExperiment( state => ( { ...state, isLoading: false } ) );
onUpdateWelcomeFlowExperiment( state => ( { ...state, isLoading: false } ) );
}
}, [ onActivateSite, onUpdateWelcomeFlowExperiment, recordEvent, resetNotice, setNotice ] );

return (
Expand Down

0 comments on commit baf4292

Please sign in to comment.