@weaveui/web 0.0.1

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 (46) hide show
  1. package/LICENSE +35 -0
  2. package/README.md +119 -0
  3. package/THIRD_PARTY_NOTICES +29 -0
  4. package/dist/apm-log.es.js +996 -0
  5. package/dist/apm-log.umd.cjs +1 -0
  6. package/dist/business/apm-log/behavior-directive.d.ts +9 -0
  7. package/dist/business/apm-log/behavior-log.d.ts +6 -0
  8. package/dist/business/apm-log/behavior-types.d.ts +121 -0
  9. package/dist/business/apm-log/browser.d.ts +3 -0
  10. package/dist/business/apm-log/directive.d.ts +13 -0
  11. package/dist/business/apm-log/index.d.ts +8 -0
  12. package/dist/business/apm-log/legacy-apm-log.d.ts +6 -0
  13. package/dist/business/apm-log/types.d.ts +147 -0
  14. package/dist/business/apm-log/vue.d.ts +5 -0
  15. package/dist/business/monitor/index.d.ts +81 -0
  16. package/dist/business/monitor/monitor-plugin.d.ts +9 -0
  17. package/dist/business/monitor/runtime-types.d.ts +166 -0
  18. package/dist/business/monitor/runtime.d.ts +6 -0
  19. package/dist/business/monitor/types.d.ts +221 -0
  20. package/dist/business/permission/Permission.d.ts +18 -0
  21. package/dist/business/permission/PermissionPluginClass.d.ts +40 -0
  22. package/dist/business/permission/directive.d.ts +7 -0
  23. package/dist/business/permission/index.d.ts +35 -0
  24. package/dist/business/permission/permission-plugin.d.ts +16 -0
  25. package/dist/business/permission/storage.d.ts +30 -0
  26. package/dist/business/permission/tree.d.ts +19 -0
  27. package/dist/business/permission/types.d.ts +115 -0
  28. package/dist/business/upload-cos/index.d.ts +117 -0
  29. package/dist/business/upload-cos/src/UploadCos.vue.d.ts +70 -0
  30. package/dist/business/upload-cos/src/types.d.ts +72 -0
  31. package/dist/business/upload-cos/src/utils.d.ts +9 -0
  32. package/dist/index.d.ts +1894 -0
  33. package/dist/index.es.js +4315 -0
  34. package/dist/index.umd.cjs +6 -0
  35. package/dist/monitor.es.js +1217 -0
  36. package/dist/monitor.umd.cjs +1 -0
  37. package/dist/permission.es.js +631 -0
  38. package/dist/permission.umd.cjs +1 -0
  39. package/dist/style.css +1 -0
  40. package/dist/upload-cos.es.js +426 -0
  41. package/dist/upload-cos.style.css +1 -0
  42. package/dist/upload-cos.umd.cjs +1 -0
  43. package/dist/utils/index.d.ts +3 -0
  44. package/dist/utils/is.d.ts +2 -0
  45. package/dist/utils/withInstall.d.ts +7 -0
  46. package/package.json +105 -0
@@ -0,0 +1,1217 @@
1
+ var N = Object.defineProperty;
2
+ var q = (r, t, e) => t in r ? N(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var o = (r, t, e) => q(r, typeof t != "symbol" ? t + "" : t, e);
4
+ const I = "element-custom-ui", O = {
5
+ fetch: !1,
6
+ xhr: !1,
7
+ includeSuccessful: !1
8
+ }, F = "[REDACTED]", v = () => {
9
+ };
10
+ function b(r) {
11
+ return typeof r == "object" && r !== null;
12
+ }
13
+ function U(r) {
14
+ return typeof URL < "u" && r instanceof URL;
15
+ }
16
+ function g(r) {
17
+ if (typeof r == "string") return r;
18
+ if (r === null) return "null";
19
+ if (r === void 0) return "undefined";
20
+ if (r instanceof Error)
21
+ return r.message || r.name;
22
+ try {
23
+ const t = JSON.stringify(r);
24
+ if (typeof t == "string") return t;
25
+ } catch {
26
+ }
27
+ try {
28
+ return String(r);
29
+ } catch {
30
+ return "Unknown error";
31
+ }
32
+ }
33
+ function w(r) {
34
+ return typeof r == "number" && Number.isFinite(r) ? r : void 0;
35
+ }
36
+ function S(r) {
37
+ return (r == null ? void 0 : r.trim().toUpperCase()) || "GET";
38
+ }
39
+ function W() {
40
+ return typeof window > "u" ? void 0 : window;
41
+ }
42
+ function f(r) {
43
+ var e;
44
+ const t = (e = r.performance) == null ? void 0 : e.now;
45
+ return typeof t == "function" ? t.call(r.performance) : Date.now();
46
+ }
47
+ function k(r, t) {
48
+ try {
49
+ return new URL(r, t.location.href).href;
50
+ } catch {
51
+ return r;
52
+ }
53
+ }
54
+ function H(r, t) {
55
+ return typeof r == "string" ? k(r, t) : U(r) ? r.href : r.url;
56
+ }
57
+ function z(r, t) {
58
+ return t != null && t.method ? S(t.method) : typeof r == "string" || U(r) ? "GET" : S(r.method);
59
+ }
60
+ function D(r, t) {
61
+ return typeof t == "string" ? r.toLowerCase() === t.toLowerCase() : (t.lastIndex = 0, t.test(r));
62
+ }
63
+ function T(r, t) {
64
+ return (t == null ? void 0 : t.some((e) => D(r, e))) ?? !1;
65
+ }
66
+ function j(r, t) {
67
+ if (!t.startsWith("/")) return r.includes(t);
68
+ try {
69
+ const e = new URL(r, `https://${I}.invalid`), n = `${e.pathname}${e.search}`;
70
+ return t.includes("?") ? n === t : e.pathname === t;
71
+ } catch {
72
+ return r.includes(t);
73
+ }
74
+ }
75
+ function x(r) {
76
+ return r.XMLHttpRequest;
77
+ }
78
+ function A(r) {
79
+ if (!r || !b(r)) return;
80
+ const t = typeof r.tagName == "string" ? r.tagName.toLowerCase() : "", e = typeof r.currentSrc == "string" ? r.currentSrc : typeof r.src == "string" ? r.src : typeof r.href == "string" ? r.href : "";
81
+ return t && e ? { element: t, url: e } : void 0;
82
+ }
83
+ function B(r) {
84
+ if (r instanceof Error)
85
+ return {
86
+ name: r.name || "Error",
87
+ message: r.message || r.name || "Unknown error",
88
+ ...r.stack ? { stack: r.stack } : {}
89
+ };
90
+ if (b(r)) {
91
+ const t = typeof r.name == "string" ? r.name : "Error", e = typeof r.message == "string" ? r.message : g(r), n = typeof r.stack == "string" ? r.stack : void 0;
92
+ return {
93
+ name: t,
94
+ message: e,
95
+ ...n ? { stack: n } : {}
96
+ };
97
+ }
98
+ return {
99
+ name: "Error",
100
+ message: g(r)
101
+ };
102
+ }
103
+ function _(r = {}) {
104
+ return new X(r);
105
+ }
106
+ class X {
107
+ constructor(t) {
108
+ o(this, "active", !1);
109
+ o(this, "destroyed", !1);
110
+ o(this, "recorderActive", !1);
111
+ o(this, "lastNavigationUrl", "");
112
+ o(this, "browserCleanups", []);
113
+ o(this, "vueCleanups", []);
114
+ o(this, "installedVueApps", /* @__PURE__ */ new WeakSet());
115
+ o(this, "start", () => {
116
+ if (this.destroyed || this.active) return !1;
117
+ const t = this.getBrowserWindow();
118
+ if (!t) return !1;
119
+ this.active = !0, this.lastNavigationUrl = t.location.href;
120
+ try {
121
+ if ((this.shouldCaptureGlobalErrors() || this.shouldCaptureResourceErrors()) && this.installErrorListener(t), this.shouldCaptureUnhandledRejections() && this.installUnhandledRejectionListener(t), this.shouldCaptureNavigation() && this.installNavigationListeners(t), this.shouldCapturePerformance() && this.installPerformanceListener(t), this.requiresInstrumentationHub()) {
122
+ const e = C(t).subscribe(this);
123
+ this.browserCleanups.push(e);
124
+ }
125
+ return this.startRecorder(), !0;
126
+ } catch {
127
+ return this.active = !1, this.runBrowserCleanups(), this.stopRecorder(), !1;
128
+ }
129
+ });
130
+ o(this, "stop", () => {
131
+ this.active && (this.active = !1, this.runBrowserCleanups(), this.stopRecorder());
132
+ });
133
+ o(this, "destroy", () => {
134
+ if (!this.destroyed) {
135
+ this.stop(), this.destroyed = !0;
136
+ for (const t of this.vueCleanups.splice(0).reverse())
137
+ this.runSafely(t);
138
+ }
139
+ });
140
+ o(this, "captureException", (t, e) => {
141
+ this.captureExceptionFromSource(t, "manual", e);
142
+ });
143
+ o(this, "captureMessage", (t, e = "info", n) => {
144
+ this.emit({
145
+ type: "message",
146
+ level: e,
147
+ timestamp: this.getTimestamp(),
148
+ url: this.getCurrentUrl(),
149
+ context: this.getContext(n),
150
+ tags: this.getTags(),
151
+ data: { message: t }
152
+ });
153
+ });
154
+ o(this, "createVuePlugin", (t = {}) => ({
155
+ install: (e) => {
156
+ if (this.destroyed || this.installedVueApps.has(e)) return;
157
+ this.installedVueApps.add(e);
158
+ const n = e.config.errorHandler, i = this, s = (a, c, h) => {
159
+ i.captureExceptionFromSource(a, "vue", {
160
+ vue: {
161
+ component: (c == null ? void 0 : c.$options.name) ?? (c == null ? void 0 : c.$options.__name) ?? "anonymous",
162
+ info: h
163
+ }
164
+ }), n == null || n(a, c, h);
165
+ };
166
+ e.config.errorHandler = s, this.vueCleanups.push(() => {
167
+ e.config.errorHandler === s && (e.config.errorHandler = n);
168
+ }), t.startOnInstall === !0 && this.start();
169
+ }
170
+ }));
171
+ o(this, "needsFetchInstrumentation", () => this.active && this.getRequestOptions().fetch);
172
+ o(this, "needsXhrInstrumentation", () => this.active && this.getRequestOptions().xhr);
173
+ o(this, "needsHistoryInstrumentation", () => this.active && this.shouldCaptureNavigation());
174
+ o(this, "shouldMonitorRequest", (t, e) => {
175
+ const n = this.getRequestOptions(), i = t === "fetch" ? n.fetch : n.xhr;
176
+ return this.active && i && !this.isIgnoredUrl(e);
177
+ });
178
+ o(this, "handleInstrumentedRequest", (t) => {
179
+ if (!this.active || this.isIgnoredUrl(t.url)) return;
180
+ const e = this.getRequestOptions(), n = e.slowThreshold !== void 0 && t.duration >= e.slowThreshold;
181
+ (e.includeSuccessful || !t.ok || n) && this.emit({
182
+ type: "request",
183
+ level: t.ok ? "info" : "error",
184
+ timestamp: this.getTimestamp(),
185
+ url: this.getCurrentUrl(),
186
+ context: this.getContext(),
187
+ tags: this.getTags(),
188
+ data: t
189
+ });
190
+ });
191
+ o(this, "handleInstrumentedNavigation", (t) => {
192
+ !this.active || !this.shouldCaptureNavigation() || (this.lastNavigationUrl = t.to, this.emit({
193
+ type: "navigation",
194
+ level: "info",
195
+ timestamp: this.getTimestamp(),
196
+ url: t.to,
197
+ context: this.getContext(),
198
+ tags: this.getTags(),
199
+ data: t
200
+ }));
201
+ });
202
+ this.options = t;
203
+ }
204
+ get started() {
205
+ return this.active;
206
+ }
207
+ getBrowserWindow() {
208
+ return this.options.window ?? W();
209
+ }
210
+ createTransportContext() {
211
+ return {
212
+ fetch: (t, e) => this.fetchForTransport(t, e),
213
+ createXMLHttpRequest: () => this.createXhrForTransport()
214
+ };
215
+ }
216
+ fetchForTransport(t, e) {
217
+ const n = this.getBrowserWindow();
218
+ return !n || typeof n.fetch != "function" ? Promise.reject(
219
+ new Error("Monitor transport fetch is unavailable outside a browser.")
220
+ ) : C(n).fetchForTransport(t, e);
221
+ }
222
+ createXhrForTransport() {
223
+ const t = this.getBrowserWindow();
224
+ if (!t || !x(t))
225
+ throw new Error("Monitor transport XMLHttpRequest is unavailable outside a browser.");
226
+ return C(t).createXhrForTransport();
227
+ }
228
+ getTimestamp() {
229
+ var t, e;
230
+ try {
231
+ const n = ((e = (t = this.options).now) == null ? void 0 : e.call(t)) ?? Date.now();
232
+ return Number.isFinite(n) ? n : Date.now();
233
+ } catch {
234
+ return Date.now();
235
+ }
236
+ }
237
+ getCurrentUrl() {
238
+ var e;
239
+ const t = this.getBrowserWindow();
240
+ return ((e = t == null ? void 0 : t.location) == null ? void 0 : e.href) ?? "";
241
+ }
242
+ getContext(t) {
243
+ var n, i;
244
+ let e;
245
+ try {
246
+ e = (i = (n = this.options).getContext) == null ? void 0 : i.call(n);
247
+ } catch {
248
+ e = void 0;
249
+ }
250
+ return {
251
+ ...this.options.context ?? {},
252
+ ...e ?? {},
253
+ ...t ?? {}
254
+ };
255
+ }
256
+ getTags() {
257
+ return {
258
+ ...this.options.tags ?? {},
259
+ ...this.options.release ? { release: this.options.release } : {},
260
+ ...this.options.environment ? { environment: this.options.environment } : {}
261
+ };
262
+ }
263
+ getRequestOptions() {
264
+ const t = this.options.captureRequests;
265
+ if (!t) return O;
266
+ if (t === !0)
267
+ return {
268
+ fetch: !0,
269
+ xhr: !0,
270
+ includeSuccessful: !1
271
+ };
272
+ const e = t.slowThreshold;
273
+ return {
274
+ fetch: t.fetch === !0,
275
+ xhr: t.xhr === !0,
276
+ includeSuccessful: t.includeSuccessful === !0,
277
+ ...typeof e == "number" && Number.isFinite(e) && e >= 0 ? { slowThreshold: e } : {}
278
+ };
279
+ }
280
+ shouldCaptureGlobalErrors() {
281
+ return this.options.captureGlobalErrors !== !1;
282
+ }
283
+ shouldCaptureResourceErrors() {
284
+ return this.options.captureResourceErrors !== !1;
285
+ }
286
+ shouldCaptureUnhandledRejections() {
287
+ return this.options.captureUnhandledRejections !== !1;
288
+ }
289
+ shouldCaptureNavigation() {
290
+ return this.options.captureNavigation !== !1;
291
+ }
292
+ shouldCapturePerformance() {
293
+ return this.options.capturePerformance !== !1;
294
+ }
295
+ requiresInstrumentationHub() {
296
+ const t = this.getRequestOptions();
297
+ return t.fetch || t.xhr || this.shouldCaptureNavigation();
298
+ }
299
+ isIgnoredUrl(t) {
300
+ var e;
301
+ return ((e = this.options.ignoreUrls) == null ? void 0 : e.some((n) => {
302
+ try {
303
+ return typeof n == "function" ? n(t) : typeof n == "string" ? j(t, n) : (n.lastIndex = 0, n.test(t));
304
+ } catch {
305
+ return !1;
306
+ }
307
+ })) ?? !1;
308
+ }
309
+ installErrorListener(t) {
310
+ const e = (n) => {
311
+ if (!this.active) return;
312
+ const i = A(n.target);
313
+ if (i) {
314
+ this.shouldCaptureResourceErrors() && this.emit({
315
+ type: "resource",
316
+ level: "error",
317
+ timestamp: this.getTimestamp(),
318
+ url: this.getCurrentUrl(),
319
+ context: this.getContext(),
320
+ tags: this.getTags(),
321
+ data: i
322
+ });
323
+ return;
324
+ }
325
+ if (!this.shouldCaptureGlobalErrors()) return;
326
+ const s = n, a = {
327
+ ...typeof s.filename == "string" ? { filename: s.filename } : {},
328
+ ...w(s.lineno) !== void 0 ? { line: w(s.lineno) } : {},
329
+ ...w(s.colno) !== void 0 ? { column: w(s.colno) } : {}
330
+ }, c = s.error ?? new Error(
331
+ typeof s.message == "string" ? s.message : "Unknown window error"
332
+ );
333
+ this.captureExceptionFromSource(c, "window.error", void 0, a);
334
+ };
335
+ t.addEventListener("error", e, !0), this.browserCleanups.push(() => {
336
+ t.removeEventListener("error", e, !0);
337
+ });
338
+ }
339
+ installUnhandledRejectionListener(t) {
340
+ const e = (n) => {
341
+ this.active && this.captureExceptionFromSource(n.reason, "unhandledrejection");
342
+ };
343
+ t.addEventListener("unhandledrejection", e), this.browserCleanups.push(() => {
344
+ t.removeEventListener("unhandledrejection", e);
345
+ });
346
+ }
347
+ installNavigationListeners(t) {
348
+ const e = () => {
349
+ const i = t.location.href;
350
+ this.handleInstrumentedNavigation({
351
+ source: "popstate",
352
+ from: this.lastNavigationUrl,
353
+ to: i,
354
+ duration: 0
355
+ });
356
+ }, n = (i) => {
357
+ this.handleInstrumentedNavigation({
358
+ source: "hashchange",
359
+ from: i.oldURL,
360
+ to: i.newURL,
361
+ duration: 0
362
+ });
363
+ };
364
+ t.addEventListener("popstate", e), t.addEventListener("hashchange", n), this.browserCleanups.push(() => {
365
+ t.removeEventListener("popstate", e), t.removeEventListener("hashchange", n);
366
+ });
367
+ }
368
+ installPerformanceListener(t) {
369
+ const e = () => {
370
+ if (!this.active) return;
371
+ const n = K(t);
372
+ n && this.emit({
373
+ type: "performance",
374
+ level: "info",
375
+ timestamp: this.getTimestamp(),
376
+ url: this.getCurrentUrl(),
377
+ context: this.getContext(),
378
+ tags: this.getTags(),
379
+ data: n
380
+ });
381
+ };
382
+ if (t.document.readyState === "complete") {
383
+ e();
384
+ return;
385
+ }
386
+ t.addEventListener("load", e, { once: !0 }), this.browserCleanups.push(() => {
387
+ t.removeEventListener("load", e);
388
+ });
389
+ }
390
+ captureExceptionFromSource(t, e, n, i = {}) {
391
+ const s = {
392
+ ...B(t),
393
+ source: e,
394
+ ...i
395
+ };
396
+ this.emit({
397
+ type: e === "unhandledrejection" ? "unhandledrejection" : "exception",
398
+ level: "error",
399
+ timestamp: this.getTimestamp(),
400
+ url: this.getCurrentUrl(),
401
+ context: this.getContext(n),
402
+ tags: this.getTags(),
403
+ data: s
404
+ });
405
+ }
406
+ emit(t) {
407
+ var i;
408
+ if (this.destroyed || !this.isSampled()) return;
409
+ const e = this.sanitizeEvent(t);
410
+ if (!e) return;
411
+ const n = this.createTransportContext();
412
+ this.options.transport && this.runSafely(
413
+ () => {
414
+ var s, a;
415
+ return (a = (s = this.options).transport) == null ? void 0 : a.call(s, e, n);
416
+ }
417
+ ), this.active && ((i = this.options.recorder) != null && i.capture) && this.runSafely(
418
+ () => {
419
+ var s, a;
420
+ return (a = (s = this.options.recorder) == null ? void 0 : s.capture) == null ? void 0 : a.call(s, e, n);
421
+ }
422
+ );
423
+ }
424
+ isSampled() {
425
+ var n, i;
426
+ const t = this.options.sampleRate, e = typeof t == "number" && Number.isFinite(t) ? Math.min(Math.max(t, 0), 1) : 1;
427
+ if (e === 0) return !1;
428
+ if (e === 1) return !0;
429
+ try {
430
+ return (((i = (n = this.options).random) == null ? void 0 : i.call(n)) ?? Math.random()) < e;
431
+ } catch {
432
+ return !0;
433
+ }
434
+ }
435
+ sanitizeEvent(t) {
436
+ let e;
437
+ switch (t.type) {
438
+ case "exception":
439
+ case "unhandledrejection":
440
+ e = {
441
+ ...t,
442
+ url: this.redactUrl(t.url),
443
+ context: this.sanitizeContext(t.context),
444
+ tags: this.sanitizeTags(t.tags),
445
+ data: {
446
+ ...t.data,
447
+ name: this.redactText(t.data.name, "name"),
448
+ message: this.redactText(t.data.message, "message"),
449
+ ...t.data.stack ? { stack: this.redactText(t.data.stack, "stack") } : {},
450
+ ...t.data.filename ? { filename: this.redactUrl(t.data.filename) } : {}
451
+ }
452
+ };
453
+ break;
454
+ case "message":
455
+ e = {
456
+ ...t,
457
+ url: this.redactUrl(t.url),
458
+ context: this.sanitizeContext(t.context),
459
+ tags: this.sanitizeTags(t.tags),
460
+ data: {
461
+ message: this.redactText(t.data.message, "message")
462
+ }
463
+ };
464
+ break;
465
+ case "resource":
466
+ e = {
467
+ ...t,
468
+ url: this.redactUrl(t.url),
469
+ context: this.sanitizeContext(t.context),
470
+ tags: this.sanitizeTags(t.tags),
471
+ data: {
472
+ element: this.redactText(t.data.element, "element"),
473
+ url: this.redactUrl(t.data.url)
474
+ }
475
+ };
476
+ break;
477
+ case "navigation":
478
+ e = {
479
+ ...t,
480
+ url: this.redactUrl(t.url),
481
+ context: this.sanitizeContext(t.context),
482
+ tags: this.sanitizeTags(t.tags),
483
+ data: {
484
+ ...t.data,
485
+ from: this.redactUrl(t.data.from),
486
+ to: this.redactUrl(t.data.to)
487
+ }
488
+ };
489
+ break;
490
+ case "performance":
491
+ e = {
492
+ ...t,
493
+ url: this.redactUrl(t.url),
494
+ context: this.sanitizeContext(t.context),
495
+ tags: this.sanitizeTags(t.tags),
496
+ data: { ...t.data }
497
+ };
498
+ break;
499
+ case "request":
500
+ e = {
501
+ ...t,
502
+ url: this.redactUrl(t.url),
503
+ context: this.sanitizeContext(t.context),
504
+ tags: this.sanitizeTags(t.tags),
505
+ data: {
506
+ ...t.data,
507
+ method: this.redactText(t.data.method, "method"),
508
+ url: this.redactUrl(t.data.url),
509
+ ...t.data.error ? { error: this.redactText(t.data.error, "error") } : {}
510
+ }
511
+ };
512
+ break;
513
+ }
514
+ try {
515
+ return this.options.sanitize ? this.options.sanitize(e) : e;
516
+ } catch {
517
+ return null;
518
+ }
519
+ }
520
+ sanitizeContext(t) {
521
+ const e = /* @__PURE__ */ new WeakSet(), n = this.sanitizeUnknown(t, "", e);
522
+ return b(n) ? n : {};
523
+ }
524
+ sanitizeUnknown(t, e, n) {
525
+ if (e && this.shouldRedactKey(e)) return this.getRedactionReplacement();
526
+ if (t == null) return t;
527
+ switch (typeof t) {
528
+ case "string":
529
+ return this.redactText(t, e);
530
+ case "number":
531
+ case "boolean":
532
+ return t;
533
+ case "bigint":
534
+ return t.toString();
535
+ case "symbol":
536
+ return t.toString();
537
+ case "function":
538
+ return `[Function ${t.name || "anonymous"}]`;
539
+ }
540
+ if (t instanceof Error)
541
+ return {
542
+ name: this.redactText(t.name || "Error", "name"),
543
+ message: this.redactText(t.message || t.name || "Unknown error", "message"),
544
+ ...t.stack ? { stack: this.redactText(t.stack, "stack") } : {}
545
+ };
546
+ if (t instanceof Date)
547
+ return Number.isNaN(t.getTime()) ? "Invalid Date" : t.toISOString();
548
+ if (U(t)) return this.redactUrl(t.href);
549
+ if (!b(t)) return g(t);
550
+ if (n.has(t)) return "[Circular]";
551
+ if (n.add(t), Array.isArray(t))
552
+ return t.map((s) => this.sanitizeUnknown(s, "", n));
553
+ const i = {};
554
+ try {
555
+ for (const [s, a] of Object.entries(t))
556
+ i[s] = this.sanitizeUnknown(a, s, n);
557
+ } catch {
558
+ return "[Unserializable object]";
559
+ }
560
+ return i;
561
+ }
562
+ sanitizeTags(t) {
563
+ const e = {};
564
+ for (const [n, i] of Object.entries(t))
565
+ typeof i == "string" ? e[n] = this.redactText(i, n) : e[n] = i;
566
+ return e;
567
+ }
568
+ shouldRedactKey(t) {
569
+ var e;
570
+ return T(t, (e = this.options.redact) == null ? void 0 : e.keys);
571
+ }
572
+ getRedactionReplacement() {
573
+ var t;
574
+ return ((t = this.options.redact) == null ? void 0 : t.replacement) ?? F;
575
+ }
576
+ redactText(t, e) {
577
+ return e && this.shouldRedactKey(e) ? this.getRedactionReplacement() : t;
578
+ }
579
+ redactUrl(t) {
580
+ var e, n;
581
+ if (this.shouldRedactKey("url")) return this.getRedactionReplacement();
582
+ if (!((n = (e = this.options.redact) == null ? void 0 : e.queryParams) != null && n.length)) return t;
583
+ try {
584
+ const i = /^[a-z][a-z\d+.-]*:/i.test(t), s = new URL(t, `https://${I}.invalid`);
585
+ for (const a of Array.from(s.searchParams.keys()))
586
+ T(a, this.options.redact.queryParams) && s.searchParams.set(a, this.getRedactionReplacement());
587
+ return i ? s.toString() : `${s.pathname}${s.search}${s.hash}`;
588
+ } catch {
589
+ return t;
590
+ }
591
+ }
592
+ startRecorder() {
593
+ var t;
594
+ !((t = this.options.recorder) != null && t.start) || this.recorderActive || (this.recorderActive = !0, this.runSafely(
595
+ () => {
596
+ var e, n;
597
+ return (n = (e = this.options.recorder) == null ? void 0 : e.start) == null ? void 0 : n.call(e, this.createTransportContext());
598
+ }
599
+ ));
600
+ }
601
+ stopRecorder() {
602
+ var t;
603
+ !((t = this.options.recorder) != null && t.stop) || !this.recorderActive || (this.recorderActive = !1, this.runSafely(
604
+ () => {
605
+ var e, n;
606
+ return (n = (e = this.options.recorder) == null ? void 0 : e.stop) == null ? void 0 : n.call(e, this.createTransportContext());
607
+ }
608
+ ));
609
+ }
610
+ runBrowserCleanups() {
611
+ for (const t of this.browserCleanups.splice(0).reverse())
612
+ this.runSafely(t);
613
+ }
614
+ runSafely(t) {
615
+ try {
616
+ const e = t();
617
+ Promise.resolve(e).catch(v);
618
+ } catch {
619
+ }
620
+ }
621
+ }
622
+ class G {
623
+ constructor(t) {
624
+ o(this, "monitors", /* @__PURE__ */ new Set());
625
+ o(this, "xhrMetadata", /* @__PURE__ */ new WeakMap());
626
+ o(this, "transportXhrs", /* @__PURE__ */ new WeakSet());
627
+ o(this, "xhrListeners", /* @__PURE__ */ new Map());
628
+ o(this, "nativeFetch");
629
+ o(this, "fetchCleanup");
630
+ o(this, "xhrCleanup");
631
+ o(this, "historyCleanup");
632
+ this.browserWindow = t;
633
+ }
634
+ subscribe(t) {
635
+ return this.monitors.add(t), this.sync(), () => {
636
+ this.monitors.delete(t), this.sync(), this.monitors.size === 0 && E.delete(this.browserWindow);
637
+ };
638
+ }
639
+ fetchForTransport(t, e) {
640
+ return (this.nativeFetch ?? this.browserWindow.fetch).call(this.browserWindow, t, e);
641
+ }
642
+ createXhrForTransport() {
643
+ const t = x(this.browserWindow);
644
+ if (!t)
645
+ throw new Error("Monitor transport XMLHttpRequest is unavailable outside a browser.");
646
+ const e = new t();
647
+ return this.transportXhrs.add(e), e;
648
+ }
649
+ sync() {
650
+ this.someMonitor((t) => t.needsFetchInstrumentation()) ? this.installFetchPatch() : this.removeFetchPatch(), this.someMonitor((t) => t.needsXhrInstrumentation()) ? this.installXhrPatch() : this.removeXhrPatch(), this.someMonitor((t) => t.needsHistoryInstrumentation()) ? this.installHistoryPatch() : this.removeHistoryPatch();
651
+ }
652
+ someMonitor(t) {
653
+ for (const e of this.monitors)
654
+ if (t(e)) return !0;
655
+ return !1;
656
+ }
657
+ getRequestMonitors(t, e) {
658
+ return Array.from(this.monitors).filter(
659
+ (n) => n.shouldMonitorRequest(t, e)
660
+ );
661
+ }
662
+ installFetchPatch() {
663
+ if (this.fetchCleanup || typeof this.browserWindow.fetch != "function") return;
664
+ const t = this.browserWindow.fetch;
665
+ this.nativeFetch = t;
666
+ const e = this, n = function(i, s) {
667
+ return e.performFetch(i, s);
668
+ };
669
+ this.browserWindow.fetch = n, this.fetchCleanup = () => {
670
+ this.browserWindow.fetch === n && (this.browserWindow.fetch = t), this.nativeFetch === t && (this.nativeFetch = void 0);
671
+ };
672
+ }
673
+ performFetch(t, e) {
674
+ const n = this.nativeFetch ?? this.browserWindow.fetch, i = H(t, this.browserWindow), s = this.getRequestMonitors("fetch", i);
675
+ if (s.length === 0)
676
+ return n.call(this.browserWindow, t, e);
677
+ const a = z(t, e), c = f(this.browserWindow);
678
+ try {
679
+ return n.call(this.browserWindow, t, e).then(
680
+ (u) => {
681
+ const l = f(this.browserWindow) - c;
682
+ return this.notifyRequest(s, {
683
+ kind: "fetch",
684
+ method: a,
685
+ url: u.url || i,
686
+ status: u.status,
687
+ duration: l,
688
+ ok: u.ok
689
+ }), u;
690
+ },
691
+ (u) => {
692
+ const l = f(this.browserWindow) - c;
693
+ throw this.notifyRequest(s, {
694
+ kind: "fetch",
695
+ method: a,
696
+ url: i,
697
+ duration: l,
698
+ ok: !1,
699
+ error: g(u)
700
+ }), u;
701
+ }
702
+ );
703
+ } catch (h) {
704
+ const u = f(this.browserWindow) - c;
705
+ throw this.notifyRequest(s, {
706
+ kind: "fetch",
707
+ method: a,
708
+ url: i,
709
+ duration: u,
710
+ ok: !1,
711
+ error: g(h)
712
+ }), h;
713
+ }
714
+ }
715
+ removeFetchPatch() {
716
+ var t;
717
+ (t = this.fetchCleanup) == null || t.call(this), this.fetchCleanup = void 0;
718
+ }
719
+ installXhrPatch() {
720
+ if (this.xhrCleanup) return;
721
+ const t = x(this.browserWindow);
722
+ if (!t) return;
723
+ const e = t.prototype, n = e.open, i = e.send, s = this, a = function(h, u, l, p, d) {
724
+ s.xhrMetadata.set(this, {
725
+ method: S(h),
726
+ url: k(String(u), s.browserWindow)
727
+ }), n.call(this, h, u, l ?? !0, p, d);
728
+ }, c = function(h) {
729
+ const u = s.xhrMetadata.get(this), l = u && !s.transportXhrs.has(this) ? s.getRequestMonitors("xhr", u.url) : [];
730
+ if (!u || l.length === 0) {
731
+ h === void 0 ? i.call(this) : i.call(this, h);
732
+ return;
733
+ }
734
+ const p = s.xhrListeners.get(this);
735
+ p && (this.removeEventListener("loadend", p), s.xhrListeners.delete(this));
736
+ const d = {
737
+ ...u,
738
+ startedAt: f(s.browserWindow),
739
+ monitors: l
740
+ }, m = () => {
741
+ this.removeEventListener("loadend", m), s.xhrListeners.delete(this), s.notifyRequest(d.monitors, {
742
+ kind: "xhr",
743
+ method: d.method,
744
+ url: this.responseURL || d.url,
745
+ status: this.status,
746
+ duration: f(s.browserWindow) - d.startedAt,
747
+ ok: this.status >= 200 && this.status < 400,
748
+ ...this.status === 0 ? { error: "Network request failed" } : {}
749
+ });
750
+ };
751
+ this.addEventListener("loadend", m), s.xhrListeners.set(this, m);
752
+ try {
753
+ h === void 0 ? i.call(this) : i.call(this, h);
754
+ } catch (y) {
755
+ throw this.removeEventListener("loadend", m), s.xhrListeners.delete(this), s.notifyRequest(d.monitors, {
756
+ kind: "xhr",
757
+ method: d.method,
758
+ url: d.url,
759
+ duration: f(s.browserWindow) - d.startedAt,
760
+ ok: !1,
761
+ error: g(y)
762
+ }), y;
763
+ }
764
+ };
765
+ e.open = a, e.send = c, this.xhrCleanup = () => {
766
+ e.open === a && (e.open = n), e.send === c && (e.send = i);
767
+ for (const [h, u] of this.xhrListeners)
768
+ h.removeEventListener("loadend", u);
769
+ this.xhrListeners.clear();
770
+ };
771
+ }
772
+ removeXhrPatch() {
773
+ var t;
774
+ (t = this.xhrCleanup) == null || t.call(this), this.xhrCleanup = void 0;
775
+ }
776
+ installHistoryPatch() {
777
+ if (this.historyCleanup) return;
778
+ const t = this.browserWindow.history, e = t.pushState, n = t.replaceState, i = this, s = (h, u) => function(l, p, d) {
779
+ const m = i.browserWindow.location.href, y = f(i.browserWindow);
780
+ h.call(this, l, p, d), i.notifyNavigation({
781
+ source: "history",
782
+ method: u,
783
+ from: m,
784
+ to: i.browserWindow.location.href,
785
+ duration: f(i.browserWindow) - y
786
+ });
787
+ }, a = s(e, "pushState"), c = s(
788
+ n,
789
+ "replaceState"
790
+ );
791
+ t.pushState = a, t.replaceState = c, this.historyCleanup = () => {
792
+ t.pushState === a && (t.pushState = e), t.replaceState === c && (t.replaceState = n);
793
+ };
794
+ }
795
+ removeHistoryPatch() {
796
+ var t;
797
+ (t = this.historyCleanup) == null || t.call(this), this.historyCleanup = void 0;
798
+ }
799
+ notifyRequest(t, e) {
800
+ for (const n of t)
801
+ n.handleInstrumentedRequest(e);
802
+ }
803
+ notifyNavigation(t) {
804
+ for (const e of this.monitors)
805
+ e.handleInstrumentedNavigation(t);
806
+ }
807
+ }
808
+ const E = /* @__PURE__ */ new WeakMap();
809
+ function C(r) {
810
+ let t = E.get(r);
811
+ return t || (t = new G(r), E.set(r, t)), t;
812
+ }
813
+ function K(r) {
814
+ const t = r.performance;
815
+ if (!(t != null && t.getEntriesByType)) return;
816
+ const e = t.getEntriesByType("navigation").find(
817
+ (n) => "domContentLoadedEventEnd" in n && "loadEventEnd" in n
818
+ );
819
+ if (e)
820
+ return {
821
+ navigationType: e.type,
822
+ duration: e.duration,
823
+ redirect: e.redirectEnd - e.redirectStart,
824
+ dns: e.domainLookupEnd - e.domainLookupStart,
825
+ connection: e.connectEnd - e.connectStart,
826
+ request: e.responseStart - e.requestStart,
827
+ response: e.responseEnd - e.responseStart,
828
+ domInteractive: e.domInteractive,
829
+ domContentLoaded: e.domContentLoadedEventEnd - e.startTime,
830
+ load: e.loadEventEnd - e.startTime
831
+ };
832
+ }
833
+ const M = "__easyOilLegacyMonitorLog", L = "easyOilLegacyMonitorSessionId", $ = {
834
+ silentWhiteScreen: "Legacy white-screen detection is not included. Use a project-owned detector and report through transport instead.",
835
+ whiteBoxElements: "Legacy white-screen container configuration is not supported because white-screen detection is not included.",
836
+ skeletonProject: "Legacy skeleton-screen detection is not supported because white-screen detection is not included.",
837
+ silentRecordScreen: "Legacy rrweb screen recording is not bundled. Keep the project-owned recording implementation when this capability is required.",
838
+ recordScreentime: "Legacy rrweb recording duration is not supported because screen recording is not included.",
839
+ recordScreenTypeList: "Legacy rrweb recording trigger types are not supported because screen recording is not included.",
840
+ useImgUpload: "Legacy image-beacon reporting is not supported. The compatibility transport uses the monitor transport context instead.",
841
+ silentClick: "Legacy click breadcrumb collection is not supported by this compatibility layer.",
842
+ throttleDelayTime: "Legacy click throttling is not supported because click breadcrumb collection is not included.",
843
+ maxBreadcrumbs: "Legacy breadcrumb buffering is not supported by this compatibility layer.",
844
+ beforePushBreadcrumb: "Legacy breadcrumb hooks are not supported because breadcrumb collection is not included.",
845
+ overTime: "Legacy request timeout handling is not supported. Configure timeouts in the application HTTP client.",
846
+ handleHttpStatus: "Legacy response-body status inspection is not supported by this compatibility layer.",
847
+ defHttp: "Legacy defHttp interception is not supported. Enable browser request capture with silentXhr or silentFetch instead.",
848
+ router: "Legacy router-instance instrumentation is not supported. Enable history or hash capture with the corresponding legacy flags instead.",
849
+ recordScreenPlugin: "Legacy RecordScreen plugins require rrweb and are not supported by this compatibility layer."
850
+ };
851
+ function P(r) {
852
+ return typeof r == "object" && r !== null && !Array.isArray(r);
853
+ }
854
+ function V() {
855
+ return !1;
856
+ }
857
+ function J(r) {
858
+ if (typeof r == "string") return r;
859
+ if (r instanceof Error) return r.message || r.name || "Unknown error";
860
+ try {
861
+ const t = JSON.stringify(r);
862
+ if (typeof t == "string") return t;
863
+ } catch {
864
+ }
865
+ try {
866
+ return String(r);
867
+ } catch {
868
+ return "Unknown message";
869
+ }
870
+ }
871
+ function R(r) {
872
+ if (typeof r.getUserId == "function")
873
+ try {
874
+ const t = r.getUserId();
875
+ if (typeof t == "string" || typeof t == "number") return t;
876
+ } catch {
877
+ return typeof r.userId == "string" || typeof r.userId == "number" ? r.userId : void 0;
878
+ }
879
+ return typeof r.userId == "string" || typeof r.userId == "number" ? r.userId : void 0;
880
+ }
881
+ function Y() {
882
+ if (typeof sessionStorage > "u") return "";
883
+ try {
884
+ const r = sessionStorage.getItem(L);
885
+ if (r) return r;
886
+ const t = typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
887
+ return sessionStorage.setItem(L, t), t;
888
+ } catch {
889
+ return "";
890
+ }
891
+ }
892
+ function Q(r) {
893
+ switch (r.type) {
894
+ case "exception":
895
+ return "error";
896
+ case "navigation":
897
+ return r.data.source === "hashchange" ? "hashchange" : "history";
898
+ case "request":
899
+ return r.data.kind;
900
+ default:
901
+ return r.type;
902
+ }
903
+ }
904
+ function Z(r) {
905
+ switch (r.type) {
906
+ case "exception":
907
+ case "unhandledrejection":
908
+ case "resource":
909
+ return "client_debug";
910
+ default:
911
+ return "user_behavior";
912
+ }
913
+ }
914
+ function tt(r) {
915
+ switch (r.type) {
916
+ case "exception":
917
+ case "unhandledrejection":
918
+ return {
919
+ message: r.data.message,
920
+ name: r.data.name,
921
+ ...r.data.stack ? { stack: r.data.stack } : {},
922
+ ...r.data.filename ? { fileName: r.data.filename } : {},
923
+ ...r.data.line !== void 0 ? { line: r.data.line } : {},
924
+ ...r.data.column !== void 0 ? { column: r.data.column } : {}
925
+ };
926
+ case "request":
927
+ return {
928
+ method: r.data.method,
929
+ url: r.data.url,
930
+ Status: r.data.status,
931
+ status: r.data.ok ? "ok" : "error",
932
+ elapsedTime: r.data.duration,
933
+ ...r.data.error ? { message: r.data.error } : {}
934
+ };
935
+ case "navigation":
936
+ return {
937
+ from: r.data.from,
938
+ to: r.data.to,
939
+ duration: r.data.duration,
940
+ source: r.data.source
941
+ };
942
+ case "performance":
943
+ return { ...r.data };
944
+ case "resource":
945
+ return {
946
+ name: r.data.element,
947
+ message: r.data.url
948
+ };
949
+ case "message":
950
+ return { message: r.data.message };
951
+ }
952
+ }
953
+ function et(r) {
954
+ if (r.type !== "message") return;
955
+ const t = r.context[M];
956
+ return P(t) ? t : void 0;
957
+ }
958
+ function rt(r, t) {
959
+ const e = R(t), n = {
960
+ moduleId: Z(r),
961
+ type: Q(r),
962
+ status: r.level === "error" || r.level === "fatal" ? "error" : "ok",
963
+ time: r.timestamp,
964
+ pageUrl: r.url,
965
+ ...t.appChannelId ? { appChannelId: t.appChannelId } : {},
966
+ ...t.dataChannelId ? { dataChannelId: t.dataChannelId } : {},
967
+ ...t.version ? { version: t.version } : {},
968
+ ...e !== void 0 ? { userId: e } : {},
969
+ message: r.type === "message" ? r.data.message : void 0,
970
+ data: tt(r)
971
+ }, i = et(r);
972
+ if (!i) return n;
973
+ const s = i.type, a = i.moduleId, c = i.data;
974
+ return {
975
+ ...n,
976
+ ...i,
977
+ type: typeof s == "string" ? s : n.type,
978
+ moduleId: typeof a == "string" ? a : n.moduleId,
979
+ data: P(c) ? c : { ...n.data, ...i }
980
+ };
981
+ }
982
+ function nt(r, t) {
983
+ return r.type !== "navigation" ? !0 : r.data.source === "hashchange" ? t.silentHashchange === !0 : t.silentHistory === !0;
984
+ }
985
+ function st(r) {
986
+ const t = [];
987
+ return r.dsn && t.push(r.dsn), r.filterXhrUrlRegExp && t.push(r.filterXhrUrlRegExp), {
988
+ captureRequests: {
989
+ xhr: r.silentXhr === !0,
990
+ fetch: r.silentFetch === !0
991
+ },
992
+ captureGlobalErrors: r.silentError === !0,
993
+ captureUnhandledRejections: r.silentUnhandledrejection === !0,
994
+ captureNavigation: r.silentHistory === !0 || r.silentHashchange === !0,
995
+ capturePerformance: r.silentPerformance === !0,
996
+ ignoredUrls: t
997
+ };
998
+ }
999
+ function it(r, t) {
1000
+ const e = R(t), n = {
1001
+ ...r,
1002
+ data: r.data ?? {}
1003
+ }, i = {
1004
+ moduleId: r.moduleId ?? "user_behavior",
1005
+ type: r.type,
1006
+ message: r.message,
1007
+ identityID: e ?? "",
1008
+ userIdentity: e ?? "",
1009
+ sessionId: Y(),
1010
+ extraContent: JSON.stringify(n)
1011
+ };
1012
+ return { content: [JSON.stringify(i)] };
1013
+ }
1014
+ async function ot(r, t) {
1015
+ if (!r) return t;
1016
+ try {
1017
+ const e = await r(t);
1018
+ return e === !1 ? void 0 : e ?? t;
1019
+ } catch {
1020
+ return;
1021
+ }
1022
+ }
1023
+ class at {
1024
+ constructor(t = {}) {
1025
+ o(this, "currentMonitor");
1026
+ o(this, "currentOptions");
1027
+ o(this, "currentMapping");
1028
+ o(this, "plugins", /* @__PURE__ */ new Set());
1029
+ o(this, "reportedErrorKeys", /* @__PURE__ */ new Set());
1030
+ o(this, "dsnWarningShown", !1);
1031
+ o(this, "init", (t = this.defaultOptions) => {
1032
+ const e = this.configure(t);
1033
+ return e == null || e.start(), this;
1034
+ });
1035
+ o(this, "install", (t, e = this.defaultOptions) => {
1036
+ const n = this.configure(e);
1037
+ n && (t.use(n.createVuePlugin()), n.start());
1038
+ });
1039
+ o(this, "log", (t) => {
1040
+ const e = this.currentMonitor;
1041
+ if (!e) return !1;
1042
+ if (typeof t == "string")
1043
+ return e.captureMessage(t), !0;
1044
+ const n = J(t.message ?? t);
1045
+ return e.captureMessage(n, "info", {
1046
+ [M]: t
1047
+ }), !0;
1048
+ });
1049
+ o(this, "errorBoundary", (t) => {
1050
+ const e = this.currentMonitor;
1051
+ return e ? (e.captureException(t, { framework: "react" }), !0) : !1;
1052
+ });
1053
+ o(this, "use", (t, e) => {
1054
+ let n;
1055
+ try {
1056
+ n = new t(e);
1057
+ } catch {
1058
+ return;
1059
+ }
1060
+ return this.plugins.add(n), n.type === "recordScreen" && this.notifyUnsupported("recordScreenPlugin", n.type), this.runPluginCore(n), n;
1061
+ });
1062
+ o(this, "stop", () => {
1063
+ var t;
1064
+ (t = this.currentMonitor) == null || t.stop();
1065
+ });
1066
+ o(this, "destroy", () => {
1067
+ var t;
1068
+ (t = this.currentMonitor) == null || t.destroy(), this.currentMonitor = void 0, this.currentMapping = void 0, this.reportedErrorKeys.clear();
1069
+ });
1070
+ this.defaultOptions = t;
1071
+ }
1072
+ get monitor() {
1073
+ return this.currentMonitor;
1074
+ }
1075
+ get started() {
1076
+ var t;
1077
+ return ((t = this.currentMonitor) == null ? void 0 : t.started) ?? !1;
1078
+ }
1079
+ get options() {
1080
+ return this.currentOptions;
1081
+ }
1082
+ configure(t) {
1083
+ if (this.destroy(), this.currentOptions = { ...t }, this.dsnWarningShown = !1, this.reportUnsupportedOptions(t), t.disabled === !0) return;
1084
+ const e = st(t);
1085
+ this.currentMapping = e;
1086
+ const n = _({
1087
+ transport: (i, s) => this.handleMonitorEvent(i, s),
1088
+ captureRequests: {
1089
+ xhr: e.captureRequests.xhr,
1090
+ fetch: e.captureRequests.fetch,
1091
+ includeSuccessful: !0
1092
+ },
1093
+ captureGlobalErrors: e.captureGlobalErrors,
1094
+ captureResourceErrors: e.captureGlobalErrors,
1095
+ captureUnhandledRejections: e.captureUnhandledRejections,
1096
+ captureNavigation: e.captureNavigation,
1097
+ capturePerformance: e.capturePerformance,
1098
+ ignoreUrls: e.ignoredUrls,
1099
+ context: {
1100
+ legacyMonitor: !0,
1101
+ ...t.appChannelId ? { appChannelId: t.appChannelId } : {},
1102
+ ...t.dataChannelId ? { dataChannelId: t.dataChannelId } : {},
1103
+ ...t.context ?? {}
1104
+ },
1105
+ getContext: () => this.getDynamicContext(t),
1106
+ tags: t.tags,
1107
+ release: t.version,
1108
+ environment: t.environment,
1109
+ redact: t.redact,
1110
+ window: t.window,
1111
+ sampleRate: t.sampleRate,
1112
+ random: t.random,
1113
+ now: t.now
1114
+ });
1115
+ this.currentMonitor = n;
1116
+ for (const i of this.plugins)
1117
+ i.type === "recordScreen" && this.notifyUnsupported("recordScreenPlugin", i.type), this.runPluginCore(i);
1118
+ return n;
1119
+ }
1120
+ getDynamicContext(t) {
1121
+ const e = R(t);
1122
+ return e === void 0 ? {} : { userId: e };
1123
+ }
1124
+ async handleMonitorEvent(t, e) {
1125
+ const n = this.currentOptions;
1126
+ if (!n || !nt(t, n) || !this.shouldReportEvent(t, n)) return;
1127
+ const i = rt(t, n), s = await ot(
1128
+ n.beforeDataReport,
1129
+ i
1130
+ );
1131
+ if (s) {
1132
+ if (this.runPluginTransforms(s), n.transport) {
1133
+ await n.transport(s, t, e);
1134
+ return;
1135
+ }
1136
+ if (!n.dsn) {
1137
+ this.warnMissingDsn();
1138
+ return;
1139
+ }
1140
+ await e.fetch(n.dsn, {
1141
+ method: "POST",
1142
+ headers: {
1143
+ "Content-Type": "application/json;charset=UTF-8",
1144
+ ...n.appChannelId ? { "x-app_channel_id": n.appChannelId } : {},
1145
+ ...n.dataChannelId ? { "x-data_channel_id": n.dataChannelId } : {}
1146
+ },
1147
+ body: JSON.stringify(it(s, n))
1148
+ });
1149
+ }
1150
+ }
1151
+ shouldReportEvent(t, e) {
1152
+ if (e.repeatCodeError !== !0 || t.type !== "exception" && t.type !== "unhandledrejection") return !0;
1153
+ const n = [
1154
+ t.type,
1155
+ t.data.name,
1156
+ t.data.message,
1157
+ t.data.filename ?? "",
1158
+ t.data.line ?? "",
1159
+ t.data.column ?? ""
1160
+ ].join("|");
1161
+ return this.reportedErrorKeys.has(n) ? !1 : (this.reportedErrorKeys.add(n), !0);
1162
+ }
1163
+ runPluginCore(t) {
1164
+ const e = this.currentOptions;
1165
+ if (!(!e || typeof t.core != "function"))
1166
+ try {
1167
+ t.core(this.createPluginContext(e));
1168
+ } catch {
1169
+ }
1170
+ }
1171
+ createPluginContext(t) {
1172
+ return {
1173
+ options: t,
1174
+ transportData: { send: this.log },
1175
+ breadcrumb: { push: this.log },
1176
+ notify: (e, n) => this.log({
1177
+ type: e,
1178
+ ...typeof n == "string" ? { message: n } : n ?? {}
1179
+ })
1180
+ };
1181
+ }
1182
+ runPluginTransforms(t) {
1183
+ for (const e of this.plugins)
1184
+ if (!(typeof e.transform != "function" || e.type && e.type !== t.type && e.type !== "*"))
1185
+ try {
1186
+ e.transform(t);
1187
+ } catch {
1188
+ }
1189
+ }
1190
+ reportUnsupportedOptions(t) {
1191
+ var e;
1192
+ t.silentWhiteScreen === !0 && this.notifyUnsupported("silentWhiteScreen", t.silentWhiteScreen), t.whiteBoxElements !== void 0 && this.notifyUnsupported("whiteBoxElements", t.whiteBoxElements), t.skeletonProject === !0 && this.notifyUnsupported("skeletonProject", t.skeletonProject), t.silentRecordScreen === !0 && this.notifyUnsupported("silentRecordScreen", t.silentRecordScreen), t.recordScreentime !== void 0 && this.notifyUnsupported("recordScreentime", t.recordScreentime), (e = t.recordScreenTypeList) != null && e.length && this.notifyUnsupported("recordScreenTypeList", t.recordScreenTypeList), t.useImgUpload === !0 && this.notifyUnsupported("useImgUpload", t.useImgUpload), t.silentClick === !0 && this.notifyUnsupported("silentClick", t.silentClick), t.throttleDelayTime !== void 0 && this.notifyUnsupported("throttleDelayTime", t.throttleDelayTime), t.maxBreadcrumbs !== void 0 && this.notifyUnsupported("maxBreadcrumbs", t.maxBreadcrumbs), typeof t.beforePushBreadcrumb == "function" && this.notifyUnsupported("beforePushBreadcrumb", t.beforePushBreadcrumb), t.overTime !== void 0 && this.notifyUnsupported("overTime", t.overTime), typeof t.handleHttpStatus == "function" && this.notifyUnsupported("handleHttpStatus", t.handleHttpStatus), t.defHttp !== void 0 && this.notifyUnsupported("defHttp", t.defHttp), t.router !== void 0 && this.notifyUnsupported("router", t.router);
1193
+ }
1194
+ notifyUnsupported(t, e) {
1195
+ var i, s, a;
1196
+ const n = {
1197
+ option: t,
1198
+ value: e,
1199
+ message: $[t]
1200
+ };
1201
+ try {
1202
+ (s = (i = this.currentOptions) == null ? void 0 : i.onUnsupportedOption) == null || s.call(i, n);
1203
+ } catch {
1204
+ }
1205
+ !((a = this.currentOptions) != null && a.onUnsupportedOption) && V();
1206
+ }
1207
+ warnMissingDsn() {
1208
+ this.dsnWarningShown;
1209
+ }
1210
+ }
1211
+ function ct(r = {}) {
1212
+ return new at(r);
1213
+ }
1214
+ const ht = ct();
1215
+ export {
1216
+ ht as default
1217
+ };