add: remove email marketing experiment (#41599)

This commit is contained in:
nigeljamesstevenson 2023-11-21 23:22:40 +00:00 committed by GitHub
commit 8ecb684da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 113 deletions

View File

@ -76,27 +76,10 @@ const recordTracksSkipBusinessLocationCompleted = () => {
} );
};
// Temporarily expand the step viewed track for BusinessInfo so that we can include the experiment assignment
// Remove this and change the action back to recordTracksStepViewed when the experiment is over
const recordTracksStepViewedBusinessInfo = (
context: CoreProfilerStateMachineContext,
_event: unknown,
{ action }: { action: unknown }
) => {
const { step } = action as { step: string };
recordEvent( 'coreprofiler_step_view', {
step,
email_marketing_experiment_assignment:
context.emailMarketingExperimentAssignment,
wc_version: getSetting( 'wcVersion' ),
} );
};
const recordTracksIsEmailChanged = (
context: CoreProfilerStateMachineContext,
event: BusinessInfoEvent
) => {
if ( context.emailMarketingExperimentAssignment === 'treatment' ) {
let emailSource, isEmailChanged;
if ( context.onboardingProfile.store_email ) {
emailSource = 'onboarding_profile_store_email'; // from previous entry
@ -117,7 +100,6 @@ const recordTracksIsEmailChanged = (
email_field_prefilled_source: emailSource,
email_field_modified: isEmailChanged,
} );
}
};
const recordTracksBusinessInfoCompleted = (
@ -126,8 +108,6 @@ const recordTracksBusinessInfoCompleted = (
) => {
recordEvent( 'coreprofiler_step_complete', {
step: 'business_info',
email_marketing_experiment_assignment:
context.emailMarketingExperimentAssignment,
wc_version: getSetting( 'wcVersion' ),
} );
@ -227,5 +207,4 @@ export default {
recordSuccessfulPluginInstallation,
recordTracksPluginsInstallationRequest,
recordTracksIsEmailChanged,
recordTracksStepViewedBusinessInfo,
};

View File

@ -34,10 +34,7 @@ import {
USER_STORE_NAME,
WCUser,
} from '@woocommerce/data';
import {
initializeExPlat,
loadExperimentAssignment,
} from '@woocommerce/explat';
import { initializeExPlat } from '@woocommerce/explat';
import { CountryStateOption } from '@woocommerce/onboarding';
import { getAdminLink } from '@woocommerce/settings';
import CurrencyFactory from '@woocommerce/currency';
@ -204,7 +201,6 @@ export type CoreProfilerStateMachineContext = {
persistBusinessInfoRef?: ReturnType< typeof spawn >;
spawnUpdateOnboardingProfileOptionRef?: ReturnType< typeof spawn >;
spawnGeolocationRef?: ReturnType< typeof spawn >;
emailMarketingExperimentAssignment: 'treatment' | 'control';
currentUserEmail: string | undefined;
};
@ -320,12 +316,6 @@ const handleOnboardingProfileOption = assign( {
},
} );
const getMarketingOptInExperimentAssignment = async () => {
return loadExperimentAssignment(
`woocommerce_core_profiler_email_marketing_opt_in_2023_Q4_V1`
);
};
const getCurrentUserEmail = async () => {
const currentUser: WCUser< 'email' > = await resolveSelect(
USER_STORE_NAME
@ -356,17 +346,6 @@ const assignOnboardingProfile = assign( {
) => event.data,
} );
const assignMarketingOptInExperimentAssignment = assign( {
emailMarketingExperimentAssignment: (
_context,
event: DoneInvokeEvent<
Awaited<
ReturnType< typeof getMarketingOptInExperimentAssignment >
>
>
) => event.data.variationName ?? 'control',
} );
const getGeolocation = async ( context: CoreProfilerStateMachineContext ) => {
if ( context.optInDataSharing ) {
return resolveSelect( COUNTRIES_STORE_NAME ).geolocate();
@ -700,7 +679,6 @@ const coreProfilerMachineActions = {
handleCountries,
handleOnboardingProfileOption,
assignOnboardingProfile,
assignMarketingOptInExperimentAssignment,
assignCurrentUserEmail,
persistBusinessInfo,
spawnUpdateOnboardingProfileOption,
@ -715,7 +693,6 @@ const coreProfilerMachineServices = {
getCountries,
getGeolocation,
getOnboardingProfileOption,
getMarketingOptInExperimentAssignment,
getCurrentUserEmail,
getPlugins,
browserPopstateHandler,
@ -753,7 +730,6 @@ export const coreProfilerStateMachineDefinition = createMachine( {
loader: {},
onboardingProfile: {} as OnboardingProfile,
jetpackAuthUrl: undefined,
emailMarketingExperimentAssignment: 'control',
currentUserEmail: undefined,
} as CoreProfilerStateMachineContext,
states: {
@ -1088,23 +1064,6 @@ export const coreProfilerStateMachineDefinition = createMachine( {
},
},
},
marketingOptInExperiment: {
initial: 'fetching',
states: {
fetching: {
invoke: {
src: 'getMarketingOptInExperimentAssignment',
onDone: {
target: 'done',
actions: [
'assignMarketingOptInExperimentAssignment',
],
},
},
},
done: { type: 'final' },
},
},
currentUserEmail: {
initial: 'fetching',
states: {
@ -1140,7 +1099,7 @@ export const coreProfilerStateMachineDefinition = createMachine( {
},
entry: [
{
type: 'recordTracksStepViewedBusinessInfo',
type: 'recordTracksStepViewed',
step: 'business_info',
},
],

View File

@ -98,12 +98,7 @@ export type BusinessInfoContextProps = Pick<
| 'is_agree_marketing'
| 'store_email'
>;
} & Partial<
Pick<
CoreProfilerStateMachineContext,
'emailMarketingExperimentAssignment' | 'currentUserEmail'
>
>;
} & Partial< Pick< CoreProfilerStateMachineContext, 'currentUserEmail' > >;
export const BusinessInfo = ( {
context,
@ -126,7 +121,6 @@ export const BusinessInfo = ( {
is_agree_marketing: isOptInMarketingFromOnboardingProfile,
store_email: storeEmailAddressFromOnboardingProfile,
},
emailMarketingExperimentAssignment,
currentUserEmail,
} = context;
@ -390,7 +384,7 @@ export const BusinessInfo = ( {
</ul>
</Notice>
) }
{ emailMarketingExperimentAssignment === 'treatment' && (
{
<>
<TextControl
className={ classNames(
@ -447,18 +441,13 @@ export const BusinessInfo = ( {
} }
/>
</>
) }
}
</form>
<div className="woocommerce-profiler-button-container">
<Button
className="woocommerce-profiler-button"
variant="primary"
disabled={
! storeCountry.key ||
( emailMarketingExperimentAssignment ===
'treatment' &&
isEmailInvalid )
}
disabled={ ! storeCountry.key || isEmailInvalid }
onClick={ () => {
sendEvent( {
type: 'BUSINESS_INFO_COMPLETED',

View File

@ -65,6 +65,8 @@ describe( 'BusinessInfo', () => {
screen.getByText( /Where is your store located?/i )
).toBeInTheDocument();
expect( screen.getByText( /Your email address/i ) ).toBeInTheDocument();
expect(
screen.getByRole( 'button', {
name: /Continue/i,
@ -314,19 +316,8 @@ describe( 'BusinessInfo', () => {
} );
} );
describe( 'business info page, email marketing variant', () => {
beforeEach( () => {
props.context.emailMarketingExperimentAssignment = 'treatment';
} );
it( 'should correctly render the experiment variant with the email field', () => {
render( <BusinessInfo { ...props } /> );
expect(
screen.getByText( /Your email address/i )
).toBeInTheDocument();
} );
it( 'should not disable the continue field when experiment variant is shown, opt in checkbox is not checked and email field is empty', () => {
describe( 'business info page, email marketing opt-in', () => {
it( 'should not disable the continue field when opt in checkbox is not checked and email field is empty', () => {
props.context.businessInfo.location = 'AW';
props.context.onboardingProfile.is_store_country_set = true;
render( <BusinessInfo { ...props } /> );
@ -336,7 +327,7 @@ describe( 'BusinessInfo', () => {
expect( continueButton ).not.toBeDisabled();
} );
it( 'should disable the continue field when experiment variant is shown, opt in checkbox is checked and email field is empty', () => {
it( 'should disable the continue field when opt in checkbox is checked and email field is empty', () => {
props.context.businessInfo.location = 'AW';
props.context.onboardingProfile.is_store_country_set = true;
render( <BusinessInfo { ...props } /> );
@ -350,7 +341,7 @@ describe( 'BusinessInfo', () => {
expect( continueButton ).toBeDisabled();
} );
it( 'should correctly send event with opt-in true when experiment variant is shown, opt in checkbox is checked and email field is filled', () => {
it( 'should correctly send event with opt-in true when opt in checkbox is checked and email field is filled', () => {
props.context.businessInfo.location = 'AW';
props.context.onboardingProfile.is_store_country_set = true;
render( <BusinessInfo { ...props } /> );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: add
Removed experimental code for email marketing opt in