mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
feat(analytics): Mixpanel implementation WIP
This commit is contained in:
@@ -46,6 +46,16 @@ angular.module('habitrpg')
|
||||
if($rootScope.selectedLanguage) url = url + '?lang=' + $rootScope.selectedLanguage.code;
|
||||
$http.post(url, scope.registerVals).success(function(data, status, headers, config) {
|
||||
runAuth(data.id, data.apiToken);
|
||||
if (status == 200) {
|
||||
mixpanel.alias(data._id);
|
||||
if (data.auth.facebook) {
|
||||
mixpanel.register({'authType':'facebook','email':data.auth.facebook._json.email})
|
||||
} else {
|
||||
mixpanel.register({'authType':'email','email':data.auth.local.email})
|
||||
}
|
||||
mixpanel.register({'UUID':data._id,'language':data.preferences.language});
|
||||
mixpanel.track('Registration');
|
||||
}
|
||||
}).error(errorAlert);
|
||||
};
|
||||
|
||||
@@ -57,6 +67,11 @@ angular.module('habitrpg')
|
||||
$http.post(ApiUrl.get() + "/api/v2/user/auth/local", data)
|
||||
.success(function(data, status, headers, config) {
|
||||
runAuth(data.id, data.token);
|
||||
if (status == 200) {
|
||||
mixpanel.identify(data.id);
|
||||
mixpanel.register({'UUID':data._id});
|
||||
mixpanel.track('Login');
|
||||
}
|
||||
}).error(errorAlert);
|
||||
};
|
||||
|
||||
@@ -121,13 +136,18 @@ angular.module('habitrpg')
|
||||
// ------ Social ----------
|
||||
|
||||
hello.init({
|
||||
facebook : window.env.FACEBOOK_KEY,
|
||||
facebook : window.env.FACEBOOK_KEY
|
||||
});
|
||||
|
||||
$scope.socialLogin = function(network){
|
||||
hello(network).login({scope:'email'}).then(function(auth){
|
||||
$http.post(ApiUrl.get() + "/api/v2/user/auth/social", auth)
|
||||
.success(function(data, status, headers, config) {
|
||||
if (status == 200) {
|
||||
mixpanel.identify(data.id);
|
||||
mixpanel.register({'UUID':data._id});
|
||||
mixpanel.track('Login');
|
||||
}
|
||||
runAuth(data.id, data.token);
|
||||
}).error(errorAlert);
|
||||
}, function( e ){
|
||||
|
||||
@@ -320,6 +320,11 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
||||
}
|
||||
$scope.message.content = '';
|
||||
$scope._sending = false;
|
||||
if (group.privacy == 'public'){
|
||||
mixpanel.track('Group Chat',{'groupType':group.type,'privacy':group.privacy,'groupName':group.name,'message':message})
|
||||
} else {
|
||||
mixpanel.track('Group Chat',{'groupType':group.type,'privacy':group.privacy})
|
||||
}
|
||||
}, function(err){
|
||||
$scope._sending = false;
|
||||
});
|
||||
@@ -431,6 +436,8 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
||||
|
||||
if (confirm(window.env.t('confirmGuild'))) {
|
||||
group.$save(function(saved){
|
||||
if (saved.privacy == 'public') {mixpanel.track('Join Group',{'owner':true,'groupType':'guild','privacy':saved.privacy,'groupName':saved.name})}
|
||||
else {mixpanel.track('Join Group',{'owner':true,'groupType':'guild','privacy':saved.privacy})}
|
||||
$rootScope.hardRedirect('/#/options/groups/guilds/' + saved._id);
|
||||
});
|
||||
}
|
||||
@@ -445,6 +452,8 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
||||
}
|
||||
|
||||
group.$join(function(joined){
|
||||
if (joined.privacy == 'public') {mixpanel.track('Join Group',{'owner':false,'groupType':'guild','privacy':joined.privacy,'groupName':joined.name})}
|
||||
else {mixpanel.track('Join Group',{'owner':false,'groupType':'guild','privacy':joined.privacy})}
|
||||
$rootScope.hardRedirect('/#/options/groups/guilds/' + joined._id);
|
||||
})
|
||||
}
|
||||
@@ -510,6 +519,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
||||
|
||||
$scope.create = function(group){
|
||||
group.$save(function(){
|
||||
mixpanel.track('Join Group',{'owner':true,'groupType':'party','privacy':'private'});
|
||||
$rootScope.hardRedirect('/#/options/groups/party');
|
||||
});
|
||||
}
|
||||
@@ -517,6 +527,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
||||
$scope.join = function(party){
|
||||
var group = new Groups.Group({_id: party.id, name: party.name});
|
||||
group.$join(function(){
|
||||
mixpanel.track('Join Group',{'owner':false,'groupType':'party','privacy':'private'});
|
||||
$rootScope.hardRedirect('/#/options/groups/party');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -180,6 +180,7 @@ habitrpg.controller("InventoryCtrl",
|
||||
$rootScope.selectedQuest = undefined;
|
||||
}
|
||||
$scope.questInit = function(){
|
||||
mixpanel.track("Quest",{"owner":true,"response":"accept","questName":$scope.selectedQuest.key});
|
||||
$rootScope.party.$questAccept({key:$scope.selectedQuest.key}, function(){
|
||||
$rootScope.party.$get();
|
||||
});
|
||||
|
||||
@@ -87,6 +87,7 @@ habitrpg.controller('NotificationCtrl',
|
||||
Notification.drop(User.user._tmp.drop.dialog);
|
||||
}
|
||||
$rootScope.playSound('Item_Drop');
|
||||
mixpanel.track("Acquire Item",{'itemName':after.key,'acquireMethod':'Drop'})
|
||||
});
|
||||
|
||||
$rootScope.$watch('user.achievements.streak', function(after, before){
|
||||
|
||||
@@ -21,7 +21,9 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
if (direction === 'down') $rootScope.playSound('Minus_Habit');
|
||||
else if (direction === 'up') $rootScope.playSound('Plus_Habit');
|
||||
}
|
||||
User.user.ops.score({params:{id: task.id, direction:direction}})
|
||||
User.user.ops.score({params:{id: task.id, direction:direction}});
|
||||
mixpanel.register({'Gold':Math.floor(User.user.stats.gp),'Health':Math.ceil(User.user.stats.hp),'Experience':Math.floor(User.user.stats.exp),'Level':User.user.stats.lvl,'Mana':Math.floor(User.user.stats.mp),'Class':User.user.stats.class,'subscription':User.user.purchased.plan.planId,'contributorLevel':User.user.contributor.level,'UUID':User.user._id});
|
||||
mixpanel.track('Score Task',{'taskType':task.type,'direction':direction});
|
||||
};
|
||||
|
||||
function addTask(addTo, listDef, task) {
|
||||
|
||||
@@ -166,11 +166,13 @@ function($rootScope, User, $timeout, $state) {
|
||||
return $timeout(function(){});
|
||||
}
|
||||
window.ga && ga('send', 'event', 'behavior', 'tour', k, i+1);
|
||||
mixpanel.track('Tutorial',{'tour':k+'-web','step':i+1,'complete':false});
|
||||
}
|
||||
step.onHide = function(){
|
||||
if (step.final) { // -2 indicates complete
|
||||
var ups={};ups['flags.tour.'+k] = -2;
|
||||
User.set(ups);
|
||||
mixpanel.track('Tutorial',{'tour':k+'-web','step':i+1,'complete':true});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user