Skip to content

Commit

Permalink
Merge pull request #3306 from Automattic/update/js-errors
Browse files Browse the repository at this point in the history
JS Errors: Remove the content headers from the JS Errors API
  • Loading branch information
scruffian committed Feb 16, 2016
2 parents 792b8b1 + bd629f0 commit 9edd95e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions catch-js-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@
params = 'client_id=39911&client_secret=cOaYKdrkgXz8xY7aysv4fU6wL6sK5J8a6ojReEIAPwggsznj4Cb6mW0nffTxtYT8&error=';
params += encodeURIComponent( JSON.stringify( savedErrors ) );

xhr.setRequestHeader( 'Content-length', params.length );
xhr.setRequestHeader( 'Connection', 'close' );
xhr.send( params );

savedErrors = [];
}
}

function errorToPlainObject( error ) {
var simpleObject = {};
Object.getOwnPropertyNames( error ).forEach( function( key ) {
simpleObject[ key ] = error[ key ];
} );
return simpleObject;
}

function handleError( error ) {
var canSendNow;

Expand All @@ -52,7 +58,7 @@

// add the message to the pack and reset flush timeout
clearTimeout( packTimeout );
savedErrors.push( error );
savedErrors.push( errorToPlainObject( error ) );

// if we can send the pack now, let's do it
if ( canSendNow ) {
Expand Down

0 comments on commit 9edd95e

Please sign in to comment.