stacktrace.js
function StackTrace$$report(stackframes, url, errorMsg, requestOptions) {
            return new Promise(function(resolve, reject) {
                var req = new XMLHttpRequest();
                req.onerror = reject;
                req.onreadystatechange = function onreadystatechange() {
                    if (req.readyState === 4) {
                        if (req.status >= 200 && req.status < 400) {
                            resolve(req.responseText);
                        } else {
                            reject(new Error('POST to ' + url + ' failed with status: ' + req.status));
                        }
                    }
                };
                req.open('post', url);

                // Set request headers
                req.setRequestHeader('Content-Type', 'application/json');
                if (requestOptions && typeof requestOptions.headers === 'object') {
                    var headers = requestOptions.headers;
                    for (var header in headers) {
                        if (headers.hasOwnProperty(header)) {
                            req.setRequestHeader(header, headers[header]);
                        }
                    }
                }

                var reportPayload = {stack: stackframes};
                if (errorMsg !== undefined && errorMsg !== null) {
                    reportPayload.message = errorMsg;
                }

                req.send(JSON.stringify(reportPayload));
            });
        }
function StackTrace$$report(stackframes, url, errorMsg, requestOptions) {
            return new Promise(function(resolve, reject) {
                var req = new XMLHttpRequest();
                req.onerror = reject;
                req.onreadystatechange = function onreadystatechange() {
                    if (req.readyState === 4) {
                        if (req.status >= 200 && req.status < 400) {
                            resolve(req.responseText);
                        } else {
                            reject(new Error('POST to ' + url + ' failed with status: ' + req.status));
                        }
                    }
                };
                req.open('post', url);

                // Set request headers
                req.setRequestHeader('Content-Type', 'application/json');
                if (requestOptions && typeof requestOptions.headers === 'object') {
                    var headers = requestOptions.headers;
                    for (var header in headers) {
                        if (headers.hasOwnProperty(header)) {
                            req.setRequestHeader(header, headers[header]);
                        }
                    }
                }

                var reportPayload = {stack: stackframes};
                if (errorMsg !== undefined && errorMsg !== null) {
                    reportPayload.message = errorMsg;
                }

                req.send(JSON.stringify(reportPayload));
            });
        }
function StackTrace$$report ( stackframes , url , errorMsg , requestOptions ) { return new Promise ( function ( resolve , reject ) { var req = new XMLHttpRequest ( ) ; req . onerror = reject ; req . onreadystatechange = function onreadystatechange ( ) { if ( req . readyState === 4 ) { if ( req . status >= 200 && req . status < 400 ) { resolve ( req . responseText ) ; } else { reject ( new Error ( 'POST to ' + url + ' failed with status: ' + req . status ) ) ; } } } ; req . open ( 'post' , url ) ; // Set request headers req . setRequestHeader ( 'Content-Type' , 'application/json' ) ; if ( requestOptions && typeof requestOptions . headers === 'object' ) { var headers = requestOptions . headers ; for ( var header in headers ) { if ( headers . hasOwnProperty ( header ) ) { req . setRequestHeader ( header , headers [ header ] ) ; } } } var reportPayload = { stack : stackframes } ; if ( errorMsg !== undefined && errorMsg !== null ) { reportPayload . message = errorMsg ; } req . send ( JSON . stringify ( reportPayload ) ) ; } ) ; }
Given an error message and Array of StackFrames, serialize and POST to given URL.

@param {Array} stackframes
@param {String} url
@param {String} errorMsg
@param {Object} requestOptions
Given an error message and Array of StackFrames serialize and POST to given URL .