1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-15 05:55:01 -05:00
kaiwa/clientapp/app/helpers/tracking.js

33 lines
1.0 KiB
JavaScript
Raw Normal View History

2013-06-03 18:51:30 -04:00
// Module for tracking user events with mix panel analytics.
/*global mixpanel*/
var initIntercom = require('helpers/intercom'),
hostname = window.location.hostname,
isLive = (hostname === 'conversat.io' || hostname === 'beta.conversat.io');
// Identifies the user with the provided unique id.
exports.identify = function (me) {
if (isLive && me && me.authed) {
mixpanel.identify(me.id);
mixpanel.name_tag(me.username);
mixpanel.people.set({
$email: me.email,
$first_name: me.firstName,
$last_name: me.lastName
});
mixpanel.people.increment('web app opened');
// init intercom
initIntercom(me);
}
};
// Logs the given action with the given data.
// action: A string representing the action to be logged.
// dict: A dictionary with additional action information.
exports.track = function (action, dict, cb) {
// allow the dict parameter to be omitted.
if (isLive) {
mixpanel.track(action, dict || {}, cb);
}
};