瀏覽代碼

HUE-1336 [pig] Call data collection on routie changes

Added global function to track additional paths on GA
Enrico Berti 12 年之前
父節點
當前提交
90cf5fd
共有 2 個文件被更改,包括 15 次插入2 次删除
  1. 9 2
      apps/pig/src/pig/templates/app.mako
  2. 6 0
      desktop/core/src/desktop/templates/common_footer.html

+ 9 - 2
apps/pig/src/pig/templates/app.mako

@@ -833,7 +833,7 @@ ${ commonheader(None, "pig", user, "100px") | n,unicode }
       resizeLogs();
     });
 
-    function showMainSection(mainSection) {
+    function showMainSection(mainSection, includeGA) {
       window.setTimeout(function () {
         codeMirror.refresh();
         codeMirror.setSize("100%", $(window).height() - 250);
@@ -844,15 +844,22 @@ ${ commonheader(None, "pig", user, "100px") | n,unicode }
         $("#" + mainSection).show();
         highlightMainMenu(mainSection);
       }
+      if (typeof trackOnGA == 'function' && includeGA == undefined){
+        trackOnGA(mainSection);
+      }
     }
 
     function showSection(mainSection, section) {
-      showMainSection(mainSection);
+      showMainSection(mainSection, false);
       if ($("#" + section).is(":hidden")) {
         $(".section").hide();
         $("#" + section).show();
         highlightMenu(section);
       }
+
+      if (typeof trackOnGA == 'function'){
+        trackOnGA(mainSection + "/" + section);
+      }
     }
 
     function highlightMainMenu(mainSection) {

+ 6 - 0
desktop/core/src/desktop/templates/common_footer.html

@@ -139,6 +139,12 @@ limitations under the License.
         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
       })();
 
+      function trackOnGA(path) {
+        if (_gaq != undefined && _gaq != null){
+          _gaq.push(['_trackPageview', '/remote/{{ version }}/' + path]);
+        }
+      }
+
       {% endif %}
 
     </script>