From f1e9ce6702f3717c4e2e2f17fb8ce78847dfbde2 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Fri, 17 Jul 2015 12:59:52 -0400 Subject: [PATCH] Localytics events. --- media/js/src/application.js | 10 ++++++++++ media/js/src/modules/snipt.js | 10 ++++++++++ media/js/src/snipts.js | 5 +++++ templates/analytics.html | 4 +++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/media/js/src/application.js b/media/js/src/application.js index d9a9f22..14fe23c 100644 --- a/media/js/src/application.js +++ b/media/js/src/application.js @@ -37,6 +37,16 @@ jQuery(function($) { root.app = app; + if (root.location.pathname === '/account/stats/') { + root.ll('tagEvent', 'Viewed stats page'); + } + if (root.location.pathname === '/pro/') { + root.ll('tagEvent', 'Viewed Pro page'); + } + if (root.location.pathname === '/pro/signup/') { + root.ll('tagEvent', 'Viewed Pro signup page'); + } + app.controller('AppController', function($scope) { $scope.ads = [ { diff --git a/media/js/src/modules/snipt.js b/media/js/src/modules/snipt.js index c4006d2..23aa028 100644 --- a/media/js/src/modules/snipt.js +++ b/media/js/src/modules/snipt.js @@ -55,6 +55,8 @@ copy: function() { + window.ll('tagEvent', 'Copied snipt'); + $('textarea', this.$copyModal).remove(); window.ui_halted = true; @@ -84,6 +86,8 @@ }, edit: function(adding) { + window.ll('tagEvent', 'Edited snipt'); + window.editing = true; window.ui_halted = true; @@ -255,6 +259,8 @@ }, embed: function() { + window.ll('tagEvent', 'Embedded snipt'); + $('textarea', this.$embedModal).remove(); window.ui_halted = true; @@ -314,6 +320,7 @@ success: function() { that.$el.removeClass('favorited'); that.$favorite.text('Favorite'); + window.ll('tagEvent', 'Unfavorited snipt'); }, headers: { 'Authorization': 'ApiKey ' + window.user + ':' + window.api_key @@ -328,6 +335,7 @@ that.$el.addClass('favorited'); that.model.set({'favorite_id': resp.id}, {'silent': true}); that.$favorite.text('Favorited'); + window.ll('tagEvent', 'Favorited snipt'); }, headers: { 'Authorization': 'ApiKey ' + window.user + ':' + window.api_key @@ -655,6 +663,8 @@ }, addNewSnipt: function() { + window.ll('tagEvent', 'Added snipt'); + var $articleNewSnipt = $('article#new-snipt'); if ($articleNewSnipt.length === 0) { diff --git a/media/js/src/snipts.js b/media/js/src/snipts.js index ec439d6..4bcf504 100644 --- a/media/js/src/snipts.js +++ b/media/js/src/snipts.js @@ -20,6 +20,11 @@ $scope.$root.account = response.data; $scope.$root.$watch('account.list_view', function(newView, oldView) { if (oldView !== newView) { + if (newView === 'N') { + window.ll('tagEvent', 'Switched to normal view'); + } else { + window.ll('tagEvent', 'Switched to compact view'); + } AccountStorage.saveAccount($scope.$root.account, ['list_view']).then(function(response) { $scope.$root.account = response.data; }); diff --git a/templates/analytics.html b/templates/analytics.html index 7de8e63..7210c0f 100644 --- a/templates/analytics.html +++ b/templates/analytics.html @@ -7,7 +7,9 @@ (s = y.createElement(t)).type = 'text/javascript'; s.src = '//web.localytics.com/v3/localytics.js'; (c = y.getElementsByTagName(t)[0]).parentNode.insertBefore(s, c); - ll('init', 'a62d3f2d950818261a89f2f-70c7cac4-2c9f-11e5-de49-00f078254409', {} /* Options */); + ll('init', 'a62d3f2d950818261a89f2f-70c7cac4-2c9f-11e5-de49-00f078254409', { + trackPageView: true + } /* Options */); }(window, document, 'script', 'll');