@xifan0/monitor-web 0.0.2-beta.1 → 0.0.2-beta.10
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.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +49 -2
- package/dist/index.mjs +48 -1
- package/package.json +9 -2
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _xifan0_monitor_core from '@xifan0/monitor-core';
|
|
2
|
+
|
|
3
|
+
declare const Monitor: _xifan0_monitor_core.Monitor;
|
|
4
|
+
declare const init: (options: any) => any;
|
|
5
|
+
declare const captureException: (error: Error, ctx?: _xifan0_monitor_core.CaptureContext) => any;
|
|
6
|
+
declare const captureMessage: (message: string, ctx?: _xifan0_monitor_core.CaptureContext) => any;
|
|
7
|
+
declare const setUser: (user: _xifan0_monitor_core.MonitorUser) => any;
|
|
8
|
+
|
|
9
|
+
export { captureException, captureMessage, Monitor as default, init, setUser };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _xifan0_monitor_core from '@xifan0/monitor-core';
|
|
2
|
+
|
|
3
|
+
declare const Monitor: _xifan0_monitor_core.Monitor;
|
|
4
|
+
declare const init: (options: any) => any;
|
|
5
|
+
declare const captureException: (error: Error, ctx?: _xifan0_monitor_core.CaptureContext) => any;
|
|
6
|
+
declare const captureMessage: (message: string, ctx?: _xifan0_monitor_core.CaptureContext) => any;
|
|
7
|
+
declare const setUser: (user: _xifan0_monitor_core.MonitorUser) => any;
|
|
8
|
+
|
|
9
|
+
export { captureException, captureMessage, Monitor as default, init, setUser };
|
package/dist/index.js
CHANGED
|
@@ -38,8 +38,55 @@ __export(index_exports, {
|
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(index_exports);
|
|
40
40
|
var Sentry = __toESM(require("@sentry/react"));
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
|
|
42
|
+
// ../monitor-core/src/createMonitor.ts
|
|
43
|
+
function createMonitor(sentry) {
|
|
44
|
+
const monitor = {
|
|
45
|
+
init(options) {
|
|
46
|
+
return sentry.init(options);
|
|
47
|
+
},
|
|
48
|
+
/** 上报异常 */
|
|
49
|
+
captureException(error, ctx) {
|
|
50
|
+
return sentry.captureException(error, (scope) => {
|
|
51
|
+
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
52
|
+
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
53
|
+
return scope;
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
/** 发送消息/提醒/日志 */
|
|
57
|
+
captureMessage(message, ctx) {
|
|
58
|
+
return sentry.captureMessage(message, (scope) => {
|
|
59
|
+
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
60
|
+
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
61
|
+
return scope;
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
/** 设置用户信息 */
|
|
65
|
+
setUser(user) {
|
|
66
|
+
return sentry.setUser(user);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const proxy = new Proxy(monitor, {
|
|
70
|
+
get(target, key, receiver) {
|
|
71
|
+
if (key in target) {
|
|
72
|
+
return Reflect.get(target, key, receiver);
|
|
73
|
+
}
|
|
74
|
+
const sentryFn = sentry[key];
|
|
75
|
+
if (typeof sentryFn === "function") {
|
|
76
|
+
const isClass = sentryFn.prototype && sentryFn.prototype.constructor === sentryFn && Object.getOwnPropertyNames(sentryFn.prototype).length > 1;
|
|
77
|
+
if (isClass) {
|
|
78
|
+
return sentryFn;
|
|
79
|
+
}
|
|
80
|
+
return sentryFn.bind(sentry);
|
|
81
|
+
}
|
|
82
|
+
return sentryFn;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return proxy;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/index.ts
|
|
89
|
+
var Monitor = createMonitor(Sentry);
|
|
43
90
|
var { init, captureException, captureMessage, setUser } = Monitor;
|
|
44
91
|
var index_default = Monitor;
|
|
45
92
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import * as Sentry from "@sentry/react";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
// ../monitor-core/src/createMonitor.ts
|
|
5
|
+
function createMonitor(sentry) {
|
|
6
|
+
const monitor = {
|
|
7
|
+
init(options) {
|
|
8
|
+
return sentry.init(options);
|
|
9
|
+
},
|
|
10
|
+
/** 上报异常 */
|
|
11
|
+
captureException(error, ctx) {
|
|
12
|
+
return sentry.captureException(error, (scope) => {
|
|
13
|
+
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
14
|
+
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
15
|
+
return scope;
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
/** 发送消息/提醒/日志 */
|
|
19
|
+
captureMessage(message, ctx) {
|
|
20
|
+
return sentry.captureMessage(message, (scope) => {
|
|
21
|
+
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
22
|
+
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
23
|
+
return scope;
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
/** 设置用户信息 */
|
|
27
|
+
setUser(user) {
|
|
28
|
+
return sentry.setUser(user);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const proxy = new Proxy(monitor, {
|
|
32
|
+
get(target, key, receiver) {
|
|
33
|
+
if (key in target) {
|
|
34
|
+
return Reflect.get(target, key, receiver);
|
|
35
|
+
}
|
|
36
|
+
const sentryFn = sentry[key];
|
|
37
|
+
if (typeof sentryFn === "function") {
|
|
38
|
+
const isClass = sentryFn.prototype && sentryFn.prototype.constructor === sentryFn && Object.getOwnPropertyNames(sentryFn.prototype).length > 1;
|
|
39
|
+
if (isClass) {
|
|
40
|
+
return sentryFn;
|
|
41
|
+
}
|
|
42
|
+
return sentryFn.bind(sentry);
|
|
43
|
+
}
|
|
44
|
+
return sentryFn;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return proxy;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/index.ts
|
|
4
51
|
var Monitor = createMonitor(Sentry);
|
|
5
52
|
var { init, captureException, captureMessage, setUser } = Monitor;
|
|
6
53
|
var index_default = Monitor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xifan0/monitor-web",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.10",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,12 +8,19 @@
|
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
11
18
|
"peerDependencies": {
|
|
12
19
|
"@sentry/react": "^7"
|
|
13
20
|
},
|
|
14
21
|
"dependencies": {
|
|
15
22
|
"@sentry/react": "^7",
|
|
16
|
-
"@xifan0/monitor-core": "0.0.2-beta.
|
|
23
|
+
"@xifan0/monitor-core": "0.0.2-beta.10"
|
|
17
24
|
},
|
|
18
25
|
"devDependencies": {
|
|
19
26
|
"@sentry/react": "^7",
|