Skip to content

Commit

Permalink
Introduce session storage item supporting experiment testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bogiii committed Sep 7, 2024
1 parent 70596fc commit 7e515dd
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const updateLaunchpadSaveModalBrowserConfig = config => {
export const settings = {
render: function LaunchpadSaveModal() {
const [ experimentVariationName, setExperimentVariationName ] = useState();
const sessionVariationName = window.sessionStorage.getItem( 'launchpad_experiment_variation' );

const { isSavingSite, isSavingPost, isCurrentPostPublished, postLink, postType } = useSelect(
select => {
Expand All @@ -64,15 +65,14 @@ export const settings = {

// Fetch the experiment data once when the component mounts
useEffect( () => {
loadExperimentAssignment( 'calypso_onboarding_launchpad_removal_test_2024_08' )
.then( experiment => {
console.log( 'experiment', experiment );
setExperimentVariationName( experiment.variationName );
} )
.catch( error => {
console.error( 'Error loading experiment assignment:', error );
} );
}, [] );
loadExperimentAssignment( 'calypso_onboarding_launchpad_removal_test_2024_08' ).then(
experiment => {
sessionVariationName
? setExperimentVariationName( sessionVariationName )
: setExperimentVariationName( experiment.variationName );
}
);
}, [ sessionVariationName ] );

const prevIsSavingSite = usePrevious( isSavingSite );
const prevIsSavingPost = usePrevious( isSavingPost );
Expand All @@ -87,8 +87,6 @@ export const settings = {
siteIntentOption,
} = window?.Jetpack_LaunchpadSaveModal || {};

console.log( 'Jetpack_LaunchpadSaveModal', window?.Jetpack_LaunchpadSaveModal );

const hideFSENextStepsModalBool = !! hideFSENextStepsModal;

const [ isModalOpen, setIsModalOpen ] = useState( false );
Expand All @@ -107,7 +105,8 @@ export const settings = {
const calypsoHomeUrl = getRedirectUrl( 'calypso-home', {
site: siteFragment,
} );
const primaryActionHref = experimentVariationName === 'control' ? launchPadUrl : calypsoHomeUrl;
const primaryActionHref =
experimentVariationName === 'treatment' ? calypsoHomeUrl : launchPadUrl;
const { tracks } = useAnalytics();

const recordTracksEvent = eventName =>
Expand All @@ -127,7 +126,7 @@ export const settings = {
),
actionButtonHref: primaryActionHref,
actionButtonTracksEvent: 'jetpack_launchpad_save_modal_next_steps',
actionButtonText: 'Bogdan Test',
actionButtonText: __( 'Next Steps', 'jetpack' ),
};

if ( siteIntentOption === 'newsletter' ) {
Expand Down

0 comments on commit 7e515dd

Please sign in to comment.