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

GF Signup : Experiment Allow Paid Domain redirect For all Domains #80647

Merged
merged 9 commits into from
Aug 24, 2023
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { getTld } from 'calypso/lib/domains';
import { useExperiment } from 'calypso/lib/explat';
import type { DataResponse } from 'calypso/my-sites/plan-features-2023-grid/types';

const useIsCustomDomainAllowedOnFreePlan = (
flowName?: string | null,
domainName?: string
hasPaidDomainName?: boolean
): DataResponse< boolean > => {
const [ isLoadingAssignment, experimentAssignment ] = useExperiment(
'calypso_onboarding_plans_dotblog_on_free_plan_202307',
{
isEligible:
flowName === 'onboarding' && domainName != null && getTld( domainName ) === 'blog',
}
);
const EXPERIMENT_NAME =
flowName === 'onboarding'
? 'calypso_onboarding_plans_paid_domain_on_free_plan'
: 'calypso_onboardingpm_plans_paid_domain_on_free_plan';
aaronyan marked this conversation as resolved.
Show resolved Hide resolved
const [ isLoading, assignment ] = useExperiment( EXPERIMENT_NAME, {
aaronyan marked this conversation as resolved.
Show resolved Hide resolved
isEligible: [ 'onboarding', 'onboarding-pm' ].includes( flowName ?? '' ) && hasPaidDomainName,
} );

return {
isLoading: isLoadingAssignment,
result: experimentAssignment?.variationName === 'treatment',
isLoading,
result: assignment?.variationName === 'treatment',
};
};

Expand Down
10 changes: 5 additions & 5 deletions client/my-sites/plans-features-main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const PlansFeaturesMain = ( {
isSpotlightOnCurrentPlan,
}: PlansFeaturesMainProps ) => {
const [ isFreePlanPaidDomainDialogOpen, setIsFreePlanPaidDomainDialogOpen ] = useState( false );
const [ isFreeFreeUpsellOpen, setIsFreeFreeUpsellOpen ] = useState( false );
const [ isFreePlanFreeDomainDialogOpen, setIsFreePlanFreeDomainDialogOpen ] = useState( false );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated: Renamed a confusing variable.

const [ showPlansComparisonGrid, setShowPlansComparisonGrid ] = useState( false );
const [ masterbarHeight, setMasterbarHeight ] = useState( 0 );
const translate = useTranslate();
Expand All @@ -230,7 +230,7 @@ const PlansFeaturesMain = ( {
const previousRoute = useSelector( ( state: IAppState ) => getPreviousRoute( state ) );
const isCustomDomainAllowedOnFreePlan = useIsCustomDomainAllowedOnFreePlan(
flowName,
paidDomainName
!! paidDomainName
);
const isPlanUpsellEnabledOnFreeDomain = useIsPlanUpsellEnabledOnFreeDomain(
flowName,
Expand Down Expand Up @@ -296,7 +296,7 @@ const PlansFeaturesMain = ( {
return;
}
if ( isPlanUpsellEnabledOnFreeDomain.result ) {
setIsFreeFreeUpsellOpen( true );
setIsFreePlanFreeDomainDialogOpen( true );
return;
}
}
Expand Down Expand Up @@ -570,11 +570,11 @@ const PlansFeaturesMain = ( {
} }
/>
) }
{ isFreeFreeUpsellOpen && (
{ isFreePlanFreeDomainDialogOpen && (
<FreePlanFreeDomainDialog
suggestedPlanSlug={ PLAN_PERSONAL }
freeSubdomain={ resolvedSubdomainName }
onClose={ () => setIsFreeFreeUpsellOpen( false ) }
onClose={ () => setIsFreePlanFreeDomainDialogOpen( false ) }
onFreePlanSelected={ () => {
if ( ! signupFlowSubdomain && wpcomFreeDomainSuggestion.result ) {
setSiteUrlAsFreeDomainSuggestion?.( wpcomFreeDomainSuggestion.result );
Expand Down