Bug 782468. Basic telemetry for SocialAPI. r=froydnj,mixedpuppy
authorFelipe Gomes <felipc@gmail.com>
Fri, 24 Aug 2012 17:24:52 -0700
changeset 105392 0e8f4d4d62fe3cd44aed3eb55f139fcf7016bd6a
parent 105391 770b96704cde49dccceee90e433e43eb6cd7a35a
child 105393 67ff83142ba5058e9370fb6e1289c929739cdd5b
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersfroydnj, mixedpuppy
bugs782468
milestone17.0a1
Bug 782468. Basic telemetry for SocialAPI. r=froydnj,mixedpuppy
toolkit/components/social/MozSocialAPI.jsm
toolkit/components/social/SocialService.jsm
toolkit/components/telemetry/Histograms.json
--- a/toolkit/components/social/MozSocialAPI.jsm
+++ b/toolkit/components/social/MozSocialAPI.jsm
@@ -8,25 +8,32 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "SocialService", "resource://gre/modules/SocialService.jsm");
 
 const EXPORTED_SYMBOLS = ["MozSocialAPI"];
 
 var MozSocialAPI = {
   _enabled: false,
+  _everEnabled: false,
   set enabled(val) {
     let enable = !!val;
     if (enable == this._enabled) {
       return;
     }
     this._enabled = enable;
 
     if (enable) {
       Services.obs.addObserver(injectController, "document-element-inserted", false);
+
+      if (!this._everEnabled) {
+        this._everEnabled = true;
+        Services.telemetry.getHistogramById("SOCIAL_ENABLED_ON_SESSION").add(true);
+      }
+
     } else {
       Services.obs.removeObserver(injectController, "document-element-inserted", false);
     }
   }
 };
 
 // Called on document-element-inserted, checks that the API should be injected,
 // and then calls attachToWindow as appropriate
--- a/toolkit/components/social/SocialService.jsm
+++ b/toolkit/components/social/SocialService.jsm
@@ -92,16 +92,17 @@ const SocialService = {
     Services.prefs.setBoolPref("social.enabled", enable);
     this._setEnabled(enable);
   },
   _setEnabled: function _setEnabled(enable) {
     SocialServiceInternal.providerArray.forEach(function (p) p.enabled = enable);
     SocialServiceInternal.enabled = enable;
     MozSocialAPI.enabled = enable;
     Services.obs.notifyObservers(null, "social:pref-changed", enable ? "enabled" : "disabled");
+    Services.telemetry.getHistogramById("SOCIAL_TOGGLED").add(enable);
   },
 
   // Adds a provider given a manifest, and returns the added provider.
   addProvider: function addProvider(manifest, onDone) {
     if (SocialServiceInternal.providers[manifest.origin])
       throw new Error("SocialService.addProvider: provider with this origin already exists");
 
     let provider = new SocialProvider(manifest, SocialServiceInternal.enabled);
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -2189,10 +2189,18 @@
     "kind": "flag",
     "description": "Killed due to an OOM condition",
     "cpp_guard": "ANDROID"
   },
   "SECURITY_UI": {
     "kind": "enumerated",
     "n_values": 100,
     "description": "Security UI Telemetry"
+  },
+  "SOCIAL_ENABLED_ON_SESSION": {
+    "kind": "flag",
+    "description": "Social has been enabled at least once on the current session"
+  },
+  "SOCIAL_TOGGLED": {
+    "kind": "boolean",
+    "description": "Social has been toggled to on or off"
   }
 }