Bug 1615987 - Collect account setup success rate. r=mkmelin a=wsmwk
authorPing Chen <remotenonsense@gmail.com>
Mon, 08 Jun 2020 13:43:32 +0300
changeset 39364 b6aec7a1e037f2432a055a5bd81e6e16283719eb
parent 39363 c19b6d0fdf3a393922362297f305aee5f5e0109a
child 39365 6064036296bfe22db390bc8b439786c50a6ee9b3
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
reviewersmkmelin, wsmwk
bugs1615987
Bug 1615987 - Collect account setup success rate. r=mkmelin a=wsmwk
mail/components/accountcreation/content/accountConfig.js
mail/components/accountcreation/content/emailWizard.js
mail/components/telemetry/Scalars.yaml
mail/test/browser/account/browser_mailAccountSetupWizard.js
--- a/mail/components/accountcreation/content/accountConfig.js
+++ b/mail/components/accountcreation/content/accountConfig.js
@@ -48,17 +48,17 @@ AccountConfig.prototype = {
    * { Array of incoming/createNewIncoming() }
    */
   incomingAlternatives: null,
   outgoingAlternatives: null,
   // just an internal string to refer to this. Do not show to user.
   id: null,
   // who created the config.
   // { one of kSource* }
-  source: 0,
+  source: null,
   displayName: null,
   // { Array of { varname (value without %), displayName, exampleValue } }
   inputFields: null,
   // email address domains for which this config is applicable
   // { Array of Strings }
   domains: null,
 
   /**
@@ -334,20 +334,20 @@ AccountConfig.prototype = {
     this.incomingAlternatives = alternatives;
     this.incoming = alternatives.shift();
   },
 };
 
 // enum consts
 
 // .source
-AccountConfig.kSourceUser = 1; // user manually entered the config
-AccountConfig.kSourceXML = 2; // config from XML from ISP or Mozilla DB
-AccountConfig.kSourceGuess = 3; // guessConfig()
-AccountConfig.kSourceExchange = 4; // from Microsoft Exchange AutoDiscover
+AccountConfig.kSourceUser = "user"; // user manually entered the config
+AccountConfig.kSourceXML = "ispdb"; // config from XML from ISP or Mozilla DB
+AccountConfig.kSourceGuess = "guess"; // guessConfig()
+AccountConfig.kSourceExchange = "autodiscover"; // from Microsoft Exchange AutoDiscover
 
 /**
  * Some fields on the account config accept placeholders (when coming from XML).
  *
  * These are the predefined ones
  * * %EMAILADDRESS% (full email address of the user, usually entered by user)
  * * %EMAILLOCALPART% (email address, part before @)
  * * %EMAILDOMAIN% (email address, part after @)
--- a/mail/components/accountcreation/content/emailWizard.js
+++ b/mail/components/accountcreation/content/emailWizard.js
@@ -2084,16 +2084,22 @@ EmailConfigWizard.prototype = {
           self._currentConfig.incoming.oauthSettings =
             successfulConfig.incoming.oauthSettings;
         }
         if (successfulConfig.outgoing.oauthSettings) {
           self._currentConfig.outgoing.oauthSettings =
             successfulConfig.outgoing.oauthSettings;
         }
         self.finish(configFilledIn);
+
+        Services.telemetry.keyedScalarAdd(
+          "tb.account.successful_email_account_setup",
+          self._currentConfig.source,
+          1
+        );
       },
       function(e) {
         // failed
         // Could be a wrong password, but there are 1000 other
         // reasons why this failed. Only the backend knows.
         // If we got no message, then something other than VerifyLogon failed.
 
         let msg = e.message || e.toString();
@@ -2107,16 +2113,22 @@ EmailConfigWizard.prototype = {
         self.showErrorMsg(msg);
 
         // TODO use switchToMode(), see above
         // give user something to proceed after fixing
         _enable("create_button");
         // hidden in non-manual mode, so it's fine to enable
         _enable("half-manual-test_button");
         resizeDialog();
+
+        Services.telemetry.keyedScalarAdd(
+          "tb.account.failed_email_account_setup",
+          self._currentConfig.source,
+          1
+        );
       }
     );
   },
 
   finish(concreteConfig) {
     gEmailWizardLogger.info("creating account in backend");
     var account = createAccountInBackend(concreteConfig);
 
--- a/mail/components/telemetry/Scalars.yaml
+++ b/mail/components/telemetry/Scalars.yaml
@@ -61,16 +61,44 @@ tb.account:
       - 'thunderbird'
     keyed: true
     kind: uint
     notification_emails:
       - "telemetry-client-dev@thunderbird.net"
     record_in_processes:
       - 'main'
 
+  successful_email_account_setup:
+    bug_numbers:
+      - 1615987
+    description: How many times email accounts setup succeeded, keyed by account config source.
+    expires: never
+    products:
+      - 'thunderbird'
+    keyed: true
+    kind: uint
+    notification_emails:
+      - "telemetry-client-dev@thunderbird.net"
+    record_in_processes:
+      - 'main'
+
+  failed_email_account_setup:
+    bug_numbers:
+      - 1615987
+    description: How many times email accounts setup failed, keyed by account config source.
+    expires: never
+    products:
+      - 'thunderbird'
+    keyed: true
+    kind: uint
+    notification_emails:
+      - "telemetry-client-dev@thunderbird.net"
+    record_in_processes:
+      - 'main'
+
 tb.compose:
   format_html:
     bug_numbers:
       - 1584889
     description: How many times messages were written in HTML composition mode.
     expires: never
     products:
       - 'thunderbird'
--- a/mail/test/browser/account/browser_mailAccountSetupWizard.js
+++ b/mail/test/browser/account/browser_mailAccountSetupWizard.js
@@ -23,16 +23,19 @@ var { gMockPromptService } = ChromeUtils
 var elib = ChromeUtils.import(
   "resource://testing-common/mozmill/elementslib.jsm"
 );
 
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { MailServices } = ChromeUtils.import(
   "resource:///modules/MailServices.jsm"
 );
+let { TelemetryTestUtils } = ChromeUtils.import(
+  "resource://testing-common/TelemetryTestUtils.jsm"
+);
 
 var user = {
   name: "Yamato Nadeshiko",
   email: "yamato.nadeshiko@example.com",
   password: "abc12345",
   incomingHost: "testin.example.com",
   outgoingHost: "testout.example.com",
 };
@@ -176,16 +179,17 @@ add_task(function test_bad_password_uses
   // Set the pref to load a local autoconfig file, that will fetch the
   // ../account/xml/example.com which contains the settings for the
   // @example.com email account (see the 'user' object).
   let url =
     "http://mochi.test:8888/browser/comm/mail/test/browser/account/xml/";
   Services.prefs.setCharPref(PREF_NAME, url);
 
   mc.sleep(0);
+  Services.telemetry.clearScalars();
   open_mail_account_setup_wizard(function(awc) {
     try {
       // Input user's account information
       awc.click(awc.eid("realname"));
       if (awc.e("realname").value) {
         // If any realname is already filled, clear it out, we have our own.
         delete_all_existing(awc, awc.eid("realname"));
       }
@@ -228,16 +232,28 @@ add_task(function test_bad_password_uses
         user.outgoingHost,
         "Outgoing server changed!"
       );
       Assert.equal(
         awc.e("incoming_hostname").value,
         user.incomingHost,
         "incoming server changed!"
       );
+
+      let scalars = TelemetryTestUtils.getProcessScalars("parent", true);
+      Assert.equal(
+        scalars["tb.account.failed_email_account_setup"].ispdb,
+        1,
+        "Count of failed email account setup with ispdb config must be correct"
+      );
+      Assert.equal(
+        scalars["tb.account.failed_email_account_setup"].user,
+        1,
+        "Count of failed email account setup with manual config must be correct"
+      );
     } finally {
       // Clean up
       Services.prefs.setCharPref(PREF_NAME, PREF_VALUE);
       awc.e("cancel_button").click();
     }
   });
 });