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 = (
|
const recordTracksIsEmailChanged = (
|
||||||
context: CoreProfilerStateMachineContext,
|
context: CoreProfilerStateMachineContext,
|
||||||
event: BusinessInfoEvent
|
event: BusinessInfoEvent
|
||||||
) => {
|
) => {
|
||||||
if ( context.emailMarketingExperimentAssignment === 'treatment' ) {
|
let emailSource, isEmailChanged;
|
||||||
let emailSource, isEmailChanged;
|
if ( context.onboardingProfile.store_email ) {
|
||||||
if ( context.onboardingProfile.store_email ) {
|
emailSource = 'onboarding_profile_store_email'; // from previous entry
|
||||||
emailSource = 'onboarding_profile_store_email'; // from previous entry
|
isEmailChanged =
|
||||||
isEmailChanged =
|
event.payload.storeEmailAddress !==
|
||||||
event.payload.storeEmailAddress !==
|
context.onboardingProfile.store_email;
|
||||||
context.onboardingProfile.store_email;
|
} else if ( context.currentUserEmail ) {
|
||||||
} else if ( context.currentUserEmail ) {
|
emailSource = 'current_user_email'; // from currentUser
|
||||||
emailSource = 'current_user_email'; // from currentUser
|
isEmailChanged =
|
||||||
isEmailChanged =
|
event.payload.storeEmailAddress !== context.currentUserEmail;
|
||||||
event.payload.storeEmailAddress !== context.currentUserEmail;
|
} else {
|
||||||
} else {
|
emailSource = 'was_empty';
|
||||||
emailSource = 'was_empty';
|
isEmailChanged = event.payload.storeEmailAddress?.length > 0;
|
||||||
isEmailChanged = event.payload.storeEmailAddress?.length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
recordEvent( 'coreprofiler_email_marketing', {
|
|
||||||
opt_in: event.payload.isOptInMarketing,
|
|
||||||
email_field_prefilled_source: emailSource,
|
|
||||||
email_field_modified: isEmailChanged,
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recordEvent( 'coreprofiler_email_marketing', {
|
||||||
|
opt_in: event.payload.isOptInMarketing,
|
||||||
|
email_field_prefilled_source: emailSource,
|
||||||
|
email_field_modified: isEmailChanged,
|
||||||
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
const recordTracksBusinessInfoCompleted = (
|
const recordTracksBusinessInfoCompleted = (
|
||||||
|
@ -126,8 +108,6 @@ const recordTracksBusinessInfoCompleted = (
|
||||||
) => {
|
) => {
|
||||||
recordEvent( 'coreprofiler_step_complete', {
|
recordEvent( 'coreprofiler_step_complete', {
|
||||||
step: 'business_info',
|
step: 'business_info',
|
||||||
email_marketing_experiment_assignment:
|
|
||||||
context.emailMarketingExperimentAssignment,
|
|
||||||
wc_version: getSetting( 'wcVersion' ),
|
wc_version: getSetting( 'wcVersion' ),
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -227,5 +207,4 @@ export default {
|
||||||
recordSuccessfulPluginInstallation,
|
recordSuccessfulPluginInstallation,
|
||||||
recordTracksPluginsInstallationRequest,
|
recordTracksPluginsInstallationRequest,
|
||||||
recordTracksIsEmailChanged,
|
recordTracksIsEmailChanged,
|
||||||
recordTracksStepViewedBusinessInfo,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,10 +34,7 @@ import {
|
||||||
USER_STORE_NAME,
|
USER_STORE_NAME,
|
||||||
WCUser,
|
WCUser,
|
||||||
} from '@woocommerce/data';
|
} from '@woocommerce/data';
|
||||||
import {
|
import { initializeExPlat } from '@woocommerce/explat';
|
||||||
initializeExPlat,
|
|
||||||
loadExperimentAssignment,
|
|
||||||
} from '@woocommerce/explat';
|
|
||||||
import { CountryStateOption } from '@woocommerce/onboarding';
|
import { CountryStateOption } from '@woocommerce/onboarding';
|
||||||
import { getAdminLink } from '@woocommerce/settings';
|
import { getAdminLink } from '@woocommerce/settings';
|
||||||
import CurrencyFactory from '@woocommerce/currency';
|
import CurrencyFactory from '@woocommerce/currency';
|
||||||
|
@ -204,7 +201,6 @@ export type CoreProfilerStateMachineContext = {
|
||||||
persistBusinessInfoRef?: ReturnType< typeof spawn >;
|
persistBusinessInfoRef?: ReturnType< typeof spawn >;
|
||||||
spawnUpdateOnboardingProfileOptionRef?: ReturnType< typeof spawn >;
|
spawnUpdateOnboardingProfileOptionRef?: ReturnType< typeof spawn >;
|
||||||
spawnGeolocationRef?: ReturnType< typeof spawn >;
|
spawnGeolocationRef?: ReturnType< typeof spawn >;
|
||||||
emailMarketingExperimentAssignment: 'treatment' | 'control';
|
|
||||||
currentUserEmail: string | undefined;
|
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 getCurrentUserEmail = async () => {
|
||||||
const currentUser: WCUser< 'email' > = await resolveSelect(
|
const currentUser: WCUser< 'email' > = await resolveSelect(
|
||||||
USER_STORE_NAME
|
USER_STORE_NAME
|
||||||
|
@ -356,17 +346,6 @@ const assignOnboardingProfile = assign( {
|
||||||
) => event.data,
|
) => event.data,
|
||||||
} );
|
} );
|
||||||
|
|
||||||
const assignMarketingOptInExperimentAssignment = assign( {
|
|
||||||
emailMarketingExperimentAssignment: (
|
|
||||||
_context,
|
|
||||||
event: DoneInvokeEvent<
|
|
||||||
Awaited<
|
|
||||||
ReturnType< typeof getMarketingOptInExperimentAssignment >
|
|
||||||
>
|
|
||||||
>
|
|
||||||
) => event.data.variationName ?? 'control',
|
|
||||||
} );
|
|
||||||
|
|
||||||
const getGeolocation = async ( context: CoreProfilerStateMachineContext ) => {
|
const getGeolocation = async ( context: CoreProfilerStateMachineContext ) => {
|
||||||
if ( context.optInDataSharing ) {
|
if ( context.optInDataSharing ) {
|
||||||
return resolveSelect( COUNTRIES_STORE_NAME ).geolocate();
|
return resolveSelect( COUNTRIES_STORE_NAME ).geolocate();
|
||||||
|
@ -700,7 +679,6 @@ const coreProfilerMachineActions = {
|
||||||
handleCountries,
|
handleCountries,
|
||||||
handleOnboardingProfileOption,
|
handleOnboardingProfileOption,
|
||||||
assignOnboardingProfile,
|
assignOnboardingProfile,
|
||||||
assignMarketingOptInExperimentAssignment,
|
|
||||||
assignCurrentUserEmail,
|
assignCurrentUserEmail,
|
||||||
persistBusinessInfo,
|
persistBusinessInfo,
|
||||||
spawnUpdateOnboardingProfileOption,
|
spawnUpdateOnboardingProfileOption,
|
||||||
|
@ -715,7 +693,6 @@ const coreProfilerMachineServices = {
|
||||||
getCountries,
|
getCountries,
|
||||||
getGeolocation,
|
getGeolocation,
|
||||||
getOnboardingProfileOption,
|
getOnboardingProfileOption,
|
||||||
getMarketingOptInExperimentAssignment,
|
|
||||||
getCurrentUserEmail,
|
getCurrentUserEmail,
|
||||||
getPlugins,
|
getPlugins,
|
||||||
browserPopstateHandler,
|
browserPopstateHandler,
|
||||||
|
@ -753,7 +730,6 @@ export const coreProfilerStateMachineDefinition = createMachine( {
|
||||||
loader: {},
|
loader: {},
|
||||||
onboardingProfile: {} as OnboardingProfile,
|
onboardingProfile: {} as OnboardingProfile,
|
||||||
jetpackAuthUrl: undefined,
|
jetpackAuthUrl: undefined,
|
||||||
emailMarketingExperimentAssignment: 'control',
|
|
||||||
currentUserEmail: undefined,
|
currentUserEmail: undefined,
|
||||||
} as CoreProfilerStateMachineContext,
|
} as CoreProfilerStateMachineContext,
|
||||||
states: {
|
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: {
|
currentUserEmail: {
|
||||||
initial: 'fetching',
|
initial: 'fetching',
|
||||||
states: {
|
states: {
|
||||||
|
@ -1140,7 +1099,7 @@ export const coreProfilerStateMachineDefinition = createMachine( {
|
||||||
},
|
},
|
||||||
entry: [
|
entry: [
|
||||||
{
|
{
|
||||||
type: 'recordTracksStepViewedBusinessInfo',
|
type: 'recordTracksStepViewed',
|
||||||
step: 'business_info',
|
step: 'business_info',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -98,12 +98,7 @@ export type BusinessInfoContextProps = Pick<
|
||||||
| 'is_agree_marketing'
|
| 'is_agree_marketing'
|
||||||
| 'store_email'
|
| 'store_email'
|
||||||
>;
|
>;
|
||||||
} & Partial<
|
} & Partial< Pick< CoreProfilerStateMachineContext, 'currentUserEmail' > >;
|
||||||
Pick<
|
|
||||||
CoreProfilerStateMachineContext,
|
|
||||||
'emailMarketingExperimentAssignment' | 'currentUserEmail'
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
|
|
||||||
export const BusinessInfo = ( {
|
export const BusinessInfo = ( {
|
||||||
context,
|
context,
|
||||||
|
@ -126,7 +121,6 @@ export const BusinessInfo = ( {
|
||||||
is_agree_marketing: isOptInMarketingFromOnboardingProfile,
|
is_agree_marketing: isOptInMarketingFromOnboardingProfile,
|
||||||
store_email: storeEmailAddressFromOnboardingProfile,
|
store_email: storeEmailAddressFromOnboardingProfile,
|
||||||
},
|
},
|
||||||
emailMarketingExperimentAssignment,
|
|
||||||
currentUserEmail,
|
currentUserEmail,
|
||||||
} = context;
|
} = context;
|
||||||
|
|
||||||
|
@ -390,7 +384,7 @@ export const BusinessInfo = ( {
|
||||||
</ul>
|
</ul>
|
||||||
</Notice>
|
</Notice>
|
||||||
) }
|
) }
|
||||||
{ emailMarketingExperimentAssignment === 'treatment' && (
|
{
|
||||||
<>
|
<>
|
||||||
<TextControl
|
<TextControl
|
||||||
className={ classNames(
|
className={ classNames(
|
||||||
|
@ -447,18 +441,13 @@ export const BusinessInfo = ( {
|
||||||
} }
|
} }
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) }
|
}
|
||||||
</form>
|
</form>
|
||||||
<div className="woocommerce-profiler-button-container">
|
<div className="woocommerce-profiler-button-container">
|
||||||
<Button
|
<Button
|
||||||
className="woocommerce-profiler-button"
|
className="woocommerce-profiler-button"
|
||||||
variant="primary"
|
variant="primary"
|
||||||
disabled={
|
disabled={ ! storeCountry.key || isEmailInvalid }
|
||||||
! storeCountry.key ||
|
|
||||||
( emailMarketingExperimentAssignment ===
|
|
||||||
'treatment' &&
|
|
||||||
isEmailInvalid )
|
|
||||||
}
|
|
||||||
onClick={ () => {
|
onClick={ () => {
|
||||||
sendEvent( {
|
sendEvent( {
|
||||||
type: 'BUSINESS_INFO_COMPLETED',
|
type: 'BUSINESS_INFO_COMPLETED',
|
||||||
|
|
|
@ -65,6 +65,8 @@ describe( 'BusinessInfo', () => {
|
||||||
screen.getByText( /Where is your store located?/i )
|
screen.getByText( /Where is your store located?/i )
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
|
||||||
|
expect( screen.getByText( /Your email address/i ) ).toBeInTheDocument();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole( 'button', {
|
screen.getByRole( 'button', {
|
||||||
name: /Continue/i,
|
name: /Continue/i,
|
||||||
|
@ -314,19 +316,8 @@ describe( 'BusinessInfo', () => {
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
describe( 'business info page, email marketing variant', () => {
|
describe( 'business info page, email marketing opt-in', () => {
|
||||||
beforeEach( () => {
|
it( 'should not disable the continue field when opt in checkbox is not checked and email field is empty', () => {
|
||||||
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', () => {
|
|
||||||
props.context.businessInfo.location = 'AW';
|
props.context.businessInfo.location = 'AW';
|
||||||
props.context.onboardingProfile.is_store_country_set = true;
|
props.context.onboardingProfile.is_store_country_set = true;
|
||||||
render( <BusinessInfo { ...props } /> );
|
render( <BusinessInfo { ...props } /> );
|
||||||
|
@ -336,7 +327,7 @@ describe( 'BusinessInfo', () => {
|
||||||
expect( continueButton ).not.toBeDisabled();
|
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.businessInfo.location = 'AW';
|
||||||
props.context.onboardingProfile.is_store_country_set = true;
|
props.context.onboardingProfile.is_store_country_set = true;
|
||||||
render( <BusinessInfo { ...props } /> );
|
render( <BusinessInfo { ...props } /> );
|
||||||
|
@ -350,7 +341,7 @@ describe( 'BusinessInfo', () => {
|
||||||
expect( continueButton ).toBeDisabled();
|
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.businessInfo.location = 'AW';
|
||||||
props.context.onboardingProfile.is_store_country_set = true;
|
props.context.onboardingProfile.is_store_country_set = true;
|
||||||
render( <BusinessInfo { ...props } /> );
|
render( <BusinessInfo { ...props } /> );
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: add
|
||||||
|
|
||||||
|
Removed experimental code for email marketing opt in
|
Loading…
Reference in New Issue