@ohbug/browser 2.0.0 → 2.0.3
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.
- package/dist/index.js +1 -674
- package/dist/index.mjs +1 -653
- package/package.json +5 -6
- package/src/capture/action/captureClick.ts +0 -35
- package/src/capture/action/captureUrlChange.ts +0 -100
- package/src/capture/console/captureConsole.ts +0 -45
- package/src/capture/index.ts +0 -64
- package/src/capture/network/captureAjaxError.ts +0 -81
- package/src/capture/network/captureFetchError.ts +0 -69
- package/src/capture/network/captureWebSocketError.ts +0 -51
- package/src/capture/script/captureUncaughtError.ts +0 -20
- package/src/capture/script/captureUnhandledrejectionError.ts +0 -20
- package/src/client.ts +0 -46
- package/src/destroy.ts +0 -22
- package/src/device.ts +0 -19
- package/src/dispatch/index.ts +0 -2
- package/src/dispatch/networkDispatcher.ts +0 -29
- package/src/dispatch/scriptDispatcher.ts +0 -30
- package/src/extension.ts +0 -12
- package/src/handle/ajaxErrorHandler.ts +0 -26
- package/src/handle/fetchErrorHandler.ts +0 -25
- package/src/handle/index.ts +0 -16
- package/src/handle/resourceErrorHandler.ts +0 -41
- package/src/handle/uncaughtErrorHandler.ts +0 -37
- package/src/handle/unhandledrejectionErrorHandler.ts +0 -21
- package/src/handle/unknownErrorHandler.ts +0 -18
- package/src/handle/websocketErrorHandler.ts +0 -23
- package/src/index.ts +0 -13
- package/src/notifier.ts +0 -42
- package/src/version.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -1,674 +1 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
var __export = (target, all) => {
|
|
23
|
-
for (var name in all)
|
|
24
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
-
};
|
|
26
|
-
var __copyProps = (to, from, except, desc) => {
|
|
27
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
-
for (let key of __getOwnPropNames(from))
|
|
29
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
-
}
|
|
32
|
-
return to;
|
|
33
|
-
};
|
|
34
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
-
|
|
36
|
-
// src/index.ts
|
|
37
|
-
var src_exports = {};
|
|
38
|
-
__export(src_exports, {
|
|
39
|
-
default: () => src_default
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(src_exports);
|
|
42
|
-
|
|
43
|
-
// src/client.ts
|
|
44
|
-
var import_core13 = require("@ohbug/core");
|
|
45
|
-
var import_utils19 = require("@ohbug/utils");
|
|
46
|
-
|
|
47
|
-
// src/device.ts
|
|
48
|
-
var device = () => {
|
|
49
|
-
const ohbugDevice = {};
|
|
50
|
-
if (navigator) {
|
|
51
|
-
const { language, userAgent } = navigator;
|
|
52
|
-
ohbugDevice.language = language;
|
|
53
|
-
ohbugDevice.userAgent = userAgent;
|
|
54
|
-
}
|
|
55
|
-
if (document) {
|
|
56
|
-
const { title } = document;
|
|
57
|
-
ohbugDevice.title = title;
|
|
58
|
-
}
|
|
59
|
-
if (window.location) {
|
|
60
|
-
const { href: url } = window.location;
|
|
61
|
-
ohbugDevice.url = url;
|
|
62
|
-
}
|
|
63
|
-
return ohbugDevice;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// src/version.ts
|
|
67
|
-
var version = "1.0.20";
|
|
68
|
-
|
|
69
|
-
// src/extension.ts
|
|
70
|
-
var import_core12 = require("@ohbug/core");
|
|
71
|
-
|
|
72
|
-
// src/capture/index.ts
|
|
73
|
-
var import_utils16 = require("@ohbug/utils");
|
|
74
|
-
|
|
75
|
-
// src/capture/action/captureUrlChange.ts
|
|
76
|
-
var import_utils = require("@ohbug/utils");
|
|
77
|
-
var global = (0, import_utils.getGlobal)();
|
|
78
|
-
var lastHref;
|
|
79
|
-
function handleUrlChange(from, to) {
|
|
80
|
-
var _a2;
|
|
81
|
-
const { client } = (0, import_utils.getOhbugObject)();
|
|
82
|
-
const parsedHref = (0, import_utils.parseUrl)((_a2 = global == null ? void 0 : global.location) == null ? void 0 : _a2.href);
|
|
83
|
-
let parsedFrom = (0, import_utils.parseUrl)(from);
|
|
84
|
-
const parsedTo = (0, import_utils.parseUrl)(to);
|
|
85
|
-
if (!parsedFrom.path)
|
|
86
|
-
parsedFrom = parsedHref;
|
|
87
|
-
lastHref = to;
|
|
88
|
-
let targetFrom = from;
|
|
89
|
-
let targetTo = to;
|
|
90
|
-
if (parsedHref.protocol === parsedTo.protocol && parsedHref.host === parsedTo.host)
|
|
91
|
-
targetTo = parsedTo.relative;
|
|
92
|
-
if (parsedHref.protocol === parsedFrom.protocol && parsedHref.host === parsedFrom.host)
|
|
93
|
-
targetFrom = parsedFrom.relative;
|
|
94
|
-
if (targetFrom === targetTo)
|
|
95
|
-
return;
|
|
96
|
-
client.addAction(`navigation to ${to}`, {
|
|
97
|
-
from,
|
|
98
|
-
to
|
|
99
|
-
}, "navigation");
|
|
100
|
-
}
|
|
101
|
-
function historyReplacement(original) {
|
|
102
|
-
return function call(data, title, url) {
|
|
103
|
-
if (url)
|
|
104
|
-
handleUrlChange(lastHref, String(url));
|
|
105
|
-
return original.apply(this, [data, title, url]);
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
var _a, _b;
|
|
109
|
-
var historyOriginal = {
|
|
110
|
-
pushState: (_a = global == null ? void 0 : global.history) == null ? void 0 : _a.pushState,
|
|
111
|
-
replaceState: (_b = global == null ? void 0 : global.history) == null ? void 0 : _b.replaceState,
|
|
112
|
-
onpopstate: global == null ? void 0 : global.onpopstate
|
|
113
|
-
};
|
|
114
|
-
function historyListener() {
|
|
115
|
-
historyOriginal.pushState = (0, import_utils.replace)(global == null ? void 0 : global.history, "pushState", historyReplacement);
|
|
116
|
-
historyOriginal.replaceState = (0, import_utils.replace)(global == null ? void 0 : global.history, "replaceState", historyReplacement);
|
|
117
|
-
historyOriginal.onpopstate = (0, import_utils.replace)(global, "onpopstate", (origin) => function call(...args) {
|
|
118
|
-
var _a2;
|
|
119
|
-
const current = (_a2 = global == null ? void 0 : global.location) == null ? void 0 : _a2.href;
|
|
120
|
-
handleUrlChange(lastHref, current);
|
|
121
|
-
return origin == null ? void 0 : origin.apply(this, args);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function hashListener(e) {
|
|
125
|
-
const { oldURL, newURL } = e;
|
|
126
|
-
handleUrlChange(oldURL, newURL);
|
|
127
|
-
}
|
|
128
|
-
function captureUrlChange() {
|
|
129
|
-
var _a2;
|
|
130
|
-
historyListener();
|
|
131
|
-
(_a2 = global == null ? void 0 : global.addEventListener) == null ? void 0 : _a2.call(global, "hashchange", hashListener, true);
|
|
132
|
-
}
|
|
133
|
-
function removeCaptureUrlChange() {
|
|
134
|
-
var _a2;
|
|
135
|
-
global.history.pushState = historyOriginal.pushState;
|
|
136
|
-
global.history.replaceState = historyOriginal.replaceState;
|
|
137
|
-
global.onpopstate = historyOriginal.onpopstate;
|
|
138
|
-
(_a2 = global == null ? void 0 : global.removeEventListener) == null ? void 0 : _a2.call(global, "hashchange", hashListener, true);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// src/capture/action/captureClick.ts
|
|
142
|
-
var import_utils2 = require("@ohbug/utils");
|
|
143
|
-
var global2 = (0, import_utils2.getGlobal)();
|
|
144
|
-
function listener(e) {
|
|
145
|
-
if (e.target) {
|
|
146
|
-
const { client } = (0, import_utils2.getOhbugObject)();
|
|
147
|
-
const { tagName, id, className, name, src, outerHTML, nodeType } = e.target;
|
|
148
|
-
const selector = (0, import_utils2.getSelector)(e);
|
|
149
|
-
client.addAction("click node", {
|
|
150
|
-
tagName,
|
|
151
|
-
id,
|
|
152
|
-
className,
|
|
153
|
-
name,
|
|
154
|
-
src,
|
|
155
|
-
outerHTML,
|
|
156
|
-
nodeType,
|
|
157
|
-
selector
|
|
158
|
-
}, "click");
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function captureClick() {
|
|
162
|
-
var _a2, _b2;
|
|
163
|
-
(_b2 = (_a2 = global2 == null ? void 0 : global2.document) == null ? void 0 : _a2.addEventListener) == null ? void 0 : _b2.call(_a2, "click", listener);
|
|
164
|
-
}
|
|
165
|
-
function removeCaptureClick() {
|
|
166
|
-
var _a2, _b2;
|
|
167
|
-
(_b2 = (_a2 = global2 == null ? void 0 : global2.document) == null ? void 0 : _a2.removeEventListener) == null ? void 0 : _b2.call(_a2, "click", listener);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// src/capture/console/captureConsole.ts
|
|
171
|
-
var import_utils3 = require("@ohbug/utils");
|
|
172
|
-
var levels = ["log", "info", "warn", "error"];
|
|
173
|
-
var consoleOriginal = Object.keys(levels).reduce((acc, cur) => __spreadProps(__spreadValues({}, acc), {
|
|
174
|
-
[cur]: console[cur]
|
|
175
|
-
}), {
|
|
176
|
-
log: null,
|
|
177
|
-
info: null,
|
|
178
|
-
warn: null,
|
|
179
|
-
error: null
|
|
180
|
-
});
|
|
181
|
-
function captureConsole() {
|
|
182
|
-
const { client } = (0, import_utils3.getOhbugObject)();
|
|
183
|
-
levels.forEach((level) => {
|
|
184
|
-
consoleOriginal[level] = (0, import_utils3.replace)(console, level, (origin) => function call(...args) {
|
|
185
|
-
const isOhbugConsole = args.some((arg) => typeof arg === "string" && arg.includes("Ohbug"));
|
|
186
|
-
if (!isOhbugConsole)
|
|
187
|
-
client.addAction(`console.${level}`, args, "console");
|
|
188
|
-
return origin.apply(this, args);
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function removeCaptureConsole() {
|
|
193
|
-
if (console) {
|
|
194
|
-
levels.forEach((level) => {
|
|
195
|
-
console[level] = consoleOriginal[level];
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// src/capture/network/captureAjaxError.ts
|
|
201
|
-
var import_utils11 = require("@ohbug/utils");
|
|
202
|
-
var import_core9 = require("@ohbug/core");
|
|
203
|
-
|
|
204
|
-
// src/handle/uncaughtErrorHandler.ts
|
|
205
|
-
var import_utils4 = require("@ohbug/utils");
|
|
206
|
-
var import_core = require("@ohbug/core");
|
|
207
|
-
function uncaughtErrorHandler(error) {
|
|
208
|
-
const {
|
|
209
|
-
message,
|
|
210
|
-
filename,
|
|
211
|
-
lineno,
|
|
212
|
-
colno,
|
|
213
|
-
error: { stack, name }
|
|
214
|
-
} = error;
|
|
215
|
-
const detail = {
|
|
216
|
-
name,
|
|
217
|
-
message,
|
|
218
|
-
filename,
|
|
219
|
-
lineno,
|
|
220
|
-
colno,
|
|
221
|
-
stack
|
|
222
|
-
};
|
|
223
|
-
const { client } = (0, import_utils4.getOhbugObject)();
|
|
224
|
-
const event = client.createEvent({
|
|
225
|
-
category: "error",
|
|
226
|
-
type: import_core.EventTypes.UNCAUGHT_ERROR,
|
|
227
|
-
detail
|
|
228
|
-
});
|
|
229
|
-
client.notify(event);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// src/handle/resourceErrorHandler.ts
|
|
233
|
-
var import_utils5 = require("@ohbug/utils");
|
|
234
|
-
var import_core2 = require("@ohbug/core");
|
|
235
|
-
function resourceErrorHandler(error) {
|
|
236
|
-
const target = error.target || error.srcElement;
|
|
237
|
-
const { outerHTML } = target;
|
|
238
|
-
const selector = (0, import_utils5.getSelector)(error);
|
|
239
|
-
const detail = {
|
|
240
|
-
outerHTML,
|
|
241
|
-
src: target && target.src,
|
|
242
|
-
tagName: target && target.tagName,
|
|
243
|
-
id: target && target.id,
|
|
244
|
-
className: target && target.className,
|
|
245
|
-
name: target && target.name,
|
|
246
|
-
nodeType: target && target.nodeType,
|
|
247
|
-
selector
|
|
248
|
-
};
|
|
249
|
-
const { client } = (0, import_utils5.getOhbugObject)();
|
|
250
|
-
const event = client.createEvent({
|
|
251
|
-
category: "error",
|
|
252
|
-
type: import_core2.EventTypes.RESOURCE_ERROR,
|
|
253
|
-
detail
|
|
254
|
-
});
|
|
255
|
-
client.notify(event);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// src/handle/unhandledrejectionErrorHandler.ts
|
|
259
|
-
var import_utils6 = require("@ohbug/utils");
|
|
260
|
-
var import_core3 = require("@ohbug/core");
|
|
261
|
-
function unhandledrejectionErrorHandler(error) {
|
|
262
|
-
const detail = {
|
|
263
|
-
message: error.reason.message || error.reason,
|
|
264
|
-
stack: error.reason.stack
|
|
265
|
-
};
|
|
266
|
-
const { client } = (0, import_utils6.getOhbugObject)();
|
|
267
|
-
const event = client.createEvent({
|
|
268
|
-
category: "error",
|
|
269
|
-
type: import_core3.EventTypes.UNHANDLEDREJECTION_ERROR,
|
|
270
|
-
detail
|
|
271
|
-
});
|
|
272
|
-
client.notify(event);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// src/handle/unknownErrorHandler.ts
|
|
276
|
-
var import_utils7 = require("@ohbug/utils");
|
|
277
|
-
var import_core4 = require("@ohbug/core");
|
|
278
|
-
function unknownErrorHandler(error) {
|
|
279
|
-
const detail = error.message ? error : { message: error };
|
|
280
|
-
const { client } = (0, import_utils7.getOhbugObject)();
|
|
281
|
-
const event = client.createEvent({
|
|
282
|
-
category: "error",
|
|
283
|
-
type: import_core4.EventTypes.UNKNOWN_ERROR,
|
|
284
|
-
detail
|
|
285
|
-
});
|
|
286
|
-
client.notify(event);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// src/handle/ajaxErrorHandler.ts
|
|
290
|
-
var import_utils8 = require("@ohbug/utils");
|
|
291
|
-
var import_core5 = require("@ohbug/core");
|
|
292
|
-
function ajaxErrorHandler(detail) {
|
|
293
|
-
const { client } = (0, import_utils8.getOhbugObject)();
|
|
294
|
-
const event = client.createEvent({
|
|
295
|
-
category: "error",
|
|
296
|
-
type: import_core5.EventTypes.AJAX_ERROR,
|
|
297
|
-
detail
|
|
298
|
-
});
|
|
299
|
-
client.notify(event);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// src/handle/fetchErrorHandler.ts
|
|
303
|
-
var import_utils9 = require("@ohbug/utils");
|
|
304
|
-
var import_core6 = require("@ohbug/core");
|
|
305
|
-
function fetchErrorHandler(detail) {
|
|
306
|
-
const { client } = (0, import_utils9.getOhbugObject)();
|
|
307
|
-
const event = client.createEvent({
|
|
308
|
-
category: "error",
|
|
309
|
-
type: import_core6.EventTypes.FETCH_ERROR,
|
|
310
|
-
detail
|
|
311
|
-
});
|
|
312
|
-
client.notify(event);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// src/handle/websocketErrorHandler.ts
|
|
316
|
-
var import_utils10 = require("@ohbug/utils");
|
|
317
|
-
var import_core7 = require("@ohbug/core");
|
|
318
|
-
function websocketErrorHandler(detail) {
|
|
319
|
-
const { client } = (0, import_utils10.getOhbugObject)();
|
|
320
|
-
const event = client.createEvent({
|
|
321
|
-
category: "error",
|
|
322
|
-
type: import_core7.EventTypes.WEBSOCKET_ERROR,
|
|
323
|
-
detail
|
|
324
|
-
});
|
|
325
|
-
client.notify(event);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// src/dispatch/scriptDispatcher.ts
|
|
329
|
-
function scriptDispatcher(e) {
|
|
330
|
-
try {
|
|
331
|
-
const { type } = e;
|
|
332
|
-
if (type === "error") {
|
|
333
|
-
const targetEvent = e;
|
|
334
|
-
const { message, error } = targetEvent;
|
|
335
|
-
const immutableTarget = e.target || e.srcElement;
|
|
336
|
-
if (message && error)
|
|
337
|
-
uncaughtErrorHandler(targetEvent);
|
|
338
|
-
else if (immutableTarget)
|
|
339
|
-
resourceErrorHandler(targetEvent);
|
|
340
|
-
} else if (type === "unhandledrejection") {
|
|
341
|
-
unhandledrejectionErrorHandler(e);
|
|
342
|
-
} else {
|
|
343
|
-
unknownErrorHandler(e);
|
|
344
|
-
}
|
|
345
|
-
} catch (error) {
|
|
346
|
-
unknownErrorHandler(error);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// src/dispatch/networkDispatcher.ts
|
|
351
|
-
var import_core8 = require("@ohbug/core");
|
|
352
|
-
function networkDispatcher(type, detail) {
|
|
353
|
-
try {
|
|
354
|
-
switch (type) {
|
|
355
|
-
case import_core8.EventTypes.AJAX_ERROR:
|
|
356
|
-
ajaxErrorHandler(detail);
|
|
357
|
-
break;
|
|
358
|
-
case import_core8.EventTypes.FETCH_ERROR:
|
|
359
|
-
fetchErrorHandler(detail);
|
|
360
|
-
break;
|
|
361
|
-
case import_core8.EventTypes.WEBSOCKET_ERROR:
|
|
362
|
-
websocketErrorHandler(detail);
|
|
363
|
-
break;
|
|
364
|
-
default:
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
367
|
-
} catch (error) {
|
|
368
|
-
unknownErrorHandler(error);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// src/capture/network/captureAjaxError.ts
|
|
373
|
-
var global3 = (0, import_utils11.getGlobal)();
|
|
374
|
-
var access = "XMLHttpRequest" in global3;
|
|
375
|
-
var xhrOriginal = access ? {
|
|
376
|
-
open: XMLHttpRequest.prototype.open,
|
|
377
|
-
send: XMLHttpRequest.prototype.send
|
|
378
|
-
} : {};
|
|
379
|
-
function captureAjaxError() {
|
|
380
|
-
if (!access)
|
|
381
|
-
return;
|
|
382
|
-
const { client } = (0, import_utils11.getOhbugObject)();
|
|
383
|
-
const desc = {
|
|
384
|
-
method: "",
|
|
385
|
-
url: ""
|
|
386
|
-
};
|
|
387
|
-
const xhrProto = XMLHttpRequest == null ? void 0 : XMLHttpRequest.prototype;
|
|
388
|
-
xhrOriginal.open = (0, import_utils11.replace)(xhrProto, "open", (origin) => function call(...args) {
|
|
389
|
-
const [method, url] = args;
|
|
390
|
-
desc.method = method;
|
|
391
|
-
desc.url = url;
|
|
392
|
-
return origin.apply(this, args);
|
|
393
|
-
});
|
|
394
|
-
xhrOriginal.send = (0, import_utils11.replace)(xhrProto, "send", (origin) => function call(...args) {
|
|
395
|
-
this.addEventListener("readystatechange", function handle() {
|
|
396
|
-
if (this.readyState === 4) {
|
|
397
|
-
if (desc.url !== client.__config.endpoint) {
|
|
398
|
-
const detail = {
|
|
399
|
-
req: {
|
|
400
|
-
url: desc.url,
|
|
401
|
-
method: desc.method,
|
|
402
|
-
data: args[0] || {}
|
|
403
|
-
},
|
|
404
|
-
res: {
|
|
405
|
-
status: this.status,
|
|
406
|
-
statusText: this.statusText,
|
|
407
|
-
response: this.response
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
client.addAction("ajax", detail, "ajax");
|
|
411
|
-
if (!this.status || this.status >= 400)
|
|
412
|
-
networkDispatcher(import_core9.EventTypes.AJAX_ERROR, detail);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
return origin.apply(this, args);
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
function removeCaptureAjaxError() {
|
|
420
|
-
if (access && xhrOriginal.open && xhrOriginal.send) {
|
|
421
|
-
const xhrProto = XMLHttpRequest == null ? void 0 : XMLHttpRequest.prototype;
|
|
422
|
-
xhrProto.open = xhrOriginal.open;
|
|
423
|
-
xhrProto.send = xhrOriginal.send;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// src/capture/network/captureFetchError.ts
|
|
428
|
-
var import_utils12 = require("@ohbug/utils");
|
|
429
|
-
var import_core10 = require("@ohbug/core");
|
|
430
|
-
var global4 = (0, import_utils12.getGlobal)();
|
|
431
|
-
var access2 = "fetch" in global4;
|
|
432
|
-
var fetchOriginal = access2 ? global4.fetch : null;
|
|
433
|
-
function captureFetchError() {
|
|
434
|
-
if (!access2)
|
|
435
|
-
return;
|
|
436
|
-
const { client } = (0, import_utils12.getOhbugObject)();
|
|
437
|
-
fetchOriginal = (0, import_utils12.replace)(global4, "fetch", (origin) => function call(...args) {
|
|
438
|
-
return origin.apply(this, args).then((res) => {
|
|
439
|
-
const [url, conf] = args;
|
|
440
|
-
const detail = {
|
|
441
|
-
req: {
|
|
442
|
-
url,
|
|
443
|
-
method: conf && conf.method,
|
|
444
|
-
data: conf && conf.body || {}
|
|
445
|
-
},
|
|
446
|
-
res: {
|
|
447
|
-
status: res.status,
|
|
448
|
-
statusText: res.statusText
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
client.addAction("fetch", detail, "fetch");
|
|
452
|
-
if (!res.status || res.status >= 400)
|
|
453
|
-
networkDispatcher(import_core10.EventTypes.FETCH_ERROR, detail);
|
|
454
|
-
return res;
|
|
455
|
-
}, (err) => {
|
|
456
|
-
const [url, conf] = args;
|
|
457
|
-
const detail = {
|
|
458
|
-
req: {
|
|
459
|
-
url,
|
|
460
|
-
method: conf && conf.method,
|
|
461
|
-
data: conf && conf.body || {}
|
|
462
|
-
},
|
|
463
|
-
res: {
|
|
464
|
-
status: 400,
|
|
465
|
-
statusText: "unknownError"
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
networkDispatcher(import_core10.EventTypes.FETCH_ERROR, detail);
|
|
469
|
-
throw err;
|
|
470
|
-
});
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
function removeCaptureFetchError() {
|
|
474
|
-
if (access2 && fetchOriginal)
|
|
475
|
-
global4.fetch = fetchOriginal;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// src/capture/network/captureWebSocketError.ts
|
|
479
|
-
var import_utils13 = require("@ohbug/utils");
|
|
480
|
-
var import_core11 = require("@ohbug/core");
|
|
481
|
-
var global5 = (0, import_utils13.getGlobal)();
|
|
482
|
-
function captureWebSocketError() {
|
|
483
|
-
if (!("WebSocket" in global5))
|
|
484
|
-
return;
|
|
485
|
-
const wsProto = WebSocket == null ? void 0 : WebSocket.prototype;
|
|
486
|
-
const backup = Object.getOwnPropertyDescriptor(wsProto, "onerror");
|
|
487
|
-
Object.defineProperty(wsProto, "onerror", {
|
|
488
|
-
set() {
|
|
489
|
-
var _a2;
|
|
490
|
-
const args = arguments;
|
|
491
|
-
const arg = args[0];
|
|
492
|
-
(_a2 = backup == null ? void 0 : backup.set) == null ? void 0 : _a2.call(this, function call(e) {
|
|
493
|
-
const {
|
|
494
|
-
target: {
|
|
495
|
-
url,
|
|
496
|
-
readyState,
|
|
497
|
-
protocol,
|
|
498
|
-
extensions,
|
|
499
|
-
binaryType,
|
|
500
|
-
bufferedAmount
|
|
501
|
-
},
|
|
502
|
-
timeStamp
|
|
503
|
-
} = e;
|
|
504
|
-
const detail = {
|
|
505
|
-
url,
|
|
506
|
-
timeStamp,
|
|
507
|
-
readyState,
|
|
508
|
-
protocol,
|
|
509
|
-
extensions,
|
|
510
|
-
binaryType,
|
|
511
|
-
bufferedAmount
|
|
512
|
-
};
|
|
513
|
-
networkDispatcher(import_core11.EventTypes.WEBSOCKET_ERROR, detail);
|
|
514
|
-
arg.apply(this, args);
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// src/capture/script/captureUncaughtError.ts
|
|
521
|
-
var import_utils14 = require("@ohbug/utils");
|
|
522
|
-
var global6 = (0, import_utils14.getGlobal)();
|
|
523
|
-
function listener2(e) {
|
|
524
|
-
scriptDispatcher(e);
|
|
525
|
-
}
|
|
526
|
-
function captureUncaughtError() {
|
|
527
|
-
var _a2;
|
|
528
|
-
(_a2 = global6 == null ? void 0 : global6.addEventListener) == null ? void 0 : _a2.call(global6, "error", listener2, true);
|
|
529
|
-
}
|
|
530
|
-
function removeCaptureUncaughtError() {
|
|
531
|
-
var _a2;
|
|
532
|
-
(_a2 = global6 == null ? void 0 : global6.removeEventListener) == null ? void 0 : _a2.call(global6, "error", listener2, true);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
// src/capture/script/captureUnhandledrejectionError.ts
|
|
536
|
-
var import_utils15 = require("@ohbug/utils");
|
|
537
|
-
var global7 = (0, import_utils15.getGlobal)();
|
|
538
|
-
function listener3(e) {
|
|
539
|
-
scriptDispatcher(e);
|
|
540
|
-
}
|
|
541
|
-
function captureUnhandledrejectionError() {
|
|
542
|
-
var _a2;
|
|
543
|
-
(_a2 = global7 == null ? void 0 : global7.addEventListener) == null ? void 0 : _a2.call(global7, "unhandledrejection", listener3, true);
|
|
544
|
-
}
|
|
545
|
-
function removeCaptureUnhandledrejectionError() {
|
|
546
|
-
var _a2;
|
|
547
|
-
(_a2 = global7 == null ? void 0 : global7.removeEventListener) == null ? void 0 : _a2.call(global7, "unhandledrejection", listener3, true);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
// src/capture/index.ts
|
|
551
|
-
function captureAction() {
|
|
552
|
-
captureUrlChange();
|
|
553
|
-
captureClick();
|
|
554
|
-
}
|
|
555
|
-
function removeCaptureAction() {
|
|
556
|
-
removeCaptureUrlChange();
|
|
557
|
-
removeCaptureClick();
|
|
558
|
-
}
|
|
559
|
-
function captureNetwork() {
|
|
560
|
-
captureAjaxError();
|
|
561
|
-
captureFetchError();
|
|
562
|
-
captureWebSocketError();
|
|
563
|
-
}
|
|
564
|
-
function removeCaptureNetwork() {
|
|
565
|
-
removeCaptureAjaxError();
|
|
566
|
-
removeCaptureFetchError();
|
|
567
|
-
}
|
|
568
|
-
function captureScript() {
|
|
569
|
-
const global9 = (0, import_utils16.getGlobal)();
|
|
570
|
-
if (!global9.addEventListener)
|
|
571
|
-
return;
|
|
572
|
-
captureUncaughtError();
|
|
573
|
-
captureUnhandledrejectionError();
|
|
574
|
-
}
|
|
575
|
-
function removeCaptureScript() {
|
|
576
|
-
removeCaptureUncaughtError();
|
|
577
|
-
removeCaptureUnhandledrejectionError();
|
|
578
|
-
}
|
|
579
|
-
function handleCapture() {
|
|
580
|
-
captureScript();
|
|
581
|
-
captureNetwork();
|
|
582
|
-
captureAction();
|
|
583
|
-
captureConsole();
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
// src/destroy.ts
|
|
587
|
-
var import_utils17 = require("@ohbug/utils");
|
|
588
|
-
var global8 = (0, import_utils17.getGlobal)();
|
|
589
|
-
function handleDestroy() {
|
|
590
|
-
var _a2;
|
|
591
|
-
(_a2 = global8 == null ? void 0 : global8.addEventListener) == null ? void 0 : _a2.call(global8, "unload", () => {
|
|
592
|
-
removeCaptureScript();
|
|
593
|
-
removeCaptureNetwork();
|
|
594
|
-
removeCaptureAction();
|
|
595
|
-
removeCaptureConsole();
|
|
596
|
-
}, true);
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// src/extension.ts
|
|
600
|
-
var extension = (0, import_core12.defineExtension)({
|
|
601
|
-
name: "OhbugBrowser",
|
|
602
|
-
setup: () => {
|
|
603
|
-
handleCapture();
|
|
604
|
-
handleDestroy();
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
// src/notifier.ts
|
|
609
|
-
var import_utils18 = require("@ohbug/utils");
|
|
610
|
-
var getCircularReplacer = () => {
|
|
611
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
612
|
-
return (_, value) => {
|
|
613
|
-
if (typeof value === "object" && value !== null) {
|
|
614
|
-
if (seen.has(value))
|
|
615
|
-
return;
|
|
616
|
-
seen.add(value);
|
|
617
|
-
}
|
|
618
|
-
return value;
|
|
619
|
-
};
|
|
620
|
-
};
|
|
621
|
-
function notifier(event) {
|
|
622
|
-
const { client } = (0, import_utils18.getOhbugObject)();
|
|
623
|
-
const url = client.__config.endpoint;
|
|
624
|
-
return new Promise((resolve, reject) => {
|
|
625
|
-
const json = JSON.stringify(event, getCircularReplacer());
|
|
626
|
-
if (navigator.sendBeacon) {
|
|
627
|
-
const result = navigator.sendBeacon(url, json);
|
|
628
|
-
resolve(result);
|
|
629
|
-
} else {
|
|
630
|
-
const xhr = new XMLHttpRequest();
|
|
631
|
-
xhr.onreadystatechange = () => {
|
|
632
|
-
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
633
|
-
if (xhr.status >= 200 && xhr.status < 300)
|
|
634
|
-
return resolve(xhr.response);
|
|
635
|
-
reject(xhr);
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
xhr.open("POST", url);
|
|
639
|
-
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
640
|
-
xhr.send(json);
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
// src/client.ts
|
|
646
|
-
function createClient(config) {
|
|
647
|
-
const global9 = (0, import_utils19.getGlobal)();
|
|
648
|
-
const sdk = {
|
|
649
|
-
platform: "ohbug-browser",
|
|
650
|
-
version
|
|
651
|
-
};
|
|
652
|
-
const client = new import_core13.Client({ sdk, config, device, notifier });
|
|
653
|
-
global9.__OHBUG__ = { client };
|
|
654
|
-
client.use(extension);
|
|
655
|
-
client.__logger.info(`%c @ohbug/browser %c Detected Ohbug v${version} %c`, "background:#333; padding: 2px 1px; color: #FFF", "background:#FF6F61; padding: 2px 1px; color: #FFF", "background:transparent");
|
|
656
|
-
return client;
|
|
657
|
-
}
|
|
658
|
-
var BrowserClient = {
|
|
659
|
-
__client: null,
|
|
660
|
-
setup(config) {
|
|
661
|
-
var _a2;
|
|
662
|
-
if (BrowserClient.__client) {
|
|
663
|
-
(_a2 = BrowserClient.__client.__logger) == null ? void 0 : _a2.warn("init() has been called. Ignored.");
|
|
664
|
-
return BrowserClient.__client;
|
|
665
|
-
}
|
|
666
|
-
BrowserClient.__client = createClient(config);
|
|
667
|
-
return BrowserClient.__client;
|
|
668
|
-
}
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
// src/index.ts
|
|
672
|
-
var src_default = BrowserClient;
|
|
673
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
674
|
-
0 && (module.exports = {});
|
|
1
|
+
var R=Object.defineProperty,rt=Object.defineProperties,ot=Object.getOwnPropertyDescriptor,nt=Object.getOwnPropertyDescriptors,it=Object.getOwnPropertyNames,J=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var $=(e,t,r)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,z=(e,t)=>{for(var r in t||(t={}))I.call(t,r)&&$(e,r,t[r]);if(J)for(var r of J(t))at.call(t,r)&&$(e,r,t[r]);return e},Q=(e,t)=>rt(e,nt(t));var st=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},ct=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of it(t))!I.call(e,o)&&o!==r&&R(e,o,{get:()=>t[o],enumerable:!(n=ot(t,o))||n.enumerable});return e};var pt=e=>ct(R({},"__esModule",{value:!0}),e);var xt={};st(xt,{default:()=>yt});module.exports=pt(xt);var ze=require("@ohbug/core"),Qe=require("@ohbug/utils");var V=()=>{let e={};if(navigator){let{language:t,userAgent:r}=navigator;e.language=t,e.userAgent=r}if(document){let{title:t}=document;e.title=t}if(window.location){let{href:t}=window.location;e.url=t}return e};var W="2.0.3";var Ke=require("@ohbug/core");var Be=require("@ohbug/utils");var u=require("@ohbug/utils"),a=(0,u.getGlobal)(),_;function U(e,t){var f;let{client:r}=(0,u.getOhbugObject)(),n=(0,u.parseUrl)((f=a==null?void 0:a.location)==null?void 0:f.href),o=(0,u.parseUrl)(e),s=(0,u.parseUrl)(t);o.path||(o=n),_=t;let i=e,p=t;n.protocol===s.protocol&&n.host===s.host&&(p=s.relative),n.protocol===o.protocol&&n.host===o.host&&(i=o.relative),i!==p&&r.addAction(`navigation to ${t}`,{from:e,to:t},"navigation")}function Y(e){return function(r,n,o){return o&&U(_,String(o)),e.apply(this,[r,n,o])}}var Z,ee,g={pushState:(Z=a==null?void 0:a.history)==null?void 0:Z.pushState,replaceState:(ee=a==null?void 0:a.history)==null?void 0:ee.replaceState,onpopstate:a==null?void 0:a.onpopstate};function ut(){g.pushState=(0,u.replace)(a==null?void 0:a.history,"pushState",Y),g.replaceState=(0,u.replace)(a==null?void 0:a.history,"replaceState",Y),g.onpopstate=(0,u.replace)(a,"onpopstate",e=>function(...r){var o;let n=(o=a==null?void 0:a.location)==null?void 0:o.href;return U(_,n),e==null?void 0:e.apply(this,r)})}function te(e){let{oldURL:t,newURL:r}=e;U(t,r)}function re(){var e;ut(),(e=a==null?void 0:a.addEventListener)==null||e.call(a,"hashchange",te,!0)}function oe(){var e;a.history.pushState=g.pushState,a.history.replaceState=g.replaceState,a.onpopstate=g.onpopstate,(e=a==null?void 0:a.removeEventListener)==null||e.call(a,"hashchange",te,!0)}var x=require("@ohbug/utils"),y=(0,x.getGlobal)();function ne(e){if(e.target){let{client:t}=(0,x.getOhbugObject)(),{tagName:r,id:n,className:o,name:s,src:i,outerHTML:p,nodeType:f}=e.target,D=(0,x.getSelector)(e);t.addAction("click node",{tagName:r,id:n,className:o,name:s,src:i,outerHTML:p,nodeType:f,selector:D},"click")}}function ie(){var e,t;(t=(e=y==null?void 0:y.document)==null?void 0:e.addEventListener)==null||t.call(e,"click",ne)}function ae(){var e,t;(t=(e=y==null?void 0:y.document)==null?void 0:e.removeEventListener)==null||t.call(e,"click",ne)}var C=require("@ohbug/utils"),S=["log","info","warn","error"],se=Object.keys(S).reduce((e,t)=>Q(z({},e),{[t]:console[t]}),{log:null,info:null,warn:null,error:null});function ce(){let{client:e}=(0,C.getOhbugObject)();S.forEach(t=>{se[t]=(0,C.replace)(console,t,r=>function(...o){return o.some(i=>typeof i=="string"&&i.includes("Ohbug"))||e.addAction(`console.${t}`,o,"console"),r.apply(this,o)})})}function A(){console&&S.forEach(e=>{console[e]=se[e]})}var h=require("@ohbug/utils"),ve=require("@ohbug/core");var pe=require("@ohbug/utils"),ue=require("@ohbug/core");function L(e){let{message:t,filename:r,lineno:n,colno:o,error:{stack:s,name:i}}=e,p={name:i,message:t,filename:r,lineno:n,colno:o,stack:s},{client:f}=(0,pe.getOhbugObject)(),D=f.createEvent({category:"error",type:ue.EventTypes.UNCAUGHT_ERROR,detail:p});f.notify(D)}var j=require("@ohbug/utils"),le=require("@ohbug/core");function F(e){let t=e.target||e.srcElement,{outerHTML:r}=t,n=(0,j.getSelector)(e),o={outerHTML:r,src:t&&t.src,tagName:t&&t.tagName,id:t&&t.id,className:t&&t.className,name:t&&t.name,nodeType:t&&t.nodeType,selector:n},{client:s}=(0,j.getOhbugObject)(),i=s.createEvent({category:"error",type:le.EventTypes.RESOURCE_ERROR,detail:o});s.notify(i)}var me=require("@ohbug/utils"),fe=require("@ohbug/core");function B(e){let t={message:e.reason.message||e.reason,stack:e.reason.stack},{client:r}=(0,me.getOhbugObject)(),n=r.createEvent({category:"error",type:fe.EventTypes.UNHANDLEDREJECTION_ERROR,detail:t});r.notify(n)}var de=require("@ohbug/utils"),he=require("@ohbug/core");function O(e){let t=e.message?e:{message:e},{client:r}=(0,de.getOhbugObject)(),n=r.createEvent({category:"error",type:he.EventTypes.UNKNOWN_ERROR,detail:t});r.notify(n)}var Ee=require("@ohbug/utils"),ge=require("@ohbug/core");function N(e){let{client:t}=(0,Ee.getOhbugObject)(),r=t.createEvent({category:"error",type:ge.EventTypes.AJAX_ERROR,detail:e});t.notify(r)}var ye=require("@ohbug/utils"),xe=require("@ohbug/core");function G(e){let{client:t}=(0,ye.getOhbugObject)(),r=t.createEvent({category:"error",type:xe.EventTypes.FETCH_ERROR,detail:e});t.notify(r)}var Oe=require("@ohbug/utils"),be=require("@ohbug/core");function q(e){let{client:t}=(0,Oe.getOhbugObject)(),r=t.createEvent({category:"error",type:be.EventTypes.WEBSOCKET_ERROR,detail:e});t.notify(r)}function k(e){try{let{type:t}=e;if(t==="error"){let r=e,{message:n,error:o}=r,s=e.target||e.srcElement;n&&o?L(r):s&&F(r)}else t==="unhandledrejection"?B(e):O(e)}catch(t){O(t)}}var H=require("@ohbug/core");function d(e,t){try{switch(e){case H.EventTypes.AJAX_ERROR:N(t);break;case H.EventTypes.FETCH_ERROR:G(t);break;case H.EventTypes.WEBSOCKET_ERROR:q(t);break;default:break}}catch(r){O(r)}}var lt=(0,h.getGlobal)(),M="XMLHttpRequest"in lt,b=M?{open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send}:{};function De(){if(!M)return;let{client:e}=(0,h.getOhbugObject)(),t={method:"",url:""},r=XMLHttpRequest==null?void 0:XMLHttpRequest.prototype;b.open=(0,h.replace)(r,"open",n=>function(...s){let[i,p]=s;return t.method=i,t.url=p,n.apply(this,s)}),b.send=(0,h.replace)(r,"send",n=>function(...s){return this.addEventListener("readystatechange",function(){if(this.readyState===4&&t.url!==e.__config.endpoint){let p={req:{url:t.url,method:t.method,data:s[0]||{}},res:{status:this.status,statusText:this.statusText,response:this.response}};e.addAction("ajax",p,"ajax"),(!this.status||this.status>=400)&&d(ve.EventTypes.AJAX_ERROR,p)}}),n.apply(this,s)})}function we(){if(M&&b.open&&b.send){let e=XMLHttpRequest==null?void 0:XMLHttpRequest.prototype;e.open=b.open,e.send=b.send}}var v=require("@ohbug/utils"),P=require("@ohbug/core");var T=(0,v.getGlobal)(),K="fetch"in T,X=K?T.fetch:null;function Re(){if(!K)return;let{client:e}=(0,v.getOhbugObject)();X=(0,v.replace)(T,"fetch",t=>function(...n){return t.apply(this,n).then(o=>{let[s,i]=n,p={req:{url:s,method:i&&i.method,data:i&&i.body||{}},res:{status:o.status,statusText:o.statusText}};return e.addAction("fetch",p,"fetch"),(!o.status||o.status>=400)&&d(P.EventTypes.FETCH_ERROR,p),o},o=>{let[s,i]=n,p={req:{url:s,method:i&&i.method,data:i&&i.body||{}},res:{status:400,statusText:"unknownError"}};throw d(P.EventTypes.FETCH_ERROR,p),o})})}function Ce(){K&&X&&(T.fetch=X)}var je=require("@ohbug/utils"),ke=require("@ohbug/core");var mt=(0,je.getGlobal)();function He(){if(!("WebSocket"in mt))return;let e=WebSocket==null?void 0:WebSocket.prototype,t=Object.getOwnPropertyDescriptor(e,"onerror");Object.defineProperty(e,"onerror",{set(){var o;let r=arguments,n=r[0];(o=t==null?void 0:t.set)==null||o.call(this,function(i){let{target:{url:p,readyState:f,protocol:D,extensions:Ve,binaryType:Ye,bufferedAmount:Ze},timeStamp:et}=i,tt={url:p,timeStamp:et,readyState:f,protocol:D,extensions:Ve,binaryType:Ye,bufferedAmount:Ze};d(ke.EventTypes.WEBSOCKET_ERROR,tt),n.apply(this,r)})}})}var Te=require("@ohbug/utils");var l=(0,Te.getGlobal)();function We(e){k(e)}function _e(){var e;(e=l==null?void 0:l.addEventListener)==null||e.call(l,"error",We,!0)}function Ue(){var e;(e=l==null?void 0:l.removeEventListener)==null||e.call(l,"error",We,!0)}var Se=require("@ohbug/utils");var m=(0,Se.getGlobal)();function Ae(e){k(e)}function Le(){var e;(e=m==null?void 0:m.addEventListener)==null||e.call(m,"unhandledrejection",Ae,!0)}function Fe(){var e;(e=m==null?void 0:m.removeEventListener)==null||e.call(m,"unhandledrejection",Ae,!0)}function ft(){re(),ie()}function Ne(){oe(),ae()}function dt(){De(),Re(),He()}function Ge(){we(),Ce()}function ht(){!(0,Be.getGlobal)().addEventListener||(_e(),Le())}function qe(){Ue(),Fe()}function Me(){ht(),dt(),ft(),ce()}var Pe=require("@ohbug/utils");var w=(0,Pe.getGlobal)();function Xe(){var e;(e=w==null?void 0:w.addEventListener)==null||e.call(w,"unload",()=>{qe(),Ge(),Ne(),A()},!0)}var Je=(0,Ke.defineExtension)({name:"OhbugBrowser",setup:()=>{Me(),Xe()}});var $e=require("@ohbug/utils"),Et=()=>{let e=new WeakSet;return(t,r)=>{if(typeof r=="object"&&r!==null){if(e.has(r))return;e.add(r)}return r}};function Ie(e){let{client:t}=(0,$e.getOhbugObject)(),r=t.__config.endpoint;return new Promise((n,o)=>{let s=JSON.stringify(e,Et());if(navigator.sendBeacon){let i=navigator.sendBeacon(r,s);n(i)}else{let i=new XMLHttpRequest;i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status>=200&&i.status<300)return n(i.response);o(i)}},i.open("POST",r),i.setRequestHeader("Content-Type","application/json;charset=UTF-8"),i.send(s)}})}function gt(e){let t=(0,Qe.getGlobal)(),r={platform:"ohbug-browser",version:W},n=new ze.Client({sdk:r,config:e,device:V,notifier:Ie});return t.__OHBUG__={client:n},n.use(Je),n.__logger.info(`%c @ohbug/browser %c Detected Ohbug v${W} %c`,"background:#333; padding: 2px 1px; color: #FFF","background:#FF6F61; padding: 2px 1px; color: #FFF","background:transparent"),n}var E={__client:null,setup(e){var t;return E.__client?((t=E.__client.__logger)==null||t.warn("init() has been called. Ignored."),E.__client):(E.__client=gt(e),E.__client)}};var yt=E;0&&(module.exports={});
|