Skip to content

Commit

Permalink
Merge pull request #17190 from mozilla/FXA-9421
Browse files Browse the repository at this point in the history
task(settings): Add reg_age_invalid glean metric
  • Loading branch information
chenba committed Jul 1, 2024
2 parents 6de0823 + 2e5c786 commit 2fb5540
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/fxa-settings/src/lib/glean/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ const recordEventMetric = (
case 'reg_success_view':
reg.successView.record();
break;
case 'reg_age_invalid':
reg.ageInvalid.record();
break;
case 'login_view':
login.view.record();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ import CannotCreateAccount, { viewName } from '.';
import { getFtlBundle, testAllL10n } from 'fxa-react/lib/test-utils';
import { FluentBundle } from '@fluent/bundle';
import { REACT_ENTRYPOINT } from '../../constants';
import GleanMetrics from '../../lib/glean';

jest.mock('../../lib/metrics', () => ({
usePageViewEvent: jest.fn(),
}));

jest.mock('../../lib/glean', () => ({
__esModule: true,
default: {
registration: { ageInvalid: jest.fn() },
},
}));

describe('CannotCreateAccount', () => {
let bundle: FluentBundle;
beforeAll(async () => {
Expand All @@ -37,5 +45,6 @@ describe('CannotCreateAccount', () => {
'href',
'https://www.ftc.gov/business-guidance/privacy-security/childrens-privacy'
);
expect(GleanMetrics.registration.ageInvalid).toBeCalledTimes(1);
});
});
2 changes: 2 additions & 0 deletions packages/fxa-settings/src/pages/CannotCreateAccount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CardHeader from '../../components/CardHeader';
import { FtlMsg } from 'fxa-react/lib/utils';
import { usePageViewEvent } from '../../lib/metrics';
import { REACT_ENTRYPOINT } from '../../constants';
import GleanMetrics from '../../lib/glean';

export const viewName = 'cannot-create-account';

Expand All @@ -21,6 +22,7 @@ const CannotCreateAccount = (_: RouteComponentProps) => {
* Alternatively, do we want to always open this in the same tab since users are locked out?
*/
usePageViewEvent(viewName, REACT_ENTRYPOINT);
GleanMetrics.registration.ageInvalid();
return (
<AppLayout>
{/* Span is temporary until sign up tests are converted to playwright */}
Expand Down
19 changes: 19 additions & 0 deletions packages/fxa-shared/metrics/glean/fxa-ui-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,25 @@ reg:
expires: never
data_sensitivity:
- interaction
age_invalid:
type: event
description: |
Indicates the user entered an age in the "Age" section that is 13 or below. If
they do this, they encounter a page that does not let them continue to register
their account.
send_in_pings:
- events
notification_emails:
- [email protected]
- [email protected]
bugs:
- https://mozilla-hub.atlassian.net/browse/FXA-9421
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1830504
- https://bugzilla.mozilla.org/show_bug.cgi?id=1844121
expires: never
data_sensitivity:
- interaction

cad_firefox:
view:
Expand Down
1 change: 1 addition & 0 deletions packages/fxa-shared/metrics/glean/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const eventsMap = {
success: 'reg_submit_success',
complete: 'reg_success_view',
cwts: 'reg_cwts_engage',
ageInvalid: 'reg_age_invalid',
},

signupConfirmation: {
Expand Down
18 changes: 18 additions & 0 deletions packages/fxa-shared/metrics/glean/web/reg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@

import EventMetricType from '@mozilla/glean/private/metrics/event';

/**
* Indicates the user entered an age in the "Age" section that is 13 or below. If
* they do this, they encounter a page that does not let them continue to register
* their account.
*
* Generated from `reg.age_invalid`.
*/
export const ageInvalid = new EventMetricType(
{
category: 'reg',
name: 'age_invalid',
sendInPings: ['events'],
lifetime: 'ping',
disabled: false,
},
[]
);

/**
* User interacted with the Sync "Choose What to Sync" options during account
* registration.
Expand Down

0 comments on commit 2fb5540

Please sign in to comment.