Skip to content

Commit

Permalink
Move experiment to Calypso
Browse files Browse the repository at this point in the history
  • Loading branch information
arcangelini committed Nov 25, 2024
1 parent 370a551 commit 6f6a403
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@ import { HelpCenter } from '@automattic/data-stores';
import { useDispatch } from '@wordpress/data';
import { useCallback } from 'react';
import AsyncLoad from 'calypso/components/async-load';
import { useExperiment } from 'calypso/lib/explat';

const HELP_CENTER_STORE = HelpCenter.register();

const AsyncHelpCenter = () => {
const { setShowHelpCenter } = useDispatch( HELP_CENTER_STORE );
const [ isLoading, experimentAssignment ] = useExperiment(
'calypso_helpcenter_new_support_flow'
);

const handleClose = useCallback( () => {
setShowHelpCenter( false );
}, [ setShowHelpCenter ] );

return (
<AsyncLoad require="@automattic/help-center" placeholder={ null } handleClose={ handleClose } />
<AsyncLoad
require="@automattic/help-center"
placeholder={ null }
handleClose={ handleClose }
shouldUseHelpCenterExperience={
! isLoading && experimentAssignment?.variationName === 'treatment'
}
/>
);
};

Expand Down
7 changes: 7 additions & 0 deletions client/layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import EmptyMasterbar from 'calypso/layout/masterbar/empty';
import MasterbarLoggedIn from 'calypso/layout/masterbar/logged-in';
import OfflineStatus from 'calypso/layout/offline-status';
import isA8CForAgencies from 'calypso/lib/a8c-for-agencies/is-a8c-for-agencies';
import { useExperiment } from 'calypso/lib/explat';
import { getGoogleMailServiceFamily } from 'calypso/lib/gsuite';
import isJetpackCloud from 'calypso/lib/jetpack/is-jetpack-cloud';
import { isWcMobileApp, isWpMobileApp } from 'calypso/lib/mobile-app';
Expand Down Expand Up @@ -149,6 +150,9 @@ function HelpCenterLoader( { sectionName, loadHelpCenter, currentRoute } ) {
const selectedSite = useSelector( getSelectedSite );
const primarySiteSlug = useSelector( getPrimarySiteSlug );
const primarySite = useSelector( ( state ) => getSiteBySlug( state, primarySiteSlug ) );
const [ isLoading, experimentAssignment ] = useExperiment(
'calypso_helpcenter_new_support_flow'
);

if ( ! loadHelpCenter ) {
return null;
Expand All @@ -169,6 +173,9 @@ function HelpCenterLoader( { sectionName, loadHelpCenter, currentRoute } ) {
hidden={ sectionName === 'gutenberg-editor' && isDesktop }
onboardingUrl={ onboardingUrl() }
googleMailServiceFamily={ getGoogleMailServiceFamily() }
shouldUseHelpCenterExperience={
! isLoading && experimentAssignment?.variationName === 'treatment'
}
/>
);
}
Expand Down
8 changes: 1 addition & 7 deletions packages/help-center/src/components/help-center.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { initializeAnalytics } from '@automattic/calypso-analytics';
import config from '@automattic/calypso-config';
import { useSelect } from '@wordpress/data';
import { createPortal, useEffect, useRef } from '@wordpress/element';
import { useExperiment } from 'calypso/lib/explat';
/**
* Internal Dependencies
*/
Expand Down Expand Up @@ -83,13 +82,8 @@ const HelpCenter: React.FC< Container > = ( {
export default function ContextualizedHelpCenter(
props: Container & HelpCenterRequiredInformation
) {
// Just testing with the Stepper experiment
const [ isLoadingExperiment, experimentAssignment ] = useExperiment(
'calypso_signup_onboarding_stepper_flow_2'
);
const shouldUseHelpCenterExperience =
config.isEnabled( 'help-center-experience' ) ||
( ! isLoadingExperiment && experimentAssignment?.variationName === 'stepper' );
config.isEnabled( 'help-center-experience' ) || props.shouldUseHelpCenterExperience;

return (
<HelpCenterRequiredContextProvider value={ { ...props, shouldUseHelpCenterExperience } }>
Expand Down
10 changes: 0 additions & 10 deletions packages/help-center/src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,3 @@ declare module '*.svg' {
const content: string;
export default content;
}

// Can be removed after experiment is removed - shouldUseHelpCenterExperience
declare module 'calypso/server/lib/logger';

// Can be removed after experiment is removed - shouldUseHelpCenterExperience
declare module 'calypso/lib/explat' {
export const useExperiment: (
experimentName: string
) => [ boolean, { variationName: string } | undefined ];
}

0 comments on commit 6f6a403

Please sign in to comment.