Fix error with mixpanel loading

This commit is contained in:
Samy Pessé
2014-04-04 18:18:50 -07:00
parent 460799828f
commit 0071594300
5 changed files with 17 additions and 46 deletions
+13 -5
View File
@@ -1,18 +1,26 @@
define([
"lodash",
"mixpanel"
], function(mixpanel) {
mixpanel.init("01eb2b950ae09a5fdb15a98dcc5ff20e");
], function(_, mixpanel) {
mixpanel.init("01eb2b950ae09a5fdb15a98dcc5ff20e", {
loaded: function() {
track("View");
}
});
var isAvailable = function() {
return (typeof mixpanel !== "undefined");
};
var track = function(event, data) {
var track = function(e, data) {
if (!isAvailable()) {
console.log("tracking not available!");
console.warn("tracking not available!");
return;
}
mixpanel.track(event, data);
console.log("track", e);
mixpanel.track(e, _.extend(data || {}, {
'domain': window.location.host
}));
};
return {
+1
View File
@@ -14,6 +14,7 @@ define(function(){
},
get: function(key, def) {
key = baseKey+":"+key;
if (localStorage[key] === undefined) return def;
try {
var v = JSON.parse(localStorage[key]);
return v == null ? def : v;;