Skip to content

Commit

Permalink
Revert "AB test for updated Premium plan bump offer (#40826)" (#41172)
Browse files Browse the repository at this point in the history
This reverts commit c0d97fb.
  • Loading branch information
niranjan-uma-shankar authored Apr 16, 2020
1 parent 9292597 commit 370157b
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 123 deletions.
9 changes: 0 additions & 9 deletions client/lib/abtest/active-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,4 @@ export default {
},
defaultVariation: 'control',
},
showPremiumPlanBump: {
datestamp: '20200402',
variations: {
variantShowPlanBump: 50,
control: 50,
},
defaultVariation: 'control',
allowExistingUsers: true,
},
};
3 changes: 0 additions & 3 deletions client/my-sites/checkout/checkout-system-decider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default function CheckoutSystemDecider( {
isComingFromSignup,
isComingFromGutenboarding,
isGutenboardingCreate,
isComingFromUpsell,
plan,
selectedSite,
reduxStore,
Expand Down Expand Up @@ -80,7 +79,6 @@ export default function CheckoutSystemDecider( {
feature={ selectedFeature }
plan={ plan }
cart={ cart }
isComingFromUpsell={ isComingFromUpsell }
/>
</StripeHookProvider>
);
Expand All @@ -95,7 +93,6 @@ export default function CheckoutSystemDecider( {
isComingFromSignup={ isComingFromSignup }
isComingFromGutenboarding={ isComingFromGutenboarding }
isGutenboardingCreate={ isGutenboardingCreate }
isComingFromUpsell={ isComingFromUpsell }
plan={ plan }
selectedSite={ selectedSite }
reduxStore={ reduxStore }
Expand Down
3 changes: 1 addition & 2 deletions client/my-sites/checkout/checkout/checkout-container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class CheckoutContainer extends React.Component {
shouldShowCart = true,
clearTransaction,
isComingFromGutenboarding,
isComingFromUpsell,
} = this.props;

const TransactionData = clearTransaction ? CartData : CheckoutData;
Expand Down Expand Up @@ -111,7 +110,7 @@ class CheckoutContainer extends React.Component {
reduxStore={ reduxStore }
redirectTo={ redirectTo }
upgradeIntent={ upgradeIntent }
hideNudge={ isComingFromGutenboarding || isComingFromUpsell }
hideNudge={ isComingFromGutenboarding }
>
{ this.props.children }
</Checkout>
Expand Down
41 changes: 11 additions & 30 deletions client/my-sites/checkout/checkout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import { isRequestingPlans } from 'state/plans/selectors';
import { isApplePayAvailable } from 'lib/web-payment';
import PageViewTracker from 'lib/analytics/page-view-tracker';
import isAtomicSite from 'state/selectors/is-site-automated-transfer';
import getPreviousPath from 'state/selectors/get-previous-path.js';
import config from 'config';
import { loadTrackingTool } from 'state/analytics/actions';
import {
Expand All @@ -93,7 +94,6 @@ import {
} from 'signup/utils';
import { isExternal } from 'lib/url';
import { withLocalizedMoment } from 'components/localized-moment';
import { abtest } from 'lib/abtest';

/**
* Style dependencies
Expand Down Expand Up @@ -441,42 +441,26 @@ export class Checkout extends React.Component {
}
}

maybeShowPlanBumpOfferConcierge( receiptId, stepResult ) {
const { cart, selectedSiteSlug } = this.props;

if ( hasPersonalPlan( cart ) && stepResult && isEmpty( stepResult.failed_purchases ) ) {
if ( 'variantShowPlanBump' === abtest( 'showPremiumPlanBump' ) ) {
return `/checkout/${ selectedSiteSlug }/offer-plan-upgrade/premium/${ receiptId }`;
}
}

return;
}

maybeRedirectToConciergeNudge( pendingOrReceiptId, stepResult, shouldHideUpsellNudges ) {
maybeRedirectToConciergeNudge( pendingOrReceiptId ) {
// Using hideNudge prop will disable any redirect to Nudge
if ( this.props.hideNudge || shouldHideUpsellNudges ) {
if ( this.props.hideNudge ) {
return;
}

const { cart, selectedSiteSlug } = this.props;
const { cart, selectedSiteSlug, previousRoute } = this.props;

// If the user has upgraded a plan from seeing our upsell (we find this by checking the previous route is /offer-plan-upgrade),
// then skip this section so that we do not show further upsells.
if (
config.isEnabled( 'upsell/concierge-session' ) &&
! hasConciergeSession( cart ) &&
! hasJetpackPlan( cart ) &&
( hasBloggerPlan( cart ) || hasPersonalPlan( cart ) || hasPremiumPlan( cart ) )
( hasBloggerPlan( cart ) || hasPersonalPlan( cart ) || hasPremiumPlan( cart ) ) &&
! previousRoute.includes( `/checkout/${ selectedSiteSlug }/offer-plan-upgrade` )
) {
// A user just purchased one of the qualifying plans
// Show them the concierge session upsell page

const upgradePath = this.maybeShowPlanBumpOfferConcierge( pendingOrReceiptId, stepResult );
if ( upgradePath ) {
return upgradePath;
}

// The conciergeUpsellDial test is used when we need to quickly dial back the volume of concierge sessions
// being offered and so sold, to be inline with HE availability.
// To dial back, uncomment the condition below and modify the test config.
Expand All @@ -486,7 +470,7 @@ export class Checkout extends React.Component {
}
}

getCheckoutCompleteRedirectPath = ( shouldHideUpsellNudges = false ) => {
getCheckoutCompleteRedirectPath = () => {
// TODO: Cleanup and simplify this function.
// I wouldn't be surprised if it doesn't work as intended in some scenarios.
// Especially around the Concierge / Checklist logic.
Expand Down Expand Up @@ -579,11 +563,7 @@ export class Checkout extends React.Component {
return `${ signupDestination }/${ pendingOrReceiptId }`;
}

const redirectPathForConciergeUpsell = this.maybeRedirectToConciergeNudge(
pendingOrReceiptId,
stepResult,
shouldHideUpsellNudges
);
const redirectPathForConciergeUpsell = this.maybeRedirectToConciergeNudge( pendingOrReceiptId );
if ( redirectPathForConciergeUpsell ) {
return redirectPathForConciergeUpsell;
}
Expand All @@ -608,7 +588,7 @@ export class Checkout extends React.Component {
window.location.href = redirectUrl;
}

handleCheckoutCompleteRedirect = ( shouldHideUpsellNudges = false ) => {
handleCheckoutCompleteRedirect = () => {
let product, purchasedProducts, renewalItem;

const {
Expand All @@ -620,7 +600,7 @@ export class Checkout extends React.Component {
translate,
} = this.props;

const redirectPath = this.getCheckoutCompleteRedirectPath( shouldHideUpsellNudges );
const redirectPath = this.getCheckoutCompleteRedirectPath();
const destinationFromCookie = retrieveSignupDestination();

this.props.clearPurchases();
Expand Down Expand Up @@ -938,6 +918,7 @@ export default connect(
isPlansListFetching: isRequestingPlans( state ),
isSitePlansListFetching: isRequestingSitePlans( state, selectedSiteId ),
planSlug: getUpgradePlanSlugFromPath( state, selectedSiteId, props.product ),
previousRoute: getPreviousPath( state ),
isJetpackNotAtomic:
isJetpackSite( state, selectedSiteId ) && ! isAtomicSite( state, selectedSiteId ),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export default function CompositeCheckout( {
purchaseId,
cart,
couponCode: couponCodeFromUrl,
isComingFromUpsell,
} ) {
const translate = useTranslate();
const isJetpackNotAtomic = useSelector(
Expand All @@ -99,7 +98,6 @@ export default function CompositeCheckout( {
const { stripe, stripeConfiguration, isStripeLoading, stripeLoadingError } = useStripe();
const isLoadingCartSynchronizer =
cart && ( ! cart.hasLoadedFromServer || cart.hasPendingServerUpdates );
const hideNudge = isComingFromUpsell;

const getThankYouUrl = useGetThankYouUrl( {
siteSlug,
Expand All @@ -110,7 +108,6 @@ export default function CompositeCheckout( {
isJetpackNotAtomic,
product,
siteId,
hideNudge,
} );
const reduxDispatch = useDispatch();
const recordEvent = useCallback( createAnalyticsEventHandler( reduxDispatch ), [] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ describe( 'getThankYouPageUrl', () => {
expect( url ).toBe( '/checkout/thank-you/foo.bar/1234abcd' );
} );

it( 'redirects to thank you page if concierge and jetpack are not in the cart, personal is in the cart, but hideNudge is true', () => {
it( 'redirects to thank you page if concierge and jetpack are not in the cart, personal is in the cart, but the previous route is the nudge', () => {
isEnabled.mockImplementation( flag => flag === 'upsell/concierge-session' );
const cart = {
products: [
Expand All @@ -507,7 +507,7 @@ describe( 'getThankYouPageUrl', () => {
siteSlug: 'foo.bar',
cart,
receiptId: '1234abcd',
hideNudge: true,
previousRoute: '/checkout/foo.bar/offer-plan-upgrade/premium/1234abcd',
} );
expect( url ).toBe( '/checkout/thank-you/foo.bar/1234abcd' );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useCallback } from 'react';
import { useSelector } from 'react-redux';
import { defaultRegistry } from '@automattic/composite-checkout';
import debugFactory from 'debug';
import { isEmpty } from 'lodash';

const { select } = defaultRegistry;
const debug = debugFactory( 'calypso:composite-checkout-thank-you' );
Expand All @@ -33,7 +32,7 @@ import { JETPACK_BACKUP_PRODUCTS } from 'lib/products-values/constants';
import { persistSignupDestination, retrieveSignupDestination } from 'signup/utils';
import { getSelectedSite } from 'state/ui/selectors';
import isEligibleForSignupDestination from 'state/selectors/is-eligible-for-signup-destination';
import { abtest } from 'lib/abtest';
import getPreviousPath from 'state/selectors/get-previous-path.js';

export function getThankYouPageUrl( {
siteSlug,
Expand All @@ -48,10 +47,8 @@ export function getThankYouPageUrl( {
product,
getUrlFromCookie = retrieveSignupDestination,
saveUrlToCookie = persistSignupDestination,
previousRoute,
isEligibleForSignupDestinationResult,
hideNudge,
didPurchaseFail,
isTransactionResultEmpty,
} ) {
// If we're given an explicit `redirectTo` query arg, make sure it's either internal
// (i.e. on WordPress.com), or a Jetpack or WP.com site's block editor (in wp-admin).
Expand Down Expand Up @@ -121,9 +118,7 @@ export function getThankYouPageUrl( {
pendingOrReceiptId,
cart,
siteSlug,
hideNudge,
didPurchaseFail,
isTransactionResultEmpty,
previousRoute,
} );
if ( redirectPathForConciergeUpsell ) {
return redirectPathForConciergeUpsell;
Expand Down Expand Up @@ -184,56 +179,19 @@ function getFallbackDestination( {
return '/';
}

function maybeShowPlanBumpOfferConcierge( {
pendingOrReceiptId,
cart,
siteSlug,
didPurchaseFail,
isTransactionResultEmpty,
} ) {
if ( hasPersonalPlan( cart ) && ! isTransactionResultEmpty && ! didPurchaseFail ) {
if ( 'variantShowPlanBump' === abtest( 'showPremiumPlanBump' ) ) {
return `/checkout/${ siteSlug }/offer-plan-upgrade/premium/${ pendingOrReceiptId }`;
}
}

return;
}

function getRedirectUrlForConciergeNudge( {
pendingOrReceiptId,
cart,
siteSlug,
hideNudge,
didPurchaseFail,
isTransactionResultEmpty,
} ) {
if ( hideNudge ) {
return;
}

function getRedirectUrlForConciergeNudge( { pendingOrReceiptId, cart, siteSlug, previousRoute } ) {
// If the user has upgraded a plan from seeing our upsell(we find this by checking the previous route is /offer-plan-upgrade),
// then skip this section so that we do not show further upsells.
if (
config.isEnabled( 'upsell/concierge-session' ) &&
! hasConciergeSession( cart ) &&
! hasJetpackPlan( cart ) &&
( hasBloggerPlan( cart ) || hasPersonalPlan( cart ) || hasPremiumPlan( cart ) )
( hasBloggerPlan( cart ) || hasPersonalPlan( cart ) || hasPremiumPlan( cart ) ) &&
! previousRoute?.includes( `/checkout/${ siteSlug }/offer-plan-upgrade` )
) {
// A user just purchased one of the qualifying plans
// Show them the concierge session upsell page

const upgradePath = maybeShowPlanBumpOfferConcierge( {
pendingOrReceiptId,
cart,
siteSlug,
didPurchaseFail,
isTransactionResultEmpty,
} );
if ( upgradePath ) {
return upgradePath;
}

// The conciergeUpsellDial test is used when we need to quickly dial back the volume of concierge sessions
// being offered and so sold, to be inline with HE availability.
// To dial back, uncomment the condition below and modify the test config.
Expand Down Expand Up @@ -309,21 +267,19 @@ export function useGetThankYouUrl( {
isJetpackNotAtomic,
product,
siteId,
hideNudge,
} ) {
const selectedSiteData = useSelector( state => getSelectedSite( state ) );
const adminUrl = selectedSiteData?.options?.admin_url;
const isEligibleForSignupDestinationResult = useSelector( state =>
isEligibleForSignupDestination( state, siteId, cart )
);
const previousRoute = useSelector( state => getPreviousPath( state ) );

const getThankYouUrl = useCallback( () => {
const transactionResult = select( 'wpcom' ).getTransactionResult();
debug( 'for getThankYouUrl, transactionResult is', transactionResult );
const didPurchaseFail = Object.keys( transactionResult.failed_purchases ?? {} ).length > 0;
const receiptId = transactionResult.receipt_id;
const orderId = transactionResult.order_id;
const isTransactionResultEmpty = isEmpty( transactionResult );

debug( 'getThankYouUrl called with', {
siteSlug,
Expand All @@ -336,10 +292,8 @@ export function useGetThankYouUrl( {
cart,
isJetpackNotAtomic,
product,
previousRoute,
isEligibleForSignupDestinationResult,
hideNudge,
didPurchaseFail,
isTransactionResultEmpty,
} );
const url = getThankYouPageUrl( {
siteSlug,
Expand All @@ -352,14 +306,13 @@ export function useGetThankYouUrl( {
cart,
isJetpackNotAtomic,
product,
previousRoute,
isEligibleForSignupDestinationResult,
hideNudge,
didPurchaseFail,
isTransactionResultEmpty,
} );
debug( 'getThankYouUrl returned', url );
return url;
}, [
previousRoute,
isEligibleForSignupDestinationResult,
siteSlug,
adminUrl,
Expand All @@ -369,7 +322,6 @@ export function useGetThankYouUrl( {
feature,
purchaseId,
cart,
hideNudge,
] );
return getThankYouUrl;
}
1 change: 0 additions & 1 deletion client/my-sites/checkout/controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export function checkout( context, next ) {
isComingFromSignup={ !! context.query.signup }
isComingFromGutenboarding={ !! context.query.preLaunch }
isGutenboardingCreate={ !! context.query.isGutenboardingCreate }
isComingFromUpsell={ !! context.query.upgrade }
plan={ plan }
selectedSite={ selectedSite }
reduxStore={ context.store }
Expand Down
Loading

0 comments on commit 370157b

Please sign in to comment.