bugsnagjs-rails 6.2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +6 -0
- data/Rakefile +1 -0
- data/bugsnagjs-rails.gemspec +16 -0
- data/lib/bugsnagjs-rails.rb +8 -0
- data/lib/bugsnagjs-rails/engine.rb +6 -0
- data/lib/bugsnagjs-rails/version.rb +7 -0
- data/vendor/assets/javascripts/bugsnag.js +2970 -0
- data/vendor/assets/javascripts/bugsnag.js.erb +1 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 03f954083a51e7a8fabd72aa949b6ceb252e6e18b2da614e951f8e7246fe6433
|
4
|
+
data.tar.gz: 512631bee02394063354f74b2567e472b3253b2d09cd08edd2647d336ad97101
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9a33c579d6425e01702116aefd7aa28ea05058909d919c942ec48bc7b8c40bd2e302e7cc79f625fced2ee132e00fa3b2cd37c025d813fd666ee4db21afd2e025
|
7
|
+
data.tar.gz: 4ddfeaaf122bbc16a3765ba23b4ab5ef2d6b9fb01156e75d259cd5db797339b6e59cc69b27f3fc38a7f26f3947bf7b3dc9e44ccf65d148cb9f59499a94a2068e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 localhostdotdev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'lib/bugsnagjs-rails/version.rb'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "bugsnagjs-rails"
|
5
|
+
s.authors = ["localhostdotdev"]
|
6
|
+
s.email = %q{localhostdotdev@protonmail.com}
|
7
|
+
s.summary = %q{bugsnag in your js}
|
8
|
+
s.homepage = %q{https://github.com/universal-updates/bugsnagjs-rails}
|
9
|
+
s.description = %q{bugsnagjs for rails assets pipeline}
|
10
|
+
s.version = Bugsnagjs::Rails::VERSION
|
11
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.require_paths = ['lib']
|
14
|
+
s.add_runtime_dependency(%q{rails}, ">= 4")
|
15
|
+
s.license = 'MIT'
|
16
|
+
end
|
@@ -0,0 +1,2970 @@
|
|
1
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bugsnag = f()}})(function(){var define,module,exports;
|
2
|
+
// minimal implementations of useful ES functionality
|
3
|
+
// all we really need for arrays is reduce – everything else is just sugar!
|
4
|
+
// Array#reduce
|
5
|
+
var reduce = function (arr, fn, accum) {
|
6
|
+
var val = accum;
|
7
|
+
|
8
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
9
|
+
val = fn(val, arr[i], i, arr);
|
10
|
+
}
|
11
|
+
|
12
|
+
return val;
|
13
|
+
}; // Array#filter
|
14
|
+
|
15
|
+
|
16
|
+
var filter = function (arr, fn) {
|
17
|
+
return reduce(arr, function (accum, item, i, arr) {
|
18
|
+
return !fn(item, i, arr) ? accum : accum.concat(item);
|
19
|
+
}, []);
|
20
|
+
}; // Array#map
|
21
|
+
|
22
|
+
|
23
|
+
var map = function (arr, fn) {
|
24
|
+
return reduce(arr, function (accum, item, i, arr) {
|
25
|
+
return accum.concat(fn(item, i, arr));
|
26
|
+
}, []);
|
27
|
+
}; // Array#includes
|
28
|
+
|
29
|
+
|
30
|
+
var includes = function (arr, x) {
|
31
|
+
return reduce(arr, function (accum, item, i, arr) {
|
32
|
+
return accum === true || item === x;
|
33
|
+
}, false);
|
34
|
+
};
|
35
|
+
|
36
|
+
var _hasDontEnumBug = !{
|
37
|
+
toString: null
|
38
|
+
}.propertyIsEnumerable('toString');
|
39
|
+
|
40
|
+
var _dontEnums = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor']; // Object#keys
|
41
|
+
|
42
|
+
var keys = function (obj) {
|
43
|
+
// stripped down version of
|
44
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/Keys
|
45
|
+
var result = [];
|
46
|
+
var prop;
|
47
|
+
|
48
|
+
for (prop in obj) {
|
49
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop)) result.push(prop);
|
50
|
+
}
|
51
|
+
|
52
|
+
if (!_hasDontEnumBug) return result;
|
53
|
+
|
54
|
+
for (var i = 0, len = _dontEnums.length; i < len; i++) {
|
55
|
+
if (Object.prototype.hasOwnProperty.call(obj, _dontEnums[i])) result.push(_dontEnums[i]);
|
56
|
+
}
|
57
|
+
|
58
|
+
return result;
|
59
|
+
}; // Array#isArray
|
60
|
+
|
61
|
+
|
62
|
+
var isArray = function (obj) {
|
63
|
+
return Object.prototype.toString.call(obj) === '[object Array]';
|
64
|
+
};
|
65
|
+
|
66
|
+
var _pad = function (n) {
|
67
|
+
return n < 10 ? "0" + n : n;
|
68
|
+
}; // Date#toISOString
|
69
|
+
|
70
|
+
|
71
|
+
var isoDate = function () {
|
72
|
+
// from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
|
73
|
+
var d = new Date();
|
74
|
+
return d.getUTCFullYear() + '-' + _pad(d.getUTCMonth() + 1) + '-' + _pad(d.getUTCDate()) + 'T' + _pad(d.getUTCHours()) + ':' + _pad(d.getUTCMinutes()) + ':' + _pad(d.getUTCSeconds()) + '.' + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z';
|
75
|
+
};
|
76
|
+
|
77
|
+
var _$esUtils_8 = {
|
78
|
+
map: map,
|
79
|
+
reduce: reduce,
|
80
|
+
filter: filter,
|
81
|
+
includes: includes,
|
82
|
+
keys: keys,
|
83
|
+
isArray: isArray,
|
84
|
+
isoDate: isoDate
|
85
|
+
};
|
86
|
+
|
87
|
+
var _$validators_15 = {};
|
88
|
+
_$validators_15.intRange = function (min, max) {
|
89
|
+
if (min === void 0) {
|
90
|
+
min = 1;
|
91
|
+
}
|
92
|
+
|
93
|
+
if (max === void 0) {
|
94
|
+
max = Infinity;
|
95
|
+
}
|
96
|
+
|
97
|
+
return function (value) {
|
98
|
+
return typeof value === 'number' && parseInt('' + value, 10) === value && value >= min && value <= max;
|
99
|
+
};
|
100
|
+
};
|
101
|
+
|
102
|
+
_$validators_15.stringWithLength = function (value) {
|
103
|
+
return typeof value === 'string' && !!value.length;
|
104
|
+
};
|
105
|
+
|
106
|
+
var _$config_5 = {};
|
107
|
+
var __filter_5 = _$esUtils_8.filter,
|
108
|
+
__reduce_5 = _$esUtils_8.reduce,
|
109
|
+
__keys_5 = _$esUtils_8.keys,
|
110
|
+
__isArray_5 = _$esUtils_8.isArray,
|
111
|
+
__includes_5 = _$esUtils_8.includes;
|
112
|
+
|
113
|
+
var intRange = _$validators_15.intRange,
|
114
|
+
stringWithLength = _$validators_15.stringWithLength;
|
115
|
+
|
116
|
+
_$config_5.schema = {
|
117
|
+
apiKey: {
|
118
|
+
defaultValue: function () {
|
119
|
+
return null;
|
120
|
+
},
|
121
|
+
message: 'is required',
|
122
|
+
validate: stringWithLength
|
123
|
+
},
|
124
|
+
appVersion: {
|
125
|
+
defaultValue: function () {
|
126
|
+
return null;
|
127
|
+
},
|
128
|
+
message: 'should be a string',
|
129
|
+
validate: function (value) {
|
130
|
+
return value === null || stringWithLength(value);
|
131
|
+
}
|
132
|
+
},
|
133
|
+
appType: {
|
134
|
+
defaultValue: function () {
|
135
|
+
return null;
|
136
|
+
},
|
137
|
+
message: 'should be a string',
|
138
|
+
validate: function (value) {
|
139
|
+
return value === null || stringWithLength(value);
|
140
|
+
}
|
141
|
+
},
|
142
|
+
autoNotify: {
|
143
|
+
defaultValue: function () {
|
144
|
+
return true;
|
145
|
+
},
|
146
|
+
message: 'should be true|false',
|
147
|
+
validate: function (value) {
|
148
|
+
return value === true || value === false;
|
149
|
+
}
|
150
|
+
},
|
151
|
+
beforeSend: {
|
152
|
+
defaultValue: function () {
|
153
|
+
return [];
|
154
|
+
},
|
155
|
+
message: 'should be a function or array of functions',
|
156
|
+
validate: function (value) {
|
157
|
+
return typeof value === 'function' || __isArray_5(value) && __filter_5(value, function (f) {
|
158
|
+
return typeof f === 'function';
|
159
|
+
}).length === value.length;
|
160
|
+
}
|
161
|
+
},
|
162
|
+
endpoints: {
|
163
|
+
defaultValue: function () {
|
164
|
+
return {
|
165
|
+
notify: 'https://notify.bugsnag.com',
|
166
|
+
sessions: 'https://sessions.bugsnag.com'
|
167
|
+
};
|
168
|
+
},
|
169
|
+
message: 'should be an object containing endpoint URLs { notify, sessions }. sessions is optional if autoCaptureSessions=false',
|
170
|
+
validate: function (val, obj) {
|
171
|
+
return (// first, ensure it's an object
|
172
|
+
val && typeof val === 'object' && // endpoints.notify must always be set
|
173
|
+
stringWithLength(val.notify) && ( // endpoints.sessions must be set unless session tracking is explicitly off
|
174
|
+
obj.autoCaptureSessions === false || stringWithLength(val.sessions)) && // ensure no keys other than notify/session are set on endpoints object
|
175
|
+
__filter_5(__keys_5(val), function (k) {
|
176
|
+
return !__includes_5(['notify', 'sessions'], k);
|
177
|
+
}).length === 0
|
178
|
+
);
|
179
|
+
}
|
180
|
+
},
|
181
|
+
autoCaptureSessions: {
|
182
|
+
defaultValue: function (val, opts) {
|
183
|
+
return opts.endpoints === undefined || !!opts.endpoints && !!opts.endpoints.sessions;
|
184
|
+
},
|
185
|
+
message: 'should be true|false',
|
186
|
+
validate: function (val) {
|
187
|
+
return val === true || val === false;
|
188
|
+
}
|
189
|
+
},
|
190
|
+
notifyReleaseStages: {
|
191
|
+
defaultValue: function () {
|
192
|
+
return null;
|
193
|
+
},
|
194
|
+
message: 'should be an array of strings',
|
195
|
+
validate: function (value) {
|
196
|
+
return value === null || __isArray_5(value) && __filter_5(value, function (f) {
|
197
|
+
return typeof f === 'string';
|
198
|
+
}).length === value.length;
|
199
|
+
}
|
200
|
+
},
|
201
|
+
releaseStage: {
|
202
|
+
defaultValue: function () {
|
203
|
+
return 'production';
|
204
|
+
},
|
205
|
+
message: 'should be a string',
|
206
|
+
validate: function (value) {
|
207
|
+
return typeof value === 'string' && value.length;
|
208
|
+
}
|
209
|
+
},
|
210
|
+
maxBreadcrumbs: {
|
211
|
+
defaultValue: function () {
|
212
|
+
return 20;
|
213
|
+
},
|
214
|
+
message: 'should be a number ≤40',
|
215
|
+
validate: function (value) {
|
216
|
+
return intRange(0, 40)(value);
|
217
|
+
}
|
218
|
+
},
|
219
|
+
autoBreadcrumbs: {
|
220
|
+
defaultValue: function () {
|
221
|
+
return true;
|
222
|
+
},
|
223
|
+
message: 'should be true|false',
|
224
|
+
validate: function (value) {
|
225
|
+
return typeof value === 'boolean';
|
226
|
+
}
|
227
|
+
},
|
228
|
+
user: {
|
229
|
+
defaultValue: function () {
|
230
|
+
return null;
|
231
|
+
},
|
232
|
+
message: '(object) user should be an object',
|
233
|
+
validate: function (value) {
|
234
|
+
return typeof value === 'object';
|
235
|
+
}
|
236
|
+
},
|
237
|
+
metaData: {
|
238
|
+
defaultValue: function () {
|
239
|
+
return null;
|
240
|
+
},
|
241
|
+
message: 'should be an object',
|
242
|
+
validate: function (value) {
|
243
|
+
return typeof value === 'object';
|
244
|
+
}
|
245
|
+
},
|
246
|
+
logger: {
|
247
|
+
defaultValue: function () {
|
248
|
+
return undefined;
|
249
|
+
},
|
250
|
+
message: 'should be null or an object with methods { debug, info, warn, error }',
|
251
|
+
validate: function (value) {
|
252
|
+
return !value || value && __reduce_5(['debug', 'info', 'warn', 'error'], function (accum, method) {
|
253
|
+
return accum && typeof value[method] === 'function';
|
254
|
+
}, true);
|
255
|
+
}
|
256
|
+
},
|
257
|
+
filters: {
|
258
|
+
defaultValue: function () {
|
259
|
+
return ['password'];
|
260
|
+
},
|
261
|
+
message: 'should be an array of strings|regexes',
|
262
|
+
validate: function (value) {
|
263
|
+
return __isArray_5(value) && value.length === __filter_5(value, function (s) {
|
264
|
+
return typeof s === 'string' || s && typeof s.test === 'function';
|
265
|
+
}).length;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
};
|
269
|
+
|
270
|
+
_$config_5.mergeDefaults = function (opts, schema) {
|
271
|
+
if (!opts || !schema) throw new Error('opts and schema objects are required');
|
272
|
+
return __reduce_5(__keys_5(schema), function (accum, key) {
|
273
|
+
accum[key] = opts[key] !== undefined ? opts[key] : schema[key].defaultValue(opts[key], opts);
|
274
|
+
return accum;
|
275
|
+
}, {});
|
276
|
+
};
|
277
|
+
|
278
|
+
_$config_5.validate = function (opts, schema) {
|
279
|
+
if (!opts || !schema) throw new Error('opts and schema objects are required');
|
280
|
+
var errors = __reduce_5(__keys_5(schema), function (accum, key) {
|
281
|
+
if (schema[key].validate(opts[key], opts)) return accum;
|
282
|
+
return accum.concat({
|
283
|
+
key: key,
|
284
|
+
message: schema[key].message,
|
285
|
+
value: opts[key]
|
286
|
+
});
|
287
|
+
}, []);
|
288
|
+
return {
|
289
|
+
valid: !errors.length,
|
290
|
+
errors: errors
|
291
|
+
};
|
292
|
+
};
|
293
|
+
|
294
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
295
|
+
|
296
|
+
var schema = _$config_5.schema;
|
297
|
+
|
298
|
+
var __map_1 = _$esUtils_8.map;
|
299
|
+
|
300
|
+
var __stringWithLength_1 = _$validators_15.stringWithLength;
|
301
|
+
|
302
|
+
var _$config_1 = {
|
303
|
+
releaseStage: {
|
304
|
+
defaultValue: function () {
|
305
|
+
if (/^localhost(:\d+)?$/.test(window.location.host)) return 'development';
|
306
|
+
return 'production';
|
307
|
+
},
|
308
|
+
message: 'should be set',
|
309
|
+
validate: __stringWithLength_1
|
310
|
+
},
|
311
|
+
logger: _extends({}, schema.logger, {
|
312
|
+
defaultValue: function () {
|
313
|
+
return (// set logger based on browser capability
|
314
|
+
typeof console !== 'undefined' && typeof console.debug === 'function' ? getPrefixedConsole() : undefined
|
315
|
+
);
|
316
|
+
}
|
317
|
+
})
|
318
|
+
};
|
319
|
+
|
320
|
+
var getPrefixedConsole = function () {
|
321
|
+
var logger = {};
|
322
|
+
var consoleLog = console['log'];
|
323
|
+
__map_1(['debug', 'info', 'warn', 'error'], function (method) {
|
324
|
+
var consoleMethod = console[method];
|
325
|
+
logger[method] = typeof consoleMethod === 'function' ? consoleMethod.bind(console, '[bugsnag]') : consoleLog.bind(console, '[bugsnag]');
|
326
|
+
});
|
327
|
+
return logger;
|
328
|
+
};
|
329
|
+
|
330
|
+
var __isoDate_3 = _$esUtils_8.isoDate;
|
331
|
+
|
332
|
+
var BugsnagBreadcrumb =
|
333
|
+
/*#__PURE__*/
|
334
|
+
function () {
|
335
|
+
function BugsnagBreadcrumb(name, metaData, type, timestamp) {
|
336
|
+
if (name === void 0) {
|
337
|
+
name = '[anonymous]';
|
338
|
+
}
|
339
|
+
|
340
|
+
if (metaData === void 0) {
|
341
|
+
metaData = {};
|
342
|
+
}
|
343
|
+
|
344
|
+
if (type === void 0) {
|
345
|
+
type = 'manual';
|
346
|
+
}
|
347
|
+
|
348
|
+
if (timestamp === void 0) {
|
349
|
+
timestamp = __isoDate_3();
|
350
|
+
}
|
351
|
+
|
352
|
+
this.type = type;
|
353
|
+
this.name = name;
|
354
|
+
this.metaData = metaData;
|
355
|
+
this.timestamp = timestamp;
|
356
|
+
}
|
357
|
+
|
358
|
+
var _proto = BugsnagBreadcrumb.prototype;
|
359
|
+
|
360
|
+
_proto.toJSON = function toJSON() {
|
361
|
+
return {
|
362
|
+
type: this.type,
|
363
|
+
name: this.name,
|
364
|
+
timestamp: this.timestamp,
|
365
|
+
metaData: this.metaData
|
366
|
+
};
|
367
|
+
};
|
368
|
+
|
369
|
+
return BugsnagBreadcrumb;
|
370
|
+
}();
|
371
|
+
|
372
|
+
var _$BugsnagBreadcrumb_3 = BugsnagBreadcrumb;
|
373
|
+
|
374
|
+
// This is a heavily modified/simplified version of
|
375
|
+
// https://github.com/othiym23/async-some
|
376
|
+
//
|
377
|
+
// We can't use that because:
|
378
|
+
// a) it inflates the bundle size to over 10kB
|
379
|
+
// b) it depends on a module that uses Object.keys()
|
380
|
+
// (which we can't use due to ie8 support)
|
381
|
+
// run the asynchronous test function (fn) over each item in the array (arr)
|
382
|
+
// in series until:
|
383
|
+
// - fn(item, cb) => calls cb(null, true)
|
384
|
+
// - or the end of the array is reached
|
385
|
+
// the callback (cb) will be passed true if any of the items resulted in a true
|
386
|
+
// callback, otherwise false
|
387
|
+
var _$asyncSome_6 = function (arr, fn, cb) {
|
388
|
+
var length = arr.length;
|
389
|
+
var index = 0;
|
390
|
+
|
391
|
+
var next = function () {
|
392
|
+
if (index >= length) return cb(null, false);
|
393
|
+
fn(arr[index], function (err, result) {
|
394
|
+
if (err) return cb(err, false);
|
395
|
+
if (result === true) return cb(null, true);
|
396
|
+
index++;
|
397
|
+
next();
|
398
|
+
});
|
399
|
+
};
|
400
|
+
|
401
|
+
next();
|
402
|
+
};
|
403
|
+
|
404
|
+
var _$inferReleaseStage_10 = function (client) {
|
405
|
+
return client.app && typeof client.app.releaseStage === 'string' ? client.app.releaseStage : client.config.releaseStage;
|
406
|
+
};
|
407
|
+
|
408
|
+
/**
|
409
|
+
* Expose `isError`.
|
410
|
+
*/
|
411
|
+
var _$isError_21 = isError;
|
412
|
+
/**
|
413
|
+
* Test whether `value` is error object.
|
414
|
+
*
|
415
|
+
* @param {*} value
|
416
|
+
* @returns {boolean}
|
417
|
+
*/
|
418
|
+
|
419
|
+
function isError(value) {
|
420
|
+
switch (Object.prototype.toString.call(value)) {
|
421
|
+
case '[object Error]':
|
422
|
+
return true;
|
423
|
+
|
424
|
+
case '[object Exception]':
|
425
|
+
return true;
|
426
|
+
|
427
|
+
case '[object DOMException]':
|
428
|
+
return true;
|
429
|
+
|
430
|
+
default:
|
431
|
+
return value instanceof Error;
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
435
|
+
var _$iserror_11 = _$isError_21;
|
436
|
+
|
437
|
+
var _$runBeforeSend_14 = function (report, onError) {
|
438
|
+
return function (fn, cb) {
|
439
|
+
if (typeof fn !== 'function') return cb(null, false);
|
440
|
+
|
441
|
+
try {
|
442
|
+
// if function appears sync…
|
443
|
+
if (fn.length !== 2) {
|
444
|
+
var ret = fn(report); // check if it returned a "thenable" (promise)
|
445
|
+
|
446
|
+
if (ret && typeof ret.then === 'function') {
|
447
|
+
return ret.then( // resolve
|
448
|
+
function (val) {
|
449
|
+
return setTimeout(function () {
|
450
|
+
return cb(null, shouldPreventSend(report, val));
|
451
|
+
}, 0);
|
452
|
+
}, // reject
|
453
|
+
function (err) {
|
454
|
+
setTimeout(function () {
|
455
|
+
onError(err);
|
456
|
+
return cb(null, false);
|
457
|
+
});
|
458
|
+
});
|
459
|
+
}
|
460
|
+
|
461
|
+
return cb(null, shouldPreventSend(report, ret));
|
462
|
+
} // if function is async…
|
463
|
+
|
464
|
+
|
465
|
+
fn(report, function (err, result) {
|
466
|
+
if (err) {
|
467
|
+
onError(err);
|
468
|
+
return cb(null, false);
|
469
|
+
}
|
470
|
+
|
471
|
+
cb(null, shouldPreventSend(report, result));
|
472
|
+
});
|
473
|
+
} catch (e) {
|
474
|
+
onError(e);
|
475
|
+
cb(null, false);
|
476
|
+
}
|
477
|
+
};
|
478
|
+
};
|
479
|
+
|
480
|
+
var shouldPreventSend = function (report, value) {
|
481
|
+
return report.isIgnored() || value === false;
|
482
|
+
};
|
483
|
+
|
484
|
+
var _$stackframe_23 = {};
|
485
|
+
(function (root, factory) {
|
486
|
+
'use strict'; // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
|
487
|
+
|
488
|
+
/* istanbul ignore next */
|
489
|
+
|
490
|
+
if (typeof define === 'function' && define.amd) {
|
491
|
+
define('stackframe', [], factory);
|
492
|
+
} else if (typeof _$stackframe_23 === 'object') {
|
493
|
+
_$stackframe_23 = factory();
|
494
|
+
} else {
|
495
|
+
root.StackFrame = factory();
|
496
|
+
}
|
497
|
+
})(this, function () {
|
498
|
+
'use strict';
|
499
|
+
|
500
|
+
function _isNumber(n) {
|
501
|
+
return !isNaN(parseFloat(n)) && isFinite(n);
|
502
|
+
}
|
503
|
+
|
504
|
+
function _capitalize(str) {
|
505
|
+
return str.charAt(0).toUpperCase() + str.substring(1);
|
506
|
+
}
|
507
|
+
|
508
|
+
function _getter(p) {
|
509
|
+
return function () {
|
510
|
+
return this[p];
|
511
|
+
};
|
512
|
+
}
|
513
|
+
|
514
|
+
var booleanProps = ['isConstructor', 'isEval', 'isNative', 'isToplevel'];
|
515
|
+
var numericProps = ['columnNumber', 'lineNumber'];
|
516
|
+
var stringProps = ['fileName', 'functionName', 'source'];
|
517
|
+
var arrayProps = ['args'];
|
518
|
+
var props = booleanProps.concat(numericProps, stringProps, arrayProps);
|
519
|
+
|
520
|
+
function StackFrame(obj) {
|
521
|
+
if (obj instanceof Object) {
|
522
|
+
for (var i = 0; i < props.length; i++) {
|
523
|
+
if (obj.hasOwnProperty(props[i]) && obj[props[i]] !== undefined) {
|
524
|
+
this['set' + _capitalize(props[i])](obj[props[i]]);
|
525
|
+
}
|
526
|
+
}
|
527
|
+
}
|
528
|
+
}
|
529
|
+
|
530
|
+
StackFrame.prototype = {
|
531
|
+
getArgs: function () {
|
532
|
+
return this.args;
|
533
|
+
},
|
534
|
+
setArgs: function (v) {
|
535
|
+
if (Object.prototype.toString.call(v) !== '[object Array]') {
|
536
|
+
throw new TypeError('Args must be an Array');
|
537
|
+
}
|
538
|
+
|
539
|
+
this.args = v;
|
540
|
+
},
|
541
|
+
getEvalOrigin: function () {
|
542
|
+
return this.evalOrigin;
|
543
|
+
},
|
544
|
+
setEvalOrigin: function (v) {
|
545
|
+
if (v instanceof StackFrame) {
|
546
|
+
this.evalOrigin = v;
|
547
|
+
} else if (v instanceof Object) {
|
548
|
+
this.evalOrigin = new StackFrame(v);
|
549
|
+
} else {
|
550
|
+
throw new TypeError('Eval Origin must be an Object or StackFrame');
|
551
|
+
}
|
552
|
+
},
|
553
|
+
toString: function () {
|
554
|
+
var functionName = this.getFunctionName() || '{anonymous}';
|
555
|
+
var args = '(' + (this.getArgs() || []).join(',') + ')';
|
556
|
+
var fileName = this.getFileName() ? '@' + this.getFileName() : '';
|
557
|
+
var lineNumber = _isNumber(this.getLineNumber()) ? ':' + this.getLineNumber() : '';
|
558
|
+
var columnNumber = _isNumber(this.getColumnNumber()) ? ':' + this.getColumnNumber() : '';
|
559
|
+
return functionName + args + fileName + lineNumber + columnNumber;
|
560
|
+
}
|
561
|
+
};
|
562
|
+
|
563
|
+
for (var i = 0; i < booleanProps.length; i++) {
|
564
|
+
StackFrame.prototype['get' + _capitalize(booleanProps[i])] = _getter(booleanProps[i]);
|
565
|
+
|
566
|
+
StackFrame.prototype['set' + _capitalize(booleanProps[i])] = function (p) {
|
567
|
+
return function (v) {
|
568
|
+
this[p] = Boolean(v);
|
569
|
+
};
|
570
|
+
}(booleanProps[i]);
|
571
|
+
}
|
572
|
+
|
573
|
+
for (var j = 0; j < numericProps.length; j++) {
|
574
|
+
StackFrame.prototype['get' + _capitalize(numericProps[j])] = _getter(numericProps[j]);
|
575
|
+
|
576
|
+
StackFrame.prototype['set' + _capitalize(numericProps[j])] = function (p) {
|
577
|
+
return function (v) {
|
578
|
+
if (!_isNumber(v)) {
|
579
|
+
throw new TypeError(p + ' must be a Number');
|
580
|
+
}
|
581
|
+
|
582
|
+
this[p] = Number(v);
|
583
|
+
};
|
584
|
+
}(numericProps[j]);
|
585
|
+
}
|
586
|
+
|
587
|
+
for (var k = 0; k < stringProps.length; k++) {
|
588
|
+
StackFrame.prototype['get' + _capitalize(stringProps[k])] = _getter(stringProps[k]);
|
589
|
+
|
590
|
+
StackFrame.prototype['set' + _capitalize(stringProps[k])] = function (p) {
|
591
|
+
return function (v) {
|
592
|
+
this[p] = String(v);
|
593
|
+
};
|
594
|
+
}(stringProps[k]);
|
595
|
+
}
|
596
|
+
|
597
|
+
return StackFrame;
|
598
|
+
});
|
599
|
+
|
600
|
+
var _$errorStackParser_20 = {};
|
601
|
+
(function (root, factory) {
|
602
|
+
'use strict'; // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
|
603
|
+
|
604
|
+
/* istanbul ignore next */
|
605
|
+
|
606
|
+
if (typeof define === 'function' && define.amd) {
|
607
|
+
define('error-stack-parser', ['stackframe'], factory);
|
608
|
+
} else if (typeof _$errorStackParser_20 === 'object') {
|
609
|
+
_$errorStackParser_20 = factory(_$stackframe_23);
|
610
|
+
} else {
|
611
|
+
root.ErrorStackParser = factory(root.StackFrame);
|
612
|
+
}
|
613
|
+
})(this, function ErrorStackParser(StackFrame) {
|
614
|
+
'use strict';
|
615
|
+
|
616
|
+
var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+\:\d+/;
|
617
|
+
var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+\:\d+|\(native\))/m;
|
618
|
+
var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;
|
619
|
+
return {
|
620
|
+
/**
|
621
|
+
* Given an Error object, extract the most information from it.
|
622
|
+
*
|
623
|
+
* @param {Error} error object
|
624
|
+
* @return {Array} of StackFrames
|
625
|
+
*/
|
626
|
+
parse: function ErrorStackParser$$parse(error) {
|
627
|
+
if (typeof error.stacktrace !== 'undefined' || typeof error['opera#sourceloc'] !== 'undefined') {
|
628
|
+
return this.parseOpera(error);
|
629
|
+
} else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
|
630
|
+
return this.parseV8OrIE(error);
|
631
|
+
} else if (error.stack) {
|
632
|
+
return this.parseFFOrSafari(error);
|
633
|
+
} else {
|
634
|
+
throw new Error('Cannot parse given Error object');
|
635
|
+
}
|
636
|
+
},
|
637
|
+
// Separate line and column numbers from a string of the form: (URI:Line:Column)
|
638
|
+
extractLocation: function ErrorStackParser$$extractLocation(urlLike) {
|
639
|
+
// Fail-fast but return locations like "(native)"
|
640
|
+
if (urlLike.indexOf(':') === -1) {
|
641
|
+
return [urlLike];
|
642
|
+
}
|
643
|
+
|
644
|
+
var regExp = /(.+?)(?:\:(\d+))?(?:\:(\d+))?$/;
|
645
|
+
var parts = regExp.exec(urlLike.replace(/[\(\)]/g, ''));
|
646
|
+
return [parts[1], parts[2] || undefined, parts[3] || undefined];
|
647
|
+
},
|
648
|
+
parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
|
649
|
+
var filtered = error.stack.split('\n').filter(function (line) {
|
650
|
+
return !!line.match(CHROME_IE_STACK_REGEXP);
|
651
|
+
}, this);
|
652
|
+
return filtered.map(function (line) {
|
653
|
+
if (line.indexOf('(eval ') > -1) {
|
654
|
+
// Throw away eval information until we implement stacktrace.js/stackframe#8
|
655
|
+
line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^\()]*)|(\)\,.*$)/g, '');
|
656
|
+
}
|
657
|
+
|
658
|
+
var tokens = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').split(/\s+/).slice(1);
|
659
|
+
var locationParts = this.extractLocation(tokens.pop());
|
660
|
+
var functionName = tokens.join(' ') || undefined;
|
661
|
+
var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
|
662
|
+
return new StackFrame({
|
663
|
+
functionName: functionName,
|
664
|
+
fileName: fileName,
|
665
|
+
lineNumber: locationParts[1],
|
666
|
+
columnNumber: locationParts[2],
|
667
|
+
source: line
|
668
|
+
});
|
669
|
+
}, this);
|
670
|
+
},
|
671
|
+
parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
|
672
|
+
var filtered = error.stack.split('\n').filter(function (line) {
|
673
|
+
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
|
674
|
+
}, this);
|
675
|
+
return filtered.map(function (line) {
|
676
|
+
// Throw away eval information until we implement stacktrace.js/stackframe#8
|
677
|
+
if (line.indexOf(' > eval') > -1) {
|
678
|
+
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g, ':$1');
|
679
|
+
}
|
680
|
+
|
681
|
+
if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
|
682
|
+
// Safari eval frames only have function names and nothing else
|
683
|
+
return new StackFrame({
|
684
|
+
functionName: line
|
685
|
+
});
|
686
|
+
} else {
|
687
|
+
var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
|
688
|
+
var matches = line.match(functionNameRegex);
|
689
|
+
var functionName = matches && matches[1] ? matches[1] : undefined;
|
690
|
+
var locationParts = this.extractLocation(line.replace(functionNameRegex, ''));
|
691
|
+
return new StackFrame({
|
692
|
+
functionName: functionName,
|
693
|
+
fileName: locationParts[0],
|
694
|
+
lineNumber: locationParts[1],
|
695
|
+
columnNumber: locationParts[2],
|
696
|
+
source: line
|
697
|
+
});
|
698
|
+
}
|
699
|
+
}, this);
|
700
|
+
},
|
701
|
+
parseOpera: function ErrorStackParser$$parseOpera(e) {
|
702
|
+
if (!e.stacktrace || e.message.indexOf('\n') > -1 && e.message.split('\n').length > e.stacktrace.split('\n').length) {
|
703
|
+
return this.parseOpera9(e);
|
704
|
+
} else if (!e.stack) {
|
705
|
+
return this.parseOpera10(e);
|
706
|
+
} else {
|
707
|
+
return this.parseOpera11(e);
|
708
|
+
}
|
709
|
+
},
|
710
|
+
parseOpera9: function ErrorStackParser$$parseOpera9(e) {
|
711
|
+
var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
|
712
|
+
var lines = e.message.split('\n');
|
713
|
+
var result = [];
|
714
|
+
|
715
|
+
for (var i = 2, len = lines.length; i < len; i += 2) {
|
716
|
+
var match = lineRE.exec(lines[i]);
|
717
|
+
|
718
|
+
if (match) {
|
719
|
+
result.push(new StackFrame({
|
720
|
+
fileName: match[2],
|
721
|
+
lineNumber: match[1],
|
722
|
+
source: lines[i]
|
723
|
+
}));
|
724
|
+
}
|
725
|
+
}
|
726
|
+
|
727
|
+
return result;
|
728
|
+
},
|
729
|
+
parseOpera10: function ErrorStackParser$$parseOpera10(e) {
|
730
|
+
var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
|
731
|
+
var lines = e.stacktrace.split('\n');
|
732
|
+
var result = [];
|
733
|
+
|
734
|
+
for (var i = 0, len = lines.length; i < len; i += 2) {
|
735
|
+
var match = lineRE.exec(lines[i]);
|
736
|
+
|
737
|
+
if (match) {
|
738
|
+
result.push(new StackFrame({
|
739
|
+
functionName: match[3] || undefined,
|
740
|
+
fileName: match[2],
|
741
|
+
lineNumber: match[1],
|
742
|
+
source: lines[i]
|
743
|
+
}));
|
744
|
+
}
|
745
|
+
}
|
746
|
+
|
747
|
+
return result;
|
748
|
+
},
|
749
|
+
// Opera 10.65+ Error.stack very similar to FF/Safari
|
750
|
+
parseOpera11: function ErrorStackParser$$parseOpera11(error) {
|
751
|
+
var filtered = error.stack.split('\n').filter(function (line) {
|
752
|
+
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
|
753
|
+
}, this);
|
754
|
+
return filtered.map(function (line) {
|
755
|
+
var tokens = line.split('@');
|
756
|
+
var locationParts = this.extractLocation(tokens.pop());
|
757
|
+
var functionCall = tokens.shift() || '';
|
758
|
+
var functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, '$2').replace(/\([^\)]*\)/g, '') || undefined;
|
759
|
+
var argsRaw;
|
760
|
+
|
761
|
+
if (functionCall.match(/\(([^\)]*)\)/)) {
|
762
|
+
argsRaw = functionCall.replace(/^[^\(]+\(([^\)]*)\)$/, '$1');
|
763
|
+
}
|
764
|
+
|
765
|
+
var args = argsRaw === undefined || argsRaw === '[arguments not available]' ? undefined : argsRaw.split(',');
|
766
|
+
return new StackFrame({
|
767
|
+
functionName: functionName,
|
768
|
+
args: args,
|
769
|
+
fileName: locationParts[0],
|
770
|
+
lineNumber: locationParts[1],
|
771
|
+
columnNumber: locationParts[2],
|
772
|
+
source: line
|
773
|
+
});
|
774
|
+
}, this);
|
775
|
+
}
|
776
|
+
};
|
777
|
+
});
|
778
|
+
|
779
|
+
var _$errorStackParser_7 = _$errorStackParser_20;
|
780
|
+
|
781
|
+
// Given `err` which may be an error, does it have a stack property which is a string?
|
782
|
+
var _$hasStack_9 = function (err) {
|
783
|
+
return !!err && (!!err.stack || !!err.stacktrace || !!err['opera#sourceloc']) && typeof (err.stack || err.stacktrace || err['opera#sourceloc']) === 'string' && err.stack !== err.name + ": " + err.message;
|
784
|
+
};
|
785
|
+
|
786
|
+
var _$jsRuntime_12 = "yes" ? 'browserjs' : typeof navigator !== 'undefined' && navigator.product === 'ReactNative' ? typeof Expo !== 'undefined' ? 'expojs' : 'reactnativejs' : 'nodejs';
|
787
|
+
|
788
|
+
var _$stackGenerator_22 = {};
|
789
|
+
(function (root, factory) {
|
790
|
+
'use strict'; // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
|
791
|
+
|
792
|
+
/* istanbul ignore next */
|
793
|
+
|
794
|
+
if (typeof define === 'function' && define.amd) {
|
795
|
+
define('stack-generator', ['stackframe'], factory);
|
796
|
+
} else if (typeof _$stackGenerator_22 === 'object') {
|
797
|
+
_$stackGenerator_22 = factory(_$stackframe_23);
|
798
|
+
} else {
|
799
|
+
root.StackGenerator = factory(root.StackFrame);
|
800
|
+
}
|
801
|
+
})(this, function (StackFrame) {
|
802
|
+
return {
|
803
|
+
backtrace: function StackGenerator$$backtrace(opts) {
|
804
|
+
var stack = [];
|
805
|
+
var maxStackSize = 10;
|
806
|
+
|
807
|
+
if (typeof opts === 'object' && typeof opts.maxStackSize === 'number') {
|
808
|
+
maxStackSize = opts.maxStackSize;
|
809
|
+
}
|
810
|
+
|
811
|
+
var curr = arguments.callee;
|
812
|
+
|
813
|
+
while (curr && stack.length < maxStackSize && curr['arguments']) {
|
814
|
+
// Allow V8 optimizations
|
815
|
+
var args = new Array(curr['arguments'].length);
|
816
|
+
|
817
|
+
for (var i = 0; i < args.length; ++i) {
|
818
|
+
args[i] = curr['arguments'][i];
|
819
|
+
}
|
820
|
+
|
821
|
+
if (/function(?:\s+([\w$]+))+\s*\(/.test(curr.toString())) {
|
822
|
+
stack.push(new StackFrame({
|
823
|
+
functionName: RegExp.$1 || undefined,
|
824
|
+
args: args
|
825
|
+
}));
|
826
|
+
} else {
|
827
|
+
stack.push(new StackFrame({
|
828
|
+
args: args
|
829
|
+
}));
|
830
|
+
}
|
831
|
+
|
832
|
+
try {
|
833
|
+
curr = curr.caller;
|
834
|
+
} catch (e) {
|
835
|
+
break;
|
836
|
+
}
|
837
|
+
}
|
838
|
+
|
839
|
+
return stack;
|
840
|
+
}
|
841
|
+
};
|
842
|
+
});
|
843
|
+
|
844
|
+
function ___extends_24() { ___extends_24 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_24.apply(this, arguments); }
|
845
|
+
|
846
|
+
/* removed: var _$errorStackParser_7 = require('./lib/error-stack-parser'); */;
|
847
|
+
|
848
|
+
/* removed: var _$stackGenerator_22 = require('stack-generator'); */;
|
849
|
+
|
850
|
+
/* removed: var _$hasStack_9 = require('./lib/has-stack'); */;
|
851
|
+
|
852
|
+
var __reduce_24 = _$esUtils_8.reduce,
|
853
|
+
__filter_24 = _$esUtils_8.filter;
|
854
|
+
|
855
|
+
/* removed: var _$jsRuntime_12 = require('./lib/js-runtime'); */;
|
856
|
+
|
857
|
+
var BugsnagReport =
|
858
|
+
/*#__PURE__*/
|
859
|
+
function () {
|
860
|
+
function BugsnagReport(errorClass, errorMessage, stacktrace, handledState, originalError) {
|
861
|
+
if (stacktrace === void 0) {
|
862
|
+
stacktrace = [];
|
863
|
+
}
|
864
|
+
|
865
|
+
if (handledState === void 0) {
|
866
|
+
handledState = defaultHandledState();
|
867
|
+
}
|
868
|
+
|
869
|
+
// duck-typing ftw >_<
|
870
|
+
this.__isBugsnagReport = true;
|
871
|
+
this._ignored = false; // private (un)handled state
|
872
|
+
|
873
|
+
this._handledState = handledState; // setable props
|
874
|
+
|
875
|
+
this.app = undefined;
|
876
|
+
this.apiKey = undefined;
|
877
|
+
this.breadcrumbs = [];
|
878
|
+
this.context = undefined;
|
879
|
+
this.device = undefined;
|
880
|
+
this.errorClass = stringOrFallback(errorClass, '[no error class]');
|
881
|
+
this.errorMessage = stringOrFallback(errorMessage, '[no error message]');
|
882
|
+
this.groupingHash = undefined;
|
883
|
+
this.metaData = {};
|
884
|
+
this.request = undefined;
|
885
|
+
this.severity = this._handledState.severity;
|
886
|
+
this.stacktrace = __reduce_24(stacktrace, function (accum, frame) {
|
887
|
+
var f = formatStackframe(frame); // don't include a stackframe if none of its properties are defined
|
888
|
+
|
889
|
+
try {
|
890
|
+
if (JSON.stringify(f) === '{}') return accum;
|
891
|
+
return accum.concat(f);
|
892
|
+
} catch (e) {
|
893
|
+
return accum;
|
894
|
+
}
|
895
|
+
}, []);
|
896
|
+
this.user = undefined;
|
897
|
+
this.session = undefined;
|
898
|
+
this.originalError = originalError; // Flags.
|
899
|
+
// Note these are not initialised unless they are used
|
900
|
+
// to save unnecessary bytes in the browser bundle
|
901
|
+
|
902
|
+
/* this.attemptImmediateDelivery, default: true */
|
903
|
+
}
|
904
|
+
|
905
|
+
var _proto = BugsnagReport.prototype;
|
906
|
+
|
907
|
+
_proto.ignore = function ignore() {
|
908
|
+
this._ignored = true;
|
909
|
+
};
|
910
|
+
|
911
|
+
_proto.isIgnored = function isIgnored() {
|
912
|
+
return this._ignored;
|
913
|
+
};
|
914
|
+
|
915
|
+
_proto.updateMetaData = function updateMetaData(section) {
|
916
|
+
var _updates;
|
917
|
+
|
918
|
+
if (!section) return this;
|
919
|
+
var updates; // updateMetaData("section", null) -> removes section
|
920
|
+
|
921
|
+
if ((arguments.length <= 1 ? undefined : arguments[1]) === null) return this.removeMetaData(section); // updateMetaData("section", "property", null) -> removes property from section
|
922
|
+
|
923
|
+
if ((arguments.length <= 2 ? undefined : arguments[2]) === null) return this.removeMetaData(section, arguments.length <= 1 ? undefined : arguments[1], arguments.length <= 2 ? undefined : arguments[2]); // normalise the two supported input types into object form
|
924
|
+
|
925
|
+
if (typeof (arguments.length <= 1 ? undefined : arguments[1]) === 'object') updates = arguments.length <= 1 ? undefined : arguments[1];
|
926
|
+
if (typeof (arguments.length <= 1 ? undefined : arguments[1]) === 'string') updates = (_updates = {}, _updates[arguments.length <= 1 ? undefined : arguments[1]] = arguments.length <= 2 ? undefined : arguments[2], _updates); // exit if we don't have an updates object at this point
|
927
|
+
|
928
|
+
if (!updates) return this; // ensure a section with this name exists
|
929
|
+
|
930
|
+
if (!this.metaData[section]) this.metaData[section] = {}; // merge the updates with the existing section
|
931
|
+
|
932
|
+
this.metaData[section] = ___extends_24({}, this.metaData[section], updates);
|
933
|
+
return this;
|
934
|
+
};
|
935
|
+
|
936
|
+
_proto.removeMetaData = function removeMetaData(section, property) {
|
937
|
+
if (typeof section !== 'string') return this; // remove an entire section
|
938
|
+
|
939
|
+
if (!property) {
|
940
|
+
delete this.metaData[section];
|
941
|
+
return this;
|
942
|
+
} // remove a single property from a section
|
943
|
+
|
944
|
+
|
945
|
+
if (this.metaData[section]) {
|
946
|
+
delete this.metaData[section][property];
|
947
|
+
return this;
|
948
|
+
}
|
949
|
+
|
950
|
+
return this;
|
951
|
+
};
|
952
|
+
|
953
|
+
_proto.toJSON = function toJSON() {
|
954
|
+
return {
|
955
|
+
payloadVersion: '4',
|
956
|
+
exceptions: [{
|
957
|
+
errorClass: this.errorClass,
|
958
|
+
message: this.errorMessage,
|
959
|
+
stacktrace: this.stacktrace,
|
960
|
+
type: _$jsRuntime_12
|
961
|
+
}],
|
962
|
+
severity: this.severity,
|
963
|
+
unhandled: this._handledState.unhandled,
|
964
|
+
severityReason: this._handledState.severityReason,
|
965
|
+
app: this.app,
|
966
|
+
device: this.device,
|
967
|
+
breadcrumbs: this.breadcrumbs,
|
968
|
+
context: this.context,
|
969
|
+
user: this.user,
|
970
|
+
metaData: this.metaData,
|
971
|
+
groupingHash: this.groupingHash,
|
972
|
+
request: this.request,
|
973
|
+
session: this.session
|
974
|
+
};
|
975
|
+
};
|
976
|
+
|
977
|
+
return BugsnagReport;
|
978
|
+
}(); // takes a stacktrace.js style stackframe (https://github.com/stacktracejs/stackframe)
|
979
|
+
// and returns a Bugsnag compatible stackframe (https://docs.bugsnag.com/api/error-reporting/#json-payload)
|
980
|
+
|
981
|
+
|
982
|
+
var formatStackframe = function (frame) {
|
983
|
+
var f = {
|
984
|
+
file: frame.fileName,
|
985
|
+
method: normaliseFunctionName(frame.functionName),
|
986
|
+
lineNumber: frame.lineNumber,
|
987
|
+
columnNumber: frame.columnNumber,
|
988
|
+
code: undefined,
|
989
|
+
inProject: undefined // Some instances result in no file:
|
990
|
+
// - calling notify() from chrome's terminal results in no file/method.
|
991
|
+
// - non-error exception thrown from global code in FF
|
992
|
+
// This adds one.
|
993
|
+
|
994
|
+
};
|
995
|
+
|
996
|
+
if (f.lineNumber > -1 && !f.file && !f.method) {
|
997
|
+
f.file = 'global code';
|
998
|
+
}
|
999
|
+
|
1000
|
+
return f;
|
1001
|
+
};
|
1002
|
+
|
1003
|
+
var normaliseFunctionName = function (name) {
|
1004
|
+
return /^global code$/i.test(name) ? 'global code' : name;
|
1005
|
+
};
|
1006
|
+
|
1007
|
+
var defaultHandledState = function () {
|
1008
|
+
return {
|
1009
|
+
unhandled: false,
|
1010
|
+
severity: 'warning',
|
1011
|
+
severityReason: {
|
1012
|
+
type: 'handledException'
|
1013
|
+
}
|
1014
|
+
};
|
1015
|
+
};
|
1016
|
+
|
1017
|
+
var stringOrFallback = function (str, fallback) {
|
1018
|
+
return typeof str === 'string' && str ? str : fallback;
|
1019
|
+
}; // Helpers
|
1020
|
+
|
1021
|
+
|
1022
|
+
BugsnagReport.getStacktrace = function (error, errorFramesToSkip, generatedFramesToSkip) {
|
1023
|
+
if (errorFramesToSkip === void 0) {
|
1024
|
+
errorFramesToSkip = 0;
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
if (generatedFramesToSkip === void 0) {
|
1028
|
+
generatedFramesToSkip = 0;
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
if (_$hasStack_9(error)) return _$errorStackParser_7.parse(error).slice(errorFramesToSkip); // error wasn't provided or didn't have a stacktrace so try to walk the callstack
|
1032
|
+
|
1033
|
+
return __filter_24(_$stackGenerator_22.backtrace(), function (frame) {
|
1034
|
+
return (frame.functionName || '').indexOf('StackGenerator$$') === -1;
|
1035
|
+
}).slice(1 + generatedFramesToSkip);
|
1036
|
+
};
|
1037
|
+
|
1038
|
+
BugsnagReport.ensureReport = function (reportOrError, errorFramesToSkip, generatedFramesToSkip) {
|
1039
|
+
if (errorFramesToSkip === void 0) {
|
1040
|
+
errorFramesToSkip = 0;
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
if (generatedFramesToSkip === void 0) {
|
1044
|
+
generatedFramesToSkip = 0;
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
// notify() can be called with a Report object. In this case no action is required
|
1048
|
+
if (reportOrError.__isBugsnagReport) return reportOrError;
|
1049
|
+
|
1050
|
+
try {
|
1051
|
+
var stacktrace = BugsnagReport.getStacktrace(reportOrError, errorFramesToSkip, 1 + generatedFramesToSkip);
|
1052
|
+
return new BugsnagReport(reportOrError.name, reportOrError.message, stacktrace, undefined, reportOrError);
|
1053
|
+
} catch (e) {
|
1054
|
+
return new BugsnagReport(reportOrError.name, reportOrError.message, [], undefined, reportOrError);
|
1055
|
+
}
|
1056
|
+
};
|
1057
|
+
|
1058
|
+
var _$BugsnagReport_24 = BugsnagReport;
|
1059
|
+
|
1060
|
+
var _$pad_18 = function pad(num, size) {
|
1061
|
+
var s = '000000000' + num;
|
1062
|
+
return s.substr(s.length - size);
|
1063
|
+
};
|
1064
|
+
|
1065
|
+
/* removed: var _$pad_18 = require('./pad.js'); */;
|
1066
|
+
|
1067
|
+
var env = typeof window === 'object' ? window : self;
|
1068
|
+
var globalCount = 0;
|
1069
|
+
|
1070
|
+
for (var prop in env) {
|
1071
|
+
if (Object.hasOwnProperty.call(env, prop)) globalCount++;
|
1072
|
+
}
|
1073
|
+
|
1074
|
+
var mimeTypesLength = navigator.mimeTypes ? navigator.mimeTypes.length : 0;
|
1075
|
+
var clientId = _$pad_18((mimeTypesLength + navigator.userAgent.length).toString(36) + globalCount.toString(36), 4);
|
1076
|
+
|
1077
|
+
var _$fingerprint_17 = function fingerprint() {
|
1078
|
+
return clientId;
|
1079
|
+
};
|
1080
|
+
|
1081
|
+
/**
|
1082
|
+
* cuid.js
|
1083
|
+
* Collision-resistant UID generator for browsers and node.
|
1084
|
+
* Sequential for fast db lookups and recency sorting.
|
1085
|
+
* Safe for element IDs and server-side lookups.
|
1086
|
+
*
|
1087
|
+
* Extracted from CLCTR
|
1088
|
+
*
|
1089
|
+
* Copyright (c) Eric Elliott 2012
|
1090
|
+
* MIT License
|
1091
|
+
*/
|
1092
|
+
/* removed: var _$fingerprint_17 = require('./lib/fingerprint.js'); */;
|
1093
|
+
|
1094
|
+
/* removed: var _$pad_18 = require('./lib/pad.js'); */;
|
1095
|
+
|
1096
|
+
var c = 0,
|
1097
|
+
blockSize = 4,
|
1098
|
+
base = 36,
|
1099
|
+
discreteValues = Math.pow(base, blockSize);
|
1100
|
+
|
1101
|
+
function randomBlock() {
|
1102
|
+
return _$pad_18((Math.random() * discreteValues << 0).toString(base), blockSize);
|
1103
|
+
}
|
1104
|
+
|
1105
|
+
function safeCounter() {
|
1106
|
+
c = c < discreteValues ? c : 0;
|
1107
|
+
c++; // this is not subliminal
|
1108
|
+
|
1109
|
+
return c - 1;
|
1110
|
+
}
|
1111
|
+
|
1112
|
+
function cuid() {
|
1113
|
+
// Starting with a lowercase letter makes
|
1114
|
+
// it HTML element ID friendly.
|
1115
|
+
var letter = 'c',
|
1116
|
+
// hard-coded allows for sequential access
|
1117
|
+
// timestamp
|
1118
|
+
// warning: this exposes the exact date and time
|
1119
|
+
// that the uid was created.
|
1120
|
+
timestamp = new Date().getTime().toString(base),
|
1121
|
+
// Prevent same-machine collisions.
|
1122
|
+
counter = _$pad_18(safeCounter().toString(base), blockSize),
|
1123
|
+
// A few chars to generate distinct ids for different
|
1124
|
+
// clients (so different computers are far less
|
1125
|
+
// likely to generate the same id)
|
1126
|
+
print = _$fingerprint_17(),
|
1127
|
+
// Grab some more chars from Math.random()
|
1128
|
+
random = randomBlock() + randomBlock();
|
1129
|
+
return letter + timestamp + counter + print + random;
|
1130
|
+
}
|
1131
|
+
|
1132
|
+
cuid.fingerprint = _$fingerprint_17;
|
1133
|
+
var _$cuid_16 = cuid;
|
1134
|
+
|
1135
|
+
var __isoDate_25 = _$esUtils_8.isoDate;
|
1136
|
+
|
1137
|
+
/* removed: var _$cuid_16 = require('@bugsnag/cuid'); */;
|
1138
|
+
|
1139
|
+
var Session =
|
1140
|
+
/*#__PURE__*/
|
1141
|
+
function () {
|
1142
|
+
function Session() {
|
1143
|
+
this.id = _$cuid_16();
|
1144
|
+
this.startedAt = __isoDate_25();
|
1145
|
+
this._handled = 0;
|
1146
|
+
this._unhandled = 0;
|
1147
|
+
}
|
1148
|
+
|
1149
|
+
var _proto = Session.prototype;
|
1150
|
+
|
1151
|
+
_proto.toJSON = function toJSON() {
|
1152
|
+
return {
|
1153
|
+
id: this.id,
|
1154
|
+
startedAt: this.startedAt,
|
1155
|
+
events: {
|
1156
|
+
handled: this._handled,
|
1157
|
+
unhandled: this._unhandled
|
1158
|
+
}
|
1159
|
+
};
|
1160
|
+
};
|
1161
|
+
|
1162
|
+
_proto.trackError = function trackError(report) {
|
1163
|
+
this[report._handledState.unhandled ? '_unhandled' : '_handled'] += 1;
|
1164
|
+
};
|
1165
|
+
|
1166
|
+
return Session;
|
1167
|
+
}();
|
1168
|
+
|
1169
|
+
var _$Session_25 = Session;
|
1170
|
+
|
1171
|
+
function ___extends_4() { ___extends_4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_4.apply(this, arguments); }
|
1172
|
+
|
1173
|
+
/* removed: var _$config_5 = require('./config'); */;
|
1174
|
+
|
1175
|
+
/* removed: var _$BugsnagReport_24 = require('./report'); */;
|
1176
|
+
|
1177
|
+
/* removed: var _$BugsnagBreadcrumb_3 = require('./breadcrumb'); */;
|
1178
|
+
|
1179
|
+
/* removed: var _$Session_25 = require('./session'); */;
|
1180
|
+
|
1181
|
+
var __map_4 = _$esUtils_8.map,
|
1182
|
+
__includes_4 = _$esUtils_8.includes,
|
1183
|
+
__isArray_4 = _$esUtils_8.isArray;
|
1184
|
+
|
1185
|
+
/* removed: var _$inferReleaseStage_10 = require('./lib/infer-release-stage'); */;
|
1186
|
+
|
1187
|
+
/* removed: var _$iserror_11 = require('./lib/iserror'); */;
|
1188
|
+
|
1189
|
+
/* removed: var _$asyncSome_6 = require('./lib/async-some'); */;
|
1190
|
+
|
1191
|
+
/* removed: var _$runBeforeSend_14 = require('./lib/run-before-send'); */;
|
1192
|
+
|
1193
|
+
var LOG_USAGE_ERR_PREFIX = "Usage error.";
|
1194
|
+
var REPORT_USAGE_ERR_PREFIX = "Bugsnag usage error.";
|
1195
|
+
|
1196
|
+
var BugsnagClient =
|
1197
|
+
/*#__PURE__*/
|
1198
|
+
function () {
|
1199
|
+
function BugsnagClient(notifier) {
|
1200
|
+
if (!notifier || !notifier.name || !notifier.version || !notifier.url) {
|
1201
|
+
throw new Error('`notifier` argument is required');
|
1202
|
+
} // notifier id
|
1203
|
+
|
1204
|
+
|
1205
|
+
this.notifier = notifier; // configure() should be called before notify()
|
1206
|
+
|
1207
|
+
this._configured = false; // intialise opts and config
|
1208
|
+
|
1209
|
+
this._opts = {};
|
1210
|
+
this.config = {}; // // i/o
|
1211
|
+
|
1212
|
+
this._delivery = {
|
1213
|
+
sendSession: function () {},
|
1214
|
+
sendReport: function () {}
|
1215
|
+
};
|
1216
|
+
this._logger = {
|
1217
|
+
debug: function () {},
|
1218
|
+
info: function () {},
|
1219
|
+
warn: function () {},
|
1220
|
+
error: function () {} // plugins
|
1221
|
+
|
1222
|
+
};
|
1223
|
+
this._plugins = {};
|
1224
|
+
this._session = null;
|
1225
|
+
this.breadcrumbs = []; // setable props
|
1226
|
+
|
1227
|
+
this.app = {};
|
1228
|
+
this.context = undefined;
|
1229
|
+
this.device = undefined;
|
1230
|
+
this.metaData = undefined;
|
1231
|
+
this.request = undefined;
|
1232
|
+
this.user = {}; // expose internal constructors
|
1233
|
+
|
1234
|
+
this.BugsnagClient = BugsnagClient;
|
1235
|
+
this.BugsnagReport = _$BugsnagReport_24;
|
1236
|
+
this.BugsnagBreadcrumb = _$BugsnagBreadcrumb_3;
|
1237
|
+
this.BugsnagSession = _$Session_25;
|
1238
|
+
var self = this;
|
1239
|
+
var notify = this.notify;
|
1240
|
+
|
1241
|
+
this.notify = function () {
|
1242
|
+
return notify.apply(self, arguments);
|
1243
|
+
};
|
1244
|
+
}
|
1245
|
+
|
1246
|
+
var _proto = BugsnagClient.prototype;
|
1247
|
+
|
1248
|
+
_proto.setOptions = function setOptions(opts) {
|
1249
|
+
this._opts = ___extends_4({}, this._opts, opts);
|
1250
|
+
};
|
1251
|
+
|
1252
|
+
_proto.configure = function configure(partialSchema) {
|
1253
|
+
if (partialSchema === void 0) {
|
1254
|
+
partialSchema = _$config_5.schema;
|
1255
|
+
}
|
1256
|
+
|
1257
|
+
var conf = _$config_5.mergeDefaults(this._opts, partialSchema);
|
1258
|
+
var validity = _$config_5.validate(conf, partialSchema);
|
1259
|
+
if (!validity.valid === true) throw new Error(generateConfigErrorMessage(validity.errors)); // update and elevate some special options if they were passed in at this point
|
1260
|
+
|
1261
|
+
if (typeof conf.beforeSend === 'function') conf.beforeSend = [conf.beforeSend];
|
1262
|
+
if (conf.appVersion) this.app.version = conf.appVersion;
|
1263
|
+
if (conf.appType) this.app.type = conf.appType;
|
1264
|
+
if (conf.metaData) this.metaData = conf.metaData;
|
1265
|
+
if (conf.user) this.user = conf.user;
|
1266
|
+
if (conf.logger) this.logger(conf.logger); // merge with existing config
|
1267
|
+
|
1268
|
+
this.config = ___extends_4({}, this.config, conf);
|
1269
|
+
this._configured = true;
|
1270
|
+
return this;
|
1271
|
+
};
|
1272
|
+
|
1273
|
+
_proto.use = function use(plugin) {
|
1274
|
+
if (!this._configured) throw new Error('client not configured');
|
1275
|
+
if (plugin.configSchema) this.configure(plugin.configSchema);
|
1276
|
+
|
1277
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1278
|
+
args[_key - 1] = arguments[_key];
|
1279
|
+
}
|
1280
|
+
|
1281
|
+
var result = plugin.init.apply(plugin, [this].concat(args)); // JS objects are not the safest way to store arbitrarily keyed values,
|
1282
|
+
// so bookend the key with some characters that prevent tampering with
|
1283
|
+
// stuff like __proto__ etc. (only store the result if the plugin had a
|
1284
|
+
// name)
|
1285
|
+
|
1286
|
+
if (plugin.name) this._plugins["~" + plugin.name + "~"] = result;
|
1287
|
+
return this;
|
1288
|
+
};
|
1289
|
+
|
1290
|
+
_proto.getPlugin = function getPlugin(name) {
|
1291
|
+
return this._plugins["~" + name + "~"];
|
1292
|
+
};
|
1293
|
+
|
1294
|
+
_proto.delivery = function delivery(d) {
|
1295
|
+
this._delivery = d(this);
|
1296
|
+
return this;
|
1297
|
+
};
|
1298
|
+
|
1299
|
+
_proto.logger = function logger(l, sid) {
|
1300
|
+
this._logger = l;
|
1301
|
+
return this;
|
1302
|
+
};
|
1303
|
+
|
1304
|
+
_proto.sessionDelegate = function sessionDelegate(s) {
|
1305
|
+
this._sessionDelegate = s;
|
1306
|
+
return this;
|
1307
|
+
};
|
1308
|
+
|
1309
|
+
_proto.startSession = function startSession() {
|
1310
|
+
if (!this._sessionDelegate) {
|
1311
|
+
this._logger.warn('No session implementation is installed');
|
1312
|
+
|
1313
|
+
return this;
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
return this._sessionDelegate.startSession(this);
|
1317
|
+
};
|
1318
|
+
|
1319
|
+
_proto.leaveBreadcrumb = function leaveBreadcrumb(name, metaData, type, timestamp) {
|
1320
|
+
if (!this._configured) throw new Error('client not configured'); // coerce bad values so that the defaults get set
|
1321
|
+
|
1322
|
+
name = name || undefined;
|
1323
|
+
type = typeof type === 'string' ? type : undefined;
|
1324
|
+
timestamp = typeof timestamp === 'string' ? timestamp : undefined;
|
1325
|
+
metaData = typeof metaData === 'object' && metaData !== null ? metaData : undefined; // if no name and no metaData, usefulness of this crumb is questionable at best so discard
|
1326
|
+
|
1327
|
+
if (typeof name !== 'string' && !metaData) return;
|
1328
|
+
var crumb = new _$BugsnagBreadcrumb_3(name, metaData, type, timestamp); // push the valid crumb onto the queue and maintain the length
|
1329
|
+
|
1330
|
+
this.breadcrumbs.push(crumb);
|
1331
|
+
|
1332
|
+
if (this.breadcrumbs.length > this.config.maxBreadcrumbs) {
|
1333
|
+
this.breadcrumbs = this.breadcrumbs.slice(this.breadcrumbs.length - this.config.maxBreadcrumbs);
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
return this;
|
1337
|
+
};
|
1338
|
+
|
1339
|
+
_proto.notify = function notify(error, opts, cb) {
|
1340
|
+
var _this = this;
|
1341
|
+
|
1342
|
+
if (opts === void 0) {
|
1343
|
+
opts = {};
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
if (cb === void 0) {
|
1347
|
+
cb = function () {};
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
if (!this._configured) throw new Error('client not configured'); // releaseStage can be set via config.releaseStage or client.app.releaseStage
|
1351
|
+
|
1352
|
+
var releaseStage = _$inferReleaseStage_10(this); // ensure we have an error (or a reasonable object representation of an error)
|
1353
|
+
|
1354
|
+
var _normaliseError = normaliseError(error, opts, this._logger),
|
1355
|
+
err = _normaliseError.err,
|
1356
|
+
errorFramesToSkip = _normaliseError.errorFramesToSkip,
|
1357
|
+
_opts = _normaliseError._opts;
|
1358
|
+
|
1359
|
+
if (_opts) opts = _opts; // ensure opts is an object
|
1360
|
+
|
1361
|
+
if (typeof opts !== 'object' || opts === null) opts = {}; // create a report from the error, if it isn't one already
|
1362
|
+
|
1363
|
+
var report = _$BugsnagReport_24.ensureReport(err, errorFramesToSkip, 2);
|
1364
|
+
report.app = ___extends_4({}, {
|
1365
|
+
releaseStage: releaseStage
|
1366
|
+
}, report.app, this.app);
|
1367
|
+
report.context = report.context || opts.context || this.context || undefined;
|
1368
|
+
report.device = ___extends_4({}, report.device, this.device, opts.device);
|
1369
|
+
report.request = ___extends_4({}, report.request, this.request, opts.request);
|
1370
|
+
report.user = ___extends_4({}, report.user, this.user, opts.user);
|
1371
|
+
report.metaData = ___extends_4({}, report.metaData, this.metaData, opts.metaData);
|
1372
|
+
report.breadcrumbs = this.breadcrumbs.slice(0);
|
1373
|
+
|
1374
|
+
if (this._session) {
|
1375
|
+
this._session.trackError(report);
|
1376
|
+
|
1377
|
+
report.session = this._session;
|
1378
|
+
} // set severity if supplied
|
1379
|
+
|
1380
|
+
|
1381
|
+
if (opts.severity !== undefined) {
|
1382
|
+
report.severity = opts.severity;
|
1383
|
+
report._handledState.severityReason = {
|
1384
|
+
type: 'userSpecifiedSeverity'
|
1385
|
+
};
|
1386
|
+
} // exit early if the reports should not be sent on the current releaseStage
|
1387
|
+
|
1388
|
+
|
1389
|
+
if (__isArray_4(this.config.notifyReleaseStages) && !__includes_4(this.config.notifyReleaseStages, releaseStage)) {
|
1390
|
+
this._logger.warn("Report not sent due to releaseStage/notifyReleaseStages configuration");
|
1391
|
+
|
1392
|
+
return cb(null, report);
|
1393
|
+
}
|
1394
|
+
|
1395
|
+
var originalSeverity = report.severity;
|
1396
|
+
var beforeSend = [].concat(opts.beforeSend).concat(this.config.beforeSend);
|
1397
|
+
|
1398
|
+
var onBeforeSendErr = function (err) {
|
1399
|
+
_this._logger.error("Error occurred in beforeSend callback, continuing anyway\u2026");
|
1400
|
+
|
1401
|
+
_this._logger.error(err);
|
1402
|
+
};
|
1403
|
+
|
1404
|
+
_$asyncSome_6(beforeSend, _$runBeforeSend_14(report, onBeforeSendErr), function (err, preventSend) {
|
1405
|
+
if (err) onBeforeSendErr(err);
|
1406
|
+
|
1407
|
+
if (preventSend) {
|
1408
|
+
_this._logger.debug("Report not sent due to beforeSend callback");
|
1409
|
+
|
1410
|
+
return cb(null, report);
|
1411
|
+
} // only leave a crumb for the error if actually got sent
|
1412
|
+
|
1413
|
+
|
1414
|
+
if (_this.config.autoBreadcrumbs) {
|
1415
|
+
_this.leaveBreadcrumb(report.errorClass, {
|
1416
|
+
errorClass: report.errorClass,
|
1417
|
+
errorMessage: report.errorMessage,
|
1418
|
+
severity: report.severity
|
1419
|
+
}, 'error');
|
1420
|
+
}
|
1421
|
+
|
1422
|
+
if (originalSeverity !== report.severity) {
|
1423
|
+
report._handledState.severityReason = {
|
1424
|
+
type: 'userCallbackSetSeverity'
|
1425
|
+
};
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
_this._delivery.sendReport({
|
1429
|
+
apiKey: report.apiKey || _this.config.apiKey,
|
1430
|
+
notifier: _this.notifier,
|
1431
|
+
events: [report]
|
1432
|
+
}, function (err) {
|
1433
|
+
return cb(err, report);
|
1434
|
+
});
|
1435
|
+
});
|
1436
|
+
};
|
1437
|
+
|
1438
|
+
return BugsnagClient;
|
1439
|
+
}();
|
1440
|
+
|
1441
|
+
var normaliseError = function (error, opts, logger) {
|
1442
|
+
var synthesizedErrorFramesToSkip = 3;
|
1443
|
+
|
1444
|
+
var createAndLogUsageError = function (reason) {
|
1445
|
+
var msg = generateNotifyUsageMessage(reason);
|
1446
|
+
logger.warn(LOG_USAGE_ERR_PREFIX + " " + msg);
|
1447
|
+
return new Error(REPORT_USAGE_ERR_PREFIX + " " + msg);
|
1448
|
+
};
|
1449
|
+
|
1450
|
+
var err;
|
1451
|
+
var errorFramesToSkip = 0;
|
1452
|
+
|
1453
|
+
var _opts;
|
1454
|
+
|
1455
|
+
switch (typeof error) {
|
1456
|
+
case 'string':
|
1457
|
+
if (typeof opts === 'string') {
|
1458
|
+
// ≤v3 used to have a notify('ErrorName', 'Error message') interface
|
1459
|
+
// report usage/deprecation errors if this function is called like that
|
1460
|
+
err = createAndLogUsageError('string/string');
|
1461
|
+
_opts = {
|
1462
|
+
metaData: {
|
1463
|
+
notifier: {
|
1464
|
+
notifyArgs: [error, opts]
|
1465
|
+
}
|
1466
|
+
}
|
1467
|
+
};
|
1468
|
+
} else {
|
1469
|
+
err = new Error(String(error));
|
1470
|
+
errorFramesToSkip = synthesizedErrorFramesToSkip;
|
1471
|
+
}
|
1472
|
+
|
1473
|
+
break;
|
1474
|
+
|
1475
|
+
case 'number':
|
1476
|
+
case 'boolean':
|
1477
|
+
err = new Error(String(error));
|
1478
|
+
break;
|
1479
|
+
|
1480
|
+
case 'function':
|
1481
|
+
err = createAndLogUsageError('function');
|
1482
|
+
break;
|
1483
|
+
|
1484
|
+
case 'object':
|
1485
|
+
if (error !== null && (_$iserror_11(error) || error.__isBugsnagReport)) {
|
1486
|
+
err = error;
|
1487
|
+
} else if (error !== null && hasNecessaryFields(error)) {
|
1488
|
+
err = new Error(error.message || error.errorMessage);
|
1489
|
+
err.name = error.name || error.errorClass;
|
1490
|
+
errorFramesToSkip = synthesizedErrorFramesToSkip;
|
1491
|
+
} else {
|
1492
|
+
err = createAndLogUsageError(error === null ? 'null' : 'unsupported object');
|
1493
|
+
}
|
1494
|
+
|
1495
|
+
break;
|
1496
|
+
|
1497
|
+
default:
|
1498
|
+
err = createAndLogUsageError('nothing');
|
1499
|
+
}
|
1500
|
+
|
1501
|
+
return {
|
1502
|
+
err: err,
|
1503
|
+
errorFramesToSkip: errorFramesToSkip,
|
1504
|
+
_opts: _opts
|
1505
|
+
};
|
1506
|
+
};
|
1507
|
+
|
1508
|
+
var hasNecessaryFields = function (error) {
|
1509
|
+
return (typeof error.name === 'string' || typeof error.errorClass === 'string') && (typeof error.message === 'string' || typeof error.errorMessage === 'string');
|
1510
|
+
};
|
1511
|
+
|
1512
|
+
var generateConfigErrorMessage = function (errors) {
|
1513
|
+
return "Bugsnag configuration error\n" + __map_4(errors, function (err) {
|
1514
|
+
return "\"" + err.key + "\" " + err.message + " \n got " + stringify(err.value);
|
1515
|
+
}).join('\n\n');
|
1516
|
+
};
|
1517
|
+
|
1518
|
+
var generateNotifyUsageMessage = function (actual) {
|
1519
|
+
return "notify() expected error/opts parameters, got " + actual;
|
1520
|
+
};
|
1521
|
+
|
1522
|
+
var stringify = function (val) {
|
1523
|
+
return typeof val === 'object' ? JSON.stringify(val) : String(val);
|
1524
|
+
};
|
1525
|
+
|
1526
|
+
var _$BugsnagClient_4 = BugsnagClient;
|
1527
|
+
|
1528
|
+
var _$safeJsonStringify_19 = function (data, replacer, space, opts) {
|
1529
|
+
var filterKeys = opts && opts.filterKeys ? opts.filterKeys : [];
|
1530
|
+
var filterPaths = opts && opts.filterPaths ? opts.filterPaths : [];
|
1531
|
+
return JSON.stringify(prepareObjForSerialization(data, filterKeys, filterPaths), replacer, space);
|
1532
|
+
};
|
1533
|
+
|
1534
|
+
var MAX_DEPTH = 20;
|
1535
|
+
var MAX_EDGES = 25000;
|
1536
|
+
var MIN_PRESERVED_DEPTH = 8;
|
1537
|
+
var REPLACEMENT_NODE = '...';
|
1538
|
+
|
1539
|
+
function __isError_19(o) {
|
1540
|
+
return o instanceof Error || /^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(o));
|
1541
|
+
}
|
1542
|
+
|
1543
|
+
function throwsMessage(err) {
|
1544
|
+
return '[Throws: ' + (err ? err.message : '?') + ']';
|
1545
|
+
}
|
1546
|
+
|
1547
|
+
function find(haystack, needle) {
|
1548
|
+
for (var i = 0, len = haystack.length; i < len; i++) {
|
1549
|
+
if (haystack[i] === needle) return true;
|
1550
|
+
}
|
1551
|
+
|
1552
|
+
return false;
|
1553
|
+
} // returns true if the string `path` starts with any of the provided `paths`
|
1554
|
+
|
1555
|
+
|
1556
|
+
function isDescendent(paths, path) {
|
1557
|
+
for (var i = 0, len = paths.length; i < len; i++) {
|
1558
|
+
if (path.indexOf(paths[i]) === 0) return true;
|
1559
|
+
}
|
1560
|
+
|
1561
|
+
return false;
|
1562
|
+
}
|
1563
|
+
|
1564
|
+
function shouldFilter(patterns, key) {
|
1565
|
+
for (var i = 0, len = patterns.length; i < len; i++) {
|
1566
|
+
if (typeof patterns[i] === 'string' && patterns[i] === key) return true;
|
1567
|
+
if (patterns[i] && typeof patterns[i].test === 'function' && patterns[i].test(key)) return true;
|
1568
|
+
}
|
1569
|
+
|
1570
|
+
return false;
|
1571
|
+
}
|
1572
|
+
|
1573
|
+
function __isArray_19(obj) {
|
1574
|
+
return Object.prototype.toString.call(obj) === '[object Array]';
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
function safelyGetProp(obj, prop) {
|
1578
|
+
try {
|
1579
|
+
return obj[prop];
|
1580
|
+
} catch (err) {
|
1581
|
+
return throwsMessage(err);
|
1582
|
+
}
|
1583
|
+
}
|
1584
|
+
|
1585
|
+
function prepareObjForSerialization(obj, filterKeys, filterPaths) {
|
1586
|
+
var seen = []; // store references to objects we have seen before
|
1587
|
+
|
1588
|
+
var edges = 0;
|
1589
|
+
|
1590
|
+
function visit(obj, path) {
|
1591
|
+
function edgesExceeded() {
|
1592
|
+
return path.length > MIN_PRESERVED_DEPTH && edges > MAX_EDGES;
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
edges++;
|
1596
|
+
if (path.length > MAX_DEPTH) return REPLACEMENT_NODE;
|
1597
|
+
if (edgesExceeded()) return REPLACEMENT_NODE;
|
1598
|
+
if (obj === null || typeof obj !== 'object') return obj;
|
1599
|
+
if (find(seen, obj)) return '[Circular]';
|
1600
|
+
seen.push(obj);
|
1601
|
+
|
1602
|
+
if (typeof obj.toJSON === 'function') {
|
1603
|
+
try {
|
1604
|
+
// we're not going to count this as an edge because it
|
1605
|
+
// replaces the value of the currently visited object
|
1606
|
+
edges--;
|
1607
|
+
var fResult = visit(obj.toJSON(), path);
|
1608
|
+
seen.pop();
|
1609
|
+
return fResult;
|
1610
|
+
} catch (err) {
|
1611
|
+
return throwsMessage(err);
|
1612
|
+
}
|
1613
|
+
}
|
1614
|
+
|
1615
|
+
var er = __isError_19(obj);
|
1616
|
+
|
1617
|
+
if (er) {
|
1618
|
+
edges--;
|
1619
|
+
var eResult = visit({
|
1620
|
+
name: obj.name,
|
1621
|
+
message: obj.message
|
1622
|
+
}, path);
|
1623
|
+
seen.pop();
|
1624
|
+
return eResult;
|
1625
|
+
}
|
1626
|
+
|
1627
|
+
if (__isArray_19(obj)) {
|
1628
|
+
var aResult = [];
|
1629
|
+
|
1630
|
+
for (var i = 0, len = obj.length; i < len; i++) {
|
1631
|
+
if (edgesExceeded()) {
|
1632
|
+
aResult.push(REPLACEMENT_NODE);
|
1633
|
+
break;
|
1634
|
+
}
|
1635
|
+
|
1636
|
+
aResult.push(visit(obj[i], path.concat('[]')));
|
1637
|
+
}
|
1638
|
+
|
1639
|
+
seen.pop();
|
1640
|
+
return aResult;
|
1641
|
+
}
|
1642
|
+
|
1643
|
+
var result = {};
|
1644
|
+
|
1645
|
+
try {
|
1646
|
+
for (var prop in obj) {
|
1647
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue;
|
1648
|
+
|
1649
|
+
if (isDescendent(filterPaths, path.join('.')) && shouldFilter(filterKeys, prop)) {
|
1650
|
+
result[prop] = '[Filtered]';
|
1651
|
+
continue;
|
1652
|
+
}
|
1653
|
+
|
1654
|
+
if (edgesExceeded()) {
|
1655
|
+
result[prop] = REPLACEMENT_NODE;
|
1656
|
+
break;
|
1657
|
+
}
|
1658
|
+
|
1659
|
+
result[prop] = visit(safelyGetProp(obj, prop), path.concat(prop));
|
1660
|
+
}
|
1661
|
+
} catch (e) {}
|
1662
|
+
|
1663
|
+
seen.pop();
|
1664
|
+
return result;
|
1665
|
+
}
|
1666
|
+
|
1667
|
+
return visit(obj, []);
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
var _$jsonPayload_13 = {};
|
1671
|
+
/* removed: var _$safeJsonStringify_19 = require('@bugsnag/safe-json-stringify'); */;
|
1672
|
+
|
1673
|
+
var REPORT_FILTER_PATHS = ['events.[].app', 'events.[].metaData', 'events.[].user', 'events.[].breadcrumbs', 'events.[].request', 'events.[].device'];
|
1674
|
+
var SESSION_FILTER_PATHS = ['device', 'app', 'user'];
|
1675
|
+
|
1676
|
+
_$jsonPayload_13.report = function (report, filterKeys) {
|
1677
|
+
var payload = _$safeJsonStringify_19(report, null, null, {
|
1678
|
+
filterPaths: REPORT_FILTER_PATHS,
|
1679
|
+
filterKeys: filterKeys
|
1680
|
+
});
|
1681
|
+
|
1682
|
+
if (payload.length > 10e5) {
|
1683
|
+
delete report.events[0].metaData;
|
1684
|
+
report.events[0].metaData = {
|
1685
|
+
notifier: "WARNING!\nSerialized payload was " + payload.length / 10e5 + "MB (limit = 1MB)\nmetaData was removed"
|
1686
|
+
};
|
1687
|
+
payload = _$safeJsonStringify_19(report, null, null, {
|
1688
|
+
filterPaths: REPORT_FILTER_PATHS,
|
1689
|
+
filterKeys: filterKeys
|
1690
|
+
});
|
1691
|
+
if (payload.length > 10e5) throw new Error('payload exceeded 1MB limit');
|
1692
|
+
}
|
1693
|
+
|
1694
|
+
return payload;
|
1695
|
+
};
|
1696
|
+
|
1697
|
+
_$jsonPayload_13.session = function (report, filterKeys) {
|
1698
|
+
var payload = _$safeJsonStringify_19(report, null, null, {
|
1699
|
+
filterPaths: SESSION_FILTER_PATHS,
|
1700
|
+
filterKeys: filterKeys
|
1701
|
+
});
|
1702
|
+
if (payload.length > 10e5) throw new Error('payload exceeded 1MB limit');
|
1703
|
+
return payload;
|
1704
|
+
};
|
1705
|
+
|
1706
|
+
var _$delivery_26 = {};
|
1707
|
+
var _this = this;
|
1708
|
+
|
1709
|
+
/* removed: var _$jsonPayload_13 = require('@bugsnag/core/lib/json-payload'); */;
|
1710
|
+
|
1711
|
+
var __isoDate_26 = _$esUtils_8.isoDate;
|
1712
|
+
|
1713
|
+
_$delivery_26 = function (client, win) {
|
1714
|
+
if (win === void 0) {
|
1715
|
+
win = window;
|
1716
|
+
}
|
1717
|
+
|
1718
|
+
return {
|
1719
|
+
sendReport: function (report, cb) {
|
1720
|
+
if (cb === void 0) {
|
1721
|
+
cb = function () {};
|
1722
|
+
}
|
1723
|
+
|
1724
|
+
var url = getApiUrl(client.config, 'notify', '4', win);
|
1725
|
+
var req = new win.XDomainRequest();
|
1726
|
+
|
1727
|
+
req.onload = function () {
|
1728
|
+
cb(null);
|
1729
|
+
};
|
1730
|
+
|
1731
|
+
req.open('POST', url);
|
1732
|
+
setTimeout(function () {
|
1733
|
+
try {
|
1734
|
+
req.send(_$jsonPayload_13.report(report, client.config.filters));
|
1735
|
+
} catch (e) {
|
1736
|
+
client._logger.error(e);
|
1737
|
+
|
1738
|
+
cb(e);
|
1739
|
+
}
|
1740
|
+
}, 0);
|
1741
|
+
},
|
1742
|
+
sendSession: function (session, cb) {
|
1743
|
+
if (cb === void 0) {
|
1744
|
+
cb = function () {};
|
1745
|
+
}
|
1746
|
+
|
1747
|
+
var url = getApiUrl(client.config, 'sessions', '1', win);
|
1748
|
+
var req = new win.XDomainRequest();
|
1749
|
+
|
1750
|
+
req.onload = function () {
|
1751
|
+
cb(null);
|
1752
|
+
};
|
1753
|
+
|
1754
|
+
req.open('POST', url);
|
1755
|
+
setTimeout(function () {
|
1756
|
+
try {
|
1757
|
+
req.send(_$jsonPayload_13.session(session, client.config.filters));
|
1758
|
+
} catch (e) {
|
1759
|
+
_this._logger.error(e);
|
1760
|
+
|
1761
|
+
cb(e);
|
1762
|
+
}
|
1763
|
+
}, 0);
|
1764
|
+
}
|
1765
|
+
};
|
1766
|
+
};
|
1767
|
+
|
1768
|
+
var getApiUrl = function (config, endpoint, version, win) {
|
1769
|
+
return matchPageProtocol(config.endpoints[endpoint], win.location.protocol) + "?apiKey=" + encodeURIComponent(config.apiKey) + "&payloadVersion=" + version + "&sentAt=" + encodeURIComponent(__isoDate_26());
|
1770
|
+
};
|
1771
|
+
|
1772
|
+
var matchPageProtocol = _$delivery_26._matchPageProtocol = function (endpoint, pageProtocol) {
|
1773
|
+
return pageProtocol === 'http:' ? endpoint.replace(/^https:/, 'http:') : endpoint;
|
1774
|
+
};
|
1775
|
+
|
1776
|
+
/* removed: var _$jsonPayload_13 = require('@bugsnag/core/lib/json-payload'); */;
|
1777
|
+
|
1778
|
+
var __isoDate_27 = _$esUtils_8.isoDate;
|
1779
|
+
|
1780
|
+
var _$delivery_27 = function (client, win) {
|
1781
|
+
if (win === void 0) {
|
1782
|
+
win = window;
|
1783
|
+
}
|
1784
|
+
|
1785
|
+
return {
|
1786
|
+
sendReport: function (report, cb) {
|
1787
|
+
if (cb === void 0) {
|
1788
|
+
cb = function () {};
|
1789
|
+
}
|
1790
|
+
|
1791
|
+
try {
|
1792
|
+
var url = client.config.endpoints.notify;
|
1793
|
+
var req = new win.XMLHttpRequest();
|
1794
|
+
|
1795
|
+
req.onreadystatechange = function () {
|
1796
|
+
if (req.readyState === win.XMLHttpRequest.DONE) cb(null);
|
1797
|
+
};
|
1798
|
+
|
1799
|
+
req.open('POST', url);
|
1800
|
+
req.setRequestHeader('Content-Type', 'application/json');
|
1801
|
+
req.setRequestHeader('Bugsnag-Api-Key', report.apiKey || client.config.apiKey);
|
1802
|
+
req.setRequestHeader('Bugsnag-Payload-Version', '4');
|
1803
|
+
req.setRequestHeader('Bugsnag-Sent-At', __isoDate_27());
|
1804
|
+
req.send(_$jsonPayload_13.report(report, client.config.filters));
|
1805
|
+
} catch (e) {
|
1806
|
+
client._logger.error(e);
|
1807
|
+
}
|
1808
|
+
},
|
1809
|
+
sendSession: function (session, cb) {
|
1810
|
+
if (cb === void 0) {
|
1811
|
+
cb = function () {};
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
try {
|
1815
|
+
var url = client.config.endpoints.sessions;
|
1816
|
+
var req = new win.XMLHttpRequest();
|
1817
|
+
|
1818
|
+
req.onreadystatechange = function () {
|
1819
|
+
if (req.readyState === win.XMLHttpRequest.DONE) cb(null);
|
1820
|
+
};
|
1821
|
+
|
1822
|
+
req.open('POST', url);
|
1823
|
+
req.setRequestHeader('Content-Type', 'application/json');
|
1824
|
+
req.setRequestHeader('Bugsnag-Api-Key', client.config.apiKey);
|
1825
|
+
req.setRequestHeader('Bugsnag-Payload-Version', '1');
|
1826
|
+
req.setRequestHeader('Bugsnag-Sent-At', __isoDate_27());
|
1827
|
+
req.send(_$jsonPayload_13.session(session, client.config.filters));
|
1828
|
+
} catch (e) {
|
1829
|
+
client._logger.error(e);
|
1830
|
+
}
|
1831
|
+
}
|
1832
|
+
};
|
1833
|
+
};
|
1834
|
+
|
1835
|
+
/*
|
1836
|
+
* Sets the default context to be the current URL
|
1837
|
+
*/
|
1838
|
+
var _$context_28 = {
|
1839
|
+
init: function (client, win) {
|
1840
|
+
if (win === void 0) {
|
1841
|
+
win = window;
|
1842
|
+
}
|
1843
|
+
|
1844
|
+
client.config.beforeSend.unshift(function (report) {
|
1845
|
+
if (report.context) return;
|
1846
|
+
report.context = win.location.pathname;
|
1847
|
+
});
|
1848
|
+
}
|
1849
|
+
};
|
1850
|
+
|
1851
|
+
function ___extends_29() { ___extends_29 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_29.apply(this, arguments); }
|
1852
|
+
|
1853
|
+
var __isoDate_29 = _$esUtils_8.isoDate;
|
1854
|
+
/*
|
1855
|
+
* Automatically detects browser device details
|
1856
|
+
*/
|
1857
|
+
|
1858
|
+
|
1859
|
+
var _$device_29 = {
|
1860
|
+
init: function (client, nav) {
|
1861
|
+
if (nav === void 0) {
|
1862
|
+
nav = navigator;
|
1863
|
+
}
|
1864
|
+
|
1865
|
+
var device = {
|
1866
|
+
locale: nav.browserLanguage || nav.systemLanguage || nav.userLanguage || nav.language,
|
1867
|
+
userAgent: nav.userAgent // merge with anything already set on the client
|
1868
|
+
|
1869
|
+
};
|
1870
|
+
client.device = ___extends_29({}, device, client.device); // add time just as the report is sent
|
1871
|
+
|
1872
|
+
client.config.beforeSend.unshift(function (report) {
|
1873
|
+
report.device = ___extends_29({}, report.device, {
|
1874
|
+
time: __isoDate_29()
|
1875
|
+
});
|
1876
|
+
});
|
1877
|
+
}
|
1878
|
+
};
|
1879
|
+
|
1880
|
+
function ___extends_30() { ___extends_30 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_30.apply(this, arguments); }
|
1881
|
+
|
1882
|
+
/*
|
1883
|
+
* Sets the report request: { url } to be the current href
|
1884
|
+
*/
|
1885
|
+
var _$request_30 = {
|
1886
|
+
init: function (client, win) {
|
1887
|
+
if (win === void 0) {
|
1888
|
+
win = window;
|
1889
|
+
}
|
1890
|
+
|
1891
|
+
client.config.beforeSend.unshift(function (report) {
|
1892
|
+
if (report.request && report.request.url) return;
|
1893
|
+
report.request = ___extends_30({}, report.request, {
|
1894
|
+
url: win.location.href
|
1895
|
+
});
|
1896
|
+
});
|
1897
|
+
}
|
1898
|
+
};
|
1899
|
+
|
1900
|
+
function ___extends_31() { ___extends_31 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_31.apply(this, arguments); }
|
1901
|
+
|
1902
|
+
var __isArray_31 = _$esUtils_8.isArray,
|
1903
|
+
__includes_31 = _$esUtils_8.includes;
|
1904
|
+
|
1905
|
+
/* removed: var _$inferReleaseStage_10 = require('@bugsnag/core/lib/infer-release-stage'); */;
|
1906
|
+
|
1907
|
+
var _$session_31 = {
|
1908
|
+
init: function (client) {
|
1909
|
+
return client.sessionDelegate(sessionDelegate);
|
1910
|
+
}
|
1911
|
+
};
|
1912
|
+
var sessionDelegate = {
|
1913
|
+
startSession: function (client) {
|
1914
|
+
var sessionClient = client;
|
1915
|
+
sessionClient._session = new client.BugsnagSession();
|
1916
|
+
var releaseStage = _$inferReleaseStage_10(sessionClient); // exit early if the reports should not be sent on the current releaseStage
|
1917
|
+
|
1918
|
+
if (__isArray_31(sessionClient.config.notifyReleaseStages) && !__includes_31(sessionClient.config.notifyReleaseStages, releaseStage)) {
|
1919
|
+
sessionClient._logger.warn("Session not sent due to releaseStage/notifyReleaseStages configuration");
|
1920
|
+
|
1921
|
+
return sessionClient;
|
1922
|
+
}
|
1923
|
+
|
1924
|
+
if (!sessionClient.config.endpoints.sessions) {
|
1925
|
+
sessionClient._logger.warn("Session not sent due to missing endpoints.sessions configuration");
|
1926
|
+
|
1927
|
+
return sessionClient;
|
1928
|
+
}
|
1929
|
+
|
1930
|
+
sessionClient._delivery.sendSession({
|
1931
|
+
notifier: sessionClient.notifier,
|
1932
|
+
device: sessionClient.device,
|
1933
|
+
app: ___extends_31({}, {
|
1934
|
+
releaseStage: releaseStage
|
1935
|
+
}, sessionClient.app),
|
1936
|
+
sessions: [{
|
1937
|
+
id: sessionClient._session.id,
|
1938
|
+
startedAt: sessionClient._session.startedAt,
|
1939
|
+
user: sessionClient.user
|
1940
|
+
}]
|
1941
|
+
});
|
1942
|
+
|
1943
|
+
return sessionClient;
|
1944
|
+
}
|
1945
|
+
};
|
1946
|
+
|
1947
|
+
function ___extends_32() { ___extends_32 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_32.apply(this, arguments); }
|
1948
|
+
|
1949
|
+
/*
|
1950
|
+
* Prevent collection of user IPs
|
1951
|
+
*/
|
1952
|
+
var _$clientIp_32 = {
|
1953
|
+
init: function (client) {
|
1954
|
+
if (client.config.collectUserIp) return;
|
1955
|
+
client.config.beforeSend.push(function (report) {
|
1956
|
+
// If user.id is explicitly undefined, it will be missing from the payload. It needs
|
1957
|
+
// removing so that the following line replaces it
|
1958
|
+
if (report.user && typeof report.user.id === 'undefined') delete report.user.id;
|
1959
|
+
report.user = ___extends_32({
|
1960
|
+
id: '[NOT COLLECTED]'
|
1961
|
+
}, report.user);
|
1962
|
+
report.request = ___extends_32({
|
1963
|
+
clientIp: '[NOT COLLECTED]'
|
1964
|
+
}, report.request);
|
1965
|
+
});
|
1966
|
+
},
|
1967
|
+
configSchema: {
|
1968
|
+
collectUserIp: {
|
1969
|
+
defaultValue: function () {
|
1970
|
+
return true;
|
1971
|
+
},
|
1972
|
+
message: 'should be true|false',
|
1973
|
+
validate: function (value) {
|
1974
|
+
return value === true || value === false;
|
1975
|
+
}
|
1976
|
+
}
|
1977
|
+
}
|
1978
|
+
};
|
1979
|
+
|
1980
|
+
var _$consoleBreadcrumbs_33 = {};
|
1981
|
+
var __map_33 = _$esUtils_8.map,
|
1982
|
+
__reduce_33 = _$esUtils_8.reduce,
|
1983
|
+
__filter_33 = _$esUtils_8.filter;
|
1984
|
+
/*
|
1985
|
+
* Leaves breadcrumbs when console log methods are called
|
1986
|
+
*/
|
1987
|
+
|
1988
|
+
|
1989
|
+
_$consoleBreadcrumbs_33.init = function (client) {
|
1990
|
+
var isDev = /^dev(elopment)?$/.test(client.config.releaseStage);
|
1991
|
+
var explicitlyDisabled = client.config.consoleBreadcrumbsEnabled === false;
|
1992
|
+
var implicitlyDisabled = (client.config.autoBreadcrumbs === false || isDev) && client.config.consoleBreadcrumbsEnabled !== true;
|
1993
|
+
if (explicitlyDisabled || implicitlyDisabled) return;
|
1994
|
+
__map_33(CONSOLE_LOG_METHODS, function (method) {
|
1995
|
+
var original = console[method];
|
1996
|
+
|
1997
|
+
console[method] = function () {
|
1998
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
1999
|
+
args[_key] = arguments[_key];
|
2000
|
+
}
|
2001
|
+
|
2002
|
+
client.leaveBreadcrumb('Console output', __reduce_33(args, function (accum, arg, i) {
|
2003
|
+
// do the best/simplest stringification of each argument
|
2004
|
+
var stringified = '[Unknown value]'; // this may fail if the input is:
|
2005
|
+
// - an object whose [[Prototype]] is null (no toString)
|
2006
|
+
// - an object with a broken toString or @@toPrimitive implementation
|
2007
|
+
|
2008
|
+
try {
|
2009
|
+
stringified = String(arg);
|
2010
|
+
} catch (e) {} // if it stringifies to [object Object] attempt to JSON stringify
|
2011
|
+
|
2012
|
+
|
2013
|
+
if (stringified === '[object Object]') {
|
2014
|
+
// catch stringify errors and fallback to [object Object]
|
2015
|
+
try {
|
2016
|
+
stringified = JSON.stringify(arg);
|
2017
|
+
} catch (e) {}
|
2018
|
+
}
|
2019
|
+
|
2020
|
+
accum["[" + i + "]"] = stringified;
|
2021
|
+
return accum;
|
2022
|
+
}, {
|
2023
|
+
severity: method.indexOf('group') === 0 ? 'log' : method
|
2024
|
+
}), 'log');
|
2025
|
+
original.apply(console, args);
|
2026
|
+
};
|
2027
|
+
|
2028
|
+
console[method]._restore = function () {
|
2029
|
+
console[method] = original;
|
2030
|
+
};
|
2031
|
+
});
|
2032
|
+
};
|
2033
|
+
|
2034
|
+
_$consoleBreadcrumbs_33.configSchema = {
|
2035
|
+
consoleBreadcrumbsEnabled: {
|
2036
|
+
defaultValue: function () {
|
2037
|
+
return undefined;
|
2038
|
+
},
|
2039
|
+
validate: function (value) {
|
2040
|
+
return value === true || value === false || value === undefined;
|
2041
|
+
},
|
2042
|
+
message: 'should be true|false'
|
2043
|
+
}
|
2044
|
+
};
|
2045
|
+
|
2046
|
+
if ("production" !== 'production') {
|
2047
|
+
_$consoleBreadcrumbs_33.destroy = function () {
|
2048
|
+
return CONSOLE_LOG_METHODS.forEach(function (method) {
|
2049
|
+
if (typeof console[method]._restore === 'function') console[method]._restore();
|
2050
|
+
});
|
2051
|
+
};
|
2052
|
+
}
|
2053
|
+
|
2054
|
+
var CONSOLE_LOG_METHODS = __filter_33(['log', 'debug', 'info', 'warn', 'error'], function (method) {
|
2055
|
+
return typeof console !== 'undefined' && typeof console[method] === 'function';
|
2056
|
+
});
|
2057
|
+
|
2058
|
+
var _$inlineScriptContent_34 = {};
|
2059
|
+
var __reduce_34 = _$esUtils_8.reduce;
|
2060
|
+
|
2061
|
+
_$inlineScriptContent_34 = {
|
2062
|
+
init: function (client, doc, win) {
|
2063
|
+
if (doc === void 0) {
|
2064
|
+
doc = document;
|
2065
|
+
}
|
2066
|
+
|
2067
|
+
if (win === void 0) {
|
2068
|
+
win = window;
|
2069
|
+
}
|
2070
|
+
|
2071
|
+
var html = '';
|
2072
|
+
var DOMContentLoaded = false;
|
2073
|
+
|
2074
|
+
var getHtml = function () {
|
2075
|
+
return doc.documentElement.outerHTML;
|
2076
|
+
};
|
2077
|
+
|
2078
|
+
var originalLocation = win.location.href;
|
2079
|
+
|
2080
|
+
var addInlineContent = function (report) {
|
2081
|
+
var frame = report.stacktrace[0];
|
2082
|
+
if (!frame || !frame.file || !frame.lineNumber) return frame;
|
2083
|
+
if (frame.file.replace(/#.*$/, '') !== originalLocation.replace(/#.*$/, '')) return frame;
|
2084
|
+
if (!DOMContentLoaded || !html) html = getHtml();
|
2085
|
+
var htmlLines = ['<!-- DOC START -->'].concat(html.split('\n'));
|
2086
|
+
|
2087
|
+
var _extractScriptContent = extractScriptContent(htmlLines, frame.lineNumber - 1),
|
2088
|
+
script = _extractScriptContent.script,
|
2089
|
+
start = _extractScriptContent.start;
|
2090
|
+
|
2091
|
+
var code = __reduce_34(script, function (accum, line, i) {
|
2092
|
+
if (Math.abs(start + i + 1 - frame.lineNumber) > 10) return accum;
|
2093
|
+
accum["" + (start + i + 1)] = line;
|
2094
|
+
return accum;
|
2095
|
+
}, {});
|
2096
|
+
frame.code = code;
|
2097
|
+
report.updateMetaData('script', {
|
2098
|
+
content: script.join('\n')
|
2099
|
+
});
|
2100
|
+
}; // get whatever HTML exists at this point in time
|
2101
|
+
|
2102
|
+
|
2103
|
+
html = getHtml();
|
2104
|
+
var prev = doc.onreadystatechange; // then update it when the DOM content has loaded
|
2105
|
+
|
2106
|
+
doc.onreadystatechange = function () {
|
2107
|
+
// IE8 compatible alternative to document#DOMContentLoaded
|
2108
|
+
if (doc.readyState === 'interactive') {
|
2109
|
+
html = getHtml();
|
2110
|
+
DOMContentLoaded = true;
|
2111
|
+
}
|
2112
|
+
|
2113
|
+
if (typeof prev === 'function') prev.apply(this, arguments);
|
2114
|
+
};
|
2115
|
+
|
2116
|
+
client.config.beforeSend.unshift(addInlineContent);
|
2117
|
+
}
|
2118
|
+
};
|
2119
|
+
var scriptStartRe = /^.*<script.*?>/;
|
2120
|
+
var scriptEndRe = /<\/script>.*$/;
|
2121
|
+
|
2122
|
+
var extractScriptContent = _$inlineScriptContent_34.extractScriptContent = function (lines, startLine) {
|
2123
|
+
// search down for </script>
|
2124
|
+
var line = startLine;
|
2125
|
+
|
2126
|
+
while (line < lines.length && !scriptEndRe.test(lines[line])) {
|
2127
|
+
line++;
|
2128
|
+
} // search up for <script>
|
2129
|
+
|
2130
|
+
|
2131
|
+
var end = line;
|
2132
|
+
|
2133
|
+
while (line > 0 && !scriptStartRe.test(lines[line])) {
|
2134
|
+
line--;
|
2135
|
+
}
|
2136
|
+
|
2137
|
+
var start = line; // strip <script> tags so that lines just contain js content
|
2138
|
+
|
2139
|
+
var script = lines.slice(start, end + 1);
|
2140
|
+
script[0] = script[0].replace(scriptStartRe, '');
|
2141
|
+
script[script.length - 1] = script[script.length - 1].replace(scriptEndRe, ''); // return the array of lines, and the line number the script started at
|
2142
|
+
|
2143
|
+
return {
|
2144
|
+
script: script,
|
2145
|
+
start: start
|
2146
|
+
};
|
2147
|
+
};
|
2148
|
+
|
2149
|
+
/*
|
2150
|
+
* Leaves breadcrumbs when the user interacts with the DOM
|
2151
|
+
*/
|
2152
|
+
var _$interactionBreadcrumbs_35 = {
|
2153
|
+
init: function (client, win) {
|
2154
|
+
if (win === void 0) {
|
2155
|
+
win = window;
|
2156
|
+
}
|
2157
|
+
|
2158
|
+
if (!('addEventListener' in win)) return;
|
2159
|
+
var explicitlyDisabled = client.config.interactionBreadcrumbsEnabled === false;
|
2160
|
+
var implicitlyDisabled = client.config.autoBreadcrumbs === false && client.config.interactionBreadcrumbsEnabled !== true;
|
2161
|
+
if (explicitlyDisabled || implicitlyDisabled) return;
|
2162
|
+
win.addEventListener('click', function (event) {
|
2163
|
+
var targetText, targetSelector;
|
2164
|
+
|
2165
|
+
try {
|
2166
|
+
targetText = getNodeText(event.target);
|
2167
|
+
targetSelector = getNodeSelector(event.target, win);
|
2168
|
+
} catch (e) {
|
2169
|
+
targetText = '[hidden]';
|
2170
|
+
targetSelector = '[hidden]';
|
2171
|
+
|
2172
|
+
client._logger.error('Cross domain error when tracking click event. See docs: https://tinyurl.com/y94fq5zm');
|
2173
|
+
}
|
2174
|
+
|
2175
|
+
client.leaveBreadcrumb('UI click', {
|
2176
|
+
targetText: targetText,
|
2177
|
+
targetSelector: targetSelector
|
2178
|
+
}, 'user');
|
2179
|
+
}, true);
|
2180
|
+
},
|
2181
|
+
configSchema: {
|
2182
|
+
interactionBreadcrumbsEnabled: {
|
2183
|
+
defaultValue: function () {
|
2184
|
+
return undefined;
|
2185
|
+
},
|
2186
|
+
validate: function (value) {
|
2187
|
+
return value === true || value === false || value === undefined;
|
2188
|
+
},
|
2189
|
+
message: 'should be true|false'
|
2190
|
+
}
|
2191
|
+
} // extract text content from a element
|
2192
|
+
|
2193
|
+
};
|
2194
|
+
|
2195
|
+
var getNodeText = function (el) {
|
2196
|
+
var text = el.textContent || el.innerText || '';
|
2197
|
+
if (!text && (el.type === 'submit' || el.type === 'button')) text = el.value;
|
2198
|
+
text = text.replace(/^\s+|\s+$/g, ''); // trim whitespace
|
2199
|
+
|
2200
|
+
return truncate(text, 140);
|
2201
|
+
}; // Create a label from tagname, id and css class of the element
|
2202
|
+
|
2203
|
+
|
2204
|
+
function getNodeSelector(el, win) {
|
2205
|
+
var parts = [el.tagName];
|
2206
|
+
if (el.id) parts.push('#' + el.id);
|
2207
|
+
if (el.className && el.className.length) parts.push("." + el.className.split(' ').join('.')); // Can't get much more advanced with the current browser
|
2208
|
+
|
2209
|
+
if (!win.document.querySelectorAll || !Array.prototype.indexOf) return parts.join('');
|
2210
|
+
|
2211
|
+
try {
|
2212
|
+
if (win.document.querySelectorAll(parts.join('')).length === 1) return parts.join('');
|
2213
|
+
} catch (e) {
|
2214
|
+
// Sometimes the query selector can be invalid just return it as-is
|
2215
|
+
return parts.join('');
|
2216
|
+
} // try to get a more specific selector if this one matches more than one element
|
2217
|
+
|
2218
|
+
|
2219
|
+
if (el.parentNode.childNodes.length > 1) {
|
2220
|
+
var index = Array.prototype.indexOf.call(el.parentNode.childNodes, el) + 1;
|
2221
|
+
parts.push(":nth-child(" + index + ")");
|
2222
|
+
}
|
2223
|
+
|
2224
|
+
if (win.document.querySelectorAll(parts.join('')).length === 1) return parts.join(''); // try prepending the parent node selector
|
2225
|
+
|
2226
|
+
if (el.parentNode) return getNodeSelector(el.parentNode, win) + " > " + parts.join('');
|
2227
|
+
return parts.join('');
|
2228
|
+
}
|
2229
|
+
|
2230
|
+
function truncate(value, length) {
|
2231
|
+
var ommision = '(...)';
|
2232
|
+
if (value && value.length <= length) return value;
|
2233
|
+
return value.slice(0, length - ommision.length) + ommision;
|
2234
|
+
}
|
2235
|
+
|
2236
|
+
var _$navigationBreadcrumbs_36 = {};
|
2237
|
+
/*
|
2238
|
+
* Leaves breadcrumbs when navigation methods are called or events are emitted
|
2239
|
+
*/
|
2240
|
+
_$navigationBreadcrumbs_36.init = function (client, win) {
|
2241
|
+
if (win === void 0) {
|
2242
|
+
win = window;
|
2243
|
+
}
|
2244
|
+
|
2245
|
+
if (!('addEventListener' in win)) return;
|
2246
|
+
var explicitlyDisabled = client.config.navigationBreadcrumbsEnabled === false;
|
2247
|
+
var implicitlyDisabled = client.config.autoBreadcrumbs === false && client.config.navigationBreadcrumbsEnabled !== true;
|
2248
|
+
if (explicitlyDisabled || implicitlyDisabled) return; // returns a function that will drop a breadcrumb with a given name
|
2249
|
+
|
2250
|
+
var drop = function (name) {
|
2251
|
+
return function () {
|
2252
|
+
return client.leaveBreadcrumb(name, {}, 'navigation');
|
2253
|
+
};
|
2254
|
+
}; // simple drops – just names, no meta
|
2255
|
+
|
2256
|
+
|
2257
|
+
win.addEventListener('pagehide', drop('Page hidden'), true);
|
2258
|
+
win.addEventListener('pageshow', drop('Page shown'), true);
|
2259
|
+
win.addEventListener('load', drop('Page loaded'), true);
|
2260
|
+
win.document.addEventListener('DOMContentLoaded', drop('DOMContentLoaded'), true); // some browsers like to emit popstate when the page loads, so only add the popstate listener after that
|
2261
|
+
|
2262
|
+
win.addEventListener('load', function () {
|
2263
|
+
return win.addEventListener('popstate', drop('Navigated back'), true);
|
2264
|
+
}); // hashchange has some metaData that we care about
|
2265
|
+
|
2266
|
+
win.addEventListener('hashchange', function (event) {
|
2267
|
+
var metaData = event.oldURL ? {
|
2268
|
+
from: relativeLocation(event.oldURL, win),
|
2269
|
+
to: relativeLocation(event.newURL, win),
|
2270
|
+
state: getCurrentState(win)
|
2271
|
+
} : {
|
2272
|
+
to: relativeLocation(win.location.href, win)
|
2273
|
+
};
|
2274
|
+
client.leaveBreadcrumb('Hash changed', metaData, 'navigation');
|
2275
|
+
}, true); // the only way to know about replaceState/pushState is to wrap them… >_<
|
2276
|
+
|
2277
|
+
if (win.history.replaceState) wrapHistoryFn(client, win.history, 'replaceState', win);
|
2278
|
+
if (win.history.pushState) wrapHistoryFn(client, win.history, 'pushState', win);
|
2279
|
+
client.leaveBreadcrumb('Bugsnag loaded', {}, 'navigation');
|
2280
|
+
};
|
2281
|
+
|
2282
|
+
_$navigationBreadcrumbs_36.configSchema = {
|
2283
|
+
navigationBreadcrumbsEnabled: {
|
2284
|
+
defaultValue: function () {
|
2285
|
+
return undefined;
|
2286
|
+
},
|
2287
|
+
validate: function (value) {
|
2288
|
+
return value === true || value === false || value === undefined;
|
2289
|
+
},
|
2290
|
+
message: 'should be true|false'
|
2291
|
+
}
|
2292
|
+
};
|
2293
|
+
|
2294
|
+
if ("production" !== 'production') {
|
2295
|
+
_$navigationBreadcrumbs_36.destroy = function (win) {
|
2296
|
+
if (win === void 0) {
|
2297
|
+
win = window;
|
2298
|
+
}
|
2299
|
+
|
2300
|
+
win.history.replaceState._restore();
|
2301
|
+
|
2302
|
+
win.history.pushState._restore();
|
2303
|
+
};
|
2304
|
+
} // takes a full url like http://foo.com:1234/pages/01.html?yes=no#section-2 and returns
|
2305
|
+
// just the path and hash parts, e.g. /pages/01.html?yes=no#section-2
|
2306
|
+
|
2307
|
+
|
2308
|
+
var relativeLocation = function (url, win) {
|
2309
|
+
var a = win.document.createElement('A');
|
2310
|
+
a.href = url;
|
2311
|
+
return "" + a.pathname + a.search + a.hash;
|
2312
|
+
};
|
2313
|
+
|
2314
|
+
var stateChangeToMetaData = function (win, state, title, url) {
|
2315
|
+
var currentPath = relativeLocation(win.location.href, win);
|
2316
|
+
return {
|
2317
|
+
title: title,
|
2318
|
+
state: state,
|
2319
|
+
prevState: getCurrentState(win),
|
2320
|
+
to: url || currentPath,
|
2321
|
+
from: currentPath
|
2322
|
+
};
|
2323
|
+
};
|
2324
|
+
|
2325
|
+
var wrapHistoryFn = function (client, target, fn, win) {
|
2326
|
+
var orig = target[fn];
|
2327
|
+
|
2328
|
+
target[fn] = function (state, title, url) {
|
2329
|
+
client.leaveBreadcrumb("History " + fn, stateChangeToMetaData(win, state, title, url), 'navigation'); // if throttle plugin is in use, refresh the event sent count
|
2330
|
+
|
2331
|
+
if (typeof client.refresh === 'function') client.refresh(); // if the client is operating in auto session-mode, a new route should trigger a new session
|
2332
|
+
|
2333
|
+
if (client.config.autoCaptureSessions) client.startSession(); // Internet Explorer will convert `undefined` to a string when passed, causing an unintended redirect
|
2334
|
+
// to '/undefined'. therefore we only pass the url if it's not undefined.
|
2335
|
+
|
2336
|
+
orig.apply(target, [state, title].concat(url !== undefined ? url : []));
|
2337
|
+
};
|
2338
|
+
|
2339
|
+
target[fn]._restore = function () {
|
2340
|
+
target[fn] = orig;
|
2341
|
+
};
|
2342
|
+
};
|
2343
|
+
|
2344
|
+
var getCurrentState = function (win) {
|
2345
|
+
try {
|
2346
|
+
return win.history.state;
|
2347
|
+
} catch (e) {}
|
2348
|
+
};
|
2349
|
+
|
2350
|
+
var _$networkBreadcrumbs_37 = {};
|
2351
|
+
var BREADCRUMB_TYPE = 'request'; // keys to safely store metadata on the request object
|
2352
|
+
|
2353
|
+
var REQUEST_SETUP_KEY = 'BS~~S';
|
2354
|
+
var REQUEST_URL_KEY = 'BS~~U';
|
2355
|
+
var REQUEST_METHOD_KEY = 'BS~~M';
|
2356
|
+
|
2357
|
+
var __includes_37 = _$esUtils_8.includes;
|
2358
|
+
|
2359
|
+
var restoreFunctions = [];
|
2360
|
+
var client;
|
2361
|
+
var win;
|
2362
|
+
var getIgnoredUrls;
|
2363
|
+
|
2364
|
+
var defaultIgnoredUrls = function () {
|
2365
|
+
return [client.config.endpoints.notify, client.config.endpoints.sessions];
|
2366
|
+
};
|
2367
|
+
/*
|
2368
|
+
* Leaves breadcrumbs when network requests occur
|
2369
|
+
*/
|
2370
|
+
|
2371
|
+
|
2372
|
+
_$networkBreadcrumbs_37.name = 'networkBreadcrumbs';
|
2373
|
+
|
2374
|
+
_$networkBreadcrumbs_37.init = function (_client, _getIgnoredUrls, _win) {
|
2375
|
+
if (_getIgnoredUrls === void 0) {
|
2376
|
+
_getIgnoredUrls = defaultIgnoredUrls;
|
2377
|
+
}
|
2378
|
+
|
2379
|
+
if (_win === void 0) {
|
2380
|
+
_win = window;
|
2381
|
+
}
|
2382
|
+
|
2383
|
+
var explicitlyDisabled = _client.config.networkBreadcrumbsEnabled === false;
|
2384
|
+
var implicitlyDisabled = _client.config.autoBreadcrumbs === false && _client.config.networkBreadcrumbsEnabled !== true;
|
2385
|
+
if (explicitlyDisabled || implicitlyDisabled) return;
|
2386
|
+
client = _client;
|
2387
|
+
win = _win;
|
2388
|
+
getIgnoredUrls = _getIgnoredUrls;
|
2389
|
+
monkeyPatchXMLHttpRequest();
|
2390
|
+
monkeyPatchFetch();
|
2391
|
+
};
|
2392
|
+
|
2393
|
+
_$networkBreadcrumbs_37.configSchema = {
|
2394
|
+
networkBreadcrumbsEnabled: {
|
2395
|
+
defaultValue: function () {
|
2396
|
+
return undefined;
|
2397
|
+
},
|
2398
|
+
validate: function (value) {
|
2399
|
+
return value === true || value === false || value === undefined;
|
2400
|
+
},
|
2401
|
+
message: 'should be true|false'
|
2402
|
+
}
|
2403
|
+
};
|
2404
|
+
|
2405
|
+
if ("production" !== 'production') {
|
2406
|
+
_$networkBreadcrumbs_37.destroy = function () {
|
2407
|
+
restoreFunctions.forEach(function (fn) {
|
2408
|
+
return fn();
|
2409
|
+
});
|
2410
|
+
restoreFunctions = [];
|
2411
|
+
};
|
2412
|
+
} // XMLHttpRequest monkey patch
|
2413
|
+
|
2414
|
+
|
2415
|
+
var monkeyPatchXMLHttpRequest = function () {
|
2416
|
+
if (!('addEventListener' in win.XMLHttpRequest.prototype)) return;
|
2417
|
+
var nativeOpen = win.XMLHttpRequest.prototype.open; // override native open()
|
2418
|
+
|
2419
|
+
win.XMLHttpRequest.prototype.open = function open(method, url) {
|
2420
|
+
// store url and HTTP method for later
|
2421
|
+
this[REQUEST_URL_KEY] = url;
|
2422
|
+
this[REQUEST_METHOD_KEY] = method; // if we have already setup listeners, it means open() was called twice, we need to remove
|
2423
|
+
// the listeners and recreate them
|
2424
|
+
|
2425
|
+
if (this[REQUEST_SETUP_KEY]) {
|
2426
|
+
this.removeEventListener('load', handleXHRLoad);
|
2427
|
+
this.removeEventListener('error', handleXHRError);
|
2428
|
+
} // attach load event listener
|
2429
|
+
|
2430
|
+
|
2431
|
+
this.addEventListener('load', handleXHRLoad); // attach error event listener
|
2432
|
+
|
2433
|
+
this.addEventListener('error', handleXHRError);
|
2434
|
+
this[REQUEST_SETUP_KEY] = true;
|
2435
|
+
nativeOpen.apply(this, arguments);
|
2436
|
+
};
|
2437
|
+
|
2438
|
+
if ("production" !== 'production') {
|
2439
|
+
restoreFunctions.push(function () {
|
2440
|
+
win.XMLHttpRequest.prototype.open = nativeOpen;
|
2441
|
+
});
|
2442
|
+
}
|
2443
|
+
};
|
2444
|
+
|
2445
|
+
function handleXHRLoad() {
|
2446
|
+
if (__includes_37(getIgnoredUrls(), this[REQUEST_URL_KEY])) {
|
2447
|
+
// don't leave a network breadcrumb from bugsnag notify calls
|
2448
|
+
return;
|
2449
|
+
}
|
2450
|
+
|
2451
|
+
var metaData = {
|
2452
|
+
status: this.status,
|
2453
|
+
request: this[REQUEST_METHOD_KEY] + " " + this[REQUEST_URL_KEY]
|
2454
|
+
};
|
2455
|
+
|
2456
|
+
if (this.status >= 400) {
|
2457
|
+
// contacted server but got an error response
|
2458
|
+
client.leaveBreadcrumb('XMLHttpRequest failed', metaData, BREADCRUMB_TYPE);
|
2459
|
+
} else {
|
2460
|
+
client.leaveBreadcrumb('XMLHttpRequest succeeded', metaData, BREADCRUMB_TYPE);
|
2461
|
+
}
|
2462
|
+
}
|
2463
|
+
|
2464
|
+
function handleXHRError() {
|
2465
|
+
if (__includes_37(getIgnoredUrls, this[REQUEST_URL_KEY])) {
|
2466
|
+
// don't leave a network breadcrumb from bugsnag notify calls
|
2467
|
+
return;
|
2468
|
+
} // failed to contact server
|
2469
|
+
|
2470
|
+
|
2471
|
+
client.leaveBreadcrumb('XMLHttpRequest error', {
|
2472
|
+
request: this[REQUEST_METHOD_KEY] + " " + this[REQUEST_URL_KEY]
|
2473
|
+
}, BREADCRUMB_TYPE);
|
2474
|
+
} // window.fetch monkey patch
|
2475
|
+
|
2476
|
+
|
2477
|
+
var monkeyPatchFetch = function () {
|
2478
|
+
// only patch it if it exists and if it is not a polyfill (patching a polyfilled
|
2479
|
+
// fetch() results in duplicate breadcrumbs for the same request because the
|
2480
|
+
// implementation uses XMLHttpRequest which is also patched)
|
2481
|
+
if (!('fetch' in win) || win.fetch.polyfill) return;
|
2482
|
+
var oldFetch = win.fetch;
|
2483
|
+
|
2484
|
+
win.fetch = function fetch() {
|
2485
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
2486
|
+
args[_key] = arguments[_key];
|
2487
|
+
}
|
2488
|
+
|
2489
|
+
var url = args[0],
|
2490
|
+
options = args[1];
|
2491
|
+
var method = 'GET';
|
2492
|
+
|
2493
|
+
if (options && options.method) {
|
2494
|
+
method = options.method;
|
2495
|
+
}
|
2496
|
+
|
2497
|
+
return new Promise(function (resolve, reject) {
|
2498
|
+
// pass through to native fetch
|
2499
|
+
oldFetch.apply(void 0, args).then(function (response) {
|
2500
|
+
handleFetchSuccess(response, method, url);
|
2501
|
+
resolve(response);
|
2502
|
+
})["catch"](function (error) {
|
2503
|
+
handleFetchError(method, url);
|
2504
|
+
reject(error);
|
2505
|
+
});
|
2506
|
+
});
|
2507
|
+
};
|
2508
|
+
|
2509
|
+
if ("production" !== 'production') {
|
2510
|
+
restoreFunctions.push(function () {
|
2511
|
+
win.fetch = oldFetch;
|
2512
|
+
});
|
2513
|
+
}
|
2514
|
+
};
|
2515
|
+
|
2516
|
+
var handleFetchSuccess = function (response, method, url) {
|
2517
|
+
var metaData = {
|
2518
|
+
status: response.status,
|
2519
|
+
request: method + " " + url
|
2520
|
+
};
|
2521
|
+
|
2522
|
+
if (response.status >= 400) {
|
2523
|
+
// when the request comes back with a 4xx or 5xx status it does not reject the fetch promise,
|
2524
|
+
client.leaveBreadcrumb('fetch() failed', metaData, BREADCRUMB_TYPE);
|
2525
|
+
} else {
|
2526
|
+
client.leaveBreadcrumb('fetch() succeeded', metaData, BREADCRUMB_TYPE);
|
2527
|
+
}
|
2528
|
+
};
|
2529
|
+
|
2530
|
+
var handleFetchError = function (method, url) {
|
2531
|
+
client.leaveBreadcrumb('fetch() error', {
|
2532
|
+
request: method + " " + url
|
2533
|
+
}, BREADCRUMB_TYPE);
|
2534
|
+
};
|
2535
|
+
|
2536
|
+
var __intRange_38 = _$validators_15.intRange;
|
2537
|
+
/*
|
2538
|
+
* Throttles and dedupes error reports
|
2539
|
+
*/
|
2540
|
+
|
2541
|
+
|
2542
|
+
var _$throttle_38 = {
|
2543
|
+
init: function (client) {
|
2544
|
+
// track sent events for each init of the plugin
|
2545
|
+
var n = 0; // add beforeSend hook
|
2546
|
+
|
2547
|
+
client.config.beforeSend.push(function (report) {
|
2548
|
+
// have max events been sent already?
|
2549
|
+
if (n >= client.config.maxEvents) return report.ignore();
|
2550
|
+
n++;
|
2551
|
+
});
|
2552
|
+
|
2553
|
+
client.refresh = function () {
|
2554
|
+
n = 0;
|
2555
|
+
};
|
2556
|
+
},
|
2557
|
+
configSchema: {
|
2558
|
+
maxEvents: {
|
2559
|
+
defaultValue: function () {
|
2560
|
+
return 10;
|
2561
|
+
},
|
2562
|
+
message: 'should be a positive integer ≤100',
|
2563
|
+
validate: function (val) {
|
2564
|
+
return __intRange_38(1, 100)(val);
|
2565
|
+
}
|
2566
|
+
}
|
2567
|
+
}
|
2568
|
+
};
|
2569
|
+
|
2570
|
+
var _$stripQueryString_39 = {};
|
2571
|
+
function ___extends_39() { ___extends_39 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_39.apply(this, arguments); }
|
2572
|
+
|
2573
|
+
/*
|
2574
|
+
* Remove query strings (and fragments) from stacktraces
|
2575
|
+
*/
|
2576
|
+
var __map_39 = _$esUtils_8.map;
|
2577
|
+
|
2578
|
+
_$stripQueryString_39 = {
|
2579
|
+
init: function (client) {
|
2580
|
+
client.config.beforeSend.push(function (report) {
|
2581
|
+
report.stacktrace = __map_39(report.stacktrace, function (frame) {
|
2582
|
+
return ___extends_39({}, frame, {
|
2583
|
+
file: strip(frame.file)
|
2584
|
+
});
|
2585
|
+
});
|
2586
|
+
});
|
2587
|
+
}
|
2588
|
+
};
|
2589
|
+
|
2590
|
+
var strip = _$stripQueryString_39._strip = function (str) {
|
2591
|
+
return typeof str === 'string' ? str.replace(/\?.*$/, '').replace(/#.*$/, '') : str;
|
2592
|
+
};
|
2593
|
+
|
2594
|
+
/*
|
2595
|
+
* Automatically notifies Bugsnag when window.onerror is called
|
2596
|
+
*/
|
2597
|
+
var _$onerror_40 = {
|
2598
|
+
init: function (client, win) {
|
2599
|
+
if (win === void 0) {
|
2600
|
+
win = window;
|
2601
|
+
}
|
2602
|
+
|
2603
|
+
function onerror(messageOrEvent, url, lineNo, charNo, error) {
|
2604
|
+
// Ignore errors with no info due to CORS settings
|
2605
|
+
if (lineNo === 0 && /Script error\.?/.test(messageOrEvent)) {
|
2606
|
+
client._logger.warn('Ignoring cross-domain or eval script error. See docs: https://tinyurl.com/y94fq5zm');
|
2607
|
+
} else {
|
2608
|
+
// any error sent to window.onerror is unhandled and has severity=error
|
2609
|
+
var handledState = {
|
2610
|
+
severity: 'error',
|
2611
|
+
unhandled: true,
|
2612
|
+
severityReason: {
|
2613
|
+
type: 'unhandledException'
|
2614
|
+
}
|
2615
|
+
};
|
2616
|
+
var report; // window.onerror can be called in a number of ways. This big if-else is how we
|
2617
|
+
// figure out which arguments were supplied, and what kind of values it received.
|
2618
|
+
|
2619
|
+
if (error) {
|
2620
|
+
// if the last parameter (error) was supplied, this is a modern browser's
|
2621
|
+
// way of saying "this value was thrown and not caught"
|
2622
|
+
if (error.name && error.message) {
|
2623
|
+
// if it looks like an error, construct a report object using its stack
|
2624
|
+
report = new client.BugsnagReport(error.name, error.message, decorateStack(client.BugsnagReport.getStacktrace(error), url, lineNo, charNo), handledState, error);
|
2625
|
+
} else {
|
2626
|
+
// otherwise, for non error values that were thrown, stringify it for
|
2627
|
+
// use as the error message and get/generate a stacktrace
|
2628
|
+
report = new client.BugsnagReport('window.onerror', String(error), decorateStack(client.BugsnagReport.getStacktrace(error, 1), url, lineNo, charNo), handledState, error); // include the raw input as metadata
|
2629
|
+
|
2630
|
+
report.updateMetaData('window onerror', {
|
2631
|
+
error: error
|
2632
|
+
});
|
2633
|
+
}
|
2634
|
+
} else if ( // This complex case detects "error" events that are typically synthesised
|
2635
|
+
// by jquery's trigger method (although can be created in other ways). In
|
2636
|
+
// order to detect this:
|
2637
|
+
// - the first argument (message) must exist and be an object (most likely it's a jQuery event)
|
2638
|
+
// - the second argument (url) must either not exist or be something other than a string (if it
|
2639
|
+
// exists and is not a string, it'll be the extraParameters argument from jQuery's trigger()
|
2640
|
+
// function)
|
2641
|
+
// - the third, fourth and fifth arguments must not exist (lineNo, charNo and error)
|
2642
|
+
typeof messageOrEvent === 'object' && messageOrEvent !== null && (!url || typeof url !== 'string') && !lineNo && !charNo && !error) {
|
2643
|
+
// The jQuery event may have a "type" property, if so use it as part of the error message
|
2644
|
+
var name = messageOrEvent.type ? "Event: " + messageOrEvent.type : 'window.onerror'; // attempt to find a message from one of the conventional properties, but
|
2645
|
+
// default to empty string (the report will fill it with a placeholder)
|
2646
|
+
|
2647
|
+
var message = messageOrEvent.message || messageOrEvent.detail || '';
|
2648
|
+
report = new client.BugsnagReport(name, message, client.BugsnagReport.getStacktrace(new Error(), 1).slice(1), handledState, messageOrEvent); // include the raw input as metadata – it might contain more info than we extracted
|
2649
|
+
|
2650
|
+
report.updateMetaData('window onerror', {
|
2651
|
+
event: messageOrEvent,
|
2652
|
+
extraParameters: url
|
2653
|
+
});
|
2654
|
+
} else {
|
2655
|
+
// Lastly, if there was no "error" parameter this event was probably from an old
|
2656
|
+
// browser that doesn't support that. Instead we need to generate a stacktrace.
|
2657
|
+
report = new client.BugsnagReport('window.onerror', String(messageOrEvent), decorateStack(client.BugsnagReport.getStacktrace(error, 1), url, lineNo, charNo), handledState, messageOrEvent); // include the raw input as metadata – it might contain more info than we extracted
|
2658
|
+
|
2659
|
+
report.updateMetaData('window onerror', {
|
2660
|
+
event: messageOrEvent
|
2661
|
+
});
|
2662
|
+
}
|
2663
|
+
|
2664
|
+
client.notify(report);
|
2665
|
+
}
|
2666
|
+
|
2667
|
+
if (typeof prevOnError === 'function') prevOnError.apply(this, arguments);
|
2668
|
+
}
|
2669
|
+
|
2670
|
+
var prevOnError = win.onerror;
|
2671
|
+
win.onerror = onerror;
|
2672
|
+
} // Sometimes the stacktrace has less information than was passed to window.onerror.
|
2673
|
+
// This function will augment the first stackframe with any useful info that was
|
2674
|
+
// received as arguments to the onerror callback.
|
2675
|
+
|
2676
|
+
};
|
2677
|
+
|
2678
|
+
var decorateStack = function (stack, url, lineNo, charNo) {
|
2679
|
+
var culprit = stack[0];
|
2680
|
+
if (!culprit) return stack;
|
2681
|
+
if (!culprit.fileName && typeof url === 'string') culprit.setFileName(url);
|
2682
|
+
if (!culprit.lineNumber && isActualNumber(lineNo)) culprit.setLineNumber(lineNo);
|
2683
|
+
|
2684
|
+
if (!culprit.columnNumber) {
|
2685
|
+
if (isActualNumber(charNo)) {
|
2686
|
+
culprit.setColumnNumber(charNo);
|
2687
|
+
} else if (window.event && isActualNumber(window.event.errorCharacter)) {
|
2688
|
+
culprit.setColumnNumber(window.event.errorCharacter);
|
2689
|
+
}
|
2690
|
+
}
|
2691
|
+
|
2692
|
+
return stack;
|
2693
|
+
};
|
2694
|
+
|
2695
|
+
var isActualNumber = function (n) {
|
2696
|
+
return typeof n === 'number' && String.call(n) !== 'NaN';
|
2697
|
+
};
|
2698
|
+
|
2699
|
+
var _$unhandledRejection_41 = {};
|
2700
|
+
/* removed: var _$hasStack_9 = require('@bugsnag/core/lib/has-stack'); */;
|
2701
|
+
|
2702
|
+
var __reduce_41 = _$esUtils_8.reduce;
|
2703
|
+
|
2704
|
+
/* removed: var _$errorStackParser_7 = require('@bugsnag/core/lib/error-stack-parser'); */;
|
2705
|
+
|
2706
|
+
/* removed: var _$iserror_11 = require('@bugsnag/core/lib/iserror'); */;
|
2707
|
+
/*
|
2708
|
+
* Automatically notifies Bugsnag when window.onunhandledrejection is called
|
2709
|
+
*/
|
2710
|
+
|
2711
|
+
|
2712
|
+
var _listener;
|
2713
|
+
|
2714
|
+
_$unhandledRejection_41.init = function (client, win) {
|
2715
|
+
if (win === void 0) {
|
2716
|
+
win = window;
|
2717
|
+
}
|
2718
|
+
|
2719
|
+
var listener = function (event) {
|
2720
|
+
var error = event.reason;
|
2721
|
+
var isBluebird = false; // accessing properties on event.detail can throw errors (see #394)
|
2722
|
+
|
2723
|
+
try {
|
2724
|
+
if (event.detail && event.detail.reason) {
|
2725
|
+
error = event.detail.reason;
|
2726
|
+
isBluebird = true;
|
2727
|
+
}
|
2728
|
+
} catch (e) {}
|
2729
|
+
|
2730
|
+
var handledState = {
|
2731
|
+
severity: 'error',
|
2732
|
+
unhandled: true,
|
2733
|
+
severityReason: {
|
2734
|
+
type: 'unhandledPromiseRejection'
|
2735
|
+
}
|
2736
|
+
};
|
2737
|
+
var report;
|
2738
|
+
|
2739
|
+
if (error && _$hasStack_9(error)) {
|
2740
|
+
// if it quacks like an Error…
|
2741
|
+
report = new client.BugsnagReport(error.name, error.message, _$errorStackParser_7.parse(error), handledState, error);
|
2742
|
+
|
2743
|
+
if (isBluebird) {
|
2744
|
+
report.stacktrace = __reduce_41(report.stacktrace, fixBluebirdStacktrace(error), []);
|
2745
|
+
}
|
2746
|
+
} else {
|
2747
|
+
// if it doesn't…
|
2748
|
+
var msg = 'Rejection reason was not an Error. See "Promise" tab for more detail.';
|
2749
|
+
report = new client.BugsnagReport(error && error.name ? error.name : 'UnhandledRejection', error && error.message ? error.message : msg, [], handledState, error); // stuff the rejection reason into metaData, it could be useful
|
2750
|
+
|
2751
|
+
report.updateMetaData('promise', 'rejection reason', serializableReason(error));
|
2752
|
+
}
|
2753
|
+
|
2754
|
+
client.notify(report);
|
2755
|
+
};
|
2756
|
+
|
2757
|
+
if ('addEventListener' in win) {
|
2758
|
+
win.addEventListener('unhandledrejection', listener);
|
2759
|
+
} else {
|
2760
|
+
win.onunhandledrejection = function (reason, promise) {
|
2761
|
+
listener({
|
2762
|
+
detail: {
|
2763
|
+
reason: reason,
|
2764
|
+
promise: promise
|
2765
|
+
}
|
2766
|
+
});
|
2767
|
+
};
|
2768
|
+
}
|
2769
|
+
|
2770
|
+
_listener = listener;
|
2771
|
+
};
|
2772
|
+
|
2773
|
+
if ("production" !== 'production') {
|
2774
|
+
_$unhandledRejection_41.destroy = function (win) {
|
2775
|
+
if (win === void 0) {
|
2776
|
+
win = window;
|
2777
|
+
}
|
2778
|
+
|
2779
|
+
if (_listener) {
|
2780
|
+
if ('addEventListener' in win) {
|
2781
|
+
win.removeEventListener('unhandledrejection', _listener);
|
2782
|
+
} else {
|
2783
|
+
win.onunhandledrejection = null;
|
2784
|
+
}
|
2785
|
+
}
|
2786
|
+
|
2787
|
+
_listener = null;
|
2788
|
+
};
|
2789
|
+
}
|
2790
|
+
|
2791
|
+
var serializableReason = function (err) {
|
2792
|
+
if (err === null || err === undefined) {
|
2793
|
+
return 'undefined (or null)';
|
2794
|
+
} else if (_$iserror_11(err)) {
|
2795
|
+
var _ref;
|
2796
|
+
|
2797
|
+
return _ref = {}, _ref[Object.prototype.toString.call(err)] = {
|
2798
|
+
name: err.name,
|
2799
|
+
message: err.message,
|
2800
|
+
code: err.code,
|
2801
|
+
stack: err.stack
|
2802
|
+
}, _ref;
|
2803
|
+
} else {
|
2804
|
+
return err;
|
2805
|
+
}
|
2806
|
+
}; // The stack parser on bluebird stacks in FF get a suprious first frame:
|
2807
|
+
//
|
2808
|
+
// Error: derp
|
2809
|
+
// b@http://localhost:5000/bluebird.html:22:24
|
2810
|
+
// a@http://localhost:5000/bluebird.html:18:9
|
2811
|
+
// @http://localhost:5000/bluebird.html:14:9
|
2812
|
+
//
|
2813
|
+
// results in
|
2814
|
+
// […]
|
2815
|
+
// 0: Object { file: "Error: derp", method: undefined, lineNumber: undefined, … }
|
2816
|
+
// 1: Object { file: "http://localhost:5000/bluebird.html", method: "b", lineNumber: 22, … }
|
2817
|
+
// 2: Object { file: "http://localhost:5000/bluebird.html", method: "a", lineNumber: 18, … }
|
2818
|
+
// 3: Object { file: "http://localhost:5000/bluebird.html", lineNumber: 14, columnNumber: 9, … }
|
2819
|
+
//
|
2820
|
+
// so the following reduce/accumulator function removes such frames
|
2821
|
+
//
|
2822
|
+
// Bluebird pads method names with spaces so trim that too…
|
2823
|
+
// https://github.com/petkaantonov/bluebird/blob/b7f21399816d02f979fe434585334ce901dcaf44/src/debuggability.js#L568-L571
|
2824
|
+
|
2825
|
+
|
2826
|
+
var fixBluebirdStacktrace = function (error) {
|
2827
|
+
return function (accum, frame) {
|
2828
|
+
if (frame.file === error.toString()) return accum;
|
2829
|
+
|
2830
|
+
if (frame.method) {
|
2831
|
+
frame.method = frame.method.replace(/^\s+/, '');
|
2832
|
+
}
|
2833
|
+
|
2834
|
+
return accum.concat(frame);
|
2835
|
+
};
|
2836
|
+
};
|
2837
|
+
|
2838
|
+
var _$notifier_2 = {};
|
2839
|
+
function ___extends_2() { ___extends_2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_2.apply(this, arguments); }
|
2840
|
+
|
2841
|
+
var name = 'Bugsnag JavaScript';
|
2842
|
+
var version = '6.2.0';
|
2843
|
+
var url = 'https://github.com/bugsnag/bugsnag-js';
|
2844
|
+
|
2845
|
+
/* removed: var _$BugsnagClient_4 = require('@bugsnag/core/client'); */;
|
2846
|
+
|
2847
|
+
/* removed: var _$BugsnagReport_24 = require('@bugsnag/core/report'); */;
|
2848
|
+
|
2849
|
+
/* removed: var _$Session_25 = require('@bugsnag/core/session'); */;
|
2850
|
+
|
2851
|
+
/* removed: var _$BugsnagBreadcrumb_3 = require('@bugsnag/core/breadcrumb'); */;
|
2852
|
+
|
2853
|
+
var __map_2 = _$esUtils_8.map; // extend the base config schema with some browser-specific options
|
2854
|
+
|
2855
|
+
|
2856
|
+
var __schema_2 = ___extends_2({}, _$config_5.schema, _$config_1);
|
2857
|
+
|
2858
|
+
/* removed: var _$onerror_40 = require('@bugsnag/plugin-window-onerror'); */;
|
2859
|
+
|
2860
|
+
/* removed: var _$unhandledRejection_41 = require('@bugsnag/plugin-window-unhandled-rejection'); */;
|
2861
|
+
|
2862
|
+
/* removed: var _$device_29 = require('@bugsnag/plugin-browser-device'); */;
|
2863
|
+
|
2864
|
+
/* removed: var _$context_28 = require('@bugsnag/plugin-browser-context'); */;
|
2865
|
+
|
2866
|
+
/* removed: var _$request_30 = require('@bugsnag/plugin-browser-request'); */;
|
2867
|
+
|
2868
|
+
/* removed: var _$throttle_38 = require('@bugsnag/plugin-simple-throttle'); */;
|
2869
|
+
|
2870
|
+
/* removed: var _$consoleBreadcrumbs_33 = require('@bugsnag/plugin-console-breadcrumbs'); */;
|
2871
|
+
|
2872
|
+
/* removed: var _$networkBreadcrumbs_37 = require('@bugsnag/plugin-network-breadcrumbs'); */;
|
2873
|
+
|
2874
|
+
/* removed: var _$navigationBreadcrumbs_36 = require('@bugsnag/plugin-navigation-breadcrumbs'); */;
|
2875
|
+
|
2876
|
+
/* removed: var _$interactionBreadcrumbs_35 = require('@bugsnag/plugin-interaction-breadcrumbs'); */;
|
2877
|
+
|
2878
|
+
/* removed: var _$inlineScriptContent_34 = require('@bugsnag/plugin-inline-script-content'); */;
|
2879
|
+
|
2880
|
+
/* removed: var _$session_31 = require('@bugsnag/plugin-browser-session'); */;
|
2881
|
+
|
2882
|
+
/* removed: var _$clientIp_32 = require('@bugsnag/plugin-client-ip'); */;
|
2883
|
+
|
2884
|
+
/* removed: var _$stripQueryString_39 = require('@bugsnag/plugin-strip-query-string'); */; // delivery mechanisms
|
2885
|
+
|
2886
|
+
|
2887
|
+
/* removed: var _$delivery_26 = require('@bugsnag/delivery-x-domain-request'); */;
|
2888
|
+
|
2889
|
+
/* removed: var _$delivery_27 = require('@bugsnag/delivery-xml-http-request'); */;
|
2890
|
+
|
2891
|
+
_$notifier_2 = function (opts) {
|
2892
|
+
// handle very simple use case where user supplies just the api key as a string
|
2893
|
+
if (typeof opts === 'string') opts = {
|
2894
|
+
apiKey: opts // support renamed/deprecated options
|
2895
|
+
|
2896
|
+
};
|
2897
|
+
var warnings = [];
|
2898
|
+
|
2899
|
+
if (opts.sessionTrackingEnabled) {
|
2900
|
+
warnings.push('deprecated option sessionTrackingEnabled is now called autoCaptureSessions');
|
2901
|
+
opts.autoCaptureSessions = opts.sessionTrackingEnabled;
|
2902
|
+
}
|
2903
|
+
|
2904
|
+
if ((opts.endpoint || opts.sessionEndpoint) && !opts.endpoints) {
|
2905
|
+
warnings.push('deprecated options endpoint/sessionEndpoint are now configured in the endpoints object');
|
2906
|
+
opts.endpoints = {
|
2907
|
+
notify: opts.endpoint,
|
2908
|
+
sessions: opts.sessionEndpoint
|
2909
|
+
};
|
2910
|
+
}
|
2911
|
+
|
2912
|
+
if (opts.endpoints && opts.endpoints.notify && !opts.endpoints.sessions) {
|
2913
|
+
warnings.push('notify endpoint is set but sessions endpoint is not. No sessions will be sent.');
|
2914
|
+
}
|
2915
|
+
|
2916
|
+
var bugsnag = new _$BugsnagClient_4({
|
2917
|
+
name: name,
|
2918
|
+
version: version,
|
2919
|
+
url: url
|
2920
|
+
});
|
2921
|
+
bugsnag.setOptions(opts); // set delivery based on browser capability (IE 8+9 have an XDomainRequest object)
|
2922
|
+
|
2923
|
+
bugsnag.delivery(window.XDomainRequest ? _$delivery_26 : _$delivery_27); // configure with user supplied options
|
2924
|
+
// errors can be thrown here that prevent the lib from being in a useable state
|
2925
|
+
|
2926
|
+
bugsnag.configure(__schema_2);
|
2927
|
+
__map_2(warnings, function (w) {
|
2928
|
+
return bugsnag._logger.warn(w);
|
2929
|
+
}); // always-on browser-specific plugins
|
2930
|
+
|
2931
|
+
bugsnag.use(_$device_29);
|
2932
|
+
bugsnag.use(_$context_28);
|
2933
|
+
bugsnag.use(_$request_30);
|
2934
|
+
bugsnag.use(_$inlineScriptContent_34);
|
2935
|
+
bugsnag.use(_$throttle_38);
|
2936
|
+
bugsnag.use(_$session_31);
|
2937
|
+
bugsnag.use(_$clientIp_32);
|
2938
|
+
bugsnag.use(_$stripQueryString_39); // optional browser-specific plugins
|
2939
|
+
|
2940
|
+
if (bugsnag.config.autoNotify !== false) {
|
2941
|
+
bugsnag.use(_$onerror_40);
|
2942
|
+
bugsnag.use(_$unhandledRejection_41);
|
2943
|
+
}
|
2944
|
+
|
2945
|
+
bugsnag.use(_$navigationBreadcrumbs_36);
|
2946
|
+
bugsnag.use(_$interactionBreadcrumbs_35);
|
2947
|
+
bugsnag.use(_$networkBreadcrumbs_37);
|
2948
|
+
bugsnag.use(_$consoleBreadcrumbs_33);
|
2949
|
+
|
2950
|
+
bugsnag._logger.debug("Loaded!");
|
2951
|
+
|
2952
|
+
return bugsnag.config.autoCaptureSessions ? bugsnag.startSession() : bugsnag;
|
2953
|
+
}; // Stub this value because this is what the type interface looks like
|
2954
|
+
// (types/bugsnag.d.ts). This is only an issue in Angular's development
|
2955
|
+
// mode as its TS/DI thingy attempts to use this value at runtime.
|
2956
|
+
// In most other situations, TS only uses the types at compile time.
|
2957
|
+
|
2958
|
+
|
2959
|
+
_$notifier_2.Bugsnag = {
|
2960
|
+
Client: _$BugsnagClient_4,
|
2961
|
+
Report: _$BugsnagReport_24,
|
2962
|
+
Session: _$Session_25,
|
2963
|
+
Breadcrumb: _$BugsnagBreadcrumb_3 // Export a "default" property for compatibility with ESM imports
|
2964
|
+
|
2965
|
+
};
|
2966
|
+
_$notifier_2['default'] = _$notifier_2;
|
2967
|
+
|
2968
|
+
return _$notifier_2;
|
2969
|
+
|
2970
|
+
});
|