add: remove email marketing experiment (#41599)
This commit is contained in:
commit
8ecb684da2
|
@ -76,48 +76,30 @@ 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
|
||||
isEmailChanged =
|
||||
event.payload.storeEmailAddress !==
|
||||
context.onboardingProfile.store_email;
|
||||
} else if ( context.currentUserEmail ) {
|
||||
emailSource = 'current_user_email'; // from currentUser
|
||||
isEmailChanged =
|
||||
event.payload.storeEmailAddress !== context.currentUserEmail;
|
||||
} else {
|
||||
emailSource = 'was_empty';
|
||||
isEmailChanged = event.payload.storeEmailAddress?.length > 0;
|
||||
}
|
||||
|
||||
recordEvent( 'coreprofiler_email_marketing', {
|
||||
opt_in: event.payload.isOptInMarketing,
|
||||
email_field_prefilled_source: emailSource,
|
||||
email_field_modified: isEmailChanged,
|
||||
} );
|
||||
let emailSource, isEmailChanged;
|
||||
if ( context.onboardingProfile.store_email ) {
|
||||
emailSource = 'onboarding_profile_store_email'; // from previous entry
|
||||
isEmailChanged =
|
||||
event.payload.storeEmailAddress !==
|
||||
context.onboardingProfile.store_email;
|
||||
} else if ( context.currentUserEmail ) {
|
||||
emailSource = 'current_user_email'; // from currentUser
|
||||
isEmailChanged =
|
||||
event.payload.storeEmailAddress !== context.currentUserEmail;
|
||||
} else {
|
||||
emailSource = 'was_empty';
|
||||
isEmailChanged = event.payload.storeEmailAddress?.length > 0;
|
||||
}
|
||||
|
||||
recordEvent( 'coreprofiler_email_marketing', {
|
||||
opt_in: event.payload.isOptInMarketing,
|
||||
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,
|
||||
};
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
],
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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 } /> );
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: add
|
||||
|
||||
Removed experimental code for email marketing opt in
|
Loading…
Reference in New Issue