Bug 1066816 - Allow OT toolkit to set GUID for analytics r=Standard8
authorAdam Roach [:abr] <adam@nostrum.com>
Tue, 16 Sep 2014 06:46:11 -0700
changeset 225392 1d2300d17d3b15fa8659756d5ee76bd1b335c07f
parent 225391 5b1cf6f6d72ea1a52d2cf24f2413aa0050f980a6
child 225393 07c61c94ab8cd7d272984fb8fadf2179a8785e6d
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1066816
milestone34.0a2
Bug 1066816 - Allow OT toolkit to set GUID for analytics r=Standard8
browser/components/loop/content/js/conversation.js
browser/components/loop/content/js/conversation.jsx
--- a/browser/components/loop/content/js/conversation.js
+++ b/browser/components/loop/content/js/conversation.js
@@ -450,16 +450,30 @@ loop.conversation = (function(OT, mozL10
   /**
    * Panel initialisation.
    */
   function init() {
     // Do the initial L10n setup, we do this before anything
     // else to ensure the L10n environment is setup correctly.
     mozL10n.initialize(navigator.mozLoop);
 
+    // Plug in an alternate client ID mechanism, as localStorage and cookies
+    // don't work in the conversation window
+    if (OT && OT.hasOwnProperty("overrideGuidStorage")) {
+      OT.overrideGuidStorage({
+        get: function(callback) {
+          callback(null, navigator.mozLoop.getLoopCharPref("ot.guid"));
+        },
+        set: function(guid, callback) {
+          navigator.mozLoop.setLoopCharPref("ot.guid", guid);
+          callback(null);
+        }
+      });
+    }
+
     document.title = mozL10n.get("incoming_call_title2");
 
     document.body.classList.add(loop.shared.utils.getTargetPlatform());
 
     var client = new loop.Client();
     router = new ConversationRouter({
       client: client,
       conversation: new loop.shared.models.ConversationModel(
--- a/browser/components/loop/content/js/conversation.jsx
+++ b/browser/components/loop/content/js/conversation.jsx
@@ -450,16 +450,30 @@ loop.conversation = (function(OT, mozL10
   /**
    * Panel initialisation.
    */
   function init() {
     // Do the initial L10n setup, we do this before anything
     // else to ensure the L10n environment is setup correctly.
     mozL10n.initialize(navigator.mozLoop);
 
+    // Plug in an alternate client ID mechanism, as localStorage and cookies
+    // don't work in the conversation window
+    if (OT && OT.hasOwnProperty("overrideGuidStorage")) {
+      OT.overrideGuidStorage({
+        get: function(callback) {
+          callback(null, navigator.mozLoop.getLoopCharPref("ot.guid"));
+        },
+        set: function(guid, callback) {
+          navigator.mozLoop.setLoopCharPref("ot.guid", guid);
+          callback(null);
+        }
+      });
+    }
+
     document.title = mozL10n.get("incoming_call_title2");
 
     document.body.classList.add(loop.shared.utils.getTargetPlatform());
 
     var client = new loop.Client();
     router = new ConversationRouter({
       client: client,
       conversation: new loop.shared.models.ConversationModel(