Преглед изворни кода

HUE-1399 [hbase] GA tracking not proper URL

Kevin Wang пре 12 година
родитељ
комит
df14937

+ 13 - 14
apps/hbase/src/hbase/templates/app.mako

@@ -72,7 +72,7 @@ ${ commonheader(None, "hbase", user) | n,unicode }
           % if user.is_superuser:
             <button class="btn" data-bind="enable: $data.selected().length > 0, click: $data.dropSelected, clickBubble: false"><i class="icon-trash"></i> Drop Columns</button>
           % endif
-          <a href="#new_column_modal" data-bind="click:function(){$('#new_column_row_key').val($data.row);app.focusModel($data);logGA('#new_column_modal');}" class="btn" data-toggle="modal" title="${_('Add New Column/Cell')}"><i class="icon-plus"></i></a>
+          <a href="#new_column_modal" data-bind="click:function(){$('#new_column_row_key').val($data.row);app.focusModel($data);logGA('new_column_modal');}" class="btn" data-toggle="modal" title="${_('Add New Column/Cell')}"><i class="icon-plus"></i></a>
         </span>
       </h5>
       <ul class="smartview-cells" data-bind="event: {scroll: onScroll}">
@@ -198,19 +198,18 @@ ${ commonheader(None, "hbase", user) | n,unicode }
     <div class="subnav sticky">
       <div class="container-fluid">
         <div class="row-fluid">
-          <div class="span6">
-            <div id="searchbar-main" class="span10" data-bind="click: search.clickTagBar">
-              <div id="search-tags" contenteditable="true" data-bind="editableText: search.cur_input, hasfocus: search.focused, css: { 'active': search.cur_input() != '' }, event: { 'keydown': search.onKeyDown, click: search.updateMenu.bind(null) }" data-placeholder="${_('row_key, row_key_prefix* + scan_length, row_key [family:col1, family2:col2, family3:]')}">
-              </div>
+          <div id="searchbar-main" class="span6" data-bind="click: search.clickTagBar">
+            <div id="search-tags" contenteditable="true" data-bind="editableText: search.cur_input, hasfocus: search.focused, css: { 'active': search.cur_input() != '' }, event: { 'keydown': search.onKeyDown, click: search.updateMenu.bind(null) }" data-placeholder="${_('row_key, row_key_prefix* + scan_length, row_key [family:col1, family2:col2, family3:]')}">
             </div>
-            <ul id="search-typeahead" data-bind="visible: search.focused()">
-              <!-- ko if: search.mode() != 'idle' -->
-              <li><a><b data-bind="text: search.modes[search.mode()].hint"></b>: <span data-bind="html: search.hintText()"></span> <code class="pull-right" data-bind="text: search.modes[search.mode()].type"></code></a></li>
-              <!-- /ko -->
-              <!-- ko foreach: search.activeHints() -->
-              <li data-bind="event: { mousedown: function(){app.search.cur_input(app.search.cur_input() + $data.shortcut);} }, css: {active: self.activeHint}"><a><span data-bind="text: $data.hint"></span> <code class="pull-right" data-bind="text: $data.shortcut"></code></a></li>
-              <!-- /ko -->
-            </ul>
+          </div>
+          <ul id="search-typeahead" data-bind="visible: search.focused()">
+            <!-- ko if: search.mode() != 'idle' -->
+            <li><a><b data-bind="text: search.modes[search.mode()].hint"></b>: <span data-bind="html: search.hintText()"></span> <code class="pull-right" data-bind="text: search.modes[search.mode()].type"></code></a></li>
+            <!-- /ko -->
+            <!-- ko foreach: search.activeHints() -->
+            <li data-bind="event: { mousedown: function(){app.search.cur_input(app.search.cur_input() + $data.shortcut);} }, css: {active: self.activeHint}"><a><span data-bind="text: $data.hint"></span> <code class="pull-right" data-bind="text: $data.shortcut"></code></a></li>
+            <!-- /ko -->
+          </ul>
           <span id="column-family-selectors">
             <!-- ko foreach: views.tabledata.columnFamilies() -->
               <span class="label" data-bind="text: $data.name, style: {'backgroundColor': ($data.enabled()) ? stringHashColor($data.name.split(':')[0]) : '#ccc' ,'cursor':'pointer'}, click: $data.toggle"></span>
@@ -255,7 +254,7 @@ ${ commonheader(None, "hbase", user) | n,unicode }
             % if user.is_superuser:
               <button class="btn" data-bind="enable: views.tabledata.selected().length > 0, click: views.tabledata.dropSelected"><i class="icon-trash"></i> ${_('Drop Rows')}</button>
             % endif
-            <a href="#new_row_modal" data-bind="click:function(){app.focusModel(app.views.tabledata);logGA('#new_row_modal');}" role="button" class="btn btn-primary" data-callback="" data-toggle="modal"><i class='icon-plus-sign'></i> ${_('New Row')}</a>
+            <a href="#new_row_modal" data-bind="click:function(){app.focusModel(app.views.tabledata);logGA('new_row_modal');}" role="button" class="btn btn-primary" data-callback="" data-toggle="modal"><i class='icon-plus-sign'></i> ${_('New Row')}</a>
           </span>
         </div>
     </div>

+ 4 - 4
apps/hbase/static/js/app.js

@@ -110,7 +110,7 @@ routed = false;
 routie({
   ':cluster/:table/query/:query': function(cluster, table, query)
     {
-      //logGA();
+      logGA('query_table');
       Router.setTable(cluster, table);
       Views.render('dataview');
       app.station('table');
@@ -120,7 +120,7 @@ routie({
     },
     ':cluster/:table': function(cluster, table)
     {
-      //logGA();
+      //logGA('view_table'); taken care of in reload()
       Router.setTable(cluster, table);
       app.station('table');
       Views.render('dataview');
@@ -128,7 +128,7 @@ routie({
     },
     ':cluster': function(cluster)
     {
-      //logGA();
+      logGA('view_cluster');
       Breadcrumbs.render();
       app.station('cluster');
       app.cluster(cluster);
@@ -139,7 +139,7 @@ routie({
     },
     'error': function()
     {
-      logGA();
+      logGA('error');
       routed = true;
     },
     '': function(){

+ 0 - 1
apps/hbase/static/js/base.js

@@ -118,7 +118,6 @@ var ListViewModel = function(options)
     });
   };
   self.reload = function(callback){
-    logGA();
     self.items.removeAll();
     self.isLoading(true);
     options.reload.apply(self,[function()

+ 5 - 1
apps/hbase/static/js/controls.js

@@ -70,6 +70,7 @@ var DataTableViewModel = function(options)
   var _reload = self.reload;
   self.reload = function(callback)
   {
+    logGA('view_cluster');
     if(self._table)
     {
       self._table.fnClearTable();
@@ -224,6 +225,7 @@ var SmartViewModel = function(options)
   var _reload = self.reload;
   self.reload = function(callback)
   {
+  	logGA('view_table');
     self.truncated = ko.observable(false);
     var queryStart = new Date();
     _reload(function()
@@ -405,6 +407,7 @@ var SmartViewDataRow = function(options)
   var _reload = self.reload;
   self.reload = function(callback)
   {
+  	logGA('get_row');
     _reload(function()
     {
       if(callback!=null)
@@ -426,6 +429,7 @@ var ColumnRow = function(options)
   {
     function doDrop()
     {
+      logGA('filter_columns');
       self.parent.isLoading(true);
       return API.queryTable('deleteColumn', self.parent.row, self.name).done(function(data)
       {
@@ -453,7 +457,7 @@ var ColumnRow = function(options)
   self.value.subscribe(function(value)
   {
     //change transport prep to object wrapper
-    logGA();
+    logGA('put_column');
     API.queryTable('putColumn', self.parent.row, self.name, "hbase-post-key-" + value).done(function(data)
     {
       self.reload(function(){}, true);

+ 0 - 1
apps/hbase/static/js/nav.js

@@ -34,7 +34,6 @@ var Router =
   {
     Router.set();
     app.cluster(cluster);
-    logGA();
   },
   set: function()
   {

+ 4 - 4
apps/hbase/static/js/utils.js

@@ -132,7 +132,7 @@ function launchModal(modal, data)
       break;
   }
   element.modal('show');
-  logGA('#' + modal);
+  logGA(modal.slice(0, modal.indexOf('_modal') != -1 ? modal.indexOf('_modal') : modal.length));
 }
 
 function parseXML(xml)
@@ -239,9 +239,9 @@ function logGA(postfix)
 {
   if(postfix == null)
     postfix = ""
-  if (typeof _gaq != 'undefined' && _gaq != null && _gaq != undefined){
-       _gaq.push(['_trackPageview', document.URL.slice(document.URL.indexOf('/hbase')) + postfix]);
-    }
+  if (typeof trackOnGA == 'function'){
+    trackOnGA('hbase/' + postfix);
+  }
 };
 
 function getEditablePosition(contentEditable, trimWhitespaceNodes) {