Update event-tracker to latest version

This commit is contained in:
David Wick
2016-01-11 16:27:44 -08:00
parent 517a1a49de
commit 306ceff774
2 changed files with 15 additions and 7 deletions

View File

@@ -40,9 +40,9 @@
return this;
},
send: function() {
send: function(done) {
if (tracker) {
tracker.send();
tracker.send(done);
}
return this;
}

View File

@@ -1,6 +1,6 @@
/**
* event-tracker
* @version v1.1.0
* @version v1.1.2
* DO NOT EDIT THIS FILE DIRECTLY! Edit the source at:
* @source https://github.com/reddit/event-tracker
*/
@@ -14,7 +14,13 @@
// Stub out `now` so we can use a more precise number in uuid generation, if
// available.
function now() {
return global.performance ? global.performance.now() : (new Date()).getTime();
if (global.performance && typeof global.performance.now === 'function') {
return global.performance.now();
} else if (typeof Date.now === 'function') {
return Date.now();
} else {
return (new Date()).getTime();
}
}
// Pulled from elsewhere
@@ -35,7 +41,7 @@
*
* clientKey: the name of the secret key you must have to send events, like 'Test1'
* clientSecret: the secret key you must have to send events, like 'ab42sdfsafsc'
* postData: a function with the object arg ({url, data, query, headers}).
* postData: a function with the object arg ({url, data, query, headers, done}).
* You'll supply a function that wraps jQuery.ajax or superagent.
* eventsUrl: the url of the events endpoint, like 'https://stats.redditmedia.com/events'
* appName: the name of your client app, like 'Alien Blue'
@@ -110,8 +116,9 @@
/*
* Immediately flush the buffer. Called internally as well during buffer
* timeout.
* done: optional callback to fire on complete.
*/
EventTracker.prototype.send = function send() {
EventTracker.prototype.send = function send(done) {
if (this.buffer.length) {
var data = JSON.stringify(this.buffer);
@@ -128,7 +135,8 @@
query: {
key: this.clientKey,
mac: hash,
}
},
done: done || function() {},
});
this.buffer = [];