mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1341569 - Add the form created time in handler and telemetry probe for form filling duration. r=benjamin+7044,MattN
MozReview-Commit-ID: 6mU606zEtT4 --HG-- extra : rebase_source : e55fa94c70927b9374b09d9c8ad277f274f77fb2
This commit is contained in:
parent
fb6af85bd2
commit
26f88232ff
@ -372,10 +372,12 @@ var FormAutofillContent = {
|
||||
*
|
||||
* @param {Object} profile Submitted form's address/creditcard guid and record.
|
||||
* @param {Object} domWin Current content window.
|
||||
* @param {int} timeStartedFillingMS Time of form filling started.
|
||||
*/
|
||||
_onFormSubmit(profile, domWin) {
|
||||
_onFormSubmit(profile, domWin, timeStartedFillingMS) {
|
||||
let mm = this._messageManagerFromWindow(domWin);
|
||||
mm.sendAsyncMessage("FormAutofill:OnFormSubmit", profile);
|
||||
mm.sendAsyncMessage("FormAutofill:OnFormSubmit",
|
||||
{profile, timeStartedFillingMS});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -407,7 +409,7 @@ var FormAutofillContent = {
|
||||
return true;
|
||||
}
|
||||
|
||||
this._onFormSubmit(records, domWin);
|
||||
this._onFormSubmit(records, domWin, handler.timeStartedFillingMS);
|
||||
return true;
|
||||
},
|
||||
|
||||
|
@ -120,6 +120,11 @@ FormAutofillHandler.prototype = {
|
||||
return this._formFieldCount != this.form.elements.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Time in milliseconds since epoch when a user started filling in the form.
|
||||
*/
|
||||
timeStartedFillingMS: null,
|
||||
|
||||
/**
|
||||
* Set fieldDetails from the form about fields that can be autofilled.
|
||||
*
|
||||
@ -153,9 +158,17 @@ FormAutofillHandler.prototype = {
|
||||
log.debug("Ignoring credit card related fields since it's without credit card number field");
|
||||
this.creditCard.fieldDetails = [];
|
||||
}
|
||||
let validDetails = Array.of(...(this.address.fieldDetails),
|
||||
...(this.creditCard.fieldDetails));
|
||||
for (let detail of validDetails) {
|
||||
let input = detail.elementWeakRef.get();
|
||||
if (!input) {
|
||||
continue;
|
||||
}
|
||||
input.addEventListener("input", this);
|
||||
}
|
||||
|
||||
return Array.of(...(this.address.fieldDetails),
|
||||
...(this.creditCard.fieldDetails));
|
||||
return validDetails;
|
||||
},
|
||||
|
||||
getFieldDetailByName(fieldName) {
|
||||
@ -632,4 +645,23 @@ FormAutofillHandler.prototype = {
|
||||
Services.cpmm.sendAsyncMessage("FormAutofill:GetDecryptedString", {cipherText, reauth});
|
||||
});
|
||||
},
|
||||
|
||||
handleEvent(event) {
|
||||
switch (event.type) {
|
||||
case "input":
|
||||
if (!event.isTrusted) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let detail of this.fieldDetails) {
|
||||
let input = detail.elementWeakRef.get();
|
||||
if (!input) {
|
||||
continue;
|
||||
}
|
||||
input.removeEventListener("input", this);
|
||||
}
|
||||
this.timeStartedFillingMS = Date.now();
|
||||
break;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -349,7 +349,7 @@ FormAutofillParent.prototype = {
|
||||
this._updateStatus();
|
||||
},
|
||||
|
||||
_onAddressSubmit(address, target) {
|
||||
_onAddressSubmit(address, target, timeStartedFillingMS) {
|
||||
if (address.guid) {
|
||||
// Avoid updating the fields that users don't modify.
|
||||
let originalAddress = this.profileStorage.addresses.get(address.guid);
|
||||
@ -360,6 +360,8 @@ FormAutofillParent.prototype = {
|
||||
}
|
||||
|
||||
if (!this.profileStorage.addresses.mergeIfPossible(address.guid, address.record)) {
|
||||
this._recordFormFillingTime("address", "autofill-update", timeStartedFillingMS);
|
||||
|
||||
FormAutofillDoorhanger.show(target, "update").then((state) => {
|
||||
let changedGUIDs = this.profileStorage.addresses.mergeToStorage(address.record);
|
||||
switch (state) {
|
||||
@ -383,6 +385,7 @@ FormAutofillParent.prototype = {
|
||||
Services.telemetry.scalarAdd("formautofill.addresses.fill_type_autofill_update", 1);
|
||||
return;
|
||||
}
|
||||
this._recordFormFillingTime("address", "autofill", timeStartedFillingMS);
|
||||
this.profileStorage.addresses.notifyUsed(address.guid);
|
||||
// Address is merged successfully
|
||||
Services.telemetry.scalarAdd("formautofill.addresses.fill_type_autofill", 1);
|
||||
@ -392,6 +395,7 @@ FormAutofillParent.prototype = {
|
||||
changedGUIDs.push(this.profileStorage.addresses.add(address.record));
|
||||
}
|
||||
changedGUIDs.forEach(guid => this.profileStorage.addresses.notifyUsed(guid));
|
||||
this._recordFormFillingTime("address", "manual", timeStartedFillingMS);
|
||||
|
||||
// Show first time use doorhanger
|
||||
if (Services.prefs.getBoolPref("extensions.formautofill.firstTimeUse")) {
|
||||
@ -442,13 +446,28 @@ FormAutofillParent.prototype = {
|
||||
},
|
||||
|
||||
_onFormSubmit(data, target) {
|
||||
let {address, creditCard} = data;
|
||||
let {profile: {address, creditCard}, timeStartedFillingMS} = data;
|
||||
|
||||
if (address) {
|
||||
this._onAddressSubmit(address, target);
|
||||
this._onAddressSubmit(address, target, timeStartedFillingMS);
|
||||
}
|
||||
if (creditCard) {
|
||||
this._onCreditCardSubmit(creditCard, target);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Set the probes for the filling time with specific filling type and form type.
|
||||
*
|
||||
* @private
|
||||
* @param {string} formType
|
||||
* 3 type of form (address/creditcard/address-creditcard).
|
||||
* @param {string} fillingType
|
||||
* 3 filling type (manual/autofill/autofill-update).
|
||||
* @param {int} startedFillingMS
|
||||
* Time that form started to filling in ms.
|
||||
*/
|
||||
_recordFormFillingTime(formType, fillingType, startedFillingMS) {
|
||||
let histogram = Services.telemetry.getKeyedHistogramById("FORM_FILLING_REQUIRED_TIME_MS");
|
||||
histogram.add(`${formType}-${fillingType}`, Date.now() - startedFillingMS);
|
||||
},
|
||||
};
|
||||
|
@ -13635,5 +13635,16 @@
|
||||
"n_buckets": 100,
|
||||
"bug_numbers": [1393399],
|
||||
"description": "Time in milliseconds to recover a video decoder from a HW video decoder crash, calculated since MFR gets a NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER error. The data is sent when video decoding is recovered from a GPU crash and the first frame is decoded."
|
||||
},
|
||||
"FORM_FILLING_REQUIRED_TIME_MS": {
|
||||
"record_in_processes": ["main"],
|
||||
"alert_emails": ["autofill@lists.mozilla.org", "jcheng@mozilla.com", "chsiang@mozilla.com"],
|
||||
"expires_in_version": "60",
|
||||
"kind": "exponential",
|
||||
"high": 300000,
|
||||
"n_buckets": 22,
|
||||
"keyed": true,
|
||||
"bug_numbers": [1341569],
|
||||
"description": "Milliseconds between starting to fill an autofill-eligible form field and submitting the form, keyed by the combination of form type and filling type."
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user