Skip to content

Commit db46b32

Browse files
committed
Dist
1 parent ac2070d commit db46b32

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

dist/maps/stackdriver-errors-concat.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/stackdriver-errors-concat.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5386,15 +5386,20 @@ if (!Array.prototype.forEach) {
53865386
* @param {Boolean} [config.disabled=false] - Set to true to not report errors when calling report(), this can be used when developping locally.
53875387
*/
53885388
StackdriverErrorReporter.prototype.start = function(config) {
5389-
if(!config.key) {
5390-
throw new Error('Cannot initialize: No API key provided.');
5389+
if(!config.key && !config.targetUrl) {
5390+
throw new Error('Cannot initialize: No API key or target url provided.');
53915391
}
5392-
if(!config.projectId) {
5393-
throw new Error('Cannot initialize: No project ID provided.');
5392+
if(!config.projectId && !config.targetUrl) {
5393+
throw new Error('Cannot initialize: No project ID or target url provided.');
5394+
}
5395+
if(typeof StackTrace === 'undefined') {
5396+
// Inform about missing dependency
5397+
throw new Error('make sure you loaded “dist/stackdriver-errors-concat.js” or “dist/stackdriver-errors-concat.min.js”, or that you imported the “stacktrace-js” module');
53945398
}
53955399

53965400
this.apiKey = config.key;
53975401
this.projectId = config.projectId;
5402+
this.targetUrl = config.targetUrl;
53985403
this.context = config.context || {};
53995404
this.serviceContext = {service: config.service || 'web'};
54005405
if(config.version) {
@@ -5458,7 +5463,9 @@ if (!Array.prototype.forEach) {
54585463
payload.message += '\n';
54595464
// Reconstruct the stackframe to a JS stackframe as expected by Error Reporting parsers.
54605465
// stack[s].source should not be used because not populated when created from source map.
5461-
payload.message += [' at ', stack[s].getFunctionName(), ' (', stack[s].getFileName(), ':', stack[s].getLineNumber() ,':', stack[s].getColumnNumber() , ')'].join('');
5466+
//
5467+
// If functionName or methodName isn't available <anonymous> will be used as the name.
5468+
payload.message += [' at ', stack[s].getFunctionName() || '<anonymous>', ' (', stack[s].getFileName(), ':', stack[s].getLineNumber() ,':', stack[s].getColumnNumber() , ')'].join('');
54625469
}
54635470
that.sendErrorPayload(payload, callback);
54645471
}, function(reason) {
@@ -5473,7 +5480,8 @@ if (!Array.prototype.forEach) {
54735480
};
54745481

54755482
StackdriverErrorReporter.prototype.sendErrorPayload = function(payload, callback) {
5476-
var url = baseAPIUrl + this.projectId + "/events:report?key=" + this.apiKey;
5483+
var defaultUrl = baseAPIUrl + this.projectId + "/events:report?key=" + this.apiKey;
5484+
var url = this.targetUrl || defaultUrl;
54775485

54785486
var xhr = new XMLHttpRequest();
54795487
xhr.open('POST', url, true);

0 commit comments

Comments
 (0)