@shopify/create-app 3.90.0 → 3.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/{acorn-45LE5Z2A.js → acorn-WDTBS4B3.js} +2 -2
  2. package/dist/{angular-Z5FPQPLR.js → angular-WLPEGHXZ.js} +4 -4
  3. package/dist/{babel-TRRZ6QQY.js → babel-LQYCV4NA.js} +2 -7
  4. package/dist/{brotli-2OKV26Y6.js → brotli-6CC7WD4Z.js} +1 -2
  5. package/dist/{chunk-7YUNOVUI.js → chunk-5V2QRULS.js} +5 -5
  6. package/dist/{chunk-6ONJEX7Y.js → chunk-6NVYATES.js} +2 -2
  7. package/dist/{chunk-3GXB4ZRP.js → chunk-CE4S2SGM.js} +10 -10
  8. package/dist/{chunk-V7OWCSFT.js → chunk-D7M6DPGX.js} +54 -130
  9. package/dist/{chunk-RGJ4BXIY.js → chunk-JSNPKE7R.js} +349 -374
  10. package/dist/{chunk-2HKUDD5O.js → chunk-SOPKCUZ6.js} +51098 -49016
  11. package/dist/{chunk-6J45DHE7.js → chunk-SXHGDJJG.js} +9 -9
  12. package/dist/{chunk-XD3LXUGW.js → chunk-VBBBCVMH.js} +2 -2
  13. package/dist/{chunk-GWY4CBLA.js → chunk-Y7N4CVJX.js} +3 -3
  14. package/dist/{custom-oclif-loader-2UXWLT7G.js → custom-oclif-loader-YGL55JE6.js} +4 -4
  15. package/dist/{del-OKZSX2EU.js → del-IYDC7TRH.js} +3 -3
  16. package/dist/{devtools-2SG3BFWJ.js → devtools-BAOTGU3O.js} +2 -2
  17. package/dist/{error-handler-TTBMK4H6.js → error-handler-CZSHD75Y.js} +7 -8
  18. package/dist/{estree-PY6WKTNG.js → estree-U57GTUKI.js} +14 -35
  19. package/dist/{flow-YN54TSCB.js → flow-CBPGBIW5.js} +2 -4
  20. package/dist/{glimmer-RMPUUUDS.js → glimmer-VWCK7UCR.js} +2 -6
  21. package/dist/{graphql-PPLVYWBL.js → graphql-2HHXB4VZ.js} +3 -5
  22. package/dist/hooks/postrun.js +8 -7
  23. package/dist/hooks/prerun.js +8 -7
  24. package/dist/{html-3U6QZZZ4.js → html-ST4I6M3K.js} +4 -6
  25. package/dist/index.js +5025 -1332
  26. package/dist/index.test.js +23 -26
  27. package/dist/{lib-IF6LVQLE.js → lib-YAB2PPNZ.js} +2 -2
  28. package/dist/{local-XJBENDBD.js → local-AQABQSKR.js} +6 -6
  29. package/dist/{markdown-RHRQTUMC.js → markdown-NVTT3U3H.js} +4 -13
  30. package/dist/{meriyah-7MIMHTWQ.js → meriyah-H6RUUN2F.js} +2 -9
  31. package/dist/{multipart-parser-IYYNISJK.js → multipart-parser-WKKMXACL.js} +2 -2
  32. package/dist/{node-package-manager-5CRVMYIH.js → node-package-manager-4NRVKS7Z.js} +5 -5
  33. package/dist/{postcss-MSOPGY7M.js → postcss-LKRKUSYR.js} +4 -6
  34. package/dist/{prettier-2ITB6I34.js → prettier-BJT6DAGC.js} +29 -29
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/dist/{ui-NL6F4FZE.js → ui-EEB34UNU.js} +4 -4
  37. package/dist/{yaml-6GALFXQY.js → yaml-54MHMX7H.js} +6 -9
  38. package/oclif.manifest.json +1 -1
  39. package/package.json +4 -4
  40. package/dist/chunk-2DEP3RXL.js +0 -2234
@@ -1,2234 +0,0 @@
1
- import {
2
- CLI_KIT_VERSION,
3
- fanoutHooks,
4
- getEnvironmentData,
5
- getLastSeenUserIdAfterAuth,
6
- isLocalEnvironment,
7
- reportAnalyticsEvent
8
- } from "./chunk-2HKUDD5O.js";
9
- import {
10
- runWithRateLimit
11
- } from "./chunk-6J45DHE7.js";
12
- import {
13
- AbortSilentError,
14
- CancelExecution,
15
- bugsnagApiKey,
16
- cleanSingleStackTracePath,
17
- errorMapper,
18
- getAllPublicMetadata,
19
- getAllSensitiveMetadata,
20
- handler,
21
- outputDebug,
22
- outputInfo,
23
- reportingRateLimit,
24
- require_stacktracey,
25
- shouldReportErrorAsUnexpected
26
- } from "./chunk-RGJ4BXIY.js";
27
- import {
28
- require_lib
29
- } from "./chunk-V7OWCSFT.js";
30
- import {
31
- cwd,
32
- isAbsolutePath,
33
- joinPath,
34
- normalizePath,
35
- relativePath
36
- } from "./chunk-Y2JP6WFP.js";
37
- import {
38
- require_once
39
- } from "./chunk-SHWOPMLQ.js";
40
- import {
41
- __commonJS,
42
- __require,
43
- __toESM,
44
- init_cjs_shims
45
- } from "./chunk-PKR7KJ6P.js";
46
-
47
- // ../../node_modules/.pnpm/stackframe@1.3.4/node_modules/stackframe/stackframe.js
48
- var require_stackframe = __commonJS({
49
- "../../node_modules/.pnpm/stackframe@1.3.4/node_modules/stackframe/stackframe.js"(exports, module) {
50
- init_cjs_shims();
51
- (function(root, factory) {
52
- "use strict";
53
- typeof define == "function" && define.amd ? define("stackframe", [], factory) : typeof exports == "object" ? module.exports = factory() : root.StackFrame = factory();
54
- })(exports, function() {
55
- "use strict";
56
- function _isNumber(n) {
57
- return !isNaN(parseFloat(n)) && isFinite(n);
58
- }
59
- function _capitalize(str) {
60
- return str.charAt(0).toUpperCase() + str.substring(1);
61
- }
62
- function _getter(p) {
63
- return function() {
64
- return this[p];
65
- };
66
- }
67
- var booleanProps = ["isConstructor", "isEval", "isNative", "isToplevel"], numericProps = ["columnNumber", "lineNumber"], stringProps = ["fileName", "functionName", "source"], arrayProps = ["args"], objectProps = ["evalOrigin"], props = booleanProps.concat(numericProps, stringProps, arrayProps, objectProps);
68
- function StackFrame(obj) {
69
- if (obj)
70
- for (var i2 = 0; i2 < props.length; i2++)
71
- obj[props[i2]] !== void 0 && this["set" + _capitalize(props[i2])](obj[props[i2]]);
72
- }
73
- StackFrame.prototype = {
74
- getArgs: function() {
75
- return this.args;
76
- },
77
- setArgs: function(v) {
78
- if (Object.prototype.toString.call(v) !== "[object Array]")
79
- throw new TypeError("Args must be an Array");
80
- this.args = v;
81
- },
82
- getEvalOrigin: function() {
83
- return this.evalOrigin;
84
- },
85
- setEvalOrigin: function(v) {
86
- if (v instanceof StackFrame)
87
- this.evalOrigin = v;
88
- else if (v instanceof Object)
89
- this.evalOrigin = new StackFrame(v);
90
- else
91
- throw new TypeError("Eval Origin must be an Object or StackFrame");
92
- },
93
- toString: function() {
94
- var fileName = this.getFileName() || "", lineNumber = this.getLineNumber() || "", columnNumber = this.getColumnNumber() || "", functionName = this.getFunctionName() || "";
95
- return this.getIsEval() ? fileName ? "[eval] (" + fileName + ":" + lineNumber + ":" + columnNumber + ")" : "[eval]:" + lineNumber + ":" + columnNumber : functionName ? functionName + " (" + fileName + ":" + lineNumber + ":" + columnNumber + ")" : fileName + ":" + lineNumber + ":" + columnNumber;
96
- }
97
- }, StackFrame.fromString = function(str) {
98
- var argsStartIndex = str.indexOf("("), argsEndIndex = str.lastIndexOf(")"), functionName = str.substring(0, argsStartIndex), args = str.substring(argsStartIndex + 1, argsEndIndex).split(","), locationString = str.substring(argsEndIndex + 1);
99
- if (locationString.indexOf("@") === 0)
100
- var parts = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(locationString, ""), fileName = parts[1], lineNumber = parts[2], columnNumber = parts[3];
101
- return new StackFrame({
102
- functionName,
103
- args: args || void 0,
104
- fileName,
105
- lineNumber: lineNumber || void 0,
106
- columnNumber: columnNumber || void 0
107
- });
108
- };
109
- for (var i = 0; i < booleanProps.length; i++)
110
- StackFrame.prototype["get" + _capitalize(booleanProps[i])] = _getter(booleanProps[i]), StackFrame.prototype["set" + _capitalize(booleanProps[i])] = /* @__PURE__ */ (function(p) {
111
- return function(v) {
112
- this[p] = !!v;
113
- };
114
- })(booleanProps[i]);
115
- for (var j = 0; j < numericProps.length; j++)
116
- StackFrame.prototype["get" + _capitalize(numericProps[j])] = _getter(numericProps[j]), StackFrame.prototype["set" + _capitalize(numericProps[j])] = /* @__PURE__ */ (function(p) {
117
- return function(v) {
118
- if (!_isNumber(v))
119
- throw new TypeError(p + " must be a Number");
120
- this[p] = Number(v);
121
- };
122
- })(numericProps[j]);
123
- for (var k = 0; k < stringProps.length; k++)
124
- StackFrame.prototype["get" + _capitalize(stringProps[k])] = _getter(stringProps[k]), StackFrame.prototype["set" + _capitalize(stringProps[k])] = /* @__PURE__ */ (function(p) {
125
- return function(v) {
126
- this[p] = String(v);
127
- };
128
- })(stringProps[k]);
129
- return StackFrame;
130
- });
131
- }
132
- });
133
-
134
- // ../../node_modules/.pnpm/error-stack-parser@2.1.4/node_modules/error-stack-parser/error-stack-parser.js
135
- var require_error_stack_parser = __commonJS({
136
- "../../node_modules/.pnpm/error-stack-parser@2.1.4/node_modules/error-stack-parser/error-stack-parser.js"(exports, module) {
137
- init_cjs_shims();
138
- (function(root, factory) {
139
- "use strict";
140
- typeof define == "function" && define.amd ? define("error-stack-parser", ["stackframe"], factory) : typeof exports == "object" ? module.exports = factory(require_stackframe()) : root.ErrorStackParser = factory(root.StackFrame);
141
- })(exports, function(StackFrame) {
142
- "use strict";
143
- var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/, CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m, SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
144
- return {
145
- /**
146
- * Given an Error object, extract the most information from it.
147
- *
148
- * @param {Error} error object
149
- * @return {Array} of StackFrames
150
- */
151
- parse: function(error) {
152
- if (typeof error.stacktrace < "u" || typeof error["opera#sourceloc"] < "u")
153
- return this.parseOpera(error);
154
- if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP))
155
- return this.parseV8OrIE(error);
156
- if (error.stack)
157
- return this.parseFFOrSafari(error);
158
- throw new Error("Cannot parse given Error object");
159
- },
160
- // Separate line and column numbers from a string of the form: (URI:Line:Column)
161
- extractLocation: function(urlLike) {
162
- if (urlLike.indexOf(":") === -1)
163
- return [urlLike];
164
- var regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/, parts = regExp.exec(urlLike.replace(/[()]/g, ""));
165
- return [parts[1], parts[2] || void 0, parts[3] || void 0];
166
- },
167
- parseV8OrIE: function(error) {
168
- var filtered = error.stack.split(`
169
- `).filter(function(line) {
170
- return !!line.match(CHROME_IE_STACK_REGEXP);
171
- }, this);
172
- return filtered.map(function(line) {
173
- line.indexOf("(eval ") > -1 && (line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
174
- var sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), location = sanitizedLine.match(/ (\(.+\)$)/);
175
- sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
176
- var locationParts = this.extractLocation(location ? location[1] : sanitizedLine), functionName = location && sanitizedLine || void 0, fileName = ["eval", "<anonymous>"].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];
177
- return new StackFrame({
178
- functionName,
179
- fileName,
180
- lineNumber: locationParts[1],
181
- columnNumber: locationParts[2],
182
- source: line
183
- });
184
- }, this);
185
- },
186
- parseFFOrSafari: function(error) {
187
- var filtered = error.stack.split(`
188
- `).filter(function(line) {
189
- return !line.match(SAFARI_NATIVE_CODE_REGEXP);
190
- }, this);
191
- return filtered.map(function(line) {
192
- if (line.indexOf(" > eval") > -1 && (line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), line.indexOf("@") === -1 && line.indexOf(":") === -1)
193
- return new StackFrame({
194
- functionName: line
195
- });
196
- var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/, matches = line.match(functionNameRegex), functionName = matches && matches[1] ? matches[1] : void 0, locationParts = this.extractLocation(line.replace(functionNameRegex, ""));
197
- return new StackFrame({
198
- functionName,
199
- fileName: locationParts[0],
200
- lineNumber: locationParts[1],
201
- columnNumber: locationParts[2],
202
- source: line
203
- });
204
- }, this);
205
- },
206
- parseOpera: function(e) {
207
- return !e.stacktrace || e.message.indexOf(`
208
- `) > -1 && e.message.split(`
209
- `).length > e.stacktrace.split(`
210
- `).length ? this.parseOpera9(e) : e.stack ? this.parseOpera11(e) : this.parseOpera10(e);
211
- },
212
- parseOpera9: function(e) {
213
- for (var lineRE = /Line (\d+).*script (?:in )?(\S+)/i, lines = e.message.split(`
214
- `), result = [], i = 2, len = lines.length; i < len; i += 2) {
215
- var match = lineRE.exec(lines[i]);
216
- match && result.push(new StackFrame({
217
- fileName: match[2],
218
- lineNumber: match[1],
219
- source: lines[i]
220
- }));
221
- }
222
- return result;
223
- },
224
- parseOpera10: function(e) {
225
- for (var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, lines = e.stacktrace.split(`
226
- `), result = [], i = 0, len = lines.length; i < len; i += 2) {
227
- var match = lineRE.exec(lines[i]);
228
- match && result.push(
229
- new StackFrame({
230
- functionName: match[3] || void 0,
231
- fileName: match[2],
232
- lineNumber: match[1],
233
- source: lines[i]
234
- })
235
- );
236
- }
237
- return result;
238
- },
239
- // Opera 10.65+ Error.stack very similar to FF/Safari
240
- parseOpera11: function(error) {
241
- var filtered = error.stack.split(`
242
- `).filter(function(line) {
243
- return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
244
- }, this);
245
- return filtered.map(function(line) {
246
- var tokens = line.split("@"), locationParts = this.extractLocation(tokens.pop()), functionCall = tokens.shift() || "", functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, argsRaw;
247
- functionCall.match(/\(([^)]*)\)/) && (argsRaw = functionCall.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
248
- var args = argsRaw === void 0 || argsRaw === "[arguments not available]" ? void 0 : argsRaw.split(",");
249
- return new StackFrame({
250
- functionName,
251
- args,
252
- fileName: locationParts[0],
253
- lineNumber: locationParts[1],
254
- columnNumber: locationParts[2],
255
- source: line
256
- });
257
- }, this);
258
- }
259
- };
260
- });
261
- }
262
- });
263
-
264
- // ../../node_modules/.pnpm/iserror@0.0.2/node_modules/iserror/index.js
265
- var require_iserror = __commonJS({
266
- "../../node_modules/.pnpm/iserror@0.0.2/node_modules/iserror/index.js"(exports, module) {
267
- init_cjs_shims();
268
- module.exports = isError;
269
- function isError(value) {
270
- switch (Object.prototype.toString.call(value)) {
271
- case "[object Error]":
272
- return !0;
273
- case "[object Exception]":
274
- return !0;
275
- case "[object DOMException]":
276
- return !0;
277
- default:
278
- return value instanceof Error;
279
- }
280
- }
281
- }
282
- });
283
-
284
- // ../../node_modules/.pnpm/stack-generator@2.0.10/node_modules/stack-generator/stack-generator.js
285
- var require_stack_generator = __commonJS({
286
- "../../node_modules/.pnpm/stack-generator@2.0.10/node_modules/stack-generator/stack-generator.js"(exports, module) {
287
- init_cjs_shims();
288
- (function(root, factory) {
289
- "use strict";
290
- typeof define == "function" && define.amd ? define("stack-generator", ["stackframe"], factory) : typeof exports == "object" ? module.exports = factory(require_stackframe()) : root.StackGenerator = factory(root.StackFrame);
291
- })(exports, function(StackFrame) {
292
- return {
293
- backtrace: function(opts) {
294
- var stack = [], maxStackSize = 10;
295
- typeof opts == "object" && typeof opts.maxStackSize == "number" && (maxStackSize = opts.maxStackSize);
296
- for (var curr = arguments.callee; curr && stack.length < maxStackSize && curr.arguments; ) {
297
- for (var args = new Array(curr.arguments.length), i = 0; i < args.length; ++i)
298
- args[i] = curr.arguments[i];
299
- /function(?:\s+([\w$]+))+\s*\(/.test(curr.toString()) ? stack.push(new StackFrame({ functionName: RegExp.$1 || void 0, args })) : stack.push(new StackFrame({ args }));
300
- try {
301
- curr = curr.caller;
302
- } catch {
303
- break;
304
- }
305
- }
306
- return stack;
307
- }
308
- };
309
- });
310
- }
311
- });
312
-
313
- // ../../node_modules/.pnpm/end-of-stream@1.4.5/node_modules/end-of-stream/index.js
314
- var require_end_of_stream = __commonJS({
315
- "../../node_modules/.pnpm/end-of-stream@1.4.5/node_modules/end-of-stream/index.js"(exports, module) {
316
- init_cjs_shims();
317
- var once = require_once(), noop = function() {
318
- }, qnt = global.Bare ? queueMicrotask : process.nextTick.bind(process), isRequest = function(stream) {
319
- return stream.setHeader && typeof stream.abort == "function";
320
- }, isChildProcess = function(stream) {
321
- return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3;
322
- }, eos = function(stream, opts, callback) {
323
- if (typeof opts == "function") return eos(stream, null, opts);
324
- opts || (opts = {}), callback = once(callback || noop);
325
- var ws = stream._writableState, rs = stream._readableState, readable = opts.readable || opts.readable !== !1 && stream.readable, writable = opts.writable || opts.writable !== !1 && stream.writable, cancelled = !1, onlegacyfinish = function() {
326
- stream.writable || onfinish();
327
- }, onfinish = function() {
328
- writable = !1, readable || callback.call(stream);
329
- }, onend = function() {
330
- readable = !1, writable || callback.call(stream);
331
- }, onexit = function(exitCode) {
332
- callback.call(stream, exitCode ? new Error("exited with error code: " + exitCode) : null);
333
- }, onerror = function(err) {
334
- callback.call(stream, err);
335
- }, onclose = function() {
336
- qnt(onclosenexttick);
337
- }, onclosenexttick = function() {
338
- if (!cancelled) {
339
- if (readable && !(rs && rs.ended && !rs.destroyed)) return callback.call(stream, new Error("premature close"));
340
- if (writable && !(ws && ws.ended && !ws.destroyed)) return callback.call(stream, new Error("premature close"));
341
- }
342
- }, onrequest = function() {
343
- stream.req.on("finish", onfinish);
344
- };
345
- return isRequest(stream) ? (stream.on("complete", onfinish), stream.on("abort", onclose), stream.req ? onrequest() : stream.on("request", onrequest)) : writable && !ws && (stream.on("end", onlegacyfinish), stream.on("close", onlegacyfinish)), isChildProcess(stream) && stream.on("exit", onexit), stream.on("end", onend), stream.on("finish", onfinish), opts.error !== !1 && stream.on("error", onerror), stream.on("close", onclose), function() {
346
- cancelled = !0, stream.removeListener("complete", onfinish), stream.removeListener("abort", onclose), stream.removeListener("request", onrequest), stream.req && stream.req.removeListener("finish", onfinish), stream.removeListener("end", onlegacyfinish), stream.removeListener("close", onlegacyfinish), stream.removeListener("finish", onfinish), stream.removeListener("exit", onexit), stream.removeListener("end", onend), stream.removeListener("error", onerror), stream.removeListener("close", onclose);
347
- };
348
- };
349
- module.exports = eos;
350
- }
351
- });
352
-
353
- // ../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js
354
- var require_pump = __commonJS({
355
- "../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js"(exports, module) {
356
- init_cjs_shims();
357
- var once = require_once(), eos = require_end_of_stream(), fs;
358
- try {
359
- fs = __require("fs");
360
- } catch {
361
- }
362
- var noop = function() {
363
- }, ancient = /^v?\.0/.test(process.version), isFn = function(fn) {
364
- return typeof fn == "function";
365
- }, isFS = function(stream) {
366
- return !ancient || !fs ? !1 : (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close);
367
- }, isRequest = function(stream) {
368
- return stream.setHeader && isFn(stream.abort);
369
- }, destroyer = function(stream, reading, writing, callback) {
370
- callback = once(callback);
371
- var closed = !1;
372
- stream.on("close", function() {
373
- closed = !0;
374
- }), eos(stream, { readable: reading, writable: writing }, function(err) {
375
- if (err) return callback(err);
376
- closed = !0, callback();
377
- });
378
- var destroyed = !1;
379
- return function(err) {
380
- if (!closed && !destroyed) {
381
- if (destroyed = !0, isFS(stream)) return stream.close(noop);
382
- if (isRequest(stream)) return stream.abort();
383
- if (isFn(stream.destroy)) return stream.destroy();
384
- callback(err || new Error("stream was destroyed"));
385
- }
386
- };
387
- }, call = function(fn) {
388
- fn();
389
- }, pipe = function(from, to) {
390
- return from.pipe(to);
391
- }, pump = function() {
392
- var streams = Array.prototype.slice.call(arguments), callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop;
393
- if (Array.isArray(streams[0]) && (streams = streams[0]), streams.length < 2) throw new Error("pump requires two streams per minimum");
394
- var error, destroys = streams.map(function(stream, i) {
395
- var reading = i < streams.length - 1, writing = i > 0;
396
- return destroyer(stream, reading, writing, function(err) {
397
- error || (error = err), err && destroys.forEach(call), !reading && (destroys.forEach(call), callback(error));
398
- });
399
- });
400
- return streams.reduce(pipe);
401
- };
402
- module.exports = pump;
403
- }
404
- });
405
-
406
- // ../../node_modules/.pnpm/byline@5.0.0/node_modules/byline/lib/byline.js
407
- var require_byline = __commonJS({
408
- "../../node_modules/.pnpm/byline@5.0.0/node_modules/byline/lib/byline.js"(exports, module) {
409
- init_cjs_shims();
410
- var stream = __require("stream"), util = __require("util"), timers = __require("timers");
411
- module.exports = function(readStream, options) {
412
- return module.exports.createStream(readStream, options);
413
- };
414
- module.exports.createStream = function(readStream, options) {
415
- return readStream ? createLineStream(readStream, options) : new LineStream(options);
416
- };
417
- module.exports.createLineStream = function(readStream) {
418
- return console.log("WARNING: byline#createLineStream is deprecated and will be removed soon"), createLineStream(readStream);
419
- };
420
- function createLineStream(readStream, options) {
421
- if (!readStream)
422
- throw new Error("expected readStream");
423
- if (!readStream.readable)
424
- throw new Error("readStream must be readable");
425
- var ls = new LineStream(options);
426
- return readStream.pipe(ls), ls;
427
- }
428
- module.exports.LineStream = LineStream;
429
- function LineStream(options) {
430
- stream.Transform.call(this, options), options = options || {}, this._readableState.objectMode = !0, this._lineBuffer = [], this._keepEmptyLines = options.keepEmptyLines || !1, this._lastChunkEndedWithCR = !1;
431
- var self2 = this;
432
- this.on("pipe", function(src) {
433
- self2.encoding || src instanceof stream.Readable && (self2.encoding = src._readableState.encoding);
434
- });
435
- }
436
- util.inherits(LineStream, stream.Transform);
437
- LineStream.prototype._transform = function(chunk, encoding, done) {
438
- encoding = encoding || "utf8", Buffer.isBuffer(chunk) && (encoding == "buffer" ? (chunk = chunk.toString(), encoding = "utf8") : chunk = chunk.toString(encoding)), this._chunkEncoding = encoding;
439
- var lines = chunk.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g);
440
- this._lastChunkEndedWithCR && chunk[0] == `
441
- ` && lines.shift(), this._lineBuffer.length > 0 && (this._lineBuffer[this._lineBuffer.length - 1] += lines[0], lines.shift()), this._lastChunkEndedWithCR = chunk[chunk.length - 1] == "\r", this._lineBuffer = this._lineBuffer.concat(lines), this._pushBuffer(encoding, 1, done);
442
- };
443
- LineStream.prototype._pushBuffer = function(encoding, keep, done) {
444
- for (; this._lineBuffer.length > keep; ) {
445
- var line = this._lineBuffer.shift();
446
- if ((this._keepEmptyLines || line.length > 0) && !this.push(this._reencode(line, encoding))) {
447
- var self2 = this;
448
- timers.setImmediate(function() {
449
- self2._pushBuffer(encoding, keep, done);
450
- });
451
- return;
452
- }
453
- }
454
- done();
455
- };
456
- LineStream.prototype._flush = function(done) {
457
- this._pushBuffer(this._chunkEncoding, 0, done);
458
- };
459
- LineStream.prototype._reencode = function(line, chunkEncoding) {
460
- return this.encoding && this.encoding != chunkEncoding ? new Buffer(line, chunkEncoding).toString(this.encoding) : this.encoding ? line : new Buffer(line, chunkEncoding);
461
- };
462
- }
463
- });
464
-
465
- // ../../node_modules/.pnpm/@bugsnag+node@8.6.0/node_modules/@bugsnag/node/dist/bugsnag.js
466
- var require_bugsnag = __commonJS({
467
- "../../node_modules/.pnpm/@bugsnag+node@8.6.0/node_modules/@bugsnag/node/dist/bugsnag.js"(exports, module) {
468
- init_cjs_shims();
469
- (function(f) {
470
- if (typeof exports == "object" && typeof module < "u")
471
- module.exports = f();
472
- else if (typeof define == "function" && define.amd)
473
- define([], f);
474
- else {
475
- var g;
476
- typeof window < "u" ? g = window : typeof global < "u" ? g = global : typeof self < "u" ? g = self : g = this, g.bugsnag = f();
477
- }
478
- })(function() {
479
- var define2, module2, exports2, Breadcrumb = /* @__PURE__ */ (function() {
480
- function Breadcrumb2(message, metadata, type, timestamp) {
481
- timestamp === void 0 && (timestamp = /* @__PURE__ */ new Date()), this.type = type, this.message = message, this.metadata = metadata, this.timestamp = timestamp;
482
- }
483
- var _proto = Breadcrumb2.prototype;
484
- return _proto.toJSON = function() {
485
- return {
486
- type: this.type,
487
- name: this.message,
488
- timestamp: this.timestamp,
489
- metaData: this.metadata
490
- };
491
- }, Breadcrumb2;
492
- })(), _$Breadcrumb_7 = Breadcrumb, _$breadcrumbTypes_12 = ["navigation", "request", "process", "log", "user", "state", "error", "manual"], _$reduce_22 = function(arr, fn, accum) {
493
- for (var val = accum, i = 0, len = arr.length; i < len; i++) val = fn(val, arr[i], i, arr);
494
- return val;
495
- }, _$filter_17 = function(arr, fn) {
496
- return _$reduce_22(arr, function(accum, item, i, arr2) {
497
- return fn(item, i, arr2) ? accum.concat(item) : accum;
498
- }, []);
499
- }, _$includes_18 = function(arr, x) {
500
- return _$reduce_22(arr, function(accum, item, i, arr2) {
501
- return accum === !0 || item === x;
502
- }, !1);
503
- }, _$isArray_19 = function(obj) {
504
- return Object.prototype.toString.call(obj) === "[object Array]";
505
- }, _hasDontEnumBug = !{
506
- toString: null
507
- }.propertyIsEnumerable("toString"), _dontEnums = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"], _$keys_20 = function(obj) {
508
- var result = [], prop;
509
- for (prop in obj)
510
- Object.prototype.hasOwnProperty.call(obj, prop) && result.push(prop);
511
- if (!_hasDontEnumBug) return result;
512
- for (var i = 0, len = _dontEnums.length; i < len; i++)
513
- Object.prototype.hasOwnProperty.call(obj, _dontEnums[i]) && result.push(_dontEnums[i]);
514
- return result;
515
- }, _$intRange_31 = function(min, max) {
516
- return min === void 0 && (min = 1), max === void 0 && (max = 1 / 0), function(value) {
517
- return typeof value == "number" && parseInt("" + value, 10) === value && value >= min && value <= max;
518
- };
519
- }, _$listOfFunctions_32 = function(value) {
520
- return typeof value == "function" || _$isArray_19(value) && _$filter_17(value, function(f) {
521
- return typeof f == "function";
522
- }).length === value.length;
523
- }, _$stringWithLength_33 = function(value) {
524
- return typeof value == "string" && !!value.length;
525
- }, _$config_9 = {}, defaultErrorTypes = function() {
526
- return {
527
- unhandledExceptions: !0,
528
- unhandledRejections: !0
529
- };
530
- };
531
- _$config_9.schema = {
532
- apiKey: {
533
- defaultValue: function() {
534
- return null;
535
- },
536
- message: "is required",
537
- validate: _$stringWithLength_33
538
- },
539
- appVersion: {
540
- defaultValue: function() {
541
- },
542
- message: "should be a string",
543
- validate: function(value) {
544
- return value === void 0 || _$stringWithLength_33(value);
545
- }
546
- },
547
- appType: {
548
- defaultValue: function() {
549
- },
550
- message: "should be a string",
551
- validate: function(value) {
552
- return value === void 0 || _$stringWithLength_33(value);
553
- }
554
- },
555
- autoDetectErrors: {
556
- defaultValue: function() {
557
- return !0;
558
- },
559
- message: "should be true|false",
560
- validate: function(value) {
561
- return value === !0 || value === !1;
562
- }
563
- },
564
- enabledErrorTypes: {
565
- defaultValue: function() {
566
- return defaultErrorTypes();
567
- },
568
- message: "should be an object containing the flags { unhandledExceptions:true|false, unhandledRejections:true|false }",
569
- allowPartialObject: !0,
570
- validate: function(value) {
571
- if (typeof value != "object" || !value) return !1;
572
- var providedKeys = _$keys_20(value), defaultKeys = _$keys_20(defaultErrorTypes());
573
- return !(_$filter_17(providedKeys, function(k) {
574
- return _$includes_18(defaultKeys, k);
575
- }).length < providedKeys.length || _$filter_17(_$keys_20(value), function(k) {
576
- return typeof value[k] != "boolean";
577
- }).length > 0);
578
- }
579
- },
580
- onError: {
581
- defaultValue: function() {
582
- return [];
583
- },
584
- message: "should be a function or array of functions",
585
- validate: _$listOfFunctions_32
586
- },
587
- onSession: {
588
- defaultValue: function() {
589
- return [];
590
- },
591
- message: "should be a function or array of functions",
592
- validate: _$listOfFunctions_32
593
- },
594
- onBreadcrumb: {
595
- defaultValue: function() {
596
- return [];
597
- },
598
- message: "should be a function or array of functions",
599
- validate: _$listOfFunctions_32
600
- },
601
- endpoints: {
602
- defaultValue: function(endpoints) {
603
- return typeof endpoints > "u" ? {
604
- notify: "https://notify.bugsnag.com",
605
- sessions: "https://sessions.bugsnag.com"
606
- } : {
607
- notify: null,
608
- sessions: null
609
- };
610
- },
611
- message: "should be an object containing endpoint URLs { notify, sessions }",
612
- validate: function(val) {
613
- return (
614
- // first, ensure it's an object
615
- val && typeof val == "object" && // notify and sessions must always be set
616
- _$stringWithLength_33(val.notify) && _$stringWithLength_33(val.sessions) && // ensure no keys other than notify/session are set on endpoints object
617
- _$filter_17(_$keys_20(val), function(k) {
618
- return !_$includes_18(["notify", "sessions"], k);
619
- }).length === 0
620
- );
621
- }
622
- },
623
- autoTrackSessions: {
624
- defaultValue: function(val) {
625
- return !0;
626
- },
627
- message: "should be true|false",
628
- validate: function(val) {
629
- return val === !0 || val === !1;
630
- }
631
- },
632
- enabledReleaseStages: {
633
- defaultValue: function() {
634
- return null;
635
- },
636
- message: "should be an array of strings",
637
- validate: function(value) {
638
- return value === null || _$isArray_19(value) && _$filter_17(value, function(f) {
639
- return typeof f == "string";
640
- }).length === value.length;
641
- }
642
- },
643
- releaseStage: {
644
- defaultValue: function() {
645
- return "production";
646
- },
647
- message: "should be a string",
648
- validate: function(value) {
649
- return typeof value == "string" && value.length;
650
- }
651
- },
652
- maxBreadcrumbs: {
653
- defaultValue: function() {
654
- return 25;
655
- },
656
- message: "should be a number \u2264100",
657
- validate: function(value) {
658
- return _$intRange_31(0, 100)(value);
659
- }
660
- },
661
- enabledBreadcrumbTypes: {
662
- defaultValue: function() {
663
- return _$breadcrumbTypes_12;
664
- },
665
- message: "should be null or a list of available breadcrumb types (" + _$breadcrumbTypes_12.join(",") + ")",
666
- validate: function(value) {
667
- return value === null || _$isArray_19(value) && _$reduce_22(value, function(accum, maybeType) {
668
- return accum === !1 ? accum : _$includes_18(_$breadcrumbTypes_12, maybeType);
669
- }, !0);
670
- }
671
- },
672
- context: {
673
- defaultValue: function() {
674
- },
675
- message: "should be a string",
676
- validate: function(value) {
677
- return value === void 0 || typeof value == "string";
678
- }
679
- },
680
- user: {
681
- defaultValue: function() {
682
- return {};
683
- },
684
- message: "should be an object with { id, email, name } properties",
685
- validate: function(value) {
686
- return value === null || value && _$reduce_22(_$keys_20(value), function(accum, key) {
687
- return accum && _$includes_18(["id", "email", "name"], key);
688
- }, !0);
689
- }
690
- },
691
- metadata: {
692
- defaultValue: function() {
693
- return {};
694
- },
695
- message: "should be an object",
696
- validate: function(value) {
697
- return typeof value == "object" && value !== null;
698
- }
699
- },
700
- logger: {
701
- defaultValue: function() {
702
- },
703
- message: "should be null or an object with methods { debug, info, warn, error }",
704
- validate: function(value) {
705
- return !value || value && _$reduce_22(["debug", "info", "warn", "error"], function(accum, method) {
706
- return accum && typeof value[method] == "function";
707
- }, !0);
708
- }
709
- },
710
- redactedKeys: {
711
- defaultValue: function() {
712
- return ["password"];
713
- },
714
- message: "should be an array of strings|regexes",
715
- validate: function(value) {
716
- return _$isArray_19(value) && value.length === _$filter_17(value, function(s) {
717
- return typeof s == "string" || s && typeof s.test == "function";
718
- }).length;
719
- }
720
- },
721
- plugins: {
722
- defaultValue: function() {
723
- return [];
724
- },
725
- message: "should be an array of plugin objects",
726
- validate: function(value) {
727
- return _$isArray_19(value) && value.length === _$filter_17(value, function(p) {
728
- return p && typeof p == "object" && typeof p.load == "function";
729
- }).length;
730
- }
731
- },
732
- featureFlags: {
733
- defaultValue: function() {
734
- return [];
735
- },
736
- message: 'should be an array of objects that have a "name" property',
737
- validate: function(value) {
738
- return _$isArray_19(value) && value.length === _$filter_17(value, function(feature) {
739
- return feature && typeof feature == "object" && typeof feature.name == "string";
740
- }).length;
741
- }
742
- },
743
- reportUnhandledPromiseRejectionsAsHandled: {
744
- defaultValue: function() {
745
- return !1;
746
- },
747
- message: "should be true|false",
748
- validate: function(value) {
749
- return value === !0 || value === !1;
750
- }
751
- },
752
- sendPayloadChecksums: {
753
- defaultValue: function() {
754
- return !1;
755
- },
756
- message: "should be true|false",
757
- validate: function(value) {
758
- return value === !0 || value === !1;
759
- }
760
- }
761
- };
762
- var _$errorStackParser_15 = require_error_stack_parser(), _$assign_16 = function(target) {
763
- for (var i = 1; i < arguments.length; i++) {
764
- var source = arguments[i];
765
- for (var key in source)
766
- Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
767
- }
768
- return target;
769
- }, _$map_21 = function(arr, fn) {
770
- return _$reduce_22(arr, function(accum, item, i, arr2) {
771
- return accum.concat(fn(item, i, arr2));
772
- }, []);
773
- }, _$safeJsonStringify_5 = function(data, replacer, space, opts) {
774
- var redactedKeys = opts && opts.redactedKeys ? opts.redactedKeys : [], redactedPaths = opts && opts.redactedPaths ? opts.redactedPaths : [];
775
- return JSON.stringify(prepareObjForSerialization(data, redactedKeys, redactedPaths), replacer, space);
776
- }, MAX_DEPTH = 20, MAX_EDGES = 25e3, MIN_PRESERVED_DEPTH = 8, REPLACEMENT_NODE = "...";
777
- function isError(o) {
778
- return o instanceof Error || /^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(o));
779
- }
780
- function throwsMessage(err) {
781
- return "[Throws: " + (err ? err.message : "?") + "]";
782
- }
783
- function find(haystack, needle) {
784
- for (var i = 0, len = haystack.length; i < len; i++)
785
- if (haystack[i] === needle) return !0;
786
- return !1;
787
- }
788
- function isDescendent(paths, path2) {
789
- for (var i = 0, len = paths.length; i < len; i++)
790
- if (path2.indexOf(paths[i]) === 0) return !0;
791
- return !1;
792
- }
793
- function shouldRedact(patterns, key) {
794
- for (var i = 0, len = patterns.length; i < len; i++)
795
- if (typeof patterns[i] == "string" && patterns[i].toLowerCase() === key.toLowerCase() || patterns[i] && typeof patterns[i].test == "function" && patterns[i].test(key)) return !0;
796
- return !1;
797
- }
798
- function __isArray_5(obj) {
799
- return Object.prototype.toString.call(obj) === "[object Array]";
800
- }
801
- function safelyGetProp(obj, prop) {
802
- try {
803
- return obj[prop];
804
- } catch (err) {
805
- return throwsMessage(err);
806
- }
807
- }
808
- function prepareObjForSerialization(obj, redactedKeys, redactedPaths) {
809
- var seen = [], edges = 0;
810
- function visit(obj2, path2) {
811
- function edgesExceeded() {
812
- return path2.length > MIN_PRESERVED_DEPTH && edges > MAX_EDGES;
813
- }
814
- if (edges++, path2.length > MAX_DEPTH || edgesExceeded()) return REPLACEMENT_NODE;
815
- if (obj2 === null || typeof obj2 != "object") return obj2;
816
- if (find(seen, obj2)) return "[Circular]";
817
- if (seen.push(obj2), typeof obj2.toJSON == "function")
818
- try {
819
- edges--;
820
- var fResult = visit(obj2.toJSON(), path2);
821
- return seen.pop(), fResult;
822
- } catch (err) {
823
- return throwsMessage(err);
824
- }
825
- var er = isError(obj2);
826
- if (er) {
827
- edges--;
828
- var eResult = visit({
829
- name: obj2.name,
830
- message: obj2.message
831
- }, path2);
832
- return seen.pop(), eResult;
833
- }
834
- if (__isArray_5(obj2)) {
835
- for (var aResult = [], i = 0, len = obj2.length; i < len; i++) {
836
- if (edgesExceeded()) {
837
- aResult.push(REPLACEMENT_NODE);
838
- break;
839
- }
840
- aResult.push(visit(obj2[i], path2.concat("[]")));
841
- }
842
- return seen.pop(), aResult;
843
- }
844
- var result = {};
845
- try {
846
- for (var prop in obj2)
847
- if (Object.prototype.hasOwnProperty.call(obj2, prop)) {
848
- if (isDescendent(redactedPaths, path2.join(".")) && shouldRedact(redactedKeys, prop)) {
849
- result[prop] = "[REDACTED]";
850
- continue;
851
- }
852
- if (edgesExceeded()) {
853
- result[prop] = REPLACEMENT_NODE;
854
- break;
855
- }
856
- result[prop] = visit(safelyGetProp(obj2, prop), path2.concat(prop));
857
- }
858
- } catch {
859
- }
860
- return seen.pop(), result;
861
- }
862
- return visit(obj, []);
863
- }
864
- function add(existingFeatures, existingFeatureKeys, name2, variant) {
865
- if (typeof name2 == "string") {
866
- variant === void 0 ? variant = null : variant !== null && typeof variant != "string" && (variant = _$safeJsonStringify_5(variant));
867
- var existingIndex = existingFeatureKeys[name2];
868
- if (typeof existingIndex == "number") {
869
- existingFeatures[existingIndex] = {
870
- name: name2,
871
- variant
872
- };
873
- return;
874
- }
875
- existingFeatures.push({
876
- name: name2,
877
- variant
878
- }), existingFeatureKeys[name2] = existingFeatures.length - 1;
879
- }
880
- }
881
- function merge(existingFeatures, newFeatures, existingFeatureKeys) {
882
- if (_$isArray_19(newFeatures)) {
883
- for (var i = 0; i < newFeatures.length; ++i) {
884
- var feature = newFeatures[i];
885
- feature === null || typeof feature != "object" || add(existingFeatures, existingFeatureKeys, feature.name, feature.variant);
886
- }
887
- return existingFeatures;
888
- }
889
- }
890
- function toEventApi(featureFlags) {
891
- return _$map_21(_$filter_17(featureFlags, Boolean), function(_ref) {
892
- var name2 = _ref.name, variant = _ref.variant, flag = {
893
- featureFlag: name2
894
- };
895
- return typeof variant == "string" && (flag.variant = variant), flag;
896
- });
897
- }
898
- function clear(features, featuresIndex, name2) {
899
- var existingIndex = featuresIndex[name2];
900
- typeof existingIndex == "number" && (features[existingIndex] = null, delete featuresIndex[name2]);
901
- }
902
- var _$featureFlagDelegate_23 = {
903
- add,
904
- clear,
905
- merge,
906
- toEventApi
907
- }, _$hasStack_24 = function(err) {
908
- return !!err && (!!err.stack || !!err.stacktrace || !!err["opera#sourceloc"]) && typeof (err.stack || err.stacktrace || err["opera#sourceloc"]) == "string" && err.stack !== err.name + ": " + err.message;
909
- }, _$iserror_25 = require_iserror(), __add_27 = function(state, section, keyOrObj, maybeVal) {
910
- var _updates;
911
- if (section) {
912
- var updates;
913
- if (keyOrObj === null) return __clear_27(state, section);
914
- typeof keyOrObj == "object" && (updates = keyOrObj), typeof keyOrObj == "string" && (updates = (_updates = {}, _updates[keyOrObj] = maybeVal, _updates)), updates && (section === "__proto__" || section === "constructor" || section === "prototype" || (state[section] || (state[section] = {}), state[section] = _$assign_16({}, state[section], updates)));
915
- }
916
- }, get = function(state, section, key) {
917
- if (typeof section == "string") {
918
- if (!key)
919
- return state[section];
920
- if (state[section])
921
- return state[section][key];
922
- }
923
- }, __clear_27 = function(state, section, key) {
924
- if (typeof section == "string") {
925
- if (!key) {
926
- delete state[section];
927
- return;
928
- }
929
- section === "__proto__" || section === "constructor" || section === "prototype" || state[section] && delete state[section][key];
930
- }
931
- }, _$metadataDelegate_27 = {
932
- add: __add_27,
933
- get,
934
- clear: __clear_27
935
- };
936
- function _extends() {
937
- return _extends = Object.assign ? Object.assign.bind() : function(n) {
938
- for (var e = 1; e < arguments.length; e++) {
939
- var t = arguments[e];
940
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
941
- }
942
- return n;
943
- }, _extends.apply(null, arguments);
944
- }
945
- var StackGenerator = require_stack_generator(), Event = /* @__PURE__ */ (function() {
946
- function Event2(errorClass, errorMessage, stacktrace, handledState, originalError) {
947
- stacktrace === void 0 && (stacktrace = []), handledState === void 0 && (handledState = defaultHandledState()), this.apiKey = void 0, this.context = void 0, this.groupingHash = void 0, this.originalError = originalError, this._handledState = handledState, this.severity = this._handledState.severity, this.unhandled = this._handledState.unhandled, this.app = {}, this.device = {}, this.request = {}, this.breadcrumbs = [], this.threads = [], this._metadata = {}, this._features = [], this._featuresIndex = {}, this._user = {}, this._session = void 0, this._correlation = void 0, this._groupingDiscriminator = void 0, this.errors = [createBugsnagError(errorClass, errorMessage, Event2.__type, stacktrace)];
948
- }
949
- var _proto = Event2.prototype;
950
- return _proto.addMetadata = function(section, keyOrObj, maybeVal) {
951
- return _$metadataDelegate_27.add(this._metadata, section, keyOrObj, maybeVal);
952
- }, _proto.setTraceCorrelation = function(traceId, spanId) {
953
- typeof traceId == "string" && (this._correlation = _extends({
954
- traceId
955
- }, typeof spanId == "string" ? {
956
- spanId
957
- } : {}));
958
- }, _proto.getGroupingDiscriminator = function() {
959
- return this._groupingDiscriminator;
960
- }, _proto.setGroupingDiscriminator = function(value) {
961
- var previousValue = this._groupingDiscriminator;
962
- return (typeof value == "string" || value === null || value === void 0) && (this._groupingDiscriminator = value), previousValue;
963
- }, _proto.getMetadata = function(section, key) {
964
- return _$metadataDelegate_27.get(this._metadata, section, key);
965
- }, _proto.clearMetadata = function(section, key) {
966
- return _$metadataDelegate_27.clear(this._metadata, section, key);
967
- }, _proto.addFeatureFlag = function(name2, variant) {
968
- variant === void 0 && (variant = null), _$featureFlagDelegate_23.add(this._features, this._featuresIndex, name2, variant);
969
- }, _proto.addFeatureFlags = function(featureFlags) {
970
- _$featureFlagDelegate_23.merge(this._features, featureFlags, this._featuresIndex);
971
- }, _proto.getFeatureFlags = function() {
972
- return _$featureFlagDelegate_23.toEventApi(this._features);
973
- }, _proto.clearFeatureFlag = function(name2) {
974
- _$featureFlagDelegate_23.clear(this._features, this._featuresIndex, name2);
975
- }, _proto.clearFeatureFlags = function() {
976
- this._features = [], this._featuresIndex = {};
977
- }, _proto.getUser = function() {
978
- return this._user;
979
- }, _proto.setUser = function(id, email, name2) {
980
- this._user = {
981
- id,
982
- email,
983
- name: name2
984
- };
985
- }, _proto.toJSON = function() {
986
- return {
987
- payloadVersion: "4",
988
- exceptions: _$map_21(this.errors, function(er) {
989
- return _$assign_16({}, er, {
990
- message: er.errorMessage
991
- });
992
- }),
993
- severity: this.severity,
994
- unhandled: this._handledState.unhandled,
995
- severityReason: this._handledState.severityReason,
996
- app: this.app,
997
- device: this.device,
998
- request: this.request,
999
- breadcrumbs: this.breadcrumbs,
1000
- context: this.context,
1001
- groupingHash: this.groupingHash,
1002
- groupingDiscriminator: this._groupingDiscriminator,
1003
- metaData: this._metadata,
1004
- user: this._user,
1005
- session: this._session,
1006
- featureFlags: this.getFeatureFlags(),
1007
- correlation: this._correlation
1008
- };
1009
- }, Event2;
1010
- })(), formatStackframe = function(frame) {
1011
- var f = {
1012
- file: frame.fileName,
1013
- method: normaliseFunctionName(frame.functionName),
1014
- lineNumber: frame.lineNumber,
1015
- columnNumber: frame.columnNumber,
1016
- code: void 0,
1017
- inProject: void 0
1018
- };
1019
- return f.lineNumber > -1 && !f.file && !f.method && (f.file = "global code"), f;
1020
- }, normaliseFunctionName = function(name2) {
1021
- return /^global code$/i.test(name2) ? "global code" : name2;
1022
- }, defaultHandledState = function() {
1023
- return {
1024
- unhandled: !1,
1025
- severity: "warning",
1026
- severityReason: {
1027
- type: "handledException"
1028
- }
1029
- };
1030
- }, ensureString = function(str) {
1031
- return typeof str == "string" ? str : "";
1032
- };
1033
- function createBugsnagError(errorClass, errorMessage, type, stacktrace) {
1034
- return {
1035
- errorClass: ensureString(errorClass),
1036
- errorMessage: ensureString(errorMessage),
1037
- type,
1038
- stacktrace: _$reduce_22(stacktrace, function(accum, frame) {
1039
- var f = formatStackframe(frame);
1040
- try {
1041
- return JSON.stringify(f) === "{}" ? accum : accum.concat(f);
1042
- } catch {
1043
- return accum;
1044
- }
1045
- }, [])
1046
- };
1047
- }
1048
- function getCauseStack(error) {
1049
- return error.cause ? [error].concat(getCauseStack(error.cause)) : [error];
1050
- }
1051
- Event.getStacktrace = function(error, errorFramesToSkip, backtraceFramesToSkip) {
1052
- if (_$hasStack_24(error)) return _$errorStackParser_15.parse(error).slice(errorFramesToSkip);
1053
- try {
1054
- return _$filter_17(StackGenerator.backtrace(), function(frame) {
1055
- return (frame.functionName || "").indexOf("StackGenerator$$") === -1;
1056
- }).slice(1 + backtraceFramesToSkip);
1057
- } catch {
1058
- return [];
1059
- }
1060
- }, Event.create = function(maybeError, tolerateNonErrors, handledState, component, errorFramesToSkip, logger) {
1061
- errorFramesToSkip === void 0 && (errorFramesToSkip = 0);
1062
- var _normaliseError = normaliseError(maybeError, tolerateNonErrors, component, logger), error = _normaliseError[0], internalFrames = _normaliseError[1], event;
1063
- try {
1064
- var stacktrace = Event.getStacktrace(
1065
- error,
1066
- // if an error was created/throw in the normaliseError() function, we need to
1067
- // tell the getStacktrace() function to skip the number of frames we know will
1068
- // be from our own functions. This is added to the number of frames deep we
1069
- // were told about
1070
- internalFrames > 0 ? 1 + internalFrames + errorFramesToSkip : 0,
1071
- // if there's no stacktrace, the callstack may be walked to generated one.
1072
- // this is how many frames should be removed because they come from our library
1073
- 1 + errorFramesToSkip
1074
- );
1075
- event = new Event(error.name, error.message, stacktrace, handledState, maybeError);
1076
- } catch {
1077
- event = new Event(error.name, error.message, [], handledState, maybeError);
1078
- }
1079
- if (error.name === "InvalidError" && event.addMetadata("" + component, "non-error parameter", makeSerialisable(maybeError)), error.cause) {
1080
- var _event$errors, causes = getCauseStack(error).slice(1), normalisedCauses = _$map_21(causes, function(cause) {
1081
- var stacktrace2 = _$iserror_25(cause) && _$hasStack_24(cause) ? _$errorStackParser_15.parse(cause) : [], _normaliseError2 = normaliseError(cause, !0, "error cause"), error2 = _normaliseError2[0];
1082
- return error2.name === "InvalidError" && event.addMetadata("error cause", makeSerialisable(cause)), createBugsnagError(error2.name, error2.message, Event.__type, stacktrace2);
1083
- });
1084
- (_event$errors = event.errors).push.apply(_event$errors, normalisedCauses);
1085
- }
1086
- return event;
1087
- };
1088
- var makeSerialisable = function(err) {
1089
- return err === null ? "null" : err === void 0 ? "undefined" : err;
1090
- }, normaliseError = function(maybeError, tolerateNonErrors, component, logger) {
1091
- var error, internalFrames = 0, createAndLogInputError = function(reason) {
1092
- var verb = component === "error cause" ? "was" : "received";
1093
- logger && logger.warn(component + " " + verb + ' a non-error: "' + reason + '"');
1094
- var err = new Error(component + " " + verb + ' a non-error. See "' + component + '" tab for more detail.');
1095
- return err.name = "InvalidError", err;
1096
- };
1097
- if (!tolerateNonErrors)
1098
- _$iserror_25(maybeError) ? error = maybeError : (error = createAndLogInputError(typeof maybeError), internalFrames += 2);
1099
- else
1100
- switch (typeof maybeError) {
1101
- case "string":
1102
- case "number":
1103
- case "boolean":
1104
- error = new Error(String(maybeError)), internalFrames += 1;
1105
- break;
1106
- case "function":
1107
- error = createAndLogInputError("function"), internalFrames += 2;
1108
- break;
1109
- case "object":
1110
- maybeError !== null && _$iserror_25(maybeError) ? error = maybeError : maybeError !== null && hasNecessaryFields(maybeError) ? (error = new Error(maybeError.message || maybeError.errorMessage), error.name = maybeError.name || maybeError.errorClass, internalFrames += 1) : (error = createAndLogInputError(maybeError === null ? "null" : "unsupported object"), internalFrames += 2);
1111
- break;
1112
- default:
1113
- error = createAndLogInputError("nothing"), internalFrames += 2;
1114
- }
1115
- if (!_$hasStack_24(error))
1116
- try {
1117
- throw error;
1118
- } catch (e) {
1119
- _$hasStack_24(e) && (error = e, internalFrames = 1);
1120
- }
1121
- return [error, internalFrames];
1122
- };
1123
- Event.__type = "browserjs";
1124
- var hasNecessaryFields = function(error) {
1125
- return (typeof error.name == "string" || typeof error.errorClass == "string") && (typeof error.message == "string" || typeof error.errorMessage == "string");
1126
- }, _$Event_10 = Event, _$asyncEvery_11 = function(arr, fn, cb) {
1127
- var index = 0, next = function() {
1128
- if (index >= arr.length) return cb(null, !0);
1129
- fn(arr[index], function(err, result) {
1130
- if (err) return cb(err);
1131
- if (result === !1) return cb(null, !1);
1132
- index++, next();
1133
- });
1134
- };
1135
- next();
1136
- }, _$callbackRunner_13 = function(callbacks, event, onCallbackError, cb) {
1137
- var runMaybeAsyncCallback = function(fn, cb2) {
1138
- if (typeof fn != "function") return cb2(null);
1139
- try {
1140
- if (fn.length !== 2) {
1141
- var ret = fn(event);
1142
- return ret && typeof ret.then == "function" ? ret.then(
1143
- // resolve
1144
- function(val) {
1145
- return setTimeout(function() {
1146
- return cb2(null, val);
1147
- });
1148
- },
1149
- // reject
1150
- function(err) {
1151
- setTimeout(function() {
1152
- return onCallbackError(err), cb2(null, !0);
1153
- });
1154
- }
1155
- ) : cb2(null, ret);
1156
- }
1157
- fn(event, function(err, result) {
1158
- if (err)
1159
- return onCallbackError(err), cb2(null);
1160
- cb2(null, result);
1161
- });
1162
- } catch (e) {
1163
- onCallbackError(e), cb2(null);
1164
- }
1165
- };
1166
- _$asyncEvery_11(callbacks, runMaybeAsyncCallback, cb);
1167
- }, _$syncCallbackRunner_30 = function(callbacks, callbackArg, callbackType, logger) {
1168
- for (var ignore = !1, cbs = callbacks.slice(); !ignore && cbs.length; )
1169
- try {
1170
- ignore = cbs.pop()(callbackArg) === !1;
1171
- } catch (e) {
1172
- logger.error("Error occurred in " + callbackType + " callback, continuing anyway\u2026"), logger.error(e);
1173
- }
1174
- return ignore;
1175
- }, _$pad_4 = function(num, size) {
1176
- var s = "000000000" + num;
1177
- return s.substr(s.length - size);
1178
- }, os = __require("os");
1179
- function getHostname() {
1180
- try {
1181
- return os.hostname();
1182
- } catch {
1183
- return process.env._CLUSTER_NETWORK_NAME_ || process.env.COMPUTERNAME || "hostname";
1184
- }
1185
- }
1186
- var padding = 2, pid = _$pad_4(process.pid.toString(36), padding), hostname = getHostname(), length = hostname.length, hostId = _$pad_4(hostname.split("").reduce(function(prev, char) {
1187
- return +prev + char.charCodeAt(0);
1188
- }, +length + 36).toString(36), padding), _$fingerprint_2 = function() {
1189
- return pid + hostId;
1190
- }, _$isCuid_3 = function(value) {
1191
- return typeof value == "string" && /^c[a-z0-9]{20,32}$/.test(value);
1192
- }, c = 0, blockSize = 4, base = 36, discreteValues = Math.pow(base, blockSize);
1193
- function randomBlock() {
1194
- return _$pad_4((Math.random() * discreteValues << 0).toString(base), blockSize);
1195
- }
1196
- function safeCounter() {
1197
- return c = c < discreteValues ? c : 0, c++, c - 1;
1198
- }
1199
- function cuid() {
1200
- var letter = "c", timestamp = (/* @__PURE__ */ new Date()).getTime().toString(base), counter = _$pad_4(safeCounter().toString(base), blockSize), print = _$fingerprint_2(), random = randomBlock() + randomBlock();
1201
- return letter + timestamp + counter + print + random;
1202
- }
1203
- cuid.fingerprint = _$fingerprint_2, cuid.isCuid = _$isCuid_3;
1204
- var _$cuid_1 = cuid, Session = /* @__PURE__ */ (function() {
1205
- function Session2() {
1206
- this.id = _$cuid_1(), this.startedAt = /* @__PURE__ */ new Date(), this._handled = 0, this._unhandled = 0, this._user = {}, this.app = {}, this.device = {};
1207
- }
1208
- var _proto = Session2.prototype;
1209
- return _proto.getUser = function() {
1210
- return this._user;
1211
- }, _proto.setUser = function(id, email, name2) {
1212
- this._user = {
1213
- id,
1214
- email,
1215
- name: name2
1216
- };
1217
- }, _proto.toJSON = function() {
1218
- return {
1219
- id: this.id,
1220
- startedAt: this.startedAt,
1221
- events: {
1222
- handled: this._handled,
1223
- unhandled: this._unhandled
1224
- }
1225
- };
1226
- }, _proto._track = function(event) {
1227
- this[event._handledState.unhandled ? "_unhandled" : "_handled"] += 1;
1228
- }, Session2;
1229
- })(), _$Session_34 = Session, __add_8 = _$featureFlagDelegate_23.add, __clear_8 = _$featureFlagDelegate_23.clear, __merge_8 = _$featureFlagDelegate_23.merge, HUB_PREFIX = "00000", HUB_NOTIFY = "https://notify.insighthub.smartbear.com", HUB_SESSION = "https://sessions.insighthub.smartbear.com", noop = function() {
1230
- }, Client = /* @__PURE__ */ (function() {
1231
- function Client2(configuration, schema2, internalPlugins2, notifier) {
1232
- var _this = this;
1233
- schema2 === void 0 && (schema2 = _$config_9.schema), internalPlugins2 === void 0 && (internalPlugins2 = []), this._notifier = notifier, this._config = {}, this._schema = schema2, this._delivery = {
1234
- sendSession: noop,
1235
- sendEvent: noop
1236
- }, this._logger = {
1237
- debug: noop,
1238
- info: noop,
1239
- warn: noop,
1240
- error: noop
1241
- }, this._plugins = {}, this._breadcrumbs = [], this._session = null, this._metadata = {}, this._featuresIndex = {}, this._features = [], this._context = void 0, this._user = {}, this._groupingDiscriminator = void 0, this._cbs = {
1242
- e: [],
1243
- s: [],
1244
- sp: [],
1245
- b: []
1246
- }, this.Client = Client2, this.Event = _$Event_10, this.Breadcrumb = _$Breadcrumb_7, this.Session = _$Session_34, this._config = this._configure(configuration, internalPlugins2), _$map_21(internalPlugins2.concat(this._config.plugins), function(pl) {
1247
- pl && _this._loadPlugin(pl);
1248
- }), this._depth = 1;
1249
- var self2 = this, notify = this.notify;
1250
- this.notify = function() {
1251
- return notify.apply(self2, arguments);
1252
- };
1253
- }
1254
- var _proto = Client2.prototype;
1255
- return _proto.addMetadata = function(section, keyOrObj, maybeVal) {
1256
- return _$metadataDelegate_27.add(this._metadata, section, keyOrObj, maybeVal);
1257
- }, _proto.getMetadata = function(section, key) {
1258
- return _$metadataDelegate_27.get(this._metadata, section, key);
1259
- }, _proto.clearMetadata = function(section, key) {
1260
- return _$metadataDelegate_27.clear(this._metadata, section, key);
1261
- }, _proto.addFeatureFlag = function(name2, variant) {
1262
- variant === void 0 && (variant = null), __add_8(this._features, this._featuresIndex, name2, variant);
1263
- }, _proto.addFeatureFlags = function(featureFlags) {
1264
- __merge_8(this._features, featureFlags, this._featuresIndex);
1265
- }, _proto.clearFeatureFlag = function(name2) {
1266
- __clear_8(this._features, this._featuresIndex, name2);
1267
- }, _proto.clearFeatureFlags = function() {
1268
- this._features = [], this._featuresIndex = {};
1269
- }, _proto.getContext = function() {
1270
- return this._context;
1271
- }, _proto.setContext = function(c2) {
1272
- this._context = c2;
1273
- }, _proto.getGroupingDiscriminator = function() {
1274
- return this._groupingDiscriminator;
1275
- }, _proto.setGroupingDiscriminator = function(value) {
1276
- var previousValue = this._groupingDiscriminator;
1277
- return (typeof value == "string" || value === null || value === void 0) && (this._groupingDiscriminator = value), previousValue;
1278
- }, _proto._configure = function(opts, internalPlugins2) {
1279
- var schema2 = _$reduce_22(internalPlugins2, function(schema3, plugin) {
1280
- return plugin && plugin.configSchema ? _$assign_16({}, schema3, plugin.configSchema) : schema3;
1281
- }, this._schema);
1282
- opts.endpoints || (opts.sendPayloadChecksums = "sendPayloadChecksums" in opts ? opts.sendPayloadChecksums : !0);
1283
- var _reduce = _$reduce_22(_$keys_20(schema2), function(accum, key) {
1284
- var defaultValue = schema2[key].defaultValue(opts[key]);
1285
- if (opts[key] !== void 0) {
1286
- var valid = schema2[key].validate(opts[key]);
1287
- valid ? schema2[key].allowPartialObject ? accum.config[key] = _$assign_16(defaultValue, opts[key]) : accum.config[key] = opts[key] : (accum.errors[key] = schema2[key].message, accum.config[key] = defaultValue);
1288
- } else
1289
- accum.config[key] = defaultValue;
1290
- return accum;
1291
- }, {
1292
- errors: {},
1293
- config: {}
1294
- }), errors = _reduce.errors, config = _reduce.config;
1295
- if (schema2.apiKey) {
1296
- if (!config.apiKey) throw new Error("No Bugsnag API Key set");
1297
- /^[0-9a-f]{32}$/i.test(config.apiKey) || (errors.apiKey = "should be a string of 32 hexadecimal characters"), opts.endpoints === void 0 && config.apiKey.startsWith(HUB_PREFIX) && (config.endpoints = {
1298
- notify: HUB_NOTIFY,
1299
- sessions: HUB_SESSION
1300
- });
1301
- }
1302
- return this._metadata = _$assign_16({}, config.metadata), __merge_8(this._features, config.featureFlags, this._featuresIndex), this._user = _$assign_16({}, config.user), this._context = config.context, config.logger && (this._logger = config.logger), config.onError && (this._cbs.e = this._cbs.e.concat(config.onError)), config.onBreadcrumb && (this._cbs.b = this._cbs.b.concat(config.onBreadcrumb)), config.onSession && (this._cbs.s = this._cbs.s.concat(config.onSession)), _$keys_20(errors).length && this._logger.warn(generateConfigErrorMessage(errors, opts)), config;
1303
- }, _proto.getUser = function() {
1304
- return this._user;
1305
- }, _proto.setUser = function(id, email, name2) {
1306
- this._user = {
1307
- id,
1308
- email,
1309
- name: name2
1310
- };
1311
- }, _proto._loadPlugin = function(plugin) {
1312
- var result = plugin.load(this);
1313
- plugin.name && (this._plugins["~" + plugin.name + "~"] = result);
1314
- }, _proto.getPlugin = function(name2) {
1315
- return this._plugins["~" + name2 + "~"];
1316
- }, _proto._setDelivery = function(d) {
1317
- this._delivery = d(this);
1318
- }, _proto.startSession = function() {
1319
- var session = new _$Session_34();
1320
- session.app.releaseStage = this._config.releaseStage, session.app.version = this._config.appVersion, session.app.type = this._config.appType, session._user = _$assign_16({}, this._user);
1321
- var ignore = _$syncCallbackRunner_30(this._cbs.s, session, "onSession", this._logger);
1322
- return ignore ? (this._logger.debug("Session not started due to onSession callback"), this) : this._sessionDelegate.startSession(this, session);
1323
- }, _proto.addOnError = function(fn, front) {
1324
- front === void 0 && (front = !1), this._cbs.e[front ? "unshift" : "push"](fn);
1325
- }, _proto.removeOnError = function(fn) {
1326
- this._cbs.e = _$filter_17(this._cbs.e, function(f) {
1327
- return f !== fn;
1328
- });
1329
- }, _proto._addOnSessionPayload = function(fn) {
1330
- this._cbs.sp.push(fn);
1331
- }, _proto.addOnSession = function(fn) {
1332
- this._cbs.s.push(fn);
1333
- }, _proto.removeOnSession = function(fn) {
1334
- this._cbs.s = _$filter_17(this._cbs.s, function(f) {
1335
- return f !== fn;
1336
- });
1337
- }, _proto.addOnBreadcrumb = function(fn, front) {
1338
- front === void 0 && (front = !1), this._cbs.b[front ? "unshift" : "push"](fn);
1339
- }, _proto.removeOnBreadcrumb = function(fn) {
1340
- this._cbs.b = _$filter_17(this._cbs.b, function(f) {
1341
- return f !== fn;
1342
- });
1343
- }, _proto.pauseSession = function() {
1344
- return this._sessionDelegate.pauseSession(this);
1345
- }, _proto.resumeSession = function() {
1346
- return this._sessionDelegate.resumeSession(this);
1347
- }, _proto.leaveBreadcrumb = function(message, metadata, type) {
1348
- if (message = typeof message == "string" ? message : "", type = typeof type == "string" && _$includes_18(_$breadcrumbTypes_12, type) ? type : "manual", metadata = typeof metadata == "object" && metadata !== null ? metadata : {}, !!message) {
1349
- var crumb = new _$Breadcrumb_7(message, metadata, type), ignore = _$syncCallbackRunner_30(this._cbs.b, crumb, "onBreadcrumb", this._logger);
1350
- if (ignore) {
1351
- this._logger.debug("Breadcrumb not attached due to onBreadcrumb callback");
1352
- return;
1353
- }
1354
- this._breadcrumbs.push(crumb), this._breadcrumbs.length > this._config.maxBreadcrumbs && (this._breadcrumbs = this._breadcrumbs.slice(this._breadcrumbs.length - this._config.maxBreadcrumbs));
1355
- }
1356
- }, _proto._isBreadcrumbTypeEnabled = function(type) {
1357
- var types = this._config.enabledBreadcrumbTypes;
1358
- return types === null || _$includes_18(types, type);
1359
- }, _proto.notify = function(maybeError, onError, postReportCallback) {
1360
- postReportCallback === void 0 && (postReportCallback = noop);
1361
- var event = _$Event_10.create(maybeError, !0, void 0, "notify()", this._depth + 1, this._logger);
1362
- this._notify(event, onError, postReportCallback);
1363
- }, _proto._notify = function(event, onError, postReportCallback) {
1364
- var _this2 = this;
1365
- if (postReportCallback === void 0 && (postReportCallback = noop), event.app = _$assign_16({}, event.app, {
1366
- releaseStage: this._config.releaseStage,
1367
- version: this._config.appVersion,
1368
- type: this._config.appType
1369
- }), event.context = event.context || this._context, event._metadata = _$assign_16({}, event._metadata, this._metadata), event._user = _$assign_16({}, event._user, this._user), event.breadcrumbs = this._breadcrumbs.slice(), event.setGroupingDiscriminator(this._groupingDiscriminator), __merge_8(event._features, this._features, event._featuresIndex), this._config.enabledReleaseStages !== null && !_$includes_18(this._config.enabledReleaseStages, this._config.releaseStage))
1370
- return this._logger.warn("Event not sent due to releaseStage/enabledReleaseStages configuration"), postReportCallback(null, event);
1371
- var originalSeverity = event.severity, onCallbackError = function(err) {
1372
- _this2._logger.error("Error occurred in onError callback, continuing anyway\u2026"), _this2._logger.error(err);
1373
- }, callbacks = [].concat(this._cbs.e).concat(onError);
1374
- _$callbackRunner_13(callbacks, event, onCallbackError, function(err, shouldSend) {
1375
- if (err && onCallbackError(err), !shouldSend)
1376
- return _this2._logger.debug("Event not sent due to onError callback"), postReportCallback(null, event);
1377
- _this2._isBreadcrumbTypeEnabled("error") && Client2.prototype.leaveBreadcrumb.call(_this2, event.errors[0].errorClass, {
1378
- errorClass: event.errors[0].errorClass,
1379
- errorMessage: event.errors[0].errorMessage,
1380
- severity: event.severity
1381
- }, "error"), originalSeverity !== event.severity && (event._handledState.severityReason = {
1382
- type: "userCallbackSetSeverity"
1383
- }), event.unhandled !== event._handledState.unhandled && (event._handledState.severityReason.unhandledOverridden = !0, event._handledState.unhandled = event.unhandled), _this2._session && (_this2._session._track(event), event._session = _this2._session), _this2._delivery.sendEvent({
1384
- apiKey: event.apiKey || _this2._config.apiKey,
1385
- notifier: _this2._notifier,
1386
- events: [event]
1387
- }, function(err2) {
1388
- return postReportCallback(err2, event);
1389
- });
1390
- });
1391
- }, Client2;
1392
- })(), generateConfigErrorMessage = function(errors, rawInput) {
1393
- var er = new Error(`Invalid configuration
1394
- ` + _$map_21(_$keys_20(errors), function(key) {
1395
- return " - " + key + " " + errors[key] + ", got " + stringify(rawInput[key]);
1396
- }).join(`
1397
-
1398
- `));
1399
- return er;
1400
- }, stringify = function(val) {
1401
- switch (typeof val) {
1402
- case "string":
1403
- case "number":
1404
- case "object":
1405
- return JSON.stringify(val);
1406
- default:
1407
- return String(val);
1408
- }
1409
- }, _$Client_8 = Client, _$jsonPayload_26 = {}, EVENT_REDACTION_PATHS = ["events.[].metaData", "events.[].breadcrumbs.[].metaData", "events.[].request"];
1410
- _$jsonPayload_26.event = function(event, redactedKeys) {
1411
- var payload = _$safeJsonStringify_5(event, null, null, {
1412
- redactedPaths: EVENT_REDACTION_PATHS,
1413
- redactedKeys
1414
- });
1415
- return payload.length > 1e6 && (event.events[0]._metadata = {
1416
- notifier: `WARNING!
1417
- Serialized payload was ` + payload.length / 1e6 + `MB (limit = 1MB)
1418
- metadata was removed`
1419
- }, payload = _$safeJsonStringify_5(event, null, null, {
1420
- redactedPaths: EVENT_REDACTION_PATHS,
1421
- redactedKeys
1422
- })), payload;
1423
- }, _$jsonPayload_26.session = function(session, redactedKeys) {
1424
- var payload = _$safeJsonStringify_5(session, null, null);
1425
- return payload;
1426
- };
1427
- var http = __require("http"), https = __require("https"), ___require_36 = __require("url"), parse = ___require_36.parse, _$request_36 = function(_ref, cb) {
1428
- var url2 = _ref.url, headers = _ref.headers, body = _ref.body, agent = _ref.agent, didError = !1, onError = function(err) {
1429
- didError || (didError = !0, cb(err));
1430
- }, parsedUrl = parse(url2), secure = parsedUrl.protocol === "https:", transport = secure ? https : http, req = transport.request({
1431
- method: "POST",
1432
- hostname: parsedUrl.hostname,
1433
- port: parsedUrl.port,
1434
- path: parsedUrl.path,
1435
- headers,
1436
- agent
1437
- });
1438
- req.on("error", onError), req.on("response", function(res) {
1439
- bufferResponse(res, function(err, body2) {
1440
- if (err) return onError(err);
1441
- if (res.statusCode < 200 || res.statusCode >= 300)
1442
- return onError(new Error("Bad statusCode from API: " + res.statusCode + `
1443
- ` + body2));
1444
- cb(null, body2);
1445
- });
1446
- }), req.write(body), req.end();
1447
- }, bufferResponse = function(stream, cb) {
1448
- var data = "";
1449
- stream.on("error", cb), stream.setEncoding("utf8"), stream.on("data", function(d) {
1450
- data += d;
1451
- }), stream.on("end", function() {
1452
- return cb(null, data);
1453
- });
1454
- }, _$delivery_35 = function(client) {
1455
- return {
1456
- sendEvent: function(event, cb) {
1457
- cb === void 0 && (cb = function() {
1458
- });
1459
- var body = _$jsonPayload_26.event(event, client._config.redactedKeys), _cb = function(err2) {
1460
- err2 && client._logger.error(`Event failed to send\u2026
1461
- ` + (err2 && err2.stack ? err2.stack : err2), err2), body.length > 1e6 && client._logger.warn("Event oversized (" + (body.length / 1e6).toFixed(2) + " MB)"), cb(err2);
1462
- };
1463
- if (client._config.endpoints.notify === null) {
1464
- var err = new Error("Event not sent due to incomplete endpoint configuration");
1465
- return _cb(err);
1466
- }
1467
- try {
1468
- _$request_36({
1469
- url: client._config.endpoints.notify,
1470
- headers: {
1471
- "Content-Type": "application/json",
1472
- "Bugsnag-Api-Key": event.apiKey || client._config.apiKey,
1473
- "Bugsnag-Payload-Version": "4",
1474
- "Bugsnag-Sent-At": (/* @__PURE__ */ new Date()).toISOString()
1475
- },
1476
- body,
1477
- agent: client._config.agent
1478
- }, function(err2, body2) {
1479
- return _cb(err2);
1480
- });
1481
- } catch (e) {
1482
- _cb(e);
1483
- }
1484
- },
1485
- sendSession: function(session, cb) {
1486
- cb === void 0 && (cb = function() {
1487
- });
1488
- var _cb = function(err2) {
1489
- err2 && client._logger.error(`Session failed to send\u2026
1490
- ` + (err2 && err2.stack ? err2.stack : err2), err2), cb(err2);
1491
- };
1492
- if (client._config.endpoints.session === null) {
1493
- var err = new Error("Session not sent due to incomplete endpoint configuration");
1494
- return _cb(err);
1495
- }
1496
- try {
1497
- _$request_36({
1498
- url: client._config.endpoints.sessions,
1499
- headers: {
1500
- "Content-Type": "application/json",
1501
- "Bugsnag-Api-Key": client._config.apiKey,
1502
- "Bugsnag-Payload-Version": "1",
1503
- "Bugsnag-Sent-At": (/* @__PURE__ */ new Date()).toISOString()
1504
- },
1505
- body: _$jsonPayload_26.session(session, client._config.redactedKeys),
1506
- agent: client._config.agent
1507
- }, function(err2) {
1508
- return _cb(err2);
1509
- });
1510
- } catch (e) {
1511
- _cb(e);
1512
- }
1513
- }
1514
- };
1515
- };
1516
- function ___extends_37() {
1517
- return ___extends_37 = Object.assign ? Object.assign.bind() : function(n) {
1518
- for (var e = 1; e < arguments.length; e++) {
1519
- var t = arguments[e];
1520
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
1521
- }
1522
- return n;
1523
- }, ___extends_37.apply(null, arguments);
1524
- }
1525
- var schema = _$config_9.schema, __os_37 = __require("os"), _require2 = __require("util"), inspect = _require2.inspect, _$config_37 = {
1526
- appType: ___extends_37({}, schema.appType, {
1527
- defaultValue: function() {
1528
- return "node";
1529
- }
1530
- }),
1531
- projectRoot: {
1532
- defaultValue: function() {
1533
- return process.cwd();
1534
- },
1535
- validate: function(value) {
1536
- return value === null || _$stringWithLength_33(value);
1537
- },
1538
- message: "should be string"
1539
- },
1540
- hostname: {
1541
- defaultValue: function() {
1542
- return __os_37.hostname();
1543
- },
1544
- message: "should be a string",
1545
- validate: function(value) {
1546
- return value === null || _$stringWithLength_33(value);
1547
- }
1548
- },
1549
- logger: ___extends_37({}, schema.logger, {
1550
- defaultValue: function() {
1551
- return getPrefixedConsole();
1552
- }
1553
- }),
1554
- releaseStage: ___extends_37({}, schema.releaseStage, {
1555
- defaultValue: function() {
1556
- return process.env.NODE_ENV || "production";
1557
- }
1558
- }),
1559
- agent: {
1560
- defaultValue: function() {
1561
- },
1562
- message: "should be an HTTP(s) agent",
1563
- validate: function(value) {
1564
- return value === void 0 || isAgent(value);
1565
- }
1566
- },
1567
- onUncaughtException: {
1568
- defaultValue: function() {
1569
- return function(err, event, logger) {
1570
- logger.error("Uncaught exception" + getContext(event) + `, the process will now terminate\u2026
1571
- ` + printError(err)), process.exit(1);
1572
- };
1573
- },
1574
- message: "should be a function",
1575
- validate: function(value) {
1576
- return typeof value == "function";
1577
- }
1578
- },
1579
- onUnhandledRejection: {
1580
- defaultValue: function() {
1581
- return function(err, event, logger) {
1582
- logger.error("Unhandled rejection" + getContext(event) + `\u2026
1583
- ` + printError(err));
1584
- };
1585
- },
1586
- message: "should be a function",
1587
- validate: function(value) {
1588
- return typeof value == "function";
1589
- }
1590
- }
1591
- }, printError = function(err) {
1592
- return err && err.stack ? err.stack : inspect(err);
1593
- }, getPrefixedConsole = function() {
1594
- return ["debug", "info", "warn", "error"].reduce(function(accum, method) {
1595
- var consoleMethod = console[method] || console.log;
1596
- return accum[method] = consoleMethod.bind(console, "[bugsnag]"), accum;
1597
- }, {});
1598
- }, getContext = function(event) {
1599
- return event.request && Object.keys(event.request).length ? " at " + event.request.httpMethod + " " + (event.request.path || event.request.url) : "";
1600
- }, isAgent = function(value) {
1601
- return typeof value == "object" && value !== null || typeof value == "boolean";
1602
- }, appStart = /* @__PURE__ */ new Date(), reset = function() {
1603
- appStart = /* @__PURE__ */ new Date();
1604
- }, _$app_39 = {
1605
- name: "appDuration",
1606
- load: function(client) {
1607
- return client.addOnError(function(event) {
1608
- var now = /* @__PURE__ */ new Date();
1609
- event.app.duration = now - appStart;
1610
- }, !0), {
1611
- reset
1612
- };
1613
- }
1614
- }, _$consoleBreadcrumbs_40 = {};
1615
- _$consoleBreadcrumbs_40.load = function(client) {
1616
- var isDev = /^(local-)?dev(elopment)?$/.test(client._config.releaseStage);
1617
- isDev || !client._isBreadcrumbTypeEnabled("log") || _$map_21(CONSOLE_LOG_METHODS, function(method) {
1618
- var original = console[method];
1619
- console[method] = function() {
1620
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)
1621
- args[_key] = arguments[_key];
1622
- client.leaveBreadcrumb("Console output", _$reduce_22(args, function(accum, arg, i) {
1623
- var stringified = "[Unknown value]";
1624
- try {
1625
- stringified = String(arg);
1626
- } catch {
1627
- }
1628
- if (stringified === "[object Object]")
1629
- try {
1630
- stringified = JSON.stringify(arg);
1631
- } catch {
1632
- }
1633
- return accum["[" + i + "]"] = stringified, accum;
1634
- }, {
1635
- severity: method.indexOf("group") === 0 ? "log" : method
1636
- }), "log"), original.apply(console, args);
1637
- }, console[method]._restore = function() {
1638
- console[method] = original;
1639
- };
1640
- });
1641
- }, process.env.NODE_ENV !== "production" && (_$consoleBreadcrumbs_40.destroy = function() {
1642
- return CONSOLE_LOG_METHODS.forEach(function(method) {
1643
- typeof console[method]._restore == "function" && console[method]._restore();
1644
- });
1645
- });
1646
- var CONSOLE_LOG_METHODS = _$filter_17(["log", "debug", "info", "warn", "error"], function(method) {
1647
- return typeof console < "u" && typeof console[method] == "function";
1648
- }), _$cloneClient_14 = {}, onCloneCallbacks = [];
1649
- _$cloneClient_14 = function(client) {
1650
- var clone = new client.Client({}, {}, [], client._notifier);
1651
- return clone._config = client._config, clone._breadcrumbs = client._breadcrumbs.slice(), clone._metadata = _$assign_16({}, client._metadata), clone._features = [].concat(client._features), clone._featuresIndex = _$assign_16({}, client._featuresIndex), clone._user = _$assign_16({}, client._user), clone._context = client._context, clone._cbs = {
1652
- e: client._cbs.e.slice(),
1653
- s: client._cbs.s.slice(),
1654
- sp: client._cbs.sp.slice(),
1655
- b: client._cbs.b.slice()
1656
- }, clone._logger = client._logger, clone._delivery = client._delivery, clone._sessionDelegate = client._sessionDelegate, onCloneCallbacks.forEach(function(callback) {
1657
- callback(clone);
1658
- }), clone;
1659
- }, _$cloneClient_14.registerCallback = function(callback) {
1660
- onCloneCallbacks.push(callback);
1661
- };
1662
- var _$nodeFallbackStack_28 = {};
1663
- _$nodeFallbackStack_28.getStack = function() {
1664
- return new Error().stack.split(`
1665
- `).slice(3).join(`
1666
- `);
1667
- }, _$nodeFallbackStack_28.maybeUseFallbackStack = function(err, fallbackStack) {
1668
- var lines = err.stack.split(`
1669
- `);
1670
- return (lines.length === 1 || lines.length === 2 && /at Error \(native\)/.test(lines[1])) && (err.stack = lines[0] + `
1671
- ` + fallbackStack), err;
1672
- };
1673
- var _$contextualize_41 = {}, getStack = _$nodeFallbackStack_28.getStack;
1674
- _$contextualize_41 = {
1675
- name: "contextualize",
1676
- load: function(client) {
1677
- var contextualize = function(fn, onError) {
1678
- var fallbackStack = getStack(), clonedClient = _$cloneClient_14(client);
1679
- clonedClient.fallbackStack = fallbackStack, clonedClient.addOnError(onError), client._clientContext.run(clonedClient, fn);
1680
- };
1681
- return contextualize;
1682
- }
1683
- }, _$contextualize_41.default = _$contextualize_41;
1684
- var _$intercept_42 = {}, __getStack_42 = _$nodeFallbackStack_28.getStack, maybeUseFallbackStack = _$nodeFallbackStack_28.maybeUseFallbackStack;
1685
- _$intercept_42 = {
1686
- name: "intercept",
1687
- load: function(client) {
1688
- var intercept = function(onError, cb) {
1689
- onError === void 0 && (onError = function() {
1690
- }), typeof cb != "function" && (cb = onError, onError = function() {
1691
- });
1692
- var fallbackStack = __getStack_42();
1693
- return function(err) {
1694
- if (err) {
1695
- err.stack && maybeUseFallbackStack(err, fallbackStack);
1696
- var event = client.Event.create(err, !0, {
1697
- severity: "warning",
1698
- unhandled: !1,
1699
- severityReason: {
1700
- type: "callbackErrorIntercept"
1701
- }
1702
- }, "intercept()", 1);
1703
- client._notify(event, onError);
1704
- return;
1705
- }
1706
- for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)
1707
- data[_key - 1] = arguments[_key];
1708
- cb.apply(void 0, data);
1709
- };
1710
- };
1711
- return intercept;
1712
- }
1713
- }, _$intercept_42.default = _$intercept_42;
1714
- function ___extends_43() {
1715
- return ___extends_43 = Object.assign ? Object.assign.bind() : function(n) {
1716
- for (var e = 1; e < arguments.length; e++) {
1717
- var t = arguments[e];
1718
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
1719
- }
1720
- return n;
1721
- }, ___extends_43.apply(null, arguments);
1722
- }
1723
- var __os_43 = __require("os"), _$device_43 = {
1724
- load: function(client) {
1725
- var device = {
1726
- osName: __os_43.platform() + " (" + __os_43.arch() + ")",
1727
- osVersion: __os_43.release(),
1728
- totalMemory: __os_43.totalmem(),
1729
- hostname: client._config.hostname,
1730
- runtimeVersions: {
1731
- node: process.versions.node
1732
- }
1733
- };
1734
- client._addOnSessionPayload(function(sp) {
1735
- sp.device = ___extends_43({}, sp.device, device);
1736
- }), client.addOnError(function(event) {
1737
- event.device = ___extends_43({}, event.device, device, {
1738
- freeMemory: __os_43.freemem(),
1739
- time: /* @__PURE__ */ new Date()
1740
- });
1741
- }, !0);
1742
- }
1743
- }, ___require_29 = __require("path"), join = ___require_29.join, resolve = ___require_29.resolve, _$pathNormalizer_29 = function(p) {
1744
- return join(resolve(p), "/");
1745
- }, _$inProject_44 = {
1746
- load: function(client) {
1747
- return client.addOnError(function(event) {
1748
- if (client._config.projectRoot) {
1749
- var projectRoot = _$pathNormalizer_29(client._config.projectRoot), allFrames = event.errors.reduce(function(accum, er) {
1750
- return accum.concat(er.stacktrace);
1751
- }, []);
1752
- allFrames.map(function(stackframe) {
1753
- stackframe.inProject = typeof stackframe.file == "string" && stackframe.file.indexOf(projectRoot) === 0 && !/\/node_modules\//.test(stackframe.file);
1754
- });
1755
- }
1756
- });
1757
- }
1758
- };
1759
- function ___extends_45() {
1760
- return ___extends_45 = Object.assign ? Object.assign.bind() : function(n) {
1761
- for (var e = 1; e < arguments.length; e++) {
1762
- var t = arguments[e];
1763
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
1764
- }
1765
- return n;
1766
- }, ___extends_45.apply(null, arguments);
1767
- }
1768
- function _inheritsLoose(t, o) {
1769
- t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
1770
- }
1771
- function _setPrototypeOf(t, e) {
1772
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t2, e2) {
1773
- return t2.__proto__ = e2, t2;
1774
- }, _setPrototypeOf(t, e);
1775
- }
1776
- var SURROUNDING_LINES = 3, MAX_LINE_LENGTH = 200, ___require_45 = __require("fs"), createReadStream = ___require_45.createReadStream, ___require2_45 = __require("stream"), Writable = ___require2_45.Writable, pump = require_pump(), byline = require_byline(), path = __require("path"), _$surroundingCode_45 = {
1777
- load: function(client) {
1778
- if (client._config.sendCode) {
1779
- var loadSurroundingCode = function(stackframe, cache) {
1780
- return new Promise(function(resolve2, reject) {
1781
- try {
1782
- if (!stackframe.lineNumber || !stackframe.file) return resolve2(stackframe);
1783
- var file = path.resolve(client._config.projectRoot, stackframe.file), cacheKey = file + "@" + stackframe.lineNumber;
1784
- if (cacheKey in cache)
1785
- return stackframe.code = cache[cacheKey], resolve2(stackframe);
1786
- getSurroundingCode(file, stackframe.lineNumber, function(err, code) {
1787
- return err || (stackframe.code = cache[cacheKey] = code), resolve2(stackframe);
1788
- });
1789
- } catch {
1790
- return resolve2(stackframe);
1791
- }
1792
- });
1793
- };
1794
- client.addOnError(function(event) {
1795
- return new Promise(function(resolve2, reject) {
1796
- var cache = /* @__PURE__ */ Object.create(null), allFrames = event.errors.reduce(function(accum, er) {
1797
- return accum.concat(er.stacktrace);
1798
- }, []);
1799
- pMapSeries(allFrames.map(function(stackframe) {
1800
- return function() {
1801
- return loadSurroundingCode(stackframe, cache);
1802
- };
1803
- })).then(resolve2).catch(reject);
1804
- });
1805
- });
1806
- }
1807
- },
1808
- configSchema: {
1809
- sendCode: {
1810
- defaultValue: function() {
1811
- return !0;
1812
- },
1813
- validate: function(value) {
1814
- return value === !0 || value === !1;
1815
- },
1816
- message: "should be true or false"
1817
- }
1818
- }
1819
- }, getSurroundingCode = function(file, lineNumber, cb) {
1820
- var start = lineNumber - SURROUNDING_LINES, end = lineNumber + SURROUNDING_LINES, reader = createReadStream(file, {
1821
- encoding: "utf8"
1822
- }), splitter = new byline.LineStream({
1823
- keepEmptyLines: !0
1824
- }), slicer = new CodeRange({
1825
- start,
1826
- end
1827
- });
1828
- slicer.on("done", function() {
1829
- return reader.destroy();
1830
- }), pump(reader, splitter, slicer, function(err) {
1831
- if (err && err.message !== "premature close") return cb(err);
1832
- cb(null, slicer.getCode());
1833
- });
1834
- }, CodeRange = /* @__PURE__ */ (function(_Writable) {
1835
- function CodeRange2(opts) {
1836
- var _this;
1837
- return _this = _Writable.call(this, ___extends_45({}, opts, {
1838
- decodeStrings: !1
1839
- })) || this, _this._start = opts.start, _this._end = opts.end, _this._n = 0, _this._code = {}, _this;
1840
- }
1841
- _inheritsLoose(CodeRange2, _Writable);
1842
- var _proto = CodeRange2.prototype;
1843
- return _proto._write = function(chunk, enc, cb) {
1844
- return this._n++, this._n < this._start ? cb(null) : this._n <= this._end ? (this._code[String(this._n)] = chunk.length <= MAX_LINE_LENGTH ? chunk : chunk.substr(0, MAX_LINE_LENGTH), cb(null)) : (this.emit("done"), cb(null));
1845
- }, _proto.getCode = function() {
1846
- return this._code;
1847
- }, CodeRange2;
1848
- })(Writable), pMapSeries = function(ps) {
1849
- return new Promise(function(resolve2, reject) {
1850
- var res = [];
1851
- ps.reduce(function(accum, p) {
1852
- return accum.then(function(r) {
1853
- return res.push(r), p();
1854
- });
1855
- }, Promise.resolve()).then(function(r) {
1856
- res.push(r);
1857
- }).then(function() {
1858
- resolve2(res.slice(1));
1859
- });
1860
- });
1861
- }, __maybeUseFallbackStack_46 = _$nodeFallbackStack_28.maybeUseFallbackStack, _handler, _$uncaughtException_46 = {
1862
- load: function(client) {
1863
- client._config.autoDetectErrors && client._config.enabledErrorTypes.unhandledExceptions && (_handler = function(err) {
1864
- var ctx = client._clientContext && client._clientContext.getStore(), c2 = ctx || client;
1865
- err.stack && c2.fallbackStack && __maybeUseFallbackStack_46(err, c2.fallbackStack);
1866
- var event = c2.Event.create(err, !1, {
1867
- severity: "error",
1868
- unhandled: !0,
1869
- severityReason: {
1870
- type: "unhandledException"
1871
- }
1872
- }, "uncaughtException handler", 1);
1873
- return new Promise(function(resolve2) {
1874
- c2._notify(event, function() {
1875
- }, function(e, event2) {
1876
- e && c2._logger.error("Failed to send event to Bugsnag"), c2._config.onUncaughtException(err, event2, c2._logger), resolve2();
1877
- });
1878
- });
1879
- }, process.prependListener("uncaughtException", _handler));
1880
- },
1881
- destroy: function() {
1882
- process.removeListener("uncaughtException", _handler);
1883
- }
1884
- }, ___handler_47, _$unhandledRejection_47 = {
1885
- load: function(client) {
1886
- !client._config.autoDetectErrors || !client._config.enabledErrorTypes.unhandledRejections || (___handler_47 = function(err) {
1887
- var ctx = client._clientContext && client._clientContext.getStore(), c2 = ctx || client, unhandled = !client._config.reportUnhandledPromiseRejectionsAsHandled, event = c2.Event.create(err, !1, {
1888
- severity: "error",
1889
- unhandled,
1890
- severityReason: {
1891
- type: "unhandledPromiseRejection"
1892
- }
1893
- }, "unhandledRejection handler", 1);
1894
- return new Promise(function(resolve2) {
1895
- c2._notify(event, function() {
1896
- }, function(e, event2) {
1897
- e && c2._logger.error("Failed to send event to Bugsnag"), c2._config.onUnhandledRejection(err, event2, c2._logger), resolve2();
1898
- });
1899
- });
1900
- }, process.prependListener ? process.prependListener("unhandledRejection", ___handler_47) : process.on("unhandledRejection", ___handler_47));
1901
- },
1902
- destroy: function() {
1903
- process.removeListener("unhandledRejection", ___handler_47);
1904
- }
1905
- }, _$Backoff_6 = Backoff;
1906
- function Backoff(opts) {
1907
- opts = opts || {}, this.ms = opts.min || 100, this.max = opts.max || 1e4, this.factor = opts.factor || 2, this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0, this.attempts = 0;
1908
- }
1909
- Backoff.prototype.duration = function() {
1910
- var ms = this.ms * Math.pow(this.factor, this.attempts++);
1911
- if (this.jitter) {
1912
- var rand = Math.random(), deviation = Math.floor(rand * this.jitter * ms);
1913
- ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
1914
- }
1915
- return Math.min(ms, this.max) | 0;
1916
- }, Backoff.prototype.reset = function() {
1917
- this.attempts = 0;
1918
- };
1919
- function ___inheritsLoose_49(t, o) {
1920
- t.prototype = Object.create(o.prototype), t.prototype.constructor = t, ___setPrototypeOf_49(t, o);
1921
- }
1922
- function ___setPrototypeOf_49(t, e) {
1923
- return ___setPrototypeOf_49 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t2, e2) {
1924
- return t2.__proto__ = e2, t2;
1925
- }, ___setPrototypeOf_49(t, e);
1926
- }
1927
- var DEFAULT_SUMMARY_INTERVAL = 10 * 1e3, Emitter = __require("events").EventEmitter, _$tracker_49 = /* @__PURE__ */ (function(_Emitter) {
1928
- function SessionTracker(intervalLength) {
1929
- var _this;
1930
- return _this = _Emitter.call(this) || this, _this._sessions = /* @__PURE__ */ new Map(), _this._interval = null, _this._intervalLength = intervalLength || DEFAULT_SUMMARY_INTERVAL, _this._summarize = _this._summarize.bind(_this), _this;
1931
- }
1932
- ___inheritsLoose_49(SessionTracker, _Emitter);
1933
- var _proto = SessionTracker.prototype;
1934
- return _proto.start = function() {
1935
- this._interval || (this._interval = setInterval(this._summarize, this._intervalLength).unref());
1936
- }, _proto.stop = function() {
1937
- clearInterval(this._interval), this._interval = null;
1938
- }, _proto.track = function(session) {
1939
- var key = dateToMsKey(session.startedAt), cur = this._sessions.get(key);
1940
- return this._sessions.set(key, typeof cur > "u" ? 1 : cur + 1), session;
1941
- }, _proto._summarize = function() {
1942
- var _this2 = this, summary = [];
1943
- this._sessions.forEach(function(val, key) {
1944
- summary.push({
1945
- startedAt: key,
1946
- sessionsStarted: val
1947
- }), _this2._sessions.delete(key);
1948
- }), summary.length && this.emit("summary", summary);
1949
- }, SessionTracker;
1950
- })(Emitter), dateToMsKey = function(d) {
1951
- var dk = new Date(d);
1952
- return dk.setSeconds(0), dk.setMilliseconds(0), dk.toISOString();
1953
- }, _$session_48 = {
1954
- load: function(client) {
1955
- var sessionTracker = new _$tracker_49(client._config.sessionSummaryInterval);
1956
- sessionTracker.on("summary", sendSessionSummary(client)), sessionTracker.start(), client._sessionDelegate = {
1957
- startSession: function(client2, session) {
1958
- return client2._session = session, client2._pausedSession = null, sessionTracker.track(client2._session), client2;
1959
- },
1960
- pauseSession: function(client2) {
1961
- client2._pausedSession = client2._session, client2._session = null;
1962
- },
1963
- resumeSession: function(client2) {
1964
- return client2._session ? client2 : client2._pausedSession ? (client2._session = client2._pausedSession, client2._pausedSession = null, client2) : client2.startSession();
1965
- }
1966
- };
1967
- },
1968
- configSchema: {
1969
- sessionSummaryInterval: {
1970
- defaultValue: function() {
1971
- },
1972
- validate: function(value) {
1973
- return value === void 0 || _$intRange_31()(value);
1974
- },
1975
- message: "should be a positive integer"
1976
- }
1977
- }
1978
- }, sendSessionSummary = function(client) {
1979
- return function(sessionCounts) {
1980
- if (client._config.enabledReleaseStages !== null && !client._config.enabledReleaseStages.includes(client._config.releaseStage)) {
1981
- client._logger.warn("Session not sent due to releaseStage/enabledReleaseStages configuration");
1982
- return;
1983
- }
1984
- if (!sessionCounts.length) return;
1985
- var backoff = new _$Backoff_6({
1986
- min: 1e3,
1987
- max: 1e4
1988
- }), maxAttempts = 10;
1989
- req(handleRes);
1990
- function handleRes(err) {
1991
- if (!err) {
1992
- var sessionCount = sessionCounts.reduce(function(accum, s) {
1993
- return accum + s.sessionsStarted;
1994
- }, 0);
1995
- return client._logger.debug(sessionCount + " session(s) reported");
1996
- }
1997
- if (backoff.attempts === 10) {
1998
- client._logger.error("Session delivery failed, max retries exceeded", err);
1999
- return;
2000
- }
2001
- client._logger.debug("Session delivery failed, retry #" + (backoff.attempts + 1) + "/" + maxAttempts, err), setTimeout(function() {
2002
- return req(handleRes);
2003
- }, backoff.duration());
2004
- }
2005
- function req(cb) {
2006
- var payload = {
2007
- notifier: client._notifier,
2008
- device: {},
2009
- app: {
2010
- releaseStage: client._config.releaseStage,
2011
- version: client._config.appVersion,
2012
- type: client._config.appType
2013
- },
2014
- sessionCounts
2015
- }, ignore = _$syncCallbackRunner_30(client._cbs.sp, payload, "onSessionPayload", client._logger);
2016
- if (ignore)
2017
- return client._logger.debug("Session not sent due to onSessionPayload callback"), cb(null);
2018
- client._delivery.sendSession(payload, cb);
2019
- }
2020
- };
2021
- }, _$pathNormaliser_50 = {
2022
- load: function(client) {
2023
- client.addOnError(function(event) {
2024
- var allFrames = event.errors.reduce(function(accum, er) {
2025
- return accum.concat(er.stacktrace);
2026
- }, []);
2027
- allFrames.forEach(function(stackframe) {
2028
- typeof stackframe.file == "string" && (stackframe.file = stackframe.file.replace(/\\/g, "/"));
2029
- });
2030
- });
2031
- }
2032
- }, _$stripProjectRoot_51 = {
2033
- load: function(client) {
2034
- return client.addOnError(function(event) {
2035
- if (client._config.projectRoot) {
2036
- var projectRoot = _$pathNormalizer_29(client._config.projectRoot), allFrames = event.errors.reduce(function(accum, er) {
2037
- return accum.concat(er.stacktrace);
2038
- }, []);
2039
- allFrames.map(function(stackframe) {
2040
- typeof stackframe.file == "string" && stackframe.file.indexOf(projectRoot) === 0 && (stackframe.file = stackframe.file.replace(projectRoot, ""));
2041
- });
2042
- }
2043
- });
2044
- }
2045
- }, _$notifier_38 = {};
2046
- function ___extends_38() {
2047
- return ___extends_38 = Object.assign ? Object.assign.bind() : function(n) {
2048
- for (var e = 1; e < arguments.length; e++) {
2049
- var t = arguments[e];
2050
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
2051
- }
2052
- return n;
2053
- }, ___extends_38.apply(null, arguments);
2054
- }
2055
- var name = "Bugsnag Node", version = "8.6.0", url = "https://github.com/bugsnag/bugsnag-js", ___require_38 = __require("async_hooks"), AsyncLocalStorage = ___require_38.AsyncLocalStorage;
2056
- _$Event_10.__type = "nodejs";
2057
- var __schema_38 = ___extends_38({}, _$config_9.schema, _$config_37), internalPlugins = [_$app_39, _$surroundingCode_45, _$inProject_44, _$stripProjectRoot_51, _$session_48, _$device_43, _$uncaughtException_46, _$unhandledRejection_47, _$intercept_42, _$contextualize_41, _$pathNormaliser_50, _$consoleBreadcrumbs_40], Bugsnag2 = {
2058
- _client: null,
2059
- createClient: function(opts) {
2060
- typeof opts == "string" && (opts = {
2061
- apiKey: opts
2062
- }), opts || (opts = {});
2063
- var bugsnag = new _$Client_8(opts, __schema_38, internalPlugins, {
2064
- name,
2065
- version,
2066
- url
2067
- });
2068
- return Object.keys(_$Client_8.prototype).forEach(function(m) {
2069
- var original = bugsnag[m];
2070
- bugsnag[m] = function() {
2071
- var contextClient = bugsnag._clientContext && typeof bugsnag._clientContext.getStore == "function" ? bugsnag._clientContext.getStore() : null, client = contextClient || bugsnag, originalMethod = contextClient ? contextClient[m] : original;
2072
- client._depth += 1;
2073
- var ret = originalMethod.apply(client, arguments);
2074
- return client._depth -= 1, ret;
2075
- };
2076
- }), bugsnag._clientContext = new AsyncLocalStorage(), bugsnag._setDelivery(_$delivery_35), bugsnag._logger.debug("Loaded!"), bugsnag;
2077
- },
2078
- start: function(opts) {
2079
- return Bugsnag2._client ? (Bugsnag2._client._logger.warn("Bugsnag.start() was called more than once. Ignoring."), Bugsnag2._client) : (Bugsnag2._client = Bugsnag2.createClient(opts), Bugsnag2._client);
2080
- },
2081
- isStarted: function() {
2082
- return Bugsnag2._client != null;
2083
- }
2084
- };
2085
- return Object.keys(_$Client_8.prototype).forEach(function(m) {
2086
- /^_/.test(m) || (Bugsnag2[m] = function() {
2087
- var client = Bugsnag2._client, ctx = client && client._clientContext && client._clientContext.getStore();
2088
- if (ctx && (client = ctx), !client) return console.error("Bugsnag." + m + "() was called before Bugsnag.start()");
2089
- client._depth += 1;
2090
- var ret = client[m].apply(client, arguments);
2091
- return client._depth -= 1, ret;
2092
- });
2093
- }), _$notifier_38 = Bugsnag2, _$notifier_38.Client = _$Client_8, _$notifier_38.Event = _$Event_10, _$notifier_38.Session = _$Session_34, _$notifier_38.Breadcrumb = _$Breadcrumb_7, _$notifier_38.default = Bugsnag2, _$notifier_38;
2094
- });
2095
- }
2096
- });
2097
-
2098
- // ../../node_modules/.pnpm/@bugsnag+js@8.6.0/node_modules/@bugsnag/js/node/notifier.js
2099
- var require_notifier = __commonJS({
2100
- "../../node_modules/.pnpm/@bugsnag+js@8.6.0/node_modules/@bugsnag/js/node/notifier.js"(exports, module) {
2101
- init_cjs_shims();
2102
- module.exports = require_bugsnag();
2103
- }
2104
- });
2105
-
2106
- // ../cli-kit/dist/public/node/error-handler.js
2107
- init_cjs_shims();
2108
- var import_core = __toESM(require_lib(), 1), import_stacktracey = __toESM(require_stacktracey(), 1), import_js = __toESM(require_notifier(), 1);
2109
- import { realpath } from "fs/promises";
2110
- var ALLOWED_SLICE_NAMES = /* @__PURE__ */ new Set(["app", "theme", "hydrogen", "store"]);
2111
- async function errorHandler(error, config) {
2112
- if (error instanceof CancelExecution)
2113
- error.message && error.message !== "" && outputInfo(`\u2728 ${error.message}`);
2114
- else if (!(error instanceof AbortSilentError))
2115
- return errorMapper(error).then((error2) => handler(error2)).then((mappedError) => reportError(mappedError, config));
2116
- }
2117
- var reportError = async (error, config) => {
2118
- let exitMode = "expected_error";
2119
- shouldReportErrorAsUnexpected(error) && (exitMode = "unexpected_error"), config !== void 0 && await reportAnalyticsEvent({ config, errorMessage: error instanceof Error ? error.message : void 0, exitMode }), await sendErrorToBugsnag(error, exitMode);
2120
- };
2121
- async function sendErrorToBugsnag(error, exitMode) {
2122
- try {
2123
- if (isLocalEnvironment() || import_core.settings.debug)
2124
- return outputDebug("Skipping Bugsnag report"), { reported: !1, error, unhandled: void 0 };
2125
- let unhandled = exitMode === "unexpected_error", reportableError, stacktrace, report = !1;
2126
- error instanceof Error ? (report = !0, reportableError = new Error(error.message), stacktrace = error.stack) : typeof error == "string" && error.trim().length !== 0 ? (report = !0, reportableError = new Error(error), stacktrace = reportableError.stack) : (report = !1, reportableError = new Error("Unknown error"));
2127
- let formattedStacktrace = new import_stacktracey.default(stacktrace ?? "").clean().items.map((item) => {
2128
- let filePath = cleanSingleStackTracePath(item.file);
2129
- return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
2130
- }).join(`
2131
- `);
2132
- reportableError.stack = `Error: ${reportableError.message}
2133
- ${formattedStacktrace}`;
2134
- let withinRateLimit = !1;
2135
- if (await runWithRateLimit({
2136
- key: "send-error-to-bugsnag",
2137
- ...reportingRateLimit,
2138
- task: async () => {
2139
- withinRateLimit = !0;
2140
- }
2141
- }), withinRateLimit || (outputDebug("Skipping Bugsnag report due to rate limiting"), report = !1), report) {
2142
- initializeBugsnag();
2143
- let userId = await getLastSeenUserIdAfterAuth();
2144
- await new Promise((resolve, reject) => {
2145
- outputDebug(`Reporting ${unhandled ? "unhandled" : "handled"} error to Bugsnag: ${reportableError.message}`);
2146
- let eventHandler = (event) => {
2147
- event.severity = "error", event.unhandled = unhandled, event.setUser(userId);
2148
- let { commandStartOptions } = getAllSensitiveMetadata(), { startCommand } = commandStartOptions ?? {};
2149
- if (startCommand) {
2150
- let firstWord = startCommand.trim().split(/\s+/)[0] ?? "cli", sliceName = ALLOWED_SLICE_NAMES.has(firstWord) ? firstWord : "cli";
2151
- event.addMetadata("custom", { slice_name: sliceName });
2152
- }
2153
- }, errorHandler2 = (error2) => {
2154
- error2 ? reject(error2) : resolve(reportableError);
2155
- };
2156
- import_js.default.notify(reportableError, eventHandler, errorHandler2);
2157
- });
2158
- }
2159
- return { error: reportableError, reported: report, unhandled };
2160
- } catch (err) {
2161
- return outputDebug(`Error reporting to Bugsnag: ${err}`), { error, reported: !1, unhandled: void 0 };
2162
- }
2163
- }
2164
- function cleanStackFrameFilePath({ currentFilePath, projectRoot, pluginLocations }) {
2165
- let fullLocation = isAbsolutePath(currentFilePath) ? currentFilePath : joinPath(projectRoot, currentFilePath), matchingPluginPath = pluginLocations.filter(({ pluginPath }) => fullLocation.startsWith(pluginPath))[0];
2166
- return matchingPluginPath !== void 0 ? joinPath(matchingPluginPath.name, relativePath(matchingPluginPath.pluginPath, fullLocation)) : currentFilePath.replace(/.*node_modules\//, "");
2167
- }
2168
- async function registerCleanBugsnagErrorsFromWithinPlugins(config) {
2169
- let bugsnagConfigProjectRoot = import_js.default?._client?._config?.projectRoot ?? cwd(), projectRoot = normalizePath(bugsnagConfigProjectRoot), pluginLocations = await Promise.all([...config.plugins].map(async ([_, plugin]) => {
2170
- let followSymlinks = await realpath(plugin.root);
2171
- return { name: plugin.name, pluginPath: normalizePath(followSymlinks) };
2172
- }));
2173
- initializeBugsnag(), import_js.default.addOnError(async (event) => {
2174
- event.errors.forEach((error) => {
2175
- error.stacktrace.forEach((stackFrame) => {
2176
- stackFrame.file = cleanStackFrameFilePath({ currentFilePath: stackFrame.file, projectRoot, pluginLocations });
2177
- });
2178
- });
2179
- try {
2180
- await addBugsnagMetadata(event, config);
2181
- } catch (metadataError) {
2182
- outputDebug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`);
2183
- }
2184
- });
2185
- }
2186
- async function addBugsnagMetadata(event, config) {
2187
- let publicData = getAllPublicMetadata(), { commandStartOptions } = getAllSensitiveMetadata(), { startCommand } = commandStartOptions ?? {}, { "@shopify/app": appPublic, ...otherPluginsPublic } = await fanoutHooks(config, "public_command_metadata", {}), environment = await getEnvironmentData(config), allMetadata = {
2188
- command: startCommand,
2189
- ...appPublic,
2190
- ...publicData,
2191
- ...environment,
2192
- pluginData: otherPluginsPublic
2193
- }, appData = {}, commandData = {}, environmentData = {}, miscData = {}, appKeys = ["api_key", "business_platform_id", "partner_id", "project_type"], commandKeys = ["command"], environmentKeys = ["cli_version", "node_version", "uname"];
2194
- Object.entries(allMetadata).forEach(([key, value]) => {
2195
- key.startsWith("app_") || appKeys.includes(key) ? appData[key] = value : key.startsWith("cmd_") || commandKeys.includes(key) ? commandData[key] = value : key.startsWith("env_") || environmentKeys ? environmentData[key] = value : miscData[key] = value;
2196
- }), Object.entries({
2197
- "Shopify App": appData,
2198
- Command: commandData,
2199
- Environment: environmentData,
2200
- Misc: miscData
2201
- }).forEach(([section, values]) => {
2202
- event.addMetadata(section, values);
2203
- });
2204
- }
2205
- function initializeBugsnag() {
2206
- import_js.default.isStarted() || import_js.default.start({
2207
- appType: "node",
2208
- apiKey: bugsnagApiKey,
2209
- logger: null,
2210
- appVersion: CLI_KIT_VERSION,
2211
- autoTrackSessions: !1,
2212
- autoDetectErrors: !1,
2213
- enabledReleaseStages: ["production"],
2214
- endpoints: {
2215
- notify: "https://error-analytics-production.shopifysvc.com",
2216
- sessions: "https://error-analytics-sessions-production.shopifysvc.com"
2217
- },
2218
- // Set the project root to `null` to prevent the default behavior of
2219
- // Bugsnag which is to set it to the cwd. That is unhelpful for us because
2220
- // the cwd can be anywhere in the user's filesystem, not necessarily
2221
- // related to the CLI codebase.
2222
- projectRoot: null
2223
- });
2224
- }
2225
-
2226
- export {
2227
- require_end_of_stream,
2228
- errorHandler,
2229
- sendErrorToBugsnag,
2230
- cleanStackFrameFilePath,
2231
- registerCleanBugsnagErrorsFromWithinPlugins,
2232
- addBugsnagMetadata
2233
- };
2234
- //# sourceMappingURL=chunk-2DEP3RXL.js.map