chore: Show optional broker scan info fields depending on experiment variant
This commit is contained in:
Родитель
3a1bcffe40
Коммит
cb63eb7f77
|
@ -29,7 +29,7 @@ features:
|
||||||
variant:
|
variant:
|
||||||
description: The optional fields to show
|
description: The optional fields to show
|
||||||
type: OptionalBrokerScanInfoFields
|
type: OptionalBrokerScanInfoFields
|
||||||
default: middleName
|
default: none
|
||||||
defaults:
|
defaults:
|
||||||
- channel: local
|
- channel: local
|
||||||
value: {
|
value: {
|
||||||
|
|
|
@ -84,8 +84,9 @@
|
||||||
padding: $spacing-lg 0;
|
padding: $spacing-lg 0;
|
||||||
|
|
||||||
@media screen and (min-width: $screen-lg) {
|
@media screen and (min-width: $screen-lg) {
|
||||||
// The child items in the grid are input fields. Items marked as “optional”
|
// The child items in the grid are input fields. If items marked as
|
||||||
// are only shown if the experiment `welcome-scan-optional-info` is enabled.
|
// “optional” are shown depends on the enabled variants in the
|
||||||
|
// `welcome-scan-optional-info` experiment.
|
||||||
// 1. First name
|
// 1. First name
|
||||||
// 2. Middle name (optional)
|
// 2. Middle name (optional)
|
||||||
// 3. Last name
|
// 3. Last name
|
||||||
|
@ -94,13 +95,18 @@
|
||||||
// 6. City and state
|
// 6. City and state
|
||||||
& > :nth-child(odd) {
|
& > :nth-child(odd) {
|
||||||
grid-column: 1 / 4;
|
grid-column: 1 / 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:has(label[for="name_suffix"]) {
|
||||||
// The field “last name” is only in an “odd” position if the experiment
|
// The field “last name” is only in an “odd” position if the experiment
|
||||||
// `welcome-scan-optional-info` is enabled.
|
// `welcome-scan-optional-info` is enabled.
|
||||||
&:has(> label[for="last_name"]) {
|
& > :nth-child(odd) {
|
||||||
grid-column: 1 / 5;
|
&:has(> label[for="last_name"]) {
|
||||||
|
grid-column: 1 / 5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& > :nth-child(even) {
|
& > :nth-child(even) {
|
||||||
grid-column: 4 / 7;
|
grid-column: 4 / 7;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import styles from "./EnterInfo.module.scss";
|
||||||
import { TelemetryButton } from "../../../../../components/client/TelemetryButton";
|
import { TelemetryButton } from "../../../../../components/client/TelemetryButton";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import * as Sentry from "@sentry/nextjs";
|
import * as Sentry from "@sentry/nextjs";
|
||||||
|
import { ExperimentData } from "../../../../../../telemetry/generated/nimbus/experiments";
|
||||||
|
|
||||||
// Not covered by tests; mostly side-effects. See test-coverage.md#mock-heavy
|
// Not covered by tests; mostly side-effects. See test-coverage.md#mock-heavy
|
||||||
/* c8 ignore start */
|
/* c8 ignore start */
|
||||||
|
@ -62,7 +63,7 @@ export type Props = {
|
||||||
user: Session["user"];
|
user: Session["user"];
|
||||||
skipInitialStep: boolean;
|
skipInitialStep: boolean;
|
||||||
previousRoute: string | null;
|
previousRoute: string | null;
|
||||||
optionalInfoIsEnabled: boolean;
|
experimentData: ExperimentData;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EnterInfo = ({
|
export const EnterInfo = ({
|
||||||
|
@ -70,7 +71,7 @@ export const EnterInfo = ({
|
||||||
onGoBack,
|
onGoBack,
|
||||||
skipInitialStep,
|
skipInitialStep,
|
||||||
previousRoute,
|
previousRoute,
|
||||||
optionalInfoIsEnabled,
|
experimentData,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const [firstName, setFirstName] = useState("");
|
const [firstName, setFirstName] = useState("");
|
||||||
const [lastName, setLastName] = useState("");
|
const [lastName, setLastName] = useState("");
|
||||||
|
@ -193,7 +194,19 @@ export const EnterInfo = ({
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
onChange: setLocation,
|
onChange: setLocation,
|
||||||
},
|
},
|
||||||
].filter((userDetail) => userDetail.isRequired || optionalInfoIsEnabled);
|
].filter((userDetail) => {
|
||||||
|
const optionalInfoExperimentData =
|
||||||
|
experimentData["welcome-scan-optional-info"];
|
||||||
|
const showOptionalInfo =
|
||||||
|
optionalInfoExperimentData.enabled &&
|
||||||
|
((userDetail.key === "middle_name" &&
|
||||||
|
(optionalInfoExperimentData.variant === "middleName" ||
|
||||||
|
optionalInfoExperimentData.variant === "suffixAndMiddleName")) ||
|
||||||
|
(userDetail.key === "name_suffix" &&
|
||||||
|
(optionalInfoExperimentData.variant === "suffix" ||
|
||||||
|
optionalInfoExperimentData.variant === "suffixAndMiddleName")));
|
||||||
|
return userDetail.isRequired || showOptionalInfo;
|
||||||
|
});
|
||||||
|
|
||||||
const getInvalidFields = () =>
|
const getInvalidFields = () =>
|
||||||
userDetailsData.filter(({ isValid }) => !isValid).map(({ key }) => key);
|
userDetailsData.filter(({ isValid }) => !isValid).map(({ key }) => key);
|
||||||
|
|
|
@ -26,6 +26,7 @@ export const Onboarding: Story = {
|
||||||
...defaultExperimentData,
|
...defaultExperimentData,
|
||||||
"welcome-scan-optional-info": {
|
"welcome-scan-optional-info": {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
variant: "suffixAndMiddleName",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -46,8 +46,6 @@ export const View = ({
|
||||||
const [currentStep, setCurrentStep] = useState<StepId>(stepId);
|
const [currentStep, setCurrentStep] = useState<StepId>(stepId);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const recordTelemetry = useTelemetry();
|
const recordTelemetry = useTelemetry();
|
||||||
const optionalInfoIsEnabled =
|
|
||||||
experimentData["welcome-scan-optional-info"].enabled;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let pageName = "welcome";
|
let pageName = "welcome";
|
||||||
|
@ -89,7 +87,7 @@ export const View = ({
|
||||||
setCurrentStep("getStarted");
|
setCurrentStep("getStarted");
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
optionalInfoIsEnabled={optionalInfoIsEnabled}
|
experimentData={experimentData}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<GetStarted
|
<GetStarted
|
||||||
|
|
|
@ -94,18 +94,24 @@ export async function POST(
|
||||||
locale: getLocale(getL10n()),
|
locale: getLocale(getL10n()),
|
||||||
previewMode: searchParams.get("nimbus_web_preview") === "true",
|
previewMode: searchParams.get("nimbus_web_preview") === "true",
|
||||||
});
|
});
|
||||||
const optionalInfoIsEnabled =
|
const optionalInfoExperimentData =
|
||||||
experimentData["welcome-scan-optional-info"].enabled;
|
experimentData["welcome-scan-optional-info"];
|
||||||
|
|
||||||
const profileData: CreateProfileRequest = {
|
const profileData: CreateProfileRequest = {
|
||||||
first_name: firstName,
|
first_name: firstName,
|
||||||
last_name: lastName,
|
last_name: lastName,
|
||||||
addresses: [{ city, state }],
|
addresses: [{ city, state }],
|
||||||
birth_date: dateOfBirth,
|
birth_date: dateOfBirth,
|
||||||
...(optionalInfoIsEnabled && {
|
...(optionalInfoExperimentData.enabled &&
|
||||||
middle_name: middleName,
|
(optionalInfoExperimentData.variant === "middleName" ||
|
||||||
name_suffix: nameSuffix,
|
optionalInfoExperimentData.variant === "suffixAndMiddleName") && {
|
||||||
}),
|
middle_name: middleName,
|
||||||
|
}),
|
||||||
|
...(optionalInfoExperimentData.enabled &&
|
||||||
|
(optionalInfoExperimentData.variant === "suffix" ||
|
||||||
|
optionalInfoExperimentData.variant === "suffixAndMiddleName") && {
|
||||||
|
name_suffix: nameSuffix,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof session?.user?.subscriber.fxa_uid === "string") {
|
if (typeof session?.user?.subscriber.fxa_uid === "string") {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче