diff --git a/lib/mixpanel-node.js b/lib/mixpanel-node.js index 06c07a1..348361e 100644 --- a/lib/mixpanel-node.js +++ b/lib/mixpanel-node.js @@ -40,7 +40,16 @@ var create_client = function(token, config) { */ metrics.send_request = function(endpoint, data, callback) { callback = callback || function() {}; - var event_data = new Buffer(JSON.stringify(data)); + + var event_data; + try { + event_data = new Buffer(JSON.stringify(data)); + } catch (e) { + setImmediate(function(){ + callback(e) + }) + return + } var request_data = { 'data': event_data.toString('base64'), 'ip': 0,