Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Migration: Add A/B test check before showing certain UI/UX updates #97572

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move logic into a hook
  • Loading branch information
sixhours committed Dec 19, 2024
commit bcd6853cc69ba20821b3ecbbc7c8b19e6ade06f0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useExperiment } from 'calypso/lib/explat';

export function useMigrationExperiment() {
const [ , experimentAssignment ] = useExperiment(
'calypso_signup_onboarding_site_migration_flow_202501_v1'
);

return 'treatment' === experimentAssignment?.variationName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { HOW_TO_MIGRATE_OPTIONS } from 'calypso/landing/stepper/constants';
import { useQuery } from 'calypso/landing/stepper/hooks/use-query';
import { useSite } from 'calypso/landing/stepper/hooks/use-site';
import { recordTracksEvent } from 'calypso/lib/analytics/tracks';
import { useExperiment } from 'calypso/lib/explat';
import { usePresalesChat } from 'calypso/lib/presales-chat';
import useHostingProviderName from 'calypso/site-profiler/hooks/use-hosting-provider-name';
import { useMigrationExperiment } from '../../hooks/use-migration-experiment';
import FlowCard from '../components/flow-card';
import { DIYOption } from './diy-option';
import type { StepProps } from '../../types';
Expand All @@ -27,10 +27,7 @@ interface Props extends StepProps {

const SiteMigrationHowToMigrate: FC< Props > = ( props ) => {
const { navigation, headerText, stepName, subHeaderText } = props;
const [ , experimentAssignment ] = useExperiment(
'calypso_signup_onboarding_site_migration_flow_202501_v1'
);
const isMigrationExperimentEnabled = 'treatment' === experimentAssignment?.variationName;
const isMigrationExperimentEnabled = useMigrationExperiment();
const translate = useTranslate();
const importSiteQueryParam = useQuery().get( 'from' ) || '';
const site = useSite();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { useAnalyzeUrlQuery } from 'calypso/data/site-profiler/use-analyze-url-q
import { useQuery } from 'calypso/landing/stepper/hooks/use-query';
import { useSiteSlug } from 'calypso/landing/stepper/hooks/use-site-slug';
import { recordTracksEvent } from 'calypso/lib/analytics/tracks';
import { useExperiment } from 'calypso/lib/explat';
import wpcom from 'calypso/lib/wp';
import { GUIDED_ONBOARDING_FLOW_REFERRER } from 'calypso/signup/steps/initial-intent/constants';
import { useMigrationExperiment } from '../../hooks/use-migration-experiment';
import { useSitePreviewMShotImageHandler } from '../site-migration-instructions/site-preview/hooks/use-site-preview-mshot-image-handler';
import type { Step } from '../../types';
import type { UrlData } from 'calypso/blocks/import/types';
Expand Down Expand Up @@ -94,11 +94,7 @@ export const Analyzer: FC< Props > = ( { onComplete, onSkip, hideImporterListLin
isFetched,
} = useAnalyzeUrlQuery( siteURL, siteURL !== '' );

const [ , experimentAssignment ] = useExperiment(
'calypso_signup_onboarding_site_migration_flow_202501_v1'
);

const isMigrationExperimentEnabled = 'treatment' === experimentAssignment?.variationName;
const isMigrationExperimentEnabled = useMigrationExperiment();

useEffect( () => {
if ( siteInfo ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useMigrationStickerMutation } from 'calypso/data/site-migration/use-mig
import { useHostingProviderUrlDetails } from 'calypso/data/site-profiler/use-hosting-provider-url-details';
import { useSite } from 'calypso/landing/stepper/hooks/use-site';
import { recordTracksEvent } from 'calypso/lib/analytics/tracks';
import { useExperiment } from 'calypso/lib/explat';
import { useMigrationExperiment } from '../../hooks/use-migration-experiment';
import FlowCard from '../components/flow-card';
import type { Step } from '../../types';
import './style.scss';
Expand All @@ -29,11 +29,7 @@ const SiteMigrationImportOrMigrate: Step = function ( { navigation } ) {

let options;

const [ , experimentAssignment ] = useExperiment(
'calypso_signup_onboarding_site_migration_flow_202501_v1'
);

const isMigrationExperimentEnabled = 'treatment' === experimentAssignment?.variationName;
const isMigrationExperimentEnabled = useMigrationExperiment();

if ( isMigrationExperimentEnabled ) {
const badgeText = isBusinessPlan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { useQuery } from 'calypso/landing/stepper/hooks/use-query';
import { useSite } from 'calypso/landing/stepper/hooks/use-site';
import { useSiteSlug } from 'calypso/landing/stepper/hooks/use-site-slug';
import { recordTracksEvent } from 'calypso/lib/analytics/tracks';
import { useExperiment } from 'calypso/lib/explat';
import { MigrationAssistanceModal } from '../../components/migration-assistance-modal';
import { useMigrationExperiment } from '../../hooks/use-migration-experiment';
import type { StepProps } from '../../types';
import './style.scss';

Expand All @@ -39,10 +39,7 @@ const SiteMigrationUpgradePlan: FC< Props > = ( {
customizedActionButtons,
...props
} ) => {
const [ , experimentAssignment ] = useExperiment(
'calypso_signup_onboarding_site_migration_flow_202501_v1'
);
const showVariants = 'treatment' === experimentAssignment?.variationName;
const showVariants = useMigrationExperiment();
const { onSkip, skipLabelText, skipPosition } = props;
const siteItem = useSite();
const siteSlug = useSiteSlug();
Expand Down
Loading