Comparing version 0.0.16 to 0.0.17
@@ -53,3 +53,3 @@ // grab the Mixpanel factory | ||
// callback as the last argument | ||
mixpanel.track("test", function(err) { if (err) throw err; }); | ||
mixpanel.track("test", function(err) { if (err) { throw err; } }); | ||
@@ -56,0 +56,0 @@ // import an old event |
@@ -72,3 +72,3 @@ /* | ||
res.on('end', function() { | ||
var e = (data != '1') ? new Error("Mixpanel Server Error: " + data) : undefined; | ||
var e = (data !== '1') ? new Error("Mixpanel Server Error: " + data) : undefined; | ||
callback(e); | ||
@@ -156,2 +156,22 @@ }); | ||
/** | ||
alias(distinct_id, alias) | ||
--- | ||
This function creates an alias for distinct_id | ||
For more information look at: | ||
https://mixpanel.com/docs/integration-libraries/using-mixpanel-alias | ||
distinct_id:string the current identifier | ||
alias:string the future alias | ||
*/ | ||
metrics.alias = function(distinct_id, alias) { | ||
var properties = { | ||
distinct_id: distinct_id, | ||
alias: alias | ||
}; | ||
metrics.track('$create_alias', properties); | ||
}; | ||
metrics.people = { | ||
@@ -180,3 +200,3 @@ /** people.set_once(distinct_id, prop, to, callback) | ||
this._set(distinct_id, $set, callback, { set_once: true }) | ||
this._set(distinct_id, $set, callback, { set_once: true }); | ||
}, | ||
@@ -208,3 +228,3 @@ | ||
this._set(distinct_id, $set, callback) | ||
this._set(distinct_id, $set, callback); | ||
}, | ||
@@ -214,3 +234,3 @@ | ||
_set: function(distinct_id, $set, callback, options) { | ||
var set_key = (options && options["set_once"]) ? "$set_once" : "$set"; | ||
var set_key = (options && options.set_once) ? "$set_once" : "$set"; | ||
@@ -220,13 +240,13 @@ var data = { | ||
'$distinct_id': distinct_id | ||
} | ||
}; | ||
data[set_key] = $set; | ||
if ('ip' in $set) { | ||
data['$ip'] = $set['ip']; | ||
delete $set['ip']; | ||
data.$ip = $set.ip; | ||
delete $set.ip; | ||
} | ||
if ($set['$ignore_time']) { | ||
data['$ignore_time'] = $set['$ignore_time']; | ||
delete $set['$ignore_time']; | ||
if ($set.$ignore_time) { | ||
data.$ignore_time = $set.$ignore_time; | ||
delete $set.$ignore_time; | ||
} | ||
@@ -266,3 +286,3 @@ | ||
increment: function(distinct_id, prop, by, callback) { | ||
var $add = {}, data = {}; | ||
var $add = {}; | ||
@@ -293,3 +313,3 @@ if (typeof(prop) === 'object') { | ||
'$distinct_id': distinct_id | ||
} | ||
}; | ||
@@ -319,3 +339,3 @@ if(metrics.config.debug) { | ||
track_charge: function(distinct_id, amount, properties, callback) { | ||
var $append = {}, data = {}; | ||
var $append = {}; | ||
@@ -332,8 +352,8 @@ if (!properties) { properties = {}; } | ||
properties['$amount'] = amount; | ||
properties.$amount = amount; | ||
if (properties.hasOwnProperty('$time')) { | ||
var time = properties['$time']; | ||
var time = properties.$time; | ||
if (Object.prototype.toString.call(time) === '[object Date]') { | ||
properties['$time'] = time.toISOString(); | ||
properties.$time = time.toISOString(); | ||
} | ||
@@ -346,3 +366,3 @@ } | ||
'$distinct_id': distinct_id | ||
} | ||
}; | ||
@@ -349,0 +369,0 @@ if(metrics.config.debug) { |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["mixpanel", "analytics", "api", "stats"], | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"homepage": "https://github.com/carlsverre/mixpanel-node", | ||
@@ -8,0 +8,0 @@ "author": "Carl Sverre", |
@@ -100,2 +100,3 @@ Mixpanel-node | ||
- [wwlinx](https://github.com/wwlinx) | ||
- [PierrickP](https://github.com/PierrickP) | ||
@@ -102,0 +103,0 @@ License |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41096
16
866
107