Pull out instrumentation stuff.

This commit is contained in:
Tom Coleman 2012-10-18 11:53:59 +11:00
parent 8d4682a558
commit f2be21d496
2 changed files with 52 additions and 50 deletions

View file

@ -0,0 +1,48 @@
var instrumentRequest = function() {
// Mixpanel
if((mixpanelId=getSetting("mixpanelId")) && window.mixpanel.length===0 ){
mixpanel.init(mixpanelId);
if(Meteor.user()){
var currentUserEmail=getCurrentUserEmail();
mixpanel.people.identify(currentUserEmail);
mixpanel.people.set({
'username': getDisplayName(Meteor.user()),
'$last_login': new Date(),
'$created': moment(Meteor.user().createdAt)._d,
'$email': currentUserEmail
});
mixpanel.register({
'username': getDisplayName(Meteor.user()),
'createdAt': moment(Meteor.user().createdAt)._d,
'email': currentUserEmail
});
mixpanel.name_tag(currentUserEmail);
}
}
// GoSquared
if (goSquaredId = getSetting("goSquaredId")) {
GoSquared.acct = goSquaredId;
GoSquaredInit();
}
// Intercom
if((intercomId=getSetting("intercomId")) && Meteor.user()){
window.intercomSettings = {
app_id: intercomId,
email: currentUserEmail,
created_at: moment(Meteor.user().createdAt).unix(),
custom_data: {
'profile link': 'http://'+document.domain+'/users/'+Meteor.user()._id
},
widget: {
activator: '#Intercom',
use_counter: true,
activator_html: function ( obj ) {
return obj.activator_html_functions.brackets();
}
}
};
IntercomInit();
}
}

View file

@ -13,56 +13,10 @@ SimpleRouter = FilteredRouter.extend({
// set all errors who have been seen to not show anymore
clearSeenErrors();
// Mixpanel
if((mixpanelId=getSetting("mixpanelId")) && window.mixpanel.length==0){
mixpanel.init(mixpanelId);
if(Meteor.user()){
var currentUserEmail=getCurrentUserEmail();
mixpanel.people.identify(currentUserEmail);
mixpanel.people.set({
'username': getDisplayName(Meteor.user()),
'$last_login': new Date(),
'$created': moment(Meteor.user().createdAt)._d,
'$email': currentUserEmail
});
mixpanel.register({
'username': getDisplayName(Meteor.user()),
'createdAt': moment(Meteor.user().createdAt)._d,
'email': currentUserEmail
});
mixpanel.name_tag(currentUserEmail);
}
}
// GoSquared
if((goSquaredId=getSetting("goSquaredId"))){
GoSquared.acct = goSquaredId;
GoSquaredInit();
}
// Intercom
if((intercomId=getSetting("intercomId")) && Meteor.user()){
window.intercomSettings = {
app_id: intercomId,
email: currentUserEmail,
created_at: moment(Meteor.user().createdAt).unix(),
custom_data: {
'profile link': 'http://'+document.domain+'/users/'+Meteor.user()._id
},
widget: {
activator: '#Intercom',
use_counter: true,
activator_html: function ( obj ) {
return obj.activator_html_functions.brackets();
}
}
};
IntercomInit();
}
// log this request with mixpanel, etc
instrumentRequest();
return page;
},
require_login: function(page) {