Browse Source

Remove JSON3 dep

master
dustinlarimer 9 years ago
parent
commit
0d3407fce4
  1. 641
      dist/keen-tracking.js
  2. 4
      dist/keen-tracking.min.js
  3. 1
      lib/index.js
  4. 7
      lib/record-events-browser.js
  5. 5
      lib/utils/cookie.js
  6. 4
      lib/utils/deepExtend.js
  7. 1
      lib/utils/json.js
  8. 3
      test/unit/modules/record-events-browser-spec.js

641
dist/keen-tracking.js

File diff suppressed because one or more lines are too long

4
dist/keen-tracking.min.js

File diff suppressed because one or more lines are too long

1
lib/index.js

@ -2,7 +2,6 @@ var K = require('keen-core');
var each = require('./utils/each'),
extend = require('./utils/extend'),
json = require('./utils/json'),
queue = require('./utils/queue');
K.helpers = K.helpers || {};

7
lib/record-events-browser.js

@ -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') {

5
lib/utils/cookie.js

@ -1,5 +1,4 @@
var Cookies = require('cookies-js');
var json = require('./json');
var extend = require('./extend');
module.exports = cookie;
@ -22,7 +21,7 @@ cookie.prototype.get = function(str){
var data = {};
if (Cookies.get(this.config.key)) {
data = json.parse( decodeURIComponent(Cookies.get(this.config.key)) );
data = JSON.parse( decodeURIComponent(Cookies.get(this.config.key)) );
}
if (str) {
return ('undefined' !== typeof data[str]) ? data[str] : null;
@ -40,7 +39,7 @@ cookie.prototype.set = function(str, value){
else if ('object' === typeof str && arguments.length === 1) {
extend(this.data, str);
}
Cookies.set(this.config.key, encodeURIComponent( json.stringify(this.data) ), this.config.options);
Cookies.set(this.config.key, encodeURIComponent( JSON.stringify(this.data) ), this.config.options);
return this;
};

4
lib/utils/deepExtend.js

@ -1,5 +1,3 @@
var json = require('./json');
module.exports = deepExtend;
function deepExtend(target){
@ -30,5 +28,5 @@ function deepExtend(target){
}
function clone(input){
return json.parse( json.stringify(input) );
return JSON.parse( JSON.stringify(input) );
}

1
lib/utils/json.js

@ -1 +0,0 @@
module.exports = ('undefined' !== typeof window && window.JSON) ? window.JSON : require("json3");

3
test/unit/modules/record-events-browser-spec.js

@ -1,5 +1,4 @@
var assert = require('proclaim');
var json = require('../../../lib/utils/json');
var Keen = require('../../../lib/browser');
var config = require('../helpers/client-config');
@ -90,7 +89,7 @@ describe('.recordEvent(s) methods (browser)', function() {
{ page: 'same again' }
]
};
this.batchResponse = json.stringify({
this.batchResponse = JSON.stringify({
click: [
{ 'success': true }
],

Loading…
Cancel
Save