fix(analytics): Correct user ID handling

This commit is contained in:
Sabe Jones
2015-06-30 16:52:18 -05:00
parent 46a7591492
commit 3d15da61ec
2 changed files with 5 additions and 13 deletions

View File

@@ -18,6 +18,9 @@ angular.module('habitrpg')
User.authenticate(id, token, function(err) { User.authenticate(id, token, function(err) {
if(!err) $scope.registrationInProgress = false; if(!err) $scope.registrationInProgress = false;
$window.location.href = ('/' + window.location.hash); $window.location.href = ('/' + window.location.hash);
Analytics.login();
Analytics.updateUser();
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'login'});
}); });
}; };
@@ -48,7 +51,6 @@ angular.module('habitrpg')
$http.post(url, scope.registerVals).success(function(data, status, headers, config) { $http.post(url, scope.registerVals).success(function(data, status, headers, config) {
runAuth(data.id, data.apiToken); runAuth(data.id, data.apiToken);
if (status == 200) { if (status == 200) {
Analytics.register();
if (data.auth.facebook) { if (data.auth.facebook) {
Analytics.updateUser({'email':data.auth.facebook._json.email,'language':data.preferences.language}); Analytics.updateUser({'email':data.auth.facebook._json.email,'language':data.preferences.language});
Analytics.track({'hitType':'event','eventCategory':'acquisition','eventAction':'register','authType':'facebook'}); Analytics.track({'hitType':'event','eventCategory':'acquisition','eventAction':'register','authType':'facebook'});
@@ -68,11 +70,6 @@ angular.module('habitrpg')
$http.post(ApiUrl.get() + "/api/v2/user/auth/local", data) $http.post(ApiUrl.get() + "/api/v2/user/auth/local", data)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
runAuth(data.id, data.token); runAuth(data.id, data.token);
if (status == 200) {
Analytics.login();
Analytics.updateUser();
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'login'});
}
}).error(errorAlert); }).error(errorAlert);
}; };
@@ -112,11 +109,6 @@ angular.module('habitrpg')
hello(network).login({scope:'email'}).then(function(auth){ hello(network).login({scope:'email'}).then(function(auth){
$http.post(ApiUrl.get() + "/api/v2/user/auth/social", auth) $http.post(ApiUrl.get() + "/api/v2/user/auth/social", auth)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
if (status == 200) {
Analytics.login();
Analytics.updateUser();
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'login'});
}
runAuth(data.id, data.token); runAuth(data.id, data.token);
}).error(errorAlert); }).error(errorAlert);
}, function( e ){ }, function( e ){

View File

@@ -23,14 +23,14 @@
var i = ["init", "logEvent", "logRevenue", "setUserId", "setUserProperties", "setOptOut", "setVersionName", "setDomain", "setDeviceId", "setGlobalUserProperties"]; var i = ["init", "logEvent", "logRevenue", "setUserId", "setUserProperties", "setOptOut", "setVersionName", "setDomain", "setDeviceId", "setGlobalUserProperties"];
for (var o = 0; o < i.length; o++) {a(i[o])} for (var o = 0; o < i.length; o++) {a(i[o])}
window.amplitude = r; window.amplitude = r;
amplitude.init(window.env.AMPLITUDE_KEY); amplitude.init(window.env.AMPLITUDE_KEY, user._id);
// Google Analytics (aka Universal Analytics) // Google Analytics (aka Universal Analytics)
window['GoogleAnalyticsObject'] = 'ga'; window['GoogleAnalyticsObject'] = 'ga';
window['ga'] = window['ga'] || function() { window['ga'] = window['ga'] || function() {
(window['ga'].q = window['ga'].q || []).push(arguments) (window['ga'].q = window['ga'].q || []).push(arguments)
}, window['ga'].l = 1 * new Date(); }, window['ga'].l = 1 * new Date();
ga('create', window.env.GA_ID, 'auto'); ga('create', window.env.GA_ID, {'userId':user._id});
function loadScripts() { function loadScripts() {
setTimeout(function() { setTimeout(function() {