Last active
August 29, 2015 14:23
-
-
Save SabreCat/1234de17ecb025a0eb2f to your computer and use it in GitHub Desktop.
Analytics service with $inject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Sabe on 6/15/2015. | |
*/ | |
'use strict'; | |
angular | |
.module('habitrpg') | |
.factory('Analytics', analyticsFactory); | |
analyticsFactory.$inject = [ | |
'User' | |
]; | |
function analyticsFactory(User) { | |
return { | |
register: register, | |
login: login, | |
track: track, | |
updateUser: updateUser, | |
revenue: revenue | |
}; | |
var user = User.user; | |
function register() { | |
} | |
function login() { | |
} | |
function track(type,action,label,properties) { | |
amplitude.logEvent(action,properties); | |
ga('send','event',type,action,label,properties.value); | |
mixpanel.track(action,properties); | |
} | |
function updateUser(properties) { | |
properties.UUID = user._id; | |
properties.Class = user.stats.class; | |
properties.Experience = Math.floor(user.stats.exp); | |
properties.Gold = Math.floor(user.stats.gp); | |
properties.Health = Math.ceil(user.stats.hp); | |
properties.Level = user.stats.lvl; | |
properties.Mana = Math.floor(user.stats.mp); | |
properties.contributorLevel = user.contributor.level; | |
properties.subscription = user.purchased.plan.planId; | |
amplitude.setUserProperties(properties); | |
ga('set',properties); | |
mixpanel.register(properties); | |
} | |
function revenue() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment