Skip to content

Commit

Permalink
Merge pull request #17778 from mozilla/FXA-9573
Browse files Browse the repository at this point in the history
feat(metrics): Fix '2FA QR Code Setup View' to fire on view
  • Loading branch information
jonalmeida authored Oct 7, 2024
2 parents 5053727 + f478857 commit de48522
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ describe('step 1', () => {
'alt',
expect.stringContaining('JFXE6ULUGM4U4WDHOFVFIRDPKZITATSK')
);
expect(GleanMetrics.accountPref.twoStepAuthQrView).toHaveBeenCalled();
});

it('does not display the QR code for the unverified', async () => {
await act(async () => {
render(account, false);
});
expect(screen.queryByTestId('2fa-qr-code')).toBeNull();
expect(
GleanMetrics.accountPref.twoStepAuthScanCodeLink
).toHaveBeenCalledTimes(0);
});

it('displays the totp secret', async () => {
Expand All @@ -153,15 +157,6 @@ describe('step 1', () => {
expect(screen.getByTestId('manual-code')).toBeInTheDocument();
expect(GleanMetrics.accountPref.twoStepAuthScanCodeLink).toHaveBeenCalled();
});

it('sends metrics when step 1 is submitted without viewing manual code', async () => {
await act(async () => {
render();
});
await submitTotp('867530');

expect(GleanMetrics.accountPref.twoStepAuthQrView).toHaveBeenCalled();
});
});

describe('step 2', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ export const PageTwoStepAuthentication = (_: RouteComponentProps) => {
GleanMetrics.accountPref.twoStepAuthEnterCodeView();
}, [recoveryCodesAcknowledged, totpVerified]);

useEffect(() => {
!totpVerified &&
showQrCode &&
totpInfo.result &&
GleanMetrics.accountPref.twoStepAuthQrView();
}, [showQrCode, totpInfo.result, totpVerified]);

const moveBack = () => {
if (!totpVerified) {
return goHome();
Expand Down Expand Up @@ -326,11 +333,6 @@ export const PageTwoStepAuthentication = (_: RouteComponentProps) => {
disabled={
!totpForm.formState.isDirty || !totpForm.formState.isValid
}
onClick={() => {
if (showQrCode) {
GleanMetrics.accountPref.twoStepAuthQrView();
}
}}
data-glean-id="two_step_auth_qr_submit"
data-glean-type="setup"
>
Expand Down

0 comments on commit de48522

Please sign in to comment.