Skip to content

Commit

Permalink
Bug 1656344 - Add a telemetry scalar on number of credit card forms s…
Browse files Browse the repository at this point in the history
…ections detected/submitted in a session. r=abr

Differential Revision: https://phabricator.services.mozilla.com/D85471
  • Loading branch information
Zibi Braniecki committed Aug 4, 2020
1 parent 83f3629 commit 36e7f48
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
6 changes: 6 additions & 0 deletions browser/extensions/formautofill/FormAutofillContent.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,12 @@ var FormAutofillContent = {
extra
);
});
if (records.creditCard.length) {
Services.telemetry.scalarAdd(
"formautofill.creditCards.submitted_sections_count",
records.creditCard.length
);
}

this._onFormSubmit(records, domWin, handler.timeStartedFillingMS);
},
Expand Down
4 changes: 4 additions & 0 deletions browser/extensions/formautofill/FormAutofillHandler.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,10 @@ class FormAutofillCreditCardSection extends FormAutofillSection {
: "false",
}
);
Services.telemetry.scalarAdd(
"formautofill.creditCards.detected_sections_count",
1
);

// For valid sections, check whether the section is in an
// <iframe>; and, if so, watch for the <iframe> to pagehide.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async function assertTelemetry(expected_content, expected_parent) {

add_task(async function test_popup_opened() {
Services.telemetry.clearEvents();
Services.telemetry.clearScalars();
Services.telemetry.setEventRecordingEnabled("creditcard", true);

await saveCreditCard(TEST_CREDIT_CARD_1);
Expand All @@ -89,6 +90,19 @@ add_task(async function test_popup_opened() {
["creditcard", "detected", "cc_form"],
["creditcard", "popup_shown", "cc_form"],
]);

TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("content"),
"formautofill.creditCards.detected_sections_count",
1,
"There should be 1 section detected."
);
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("content"),
"formautofill.creditCards.submitted_sections_count",
0,
"There should be no sections submitted."
);
});

add_task(async function test_submit_creditCard_new() {
Expand Down Expand Up @@ -142,6 +156,7 @@ add_task(async function test_submit_creditCard_new() {
}

Services.telemetry.clearEvents();
Services.telemetry.clearScalars();
Services.telemetry.setEventRecordingEnabled("creditcard", true);

let expected_content = [
Expand Down Expand Up @@ -175,6 +190,19 @@ add_task(async function test_submit_creditCard_new() {
["creditcard", "show", "capture_doorhanger"],
["creditcard", "disable", "capture_doorhanger"],
]);

TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("content"),
"formautofill.creditCards.detected_sections_count",
3,
"There should be 3 sections detected."
);
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("content"),
"formautofill.creditCards.submitted_sections_count",
3,
"There should be 1 section submitted."
);
});

add_task(async function test_submit_creditCard_autofill() {
Expand Down
33 changes: 33 additions & 0 deletions toolkit/components/telemetry/Scalars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3706,6 +3706,39 @@ formautofill.creditCards:
- 'firefox'
record_in_processes:
- 'main'
detected_sections_count:
bug_numbers:
- 1656344
description: >
Count at detection time number of credit card form sections.
A single form can contain more than one credit card form section.
expires: never
kind: uint
notification_emails:
- [email protected]
- [email protected]
- [email protected]
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'content'
submitted_sections_count:
bug_numbers:
- 1656344
description: >
Count at submission time number of credit card form sections submitted.
expires: never
kind: uint
notification_emails:
- [email protected]
- [email protected]
- [email protected]
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'content'

# The following section contains scalars for Screenshots.
screenshots:
Expand Down

0 comments on commit 36e7f48

Please sign in to comment.