From baf42926dda234e2793e408534363016de2cadfa Mon Sep 17 00:00:00 2001 From: robertsreberski Date: Mon, 5 Aug 2024 16:02:32 +0200 Subject: [PATCH] Add try/catch to explats connection --- .../welcome-flow/ConnectionStep.tsx | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx index f682e997ba1cf..358260fce50a4 100644 --- a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx +++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx @@ -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 (