Bug 1241627 - Associate account conversions with onboarding experiments r=margaret r=nalexander
authorMark Finkle <mfinkle@mozilla.com>
Thu, 03 Mar 2016 17:29:45 -0500
changeset 286608 4ad4e4652aa8a21ed83e7e63d29fe7e1229f1848
parent 286607 ad2c21a89e6e0f298d7c421426114d7849e594a8
child 286609 81091bc7558f165e3cad9fe247c466f647f8e4d0
push id30052
push usercbook@mozilla.com
push dateFri, 04 Mar 2016 10:49:19 +0000
treeherdermozilla-central@3b21d7cfcf43 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, nalexander
bugs1241627
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1241627 - Associate account conversions with onboarding experiments r=margaret r=nalexander
mobile/android/modules/FxAccountsWebChannel.jsm
--- a/mobile/android/modules/FxAccountsWebChannel.jsm
+++ b/mobile/android/modules/FxAccountsWebChannel.jsm
@@ -9,18 +9,16 @@
  * Use the WebChannel component to receive messages about account
  * state changes.
  */
 this.EXPORTED_SYMBOLS = ["EnsureFxAccountsWebChannel"];
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; /*global Components */
 
 Cu.import("resource://gre/modules/Accounts.jsm"); /*global Accounts */
-Cu.import("resource://gre/modules/Notifications.jsm"); /*global Notifications */
-Cu.import("resource://gre/modules/Prompt.jsm"); /*global Prompt */
 Cu.import("resource://gre/modules/Services.jsm"); /*global Services */
 Cu.import("resource://gre/modules/WebChannel.jsm"); /*global WebChannel */
 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); /*global XPCOMUtils */
 
 const log = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.bind("FxAccounts");
 
 const WEBCHANNEL_ID = "account_updates";
 
@@ -33,19 +31,18 @@ const COMMAND_PROFILE_CHANGE       = "pr
 const COMMAND_SYNC_PREFERENCES     = "fxaccounts:sync_preferences";
 
 const PREF_LAST_FXA_USER           = "identity.fxaccounts.lastSignedInUserHash";
 
 XPCOMUtils.defineLazyGetter(this, "strings",
                             () => Services.strings.createBundle("chrome://browser/locale/aboutAccounts.properties")); /*global strings */
 
 XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm");
-
-Object.defineProperty(this, "NativeWindow",
-                      { get: () => Services.wm.getMostRecentWindow("navigator:browser").NativeWindow }); /*global NativeWindow */
+XPCOMUtils.defineLazyModuleGetter(this, "Prompt", "resource://gre/modules/Prompt.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry", "resource://gre/modules/UITelemetry.jsm");
 
 this.FxAccountsWebChannelHelpers = function() {
 };
 
 this.FxAccountsWebChannelHelpers.prototype = {
   /**
    * Get the hash of account name of the previously signed in account.
    */
@@ -269,23 +266,25 @@ this.FxAccountsWebChannel.prototype = {
             // Android Account here.  There's not much to be done if we don't
             // succeed or get an error.
             Accounts.getFirefoxAccount().then(account => {
               if (!account) {
                 return Accounts.createFirefoxAccountFromJSON(data).then(success => {
                   if (!success) {
                     throw new Error("Could not create Firefox Account!");
                   }
+                  UITelemetry.addEvent("action.1", "content", null, "fxaccount-create");
                   return success;
                 });
               } else {
                 return Accounts.updateFirefoxAccountFromJSON(data).then(success => {
                   if (!success) {
                     throw new Error("Could not update Firefox Account!");
                   }
+                  UITelemetry.addEvent("action.1", "content", null, "fxaccount-login");
                   return success;
                 });
               }
             })
             .then(success => {
               if (!success) {
                 throw new Error("Could not create or update Firefox Account!");
               }
@@ -307,16 +306,17 @@ this.FxAccountsWebChannel.prototype = {
                 throw new Error("Can't change password of non-existent Firefox Account!");
               }
               return Accounts.updateFirefoxAccountFromJSON(data);
             })
             .then(success => {
               if (!success) {
                 throw new Error("Could not change Firefox Account password!");
               }
+              UITelemetry.addEvent("action.1", "content", null, "fxaccount-changepassword");
               log.i("Changed Firefox Account password.");
             })
             .catch(e => {
               log.e(e.toString());
             });
             break;
 
           case COMMAND_DELETE_ACCOUNT:
@@ -327,37 +327,40 @@ this.FxAccountsWebChannel.prototype = {
             Accounts.getFirefoxAccount().then(account => {
               if (!account) {
                 throw new Error("Can't delete non-existent Firefox Account!");
               }
               return Accounts.deleteFirefoxAccount().then(success => {
                 if (!success) {
                   throw new Error("Could not delete Firefox Account!");
                 }
+                UITelemetry.addEvent("action.1", "content", null, "fxaccount-delete");
                 log.i("Firefox Account deleted.");
               });
             }).catch(e => {
               log.e(e.toString());
             });
             break;
 
           case COMMAND_PROFILE_CHANGE:
             // Only update an existing Android Account.
             Accounts.getFirefoxAccount().then(account => {
               if (!account) {
                 throw new Error("Can't change profile of non-existent Firefox Account!");
               }
+              UITelemetry.addEvent("action.1", "content", null, "fxaccount-changeprofile");
               return Accounts.notifyFirefoxAccountProfileChanged();
             })
             .catch(e => {
               log.e(e.toString());
             });
             break;
 
           case COMMAND_SYNC_PREFERENCES:
+            UITelemetry.addEvent("action.1", "content", null, "fxaccount-syncprefs");
             Accounts.showSyncPreferences()
             .catch(e => {
               log.e(e.toString());
             });
             break;
 
           default:
             log.w("Ignoring unrecognized FxAccountsWebChannel command: " + JSON.stringify(command));