|
|
@ -3,7 +3,6 @@ var base64 = require('./utils/base64'); |
|
|
|
var each = require('./utils/each'); |
|
|
|
var extend = require('./utils/extend'); |
|
|
|
var extendEvents = require('./extend-events'); |
|
|
|
var json = require('./utils/json'); |
|
|
|
|
|
|
|
module.exports = { |
|
|
|
'recordEvent': recordEvent, |
|
|
@ -67,7 +66,7 @@ function recordEvent(eventCollection, eventBody, callback, async){ |
|
|
|
|
|
|
|
getRequestUrl = this.url('events', encodeURIComponent(eventCollection), { |
|
|
|
api_key : this.writeKey(), |
|
|
|
data : base64.encode( json.stringify(extendedEventBody) ), |
|
|
|
data : base64.encode( JSON.stringify(extendedEventBody) ), |
|
|
|
modified : new Date().getTime() |
|
|
|
}); |
|
|
|
getRequestUrlOkLength = getRequestUrl.length < getUrlMaxLength(); |
|
|
@ -271,7 +270,7 @@ function sendXhr(method, url, data, callback){ |
|
|
|
if (xhr.readyState == 4) { |
|
|
|
if (xhr.status >= 200 && xhr.status < 300) { |
|
|
|
try { |
|
|
|
response = json.parse( xhr.responseText ); |
|
|
|
response = JSON.parse( xhr.responseText ); |
|
|
|
} catch (e) { |
|
|
|
Keen.emit('error', 'Could not parse HTTP response: ' + xhr.responseText); |
|
|
|
if (cb) { |
|
|
@ -296,7 +295,7 @@ function sendXhr(method, url, data, callback){ |
|
|
|
xhr.setRequestHeader('Content-Type', 'application/json'); |
|
|
|
|
|
|
|
if (data) { |
|
|
|
payload = json.stringify(data); |
|
|
|
payload = JSON.stringify(data); |
|
|
|
} |
|
|
|
|
|
|
|
if (method.toUpperCase() === 'GET') { |
|
|
|