mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-23 06:07:07 +00:00
feat(event-tracking): start adding some client-side GA event-tracking
This commit is contained in:
parent
a7e3e76daa
commit
ffb42906e1
14 changed files with 46 additions and 26 deletions
|
|
@ -189,7 +189,10 @@ window.habitrpg = angular.module('habitrpg',
|
|||
})
|
||||
.state('options.settings.subscription', {
|
||||
url: "/subscription",
|
||||
templateUrl: "partials/options.settings.subscription.html"
|
||||
templateUrl: "partials/options.settings.subscription.html",
|
||||
onEnter: function(){
|
||||
window.ga && ga('send', 'event', 'page', 'view', 'Basic Subscription');
|
||||
}
|
||||
})
|
||||
|
||||
var settings = JSON.parse(localStorage.getItem(STORAGE_SETTINGS_ID));
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ angular.module('authCtrl', [])
|
|||
};
|
||||
|
||||
$scope.playButtonClick = function(){
|
||||
window.ga && ga('send', 'event', 'button', 'click', 'Play');
|
||||
if (User.authenticated()) {
|
||||
window.location.href = '/#/tasks';
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||
}
|
||||
$scope.newGroup = newGroup()
|
||||
$scope.create = function(group){
|
||||
if (User.user.balance < 1) return $rootScope.openModal('buyGems');
|
||||
if (User.user.balance < 1) return $rootScope.openModal('buyGems', {track:"Gems > Create Group"});
|
||||
|
||||
if (confirm(window.env.t('confirmGuild'))) {
|
||||
group.$save(function(saved){
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', '$window', 'User',
|
|||
if (item.lvl && item.lvl > user.stats.lvl)
|
||||
return alert(window.env.t('mustLevel', {level: item.lvl}));
|
||||
$rootScope.selectedQuest = item;
|
||||
$rootScope.openModal('showQuest', 'InventoryCtrl');
|
||||
$rootScope.openModal('showQuest', {controller:'InventoryCtrl'});
|
||||
}
|
||||
$scope.closeQuest = function(){
|
||||
$rootScope.selectedQuest = undefined;
|
||||
|
|
@ -149,7 +149,7 @@ habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', '$window', 'User',
|
|||
if (!completedPrevious)
|
||||
return $scope.purchase("quests", item);
|
||||
$rootScope.selectedQuest = item;
|
||||
$rootScope.openModal('buyQuest', 'InventoryCtrl');
|
||||
$rootScope.openModal('buyQuest', {controller:'InventoryCtrl'});
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ habitrpg.controller('NotificationCtrl',
|
|||
|
||||
$rootScope.$watch('user.stats.hp', function(after, before) {
|
||||
if (after <= 0){
|
||||
$rootScope.openModal('death', undefined, undefined, false, 'static');
|
||||
$rootScope.openModal('death', {keyboard:false, backdrop:'static'});
|
||||
}
|
||||
if (after == before) return;
|
||||
if (User.user.stats.lvl == 0) return;
|
||||
|
|
@ -105,7 +105,7 @@ habitrpg.controller('NotificationCtrl',
|
|||
// Classes modal
|
||||
$rootScope.$watch('!user.flags.classSelected && user.stats.lvl >= 10', function(after, before){
|
||||
if(after){
|
||||
$rootScope.openModal('chooseClass', 'UserCtrl', undefined, false, 'static');
|
||||
$rootScope.openModal('chooseClass', {controller:'UserCtrl', keyboard:false, backdrop:'static'});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ habitrpg.controller('NotificationCtrl',
|
|||
// Completed quest modal
|
||||
$rootScope.$watch('user.party.quest.completed', function(after, before){
|
||||
if (after == before || after != true) return;
|
||||
$rootScope.openModal('questCompleted', 'InventoryCtrl');
|
||||
$rootScope.openModal('questCompleted', {controller:'InventoryCtrl'});
|
||||
});
|
||||
|
||||
// Quest invitation modal
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
/* Make user and settings available for everyone through root scope.
|
||||
*/
|
||||
|
||||
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal',
|
||||
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal) {
|
||||
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout',
|
||||
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout) {
|
||||
var user = User.user;
|
||||
|
||||
var initSticky = _.once(function(){
|
||||
|
|
@ -66,13 +66,15 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||
|
||||
// Open a modal from a template expression (like ng-click,...)
|
||||
// Otherwise use the proper $modal.open
|
||||
$rootScope.openModal = function(template, controller, scope, keyboard, backdrop){
|
||||
$rootScope.openModal = function(template, options){//controller, scope, keyboard, backdrop){
|
||||
if (!options) options = {};
|
||||
if (options.track) window.ga && ga('send', 'event', 'button', 'click', options.track);
|
||||
return $modal.open({
|
||||
templateUrl: 'modals/' + template + '.html',
|
||||
controller: controller, // optional
|
||||
scope: scope, // optional
|
||||
keyboard: (keyboard === undefined ? true : keyboard), // optional
|
||||
backdrop: (backdrop === undefined ? true : backdrop) // optional
|
||||
controller: options.controller, // optional
|
||||
scope: options.scope, // optional
|
||||
keyboard: (options.keyboard === undefined ? true : options.keyboard), // optional
|
||||
backdrop: (options.backdrop === undefined ? true : options.backdrop) // optional
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ habitrpg.controller('SettingsCtrl',
|
|||
$rootScope.openRestoreModal = function(){
|
||||
$scope.restoreValues.stats = angular.copy(User.user.stats);
|
||||
$scope.restoreValues.achievements = {streak: User.user.achievements.streak || 0};
|
||||
$rootScope.openModal('restore', undefined, $scope);
|
||||
$rootScope.openModal('restore', {scope:$scope});
|
||||
};
|
||||
|
||||
$scope.restore = function(){
|
||||
|
|
|
|||
|
|
@ -5,3 +5,17 @@ window.habitrpgStatic = angular.module('habitrpgStatic', ['notificationServices'
|
|||
.constant("STORAGE_USER_ID", 'habitrpg-user')
|
||||
.constant("STORAGE_SETTINGS_ID", 'habit-mobile-settings')
|
||||
.constant("MOBILE_APP", false)
|
||||
|
||||
habitrpgStatic.controller("PlansCtrl", ['$rootScope', '$location', '$timeout',
|
||||
function($rootScope, $location, $timeout) {
|
||||
|
||||
// GA goal-tracking
|
||||
$timeout(function(){
|
||||
window.ga && ga('send', 'event', 'page', 'view', 'Plans');
|
||||
});
|
||||
|
||||
$rootScope.clickContact = function(){
|
||||
window.ga && ga('send', 'event', 'button', 'click', 'Contact Us (Plans)');
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ script(type='text/ng-template', id='partials/options.settings.settings.html')
|
|||
|
||||
hr
|
||||
h4=env.t('dangerZone')
|
||||
a.btn.btn-danger(ng-click='openModal("reset", "SettingsCtrl")', popover-trigger='mouseenter', popover-placement='right', popover=env.t('resetAccPop'))= env.t('resetAccount')
|
||||
a.btn.btn-danger(ng-click='openModal("delete", "SettingsCtrl")', popover-trigger='mouseenter', popover=env.t('deleteAccPop'))= env.t('deleteAccount')
|
||||
a.btn.btn-danger(ng-click='openModal("reset", {controller:"SettingsCtrl"})', popover-trigger='mouseenter', popover-placement='right', popover=env.t('resetAccPop'))= env.t('resetAccount')
|
||||
a.btn.btn-danger(ng-click='openModal("delete", {controller:"SettingsCtrl"})', popover-trigger='mouseenter', popover=env.t('deleteAccPop'))= env.t('deleteAccount')
|
||||
|
||||
script(type='text/ng-template', id='partials/options.settings.api.html')
|
||||
.containter-fluid
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ footer.footer(ng-controller='FooterCtrl')
|
|||
ul.list-unstyled
|
||||
if (!env.isStaticPage)
|
||||
li
|
||||
.btn.btn-sm.btn-success(ng-click='openModal("buyGems")')
|
||||
.btn.btn-sm.btn-success(ng-click='openModal("buyGems",{track:"Gems > Donate"})')
|
||||
span.glyphicon.glyphicon-heart
|
||||
=env.t('companyDonate')
|
||||
li
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
a.pull-right.gem-wallet(ng-click='openModal("buyGems")', popover-trigger='mouseenter', popover-title=env.t('gems'), popover=env.t('gemsWhatFor'), popover-placement='bottom')
|
||||
a.pull-right.gem-wallet(ng-click='openModal("buyGems",{track:"Gems > Wallet"})', popover-trigger='mouseenter', popover-title=env.t('gems'), popover=env.t('gemsWhatFor'), popover-placement='bottom')
|
||||
span.task-action-btn.tile.flush.bright.add-gems-btn +
|
||||
span.task-action-btn.tile.flush.neutral
|
||||
.Pet_Currency_Gem2x.Gems
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ script(type='text/ng-template', id='modals/rebirthEnabled.html')
|
|||
.modal-footer
|
||||
button.btn.btn-default(ng-click='$close()')=env.t('close')
|
||||
|
||||
script(type='text/ng-template', id='modals/rebirth.html')
|
||||
script(type='text/ng-template', id='modals/rebirth.html')
|
||||
.modal-header
|
||||
h4=env.t('rebirthBegin')
|
||||
.modal-body
|
||||
|
|
@ -42,7 +42,7 @@ script(type='text/ng-template', id='modals/rebirth.html')
|
|||
.modal-footer
|
||||
button.btn.btn-default(ng-click='$close()')=env.t('neverMind')
|
||||
span(ng-if='user.balance < 2')
|
||||
a.btn.btn-success(ng-click='openModal("buyGems")')=env.t('buyMoreGems')
|
||||
a.btn.btn-success(ng-click='openModal("buyGems",{track:"Gems > Rebirth"})')=env.t('buyMoreGems')
|
||||
span.gem-cost=env.t('notEnoughGems')
|
||||
span(ng-if='user.balance >= 2', ng-controller='SettingsCtrl')
|
||||
a.btn.btn-danger(ng-click='$close(); rebirth()')=env.t('beReborn')
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ script(type='text/ng-template', id='modals/reroll.html')
|
|||
.modal-footer
|
||||
button.btn.btn-default(ng-click='$close()')=env.t('neverMind')
|
||||
span(ng-if='user.balance < 1')
|
||||
a.btn.btn-success(ng-click='openModal("buyGems")')=env.t('buyMoreGems')
|
||||
a.btn.btn-success(ng-click='openModal("buyGems",{track:{"Gems > Reroll"}})')=env.t('buyMoreGems')
|
||||
span.gem-cost=env.t('notEnoughGems')
|
||||
span(ng-if='user.balance >= 1', ng-controller='SettingsCtrl')
|
||||
a.btn.btn-danger(ng-click='$close(); reroll()')=env.t('fortify')
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ block title
|
|||
title=env.t('groupPlans')
|
||||
|
||||
block content
|
||||
.row
|
||||
.row(ng-controller='PlansCtrl')
|
||||
.col-md-12
|
||||
h2=env.t('groupPlans')
|
||||
|
||||
|
|
@ -94,8 +94,8 @@ block content
|
|||
th
|
||||
//| Price
|
||||
td
|
||||
a.btn.btn-default.muted(href='https://docs.google.com/forms/d/17torT7OlxgtbHAPdBDRQNG2lTdIQyrGXk4O2YXvUMig/viewform',popover=env.t('notYetPlan'),popover-placement='right',popover-trigger='mouseenter')=env.t('contactUs')
|
||||
a.btn.btn-default.muted(ng-click='clickContact()', href='https://docs.google.com/forms/d/17torT7OlxgtbHAPdBDRQNG2lTdIQyrGXk4O2YXvUMig/viewform',popover=env.t('notYetPlan'),popover-placement='right',popover-trigger='mouseenter')=env.t('contactUs')
|
||||
td
|
||||
a.btn.btn-default.muted(href='https://docs.google.com/forms/d/17torT7OlxgtbHAPdBDRQNG2lTdIQyrGXk4O2YXvUMig/viewform',popover=env.t('notYetPlan'),popover-placement='right',popover-trigger='mouseenter')=env.t('contactUs')
|
||||
a.btn.btn-default.muted(ng-click='clickContact()', href='https://docs.google.com/forms/d/17torT7OlxgtbHAPdBDRQNG2lTdIQyrGXk4O2YXvUMig/viewform',popover=env.t('notYetPlan'),popover-placement='right',popover-trigger='mouseenter')=env.t('contactUs')
|
||||
td
|
||||
a.btn.btn-primary(href='https://docs.google.com/forms/d/12Jqj_8f3oQS0B3ZUHewHbK61uLjBdzBeB0zyEqB9lxM/viewform')=env.t('contactUs')
|
||||
a.btn.btn-primary(ng-click='clickContact()', href='https://docs.google.com/forms/d/12Jqj_8f3oQS0B3ZUHewHbK61uLjBdzBeB0zyEqB9lxM/viewform')=env.t('contactUs')
|
||||
|
|
|
|||
Loading…
Reference in a new issue