@xifan052/monitor 0.0.4 → 0.0.6
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 +28 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +0 -0
- package/dist/index.mjs.map +1 -0
- package/dist/metro.js +23 -1
- package/dist/metro.mjs +2 -0
- package/dist/rn.d.mts +9 -0
- package/dist/rn.d.ts +3 -10
- package/dist/rn.js +77 -42
- package/dist/rn.js.map +1 -0
- package/dist/rn.mjs +56 -0
- package/dist/rn.mjs.map +1 -0
- package/dist/types-Ch7wGRWa.d.mts +37 -0
- package/dist/types-Ch7wGRWa.d.ts +37 -0
- package/dist/web.d.mts +9 -0
- package/dist/web.d.ts +3 -10
- package/dist/web.js +77 -42
- package/dist/web.js.map +1 -0
- package/dist/web.mjs +56 -0
- package/dist/web.mjs.map +1 -0
- package/package.json +47 -49
- package/dist/baseClient--kldMm4n.d.ts +0 -14
- package/dist/baseClient-CStLSuih.d.cts +0 -23
- package/dist/baseClient-Ce8FQx7I.d.ts +0 -23
- package/dist/baseClient-CpBY_Ydd.d.cts +0 -23
- package/dist/baseClient-CpBY_Ydd.d.ts +0 -23
- package/dist/baseClient-CzPUJKaJ.d.ts +0 -13
- package/dist/baseClient-Dq6Nxof9.d.cts +0 -14
- package/dist/baseClient-DuhASKYf.d.cts +0 -13
- package/dist/index.cjs +0 -18
- package/dist/index.d.cts +0 -12
- package/dist/metro.cjs +0 -24
- package/dist/rn.cjs +0 -97
- package/dist/rn.d.cts +0 -16
- package/dist/web.cjs +0 -97
- package/dist/web.d.cts +0 -16
- /package/dist/{metro.d.cts → metro.d.mts} +0 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface MonitorUser {
|
|
2
|
+
id?: string;
|
|
3
|
+
email?: string;
|
|
4
|
+
username?: string;
|
|
5
|
+
[key: string]: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
interface CaptureContext {
|
|
8
|
+
tags?: Record<string, string>;
|
|
9
|
+
extra?: Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
interface Monitor {
|
|
12
|
+
init(options: any): any;
|
|
13
|
+
/** 上报异常 */
|
|
14
|
+
captureException(error: Error, ctx?: CaptureContext): any;
|
|
15
|
+
/** 发送消息/提醒/日志 */
|
|
16
|
+
captureMessage(message: string, ctx?: CaptureContext): any;
|
|
17
|
+
/** 设置用户信息 */
|
|
18
|
+
setUser(user: MonitorUser): any;
|
|
19
|
+
/** sentry事件 */
|
|
20
|
+
addBreadcrumb?(crumb: any): any;
|
|
21
|
+
setTag?(key: string, value: string): any;
|
|
22
|
+
setContext?(key: string, ctx: any): any;
|
|
23
|
+
withScope?(cb: (scope: any) => void): any;
|
|
24
|
+
/** 未声明事件的调用 */
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type { CaptureContext, Monitor, MonitorUser };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,5 +8,21 @@ interface CaptureContext {
|
|
|
8
8
|
tags?: Record<string, string>;
|
|
9
9
|
extra?: Record<string, any>;
|
|
10
10
|
}
|
|
11
|
+
interface Monitor {
|
|
12
|
+
init(options: any): any;
|
|
13
|
+
/** 上报异常 */
|
|
14
|
+
captureException(error: Error, ctx?: CaptureContext): any;
|
|
15
|
+
/** 发送消息/提醒/日志 */
|
|
16
|
+
captureMessage(message: string, ctx?: CaptureContext): any;
|
|
17
|
+
/** 设置用户信息 */
|
|
18
|
+
setUser(user: MonitorUser): any;
|
|
19
|
+
/** sentry事件 */
|
|
20
|
+
addBreadcrumb?(crumb: any): any;
|
|
21
|
+
setTag?(key: string, value: string): any;
|
|
22
|
+
setContext?(key: string, ctx: any): any;
|
|
23
|
+
withScope?(cb: (scope: any) => void): any;
|
|
24
|
+
/** 未声明事件的调用 */
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
11
27
|
|
|
12
|
-
export type { CaptureContext, MonitorUser };
|
|
28
|
+
export type { CaptureContext, Monitor, MonitorUser };
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/createMonitor.ts"],"names":[],"mappings":";;;AAEO,SAAS,cAAc,OAAA,EAAwC;AACpE,EAAA,MAAM,IAAA,GAAsB;AAAA,IAC1B,MAAM,OAAA,CAAQ,IAAA;AAAA,IAEd,kBAAkB,CAAC,CAAA,EAAG,QAAQ,OAAA,CAAQ,gBAAA,CAAiB,GAAG,GAAG,CAAA;AAAA,IAC7D,gBAAgB,CAAC,CAAA,EAAG,QAAQ,OAAA,CAAQ,cAAA,CAAe,GAAG,GAAG,CAAA;AAAA,IAEzD,OAAA,EAAS,CAAC,CAAA,KAAM,OAAA,CAAQ,QAAQ,CAAC,CAAA;AAAA,IACjC,QAAQ,CAAC,CAAA,EAAG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AAqB,GAAA,CAAA,EAAM;AAC7B,QAAA,OAAO,OAAA,CAAQ,WAAW,GAAG,CAAA;AAAA,MAC/B;AAEA,MAAA,MAAM,KAAK,OAAA,CAAQ,QAAA;AACnB,MAAA,MAAM,MAAM,EAAA,IAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAK,GAAA,CAAA;AAEjB,MAAA,IAAI,OAAO,QAAQ,UAAA,EAAY;AAC7B,QAAA,OAAO,GAAA,CAAI,KAAK,EAAE,CAAA;AAAA,MACpB;AACA,MAAA,OAAO,GAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH","file":"index.js","sourcesContent":["import type { MonitorAdapter, MonitorClient } from \"./types\";\r\n\r\nexport function createMonitor(adapter: MonitorAdapter): MonitorClient {\r\n const base: MonitorClient = {\r\n init: adapter.init,\r\n\r\n captureException: (e, ctx) => adapter.captureException(e, ctx),\r\n captureMessage: (m, ctx) => adapter.captureMessage(m, ctx),\r\n\r\n setUser: (u) => adapter.setUser(u),\r\n setTag: (k, v) => adapter.setTag(k, v),\r\n setExtra: (k, v) => adapter.setExtra(k, v),\r\n\r\n withScope: (cb) => adapter.withScope(cb),\r\n\r\n flush: (t) => adapter.flush?.(t) ?? Promise.resolve(true),\r\n close: (t) => adapter.close?.(t) ?? Promise.resolve(true),\r\n };\r\n\r\n return new Proxy(base as any, {\r\n get(target, prop, receiver) {\r\n if (prop in target) {\r\n return Reflect.get(target, prop, receiver);\r\n }\r\n\r\n const key = prop as string;\r\n\r\n if (adapter.extensions?.[key]) {\r\n return adapter.extensions[key];\r\n }\r\n\r\n const fb = adapter.fallback;\r\n const val = fb?.[key];\r\n\r\n if (typeof val === \"function\") {\r\n return val.bind(fb);\r\n }\r\n return val;\r\n },\r\n }) as MonitorClient & Record<string, any>;\r\n}\r\n"]}
|
package/dist/index.mjs
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/createMonitor.ts"],"names":[],"mappings":";AAEO,SA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AA,OAAO,IAAI,MAAM,IAAA,EAAa;AAAA,IAC5B,GAAA,CAAI,MAAA,EAAQ,IAAA,EAAM,QAAA,EAAU;AApBhC,MAAA,IAAA,EAAA;AAqBM,MAAA,IAAI,QAAQ,MAAA,EAAQ;AAClB,QAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,MAAA,EAAQ,IAAA,EAAM,QAAQ,CAAA;AAAA,MAC3C;AAEA,MAAA,MAAM,GAAA,GAAM,IAAA;AAEZ,MAAA,IAAA,CAAI,EAAA,GAAA,OAAA,CAAQ,UAAA,KAAR,IAAA,GAAA,MAAA,GAAA,EAAA,CAAqB,GAAA,CAAA,EAAM;AAC7B,QAAA,OAAO,OAAA,CAAQ,WAAW,GAAG,CAAA;AAAA,MAC/B;AAEA,MAAA,MAAM,KAAK,OAAA,CAAQ,QAAA;AACnB,MAAA,MAAM,MAAM,EAAA,IAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAK,GAAA,CAAA;AAEjB,MAAA,IAAI,OAAO,QAAQ,UAAA,EAAY;AAC7B,QAAA,OAAO,GAAA,CAAI,KAAK,EAAE,CAAA;AAAA,MACpB;AACA,MAAA,OAAO,GAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH","file":"index.mjs","sourcesContent":["import type { MonitorAdapter, MonitorClient } from \"./types\";\r\n\r\nexport function createMonitor(adapter: MonitorAdapter): MonitorClient {\r\n const base: MonitorClient = {\r\n init: adapter.init,\r\n\r\n captureException: (e, ctx) => adapter.captureException(e, ctx),\r\n captureMessage: (m, ctx) => adapter.captureMessage(m, ctx),\r\n\r\n setUser: (u) => adapter.setUser(u),\r\n setTag: (k, v) => adapter.setTag(k, v),\r\n setExtra: (k, v) => adapter.setExtra(k, v),\r\n\r\n withScope: (cb) => adapter.withScope(cb),\r\n\r\n flush: (t) => adapter.flush?.(t) ?? Promise.resolve(true),\r\n close: (t) => adapter.close?.(t) ?? Promise.resolve(true),\r\n };\r\n\r\n return new Proxy(base as any, {\r\n get(target, prop, receiver) {\r\n if (prop in target) {\r\n return Reflect.get(target, prop, receiver);\r\n }\r\n\r\n const key = prop as string;\r\n\r\n if (adapter.extensions?.[key]) {\r\n return adapter.extensions[key];\r\n }\r\n\r\n const fb = adapter.fallback;\r\n const val = fb?.[key];\r\n\r\n if (typeof val === \"function\") {\r\n return val.bind(fb);\r\n }\r\n return val;\r\n },\r\n }) as MonitorClient & Record<string, any>;\r\n}\r\n"]}
|
package/dist/metro.js
CHANGED
|
@@ -1,2 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
1
17
|
// src/adapter/rn/metro.ts
|
|
2
|
-
|
|
18
|
+
var metro_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(metro_exports);
|
|
20
|
+
__reExport(metro_exports, require("@sentry/react-native/metro"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@sentry/react-native/metro")
|
|
24
|
+
});
|
package/dist/metro.mjs
ADDED
package/dist/rn.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Monitor as Monitor$1, CaptureContext, MonitorUser } from './index.mjs';
|
|
2
|
+
|
|
3
|
+
declare const Monitor: Monitor$1;
|
|
4
|
+
declare const init: (options: any) => any;
|
|
5
|
+
declare const captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
6
|
+
declare const captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
7
|
+
declare const setUser: (user: MonitorUser) => any;
|
|
8
|
+
|
|
9
|
+
export { captureException, captureMessage, Monitor as default, init, setUser };
|
package/dist/rn.d.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.js';
|
|
2
|
-
import * as Sentry from '@sentry/react-native';
|
|
1
|
+
import { Monitor as Monitor$1, CaptureContext, MonitorUser } from './index.js';
|
|
3
2
|
|
|
4
|
-
declare const Monitor:
|
|
5
|
-
|
|
6
|
-
init: (options: Sentry.ReactNativeOptions) => any;
|
|
7
|
-
captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
8
|
-
captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
9
|
-
setUser: (user: MonitorUser) => any;
|
|
10
|
-
};
|
|
11
|
-
declare const init: (options: Sentry.ReactNativeOptions) => any;
|
|
3
|
+
declare const Monitor: Monitor$1;
|
|
4
|
+
declare const init: (options: any) => any;
|
|
12
5
|
declare const captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
13
6
|
declare const captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
14
7
|
declare const setUser: (user: MonitorUser) => any;
|
package/dist/rn.js
CHANGED
|
@@ -1,59 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
1
30
|
// src/adapter/rn/index.ts
|
|
2
|
-
|
|
31
|
+
var rn_exports = {};
|
|
32
|
+
__export(rn_exports, {
|
|
33
|
+
captureException: () => captureException,
|
|
34
|
+
captureMessage: () => captureMessage,
|
|
35
|
+
default: () => rn_default,
|
|
36
|
+
init: () => init,
|
|
37
|
+
setUser: () => setUser
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(rn_exports);
|
|
40
|
+
var Sentry = __toESM(require("@sentry/react-native"));
|
|
3
41
|
|
|
4
42
|
// src/core/createMonitor.ts
|
|
5
43
|
function createMonitor(sentry) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const captureException2 = (error, ctx) => {
|
|
10
|
-
return sentry.captureException(error, (scope) => {
|
|
11
|
-
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
12
|
-
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
13
|
-
return scope;
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
const captureMessage2 = (message, ctx) => {
|
|
17
|
-
return sentry.captureMessage(message, (scope) => {
|
|
18
|
-
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
19
|
-
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
20
|
-
return scope;
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
const setUser2 = (user) => {
|
|
24
|
-
return sentry.setUser(user);
|
|
25
|
-
};
|
|
26
|
-
const Monitor2 = new Proxy(
|
|
27
|
-
{
|
|
28
|
-
init: init2,
|
|
29
|
-
captureException: captureException2,
|
|
30
|
-
captureMessage: captureMessage2,
|
|
31
|
-
setUser: setUser2
|
|
44
|
+
const monitor = {
|
|
45
|
+
init(options) {
|
|
46
|
+
return sentry.init(options);
|
|
32
47
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
return sentryFn.bind(sentry);
|
|
43
77
|
}
|
|
78
|
+
return sentryFn;
|
|
44
79
|
}
|
|
45
|
-
);
|
|
46
|
-
return
|
|
80
|
+
});
|
|
81
|
+
return proxy;
|
|
47
82
|
}
|
|
48
83
|
|
|
49
84
|
// src/adapter/rn/index.ts
|
|
50
85
|
var Monitor = createMonitor(Sentry);
|
|
51
86
|
var { init, captureException, captureMessage, setUser } = Monitor;
|
|
52
87
|
var rn_default = Monitor;
|
|
53
|
-
export
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
54
90
|
captureException,
|
|
55
91
|
captureMessage,
|
|
56
|
-
rn_default as default,
|
|
57
92
|
init,
|
|
58
93
|
setUser
|
|
59
|
-
};
|
|
94
|
+
});
|
package/dist/rn.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/createMonitor.ts","../src/adapter/rn/index.ts"],"names":["adapter","Sentry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAAS,cAAcA,QAAAA,EAAwC;AACpE,EAAA,MAAM,IAAA,GAAsB;AAAA,IAC1B,MAAMA,QAAAA,CAAQ,IAAA;AAAA,IAEd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AAI,CAAA;AACpC,EAAA,IAAI,GAAA,CAAI,KAAA,EAAO,KAAA,CAAM,QAAA,CAAS,IAAI,KAAK,CAAA;AACzC;AAEA,IAAM,OAAA,GAA0B;AAAA,EAC9B,IAAA,EAAaC,iBAAA,CAAA,IAAA;AAAA,EAEb,gBAAA,CAAiB,KAAK,GAAA,EAAK;AACzB,IAAOA,iBAAA,CAAA,SAAA,CAAU,CAAC,KAAA,KAAU;AAC1B,MAAA,YAAA,CAAa,OAAO,GAAG,CAAA;AACvB,MAAOA,mCAAiB,GAAG,CAAA;AAAA,IAC7B,CAAC,CAAA;AAAA,EACH,CAAA;AAAA,EAEA,cAAA,CAAe,KAAK,GAAA,EAAK;AACvB,IAAOA,iBAAA,CAAA,SAAA,CAAU,CAAC,KAAA,KAAU;AAC1B,MAAA,YAAA,CAAa,OAAO,GAAG,CAAA;AACvB,MAAOA,iCAAe,GAAG,CAAA;AAAA,IAC3B,CAAC,CAAA;AAAA,EACH,CAAA;AAAA,EAEA,OAAA,EAAgBA,iBAAA,CAAA,OAAA;AAAA,EAChB,MAAA,EAAeA,iBAAA,CAAA,MAAA;AAAA,EACf,QAAA,EAAiBA,iBAAA,CAAA,QAAA;AAAA,EAEjB,SAAA,EAAkBA,iBAAA,CAAA,SAAA;AAAA,EAElB,KAAA,EAAcA,iBAAA,CAAA,KAAA;AAAA,EAEd,QAAA,EAAUA;AACZ,CAAA;AAEA,IAAM,OAAA,GAAU,cAAc,OAAO,CAAA;AACrC,IAAO,UAAA,GAAQ","file":"rn.js","sourcesContent":["import type { MonitorAdapter, MonitorClient } from \"./types\";\r\n\r\nexport function createMonitor(adapter: MonitorAdapter): MonitorClient {\r\n const base: MonitorClient = {\r\n init: adapter.init,\r\n\r\n captureException: (e, ctx) => adapter.captureException(e, ctx),\r\n captureMessage: (m, ctx) => adapter.captureMessage(m, ctx),\r\n\r\n setUser: (u) => adapter.setUser(u),\r\n setTag: (k, v) => adapter.setTag(k, v),\r\n setExtra: (k, v) => adapter.setExtra(k, v),\r\n\r\n withScope: (cb) => adapter.withScope(cb),\r\n\r\n flush: (t) => adapter.flush?.(t) ?? Promise.resolve(true),\r\n close: (t) => adapter.close?.(t) ?? Promise.resolve(true),\r\n };\r\n\r\n return new Proxy(base as any, {\r\n get(target, prop, receiver) {\r\n if (prop in target) {\r\n return Reflect.get(target, prop, receiver);\r\n }\r\n\r\n const key = prop as string;\r\n\r\n if (adapter.extensions?.[key]) {\r\n return adapter.extensions[key];\r\n }\r\n\r\n const fb = adapter.fallback;\r\n const val = fb?.[key];\r\n\r\n if (typeof val === \"function\") {\r\n return val.bind(fb);\r\n }\r\n return val;\r\n },\r\n }) as MonitorClient & Record<string, any>;\r\n}\r\n","import * as Sentry from \"@sentry/react-native\";\nimport { createMonitor } from \"../../core/createMonitor\";\nimport type { CaptureContext, MonitorAdapter } from \"../../core/types\";\n\nfunction applyContext(scope: any, ctx?: CaptureContext) {\n if (!ctx) return;\n if (ctx.tags)\n Object.entries(ctx.tags).forEach(([k, v]) => scope.setTag(k, v));\n if (ctx.extra)\n Object.entries(ctx.extra).forEach(([k, v]) => scope.setExtra(k, v));\n if (ctx.user) scope.setUser(ctx.user);\n if (ctx.level) scope.setLevel(ctx.level);\n}\n\nconst adapter: MonitorAdapter = {\n init: Sentry.init,\n\n captureException(err, ctx) {\n Sentry.withScope((scope) => {\n applyContext(scope, ctx);\n Sentry.captureException(err);\n });\n },\n\n captureMessage(msg, ctx) {\n Sentry.withScope((scope) => {\n applyContext(scope, ctx);\n Sentry.captureMessage(msg);\n });\n },\n\n setUser: Sentry.setUser,\n setTag: Sentry.setTag,\n setExtra: Sentry.setExtra,\n\n withScope: Sentry.withScope,\n\n flush: Sentry.flush,\n\n fallback: Sentry,\n};\n\nconst Monitor = createMonitor(adapter);\nexport default Monitor;\n"]}
|
package/dist/rn.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/adapter/rn/index.ts
|
|
2
|
+
import * as Sentry from "@sentry/react-native";
|
|
3
|
+
|
|
4
|
+
// src/core/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
|
+
return sentryFn.bind(sentry);
|
|
39
|
+
}
|
|
40
|
+
return sentryFn;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return proxy;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/adapter/rn/index.ts
|
|
47
|
+
var Monitor = createMonitor(Sentry);
|
|
48
|
+
var { init, captureException, captureMessage, setUser } = Monitor;
|
|
49
|
+
var rn_default = Monitor;
|
|
50
|
+
export {
|
|
51
|
+
captureException,
|
|
52
|
+
captureMessage,
|
|
53
|
+
rn_default as default,
|
|
54
|
+
init,
|
|
55
|
+
setUser
|
|
56
|
+
};
|
package/dist/rn.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/createMonitor.ts","../src/adapter/rn/index.ts"],"names":["adapter"],"mappings":";;;;;AAEO,SAAS,cAAcA,QAAAA,EAAwC;AACpE,EAAA,MAAM,IAAA,GAAsB;AAAA,IAC1B,MAAMA,QAAAA,CAAQ,IAAA;AAAA,IAEd,kBAAkB,CAAC,CAAA,EAAG,QAAQA,QAAAA,CAAQ,gBAAA,CAAiB,GAAG,GAAG,CAAA;AAAA,IAC7D,gBAAgB,CAAC,CAAA,EAAG,QAAQA,QAAAA,CAAQ,cAAA,CAAe,GAAG,GAAG,CAAA;AAAA,IAEzD,OAAA,EAAS,CAAC,CAAA,KAAMA,QAAAA,CAAQ,QAAQ,CAAC,CAAA;AAAA,IACjC,QAAQ,CAAC,CAAA,EAAG,MAAMA,QAAAA,CAAQ,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,IACrC,UAAU,CAAC,CAAA,EAAG,MAAMA,QAAAA,CAAQ,QAAA,CAAS,GAAG,CAAC,CAAA;AAAA,IAEzC,SAAA,EAAW,CAAC,EAAA,KAAOA,QAAAA,CAAQ,UAAU,EAAE,CAAA;AAAA,IAEvC,KAAA,EAAO,CAAC,CAAA,KAAG;AAff,MAAA,IAAA,EAAA,EAAA,EAAA;AAekB,MAAA,OAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAAA,QAAAA,CAAQ,UAAR,IAAA,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,CAAAA,QAAAA,EAAgB,OAAhB,IAAA,GAAA,EAAA,GAAsB,OAAA,CAAQ,QAAQ,IAAI,CAAA;AAAA,IAAA,CAAA;AAAA,IACxD,KAAA,EAAO,CAAC,CAAA,KAAG;AAhBf,MAAA,IAAA,EAAA,EAAA,EAA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O,CAAA;AACrC,IAAO,UAAA,GAAQ","file":"rn.mjs","sourcesContent":["import type { MonitorAdapter, MonitorClient } from \"./types\";\r\n\r\nexport function createMonitor(adapter: MonitorAdapter): MonitorClient {\r\n const base: MonitorClient = {\r\n init: adapter.init,\r\n\r\n captureException: (e, ctx) => adapter.captureException(e, ctx),\r\n captureMessage: (m, ctx) => adapter.captureMessage(m, ctx),\r\n\r\n setUser: (u) => adapter.setUser(u),\r\n setTag: (k, v) => adapter.setTag(k, v),\r\n setExtra: (k, v) => adapter.setExtra(k, v),\r\n\r\n withScope: (cb) => adapter.withScope(cb),\r\n\r\n flush: (t) => adapter.flush?.(t) ?? Promise.resolve(true),\r\n close: (t) => adapter.close?.(t) ?? Promise.resolve(true),\r\n };\r\n\r\n return new Proxy(base as any, {\r\n get(target, prop, receiver) {\r\n if (prop in target) {\r\n return Reflect.get(target, prop, receiver);\r\n }\r\n\r\n const key = prop as string;\r\n\r\n if (adapter.extensions?.[key]) {\r\n return adapter.extensions[key];\r\n }\r\n\r\n const fb = adapter.fallback;\r\n const val = fb?.[key];\r\n\r\n if (typeof val === \"function\") {\r\n return val.bind(fb);\r\n }\r\n return val;\r\n },\r\n }) as MonitorClient & Record<string, any>;\r\n}\r\n","import * as Sentry from \"@sentry/react-native\";\nimport { createMonitor } from \"../../core/createMonitor\";\nimport type { CaptureContext, MonitorAdapter } from \"../../core/types\";\n\nfunction applyContext(scope: any, ctx?: CaptureContext) {\n if (!ctx) return;\n if (ctx.tags)\n Object.entries(ctx.tags).forEach(([k, v]) => scope.setTag(k, v));\n if (ctx.extra)\n Object.entries(ctx.extra).forEach(([k, v]) => scope.setExtra(k, v));\n if (ctx.user) scope.setUser(ctx.user);\n if (ctx.level) scope.setLevel(ctx.level);\n}\n\nconst adapter: MonitorAdapter = {\n init: Sentry.init,\n\n captureException(err, ctx) {\n Sentry.withScope((scope) => {\n applyContext(scope, ctx);\n Sentry.captureException(err);\n });\n },\n\n captureMessage(msg, ctx) {\n Sentry.withScope((scope) => {\n applyContext(scope, ctx);\n Sentry.captureMessage(msg);\n });\n },\n\n setUser: Sentry.setUser,\n setTag: Sentry.setTag,\n setExtra: Sentry.setExtra,\n\n withScope: Sentry.withScope,\n\n flush: Sentry.flush,\n\n fallback: Sentry,\n};\n\nconst Monitor = createMonitor(adapter);\nexport default Monitor;\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface MonitorUser {
|
|
2
|
+
id?: string;
|
|
3
|
+
username?: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
}
|
|
6
|
+
interface CaptureContext {
|
|
7
|
+
tags?: Record<string, string>;
|
|
8
|
+
extra?: Record<string, any>;
|
|
9
|
+
user?: MonitorUser;
|
|
10
|
+
level?: "fatal" | "error" | "warning" | "info" | "debug" | "log";
|
|
11
|
+
}
|
|
12
|
+
interface MonitorClient {
|
|
13
|
+
init(options: any): void;
|
|
14
|
+
captureException(error: Error, ctx?: CaptureContext): void;
|
|
15
|
+
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
16
|
+
setUser(user: MonitorUser | null): void;
|
|
17
|
+
setTag(key: string, value: string): void;
|
|
18
|
+
setExtra(key: string, value: any): void;
|
|
19
|
+
withScope(cb: (scope: any) => void): void;
|
|
20
|
+
flush(timeout?: number): Promise<boolean>;
|
|
21
|
+
close(timeout?: number): Promise<boolean>;
|
|
22
|
+
}
|
|
23
|
+
interface MonitorAdapter {
|
|
24
|
+
init(options: any): void;
|
|
25
|
+
captureException(error: Error, ctx?: CaptureContext): void;
|
|
26
|
+
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
27
|
+
setUser(user: MonitorUser | null): void;
|
|
28
|
+
setTag(key: string, value: string): void;
|
|
29
|
+
setExtra(key: string, value: any): void;
|
|
30
|
+
withScope(cb: (scope: any) => void): void;
|
|
31
|
+
flush?(timeout?: number): Promise<boolean>;
|
|
32
|
+
close?(timeout?: number): Promise<boolean>;
|
|
33
|
+
extensions?: Record<string, (...args: any[]) => any>;
|
|
34
|
+
fallback?: Record<string, any>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type { CaptureContext as C, MonitorAdapter as M, MonitorClient as a, MonitorUser as b };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface MonitorUser {
|
|
2
|
+
id?: string;
|
|
3
|
+
username?: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
}
|
|
6
|
+
interface CaptureContext {
|
|
7
|
+
tags?: Record<string, string>;
|
|
8
|
+
extra?: Record<string, any>;
|
|
9
|
+
user?: MonitorUser;
|
|
10
|
+
level?: "fatal" | "error" | "warning" | "info" | "debug" | "log";
|
|
11
|
+
}
|
|
12
|
+
interface MonitorClient {
|
|
13
|
+
init(options: any): void;
|
|
14
|
+
captureException(error: Error, ctx?: CaptureContext): void;
|
|
15
|
+
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
16
|
+
setUser(user: MonitorUser | null): void;
|
|
17
|
+
setTag(key: string, value: string): void;
|
|
18
|
+
setExtra(key: string, value: any): void;
|
|
19
|
+
withScope(cb: (scope: any) => void): void;
|
|
20
|
+
flush(timeout?: number): Promise<boolean>;
|
|
21
|
+
close(timeout?: number): Promise<boolean>;
|
|
22
|
+
}
|
|
23
|
+
interface MonitorAdapter {
|
|
24
|
+
init(options: any): void;
|
|
25
|
+
captureException(error: Error, ctx?: CaptureContext): void;
|
|
26
|
+
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
27
|
+
setUser(user: MonitorUser | null): void;
|
|
28
|
+
setTag(key: string, value: string): void;
|
|
29
|
+
setExtra(key: string, value: any): void;
|
|
30
|
+
withScope(cb: (scope: any) => void): void;
|
|
31
|
+
flush?(timeout?: number): Promise<boolean>;
|
|
32
|
+
close?(timeout?: number): Promise<boolean>;
|
|
33
|
+
extensions?: Record<string, (...args: any[]) => any>;
|
|
34
|
+
fallback?: Record<string, any>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type { CaptureContext as C, MonitorAdapter as M, MonitorClient as a, MonitorUser as b };
|
package/dist/web.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Monitor as Monitor$1, CaptureContext, MonitorUser } from './index.mjs';
|
|
2
|
+
|
|
3
|
+
declare const Monitor: Monitor$1;
|
|
4
|
+
declare const init: (options: any) => any;
|
|
5
|
+
declare const captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
6
|
+
declare const captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
7
|
+
declare const setUser: (user: MonitorUser) => any;
|
|
8
|
+
|
|
9
|
+
export { captureException, captureMessage, Monitor as default, init, setUser };
|
package/dist/web.d.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.js';
|
|
2
|
-
import * as Sentry from '@sentry/react';
|
|
1
|
+
import { Monitor as Monitor$1, CaptureContext, MonitorUser } from './index.js';
|
|
3
2
|
|
|
4
|
-
declare const Monitor:
|
|
5
|
-
|
|
6
|
-
init: (options: Sentry.BrowserOptions) => any;
|
|
7
|
-
captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
8
|
-
captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
9
|
-
setUser: (user: MonitorUser) => any;
|
|
10
|
-
};
|
|
11
|
-
declare const init: (options: Sentry.BrowserOptions) => any;
|
|
3
|
+
declare const Monitor: Monitor$1;
|
|
4
|
+
declare const init: (options: any) => any;
|
|
12
5
|
declare const captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
13
6
|
declare const captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
14
7
|
declare const setUser: (user: MonitorUser) => any;
|
package/dist/web.js
CHANGED
|
@@ -1,59 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
1
30
|
// src/adapter/web/index.ts
|
|
2
|
-
|
|
31
|
+
var web_exports = {};
|
|
32
|
+
__export(web_exports, {
|
|
33
|
+
captureException: () => captureException,
|
|
34
|
+
captureMessage: () => captureMessage,
|
|
35
|
+
default: () => web_default,
|
|
36
|
+
init: () => init,
|
|
37
|
+
setUser: () => setUser
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(web_exports);
|
|
40
|
+
var Sentry = __toESM(require("@sentry/react"));
|
|
3
41
|
|
|
4
42
|
// src/core/createMonitor.ts
|
|
5
43
|
function createMonitor(sentry) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const captureException2 = (error, ctx) => {
|
|
10
|
-
return sentry.captureException(error, (scope) => {
|
|
11
|
-
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
12
|
-
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
13
|
-
return scope;
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
const captureMessage2 = (message, ctx) => {
|
|
17
|
-
return sentry.captureMessage(message, (scope) => {
|
|
18
|
-
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
19
|
-
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
20
|
-
return scope;
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
const setUser2 = (user) => {
|
|
24
|
-
return sentry.setUser(user);
|
|
25
|
-
};
|
|
26
|
-
const Monitor2 = new Proxy(
|
|
27
|
-
{
|
|
28
|
-
init: init2,
|
|
29
|
-
captureException: captureException2,
|
|
30
|
-
captureMessage: captureMessage2,
|
|
31
|
-
setUser: setUser2
|
|
44
|
+
const monitor = {
|
|
45
|
+
init(options) {
|
|
46
|
+
return sentry.init(options);
|
|
32
47
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
return sentryFn.bind(sentry);
|
|
43
77
|
}
|
|
78
|
+
return sentryFn;
|
|
44
79
|
}
|
|
45
|
-
);
|
|
46
|
-
return
|
|
80
|
+
});
|
|
81
|
+
return proxy;
|
|
47
82
|
}
|
|
48
83
|
|
|
49
84
|
// src/adapter/web/index.ts
|
|
50
85
|
var Monitor = createMonitor(Sentry);
|
|
51
86
|
var { init, captureException, captureMessage, setUser } = Monitor;
|
|
52
87
|
var web_default = Monitor;
|
|
53
|
-
export
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
54
90
|
captureException,
|
|
55
91
|
captureMessage,
|
|
56
|
-
web_default as default,
|
|
57
92
|
init,
|
|
58
93
|
setUser
|
|
59
|
-
};
|
|
94
|
+
});
|
package/dist/web.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/createMonitor.ts","../src/adapter/web/index.ts"],"names":["adapter","Sentry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAAS,cAAcA,QAAAA,EAAwC;AACpE,EAAA,MAAM,IAAA,GAAsB;AAAA,IAC1B,MAAMA,QAAAA,CAAQ,IAAA;AAAA,IAEd,k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I,CAAA;AACpC,EAAA,IAAI,GAAA,CAAI,KAAA,EAAO,KAAA,CAAM,QAAA,CAAS,IAAI,KAAK,CAAA;AACzC;AAEA,IAAM,OAAA,GAA0B;AAAA,EAC9B,IAAA,EAAaC,iBAAA,CAAA,IAAA;AAAA,EAEb,gBAAA,CAAiB,KAAK,GAAA,EAAK;AACzB,IAAOA,iBAAA,CAAA,SAAA,CAAU,CAAC,KAAA,KAAe;AAC/B,MAAA,YAAA,CAAa,OAAO,GAAG,CAAA;AACvB,MAAOA,mCAAiB,GAAG,CAAA;AAAA,IAC7B,CAAC,CAAA;AAAA,EACH,CAAA;AAAA,EAEA,cAAA,CAAe,KAAK,GAAA,EAAK;AACvB,IAAOA,iBAAA,CAAA,SAAA,CAAU,CAAC,KAAA,KAAe;AAC/B,MAAA,YAAA,CAAa,OAAO,GAAG,CAAA;AACvB,MAAOA,iCAAe,GAAG,CAAA;AAAA,IAC3B,CAAC,CAAA;AAAA,EACH,CAAA;AAAA,EAEA,OAAA,EAAgBA,iBAAA,CAAA,OAAA;AAAA,EAChB,MAAA,EAAeA,iBAAA,CAAA,MAAA;AAAA,EACf,QAAA,EAAiBA,iBAAA,CAAA,QAAA;AAAA,EAEjB,SAAA,EAAkBA,iBAAA,CAAA,SAAA;AAAA,EAElB,KAAA,EAAcA,iBAAA,CAAA,KAAA;AAAA,EACd,KAAA,EAAcA,iBAAA,CAAA,KAAA;AAAA,EAEd,QAAA,EAAUA;AACZ,CAAA;AAEA,IAAM,OAAA,GAAU,cAAc,OAAO,CAAA;AACrC,IAAO,WAAA,GAAQ","file":"web.js","sourcesContent":["import type { MonitorAdapter, MonitorClient } from \"./types\";\r\n\r\nexport function createMonitor(adapter: MonitorAdapter): MonitorClient {\r\n const base: MonitorClient = {\r\n init: adapter.init,\r\n\r\n captureException: (e, ctx) => adapter.captureException(e, ctx),\r\n captureMessage: (m, ctx) => adapter.captureMessage(m, ctx),\r\n\r\n setUser: (u) => adapter.setUser(u),\r\n setTag: (k, v) => adapter.setTag(k, v),\r\n setExtra: (k, v) => adapter.setExtra(k, v),\r\n\r\n withScope: (cb) => adapter.withScope(cb),\r\n\r\n flush: (t) => adapter.flush?.(t) ?? Promise.resolve(true),\r\n close: (t) => adapter.close?.(t) ?? Promise.resolve(true),\r\n };\r\n\r\n return new Proxy(base as any, {\r\n get(target, prop, receiver) {\r\n if (prop in target) {\r\n return Reflect.get(target, prop, receiver);\r\n }\r\n\r\n const key = prop as string;\r\n\r\n if (adapter.extensions?.[key]) {\r\n return adapter.extensions[key];\r\n }\r\n\r\n const fb = adapter.fallback;\r\n const val = fb?.[key];\r\n\r\n if (typeof val === \"function\") {\r\n return val.bind(fb);\r\n }\r\n return val;\r\n },\r\n }) as MonitorClient & Record<string, any>;\r\n}\r\n","import * as Sentry from \"@sentry/react\";\nimport { createMonitor } from \"../../core/createMonitor\";\nimport type { CaptureContext, MonitorAdapter } from \"../../core/types\";\n\nfunction applyContext(scope: any, ctx?: CaptureContext) {\n if (!ctx) return;\n if (ctx.tags)\n Object.entries(ctx.tags).forEach(([k, v]) => scope.setTag(k, v));\n if (ctx.extra)\n Object.entries(ctx.extra).forEach(([k, v]) => scope.setExtra(k, v));\n if (ctx.user) scope.setUser(ctx.user);\n if (ctx.level) scope.setLevel(ctx.level);\n}\n\nconst adapter: MonitorAdapter = {\n init: Sentry.init,\n\n captureException(err, ctx) {\n Sentry.withScope((scope: any) => {\n applyContext(scope, ctx);\n Sentry.captureException(err);\n });\n },\n\n captureMessage(msg, ctx) {\n Sentry.withScope((scope: any) => {\n applyContext(scope, ctx);\n Sentry.captureMessage(msg);\n });\n },\n\n setUser: Sentry.setUser,\n setTag: Sentry.setTag,\n setExtra: Sentry.setExtra,\n\n withScope: Sentry.withScope,\n\n flush: Sentry.flush,\n close: Sentry.close,\n\n fallback: Sentry,\n};\n\nconst Monitor = createMonitor(adapter);\nexport default Monitor;\n"]}
|
package/dist/web.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/adapter/web/index.ts
|
|
2
|
+
import * as Sentry from "@sentry/react";
|
|
3
|
+
|
|
4
|
+
// src/core/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
|
+
return sentryFn.bind(sentry);
|
|
39
|
+
}
|
|
40
|
+
return sentryFn;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return proxy;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/adapter/web/index.ts
|
|
47
|
+
var Monitor = createMonitor(Sentry);
|
|
48
|
+
var { init, captureException, captureMessage, setUser } = Monitor;
|
|
49
|
+
var web_default = Monitor;
|
|
50
|
+
export {
|
|
51
|
+
captureException,
|
|
52
|
+
captureMessage,
|
|
53
|
+
web_default as default,
|
|
54
|
+
init,
|
|
55
|
+
setUser
|
|
56
|
+
};
|
package/dist/web.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/createMonitor.ts","../src/adapter/web/index.ts"],"names":["adapter"],"mappings":";;;;;AAEO,SAAS,cAAcA,QAAAA,EAAwC;AACpE,EAAA,MAAM,IAAA,GAAsB;AAAA,IAC1B,MAAMA,QAAAA,CAAQ,IAAA;AAAA,IAEd,kBAAkB,CAAC,CAAA,EAAG,QAAQA,QAAAA,CAAQ,gBAAA,CAAiB,GAAG,GAAG,CAAA;AAAA,IAC7D,gBAAgB,CAAC,CAAA,EAAG,QAAQA,QAAAA,CAAQ,cAAA,CAAe,GAAG,GAAG,CAAA;AAAA,IAEzD,OAAA,EAAS,CAAC,CAAA,KAAMA,QAAAA,CAAQ,QAAQ,CAAC,CAAA;AAAA,IACjC,QAAQ,CAAC,CAAA,EAAG,MAAMA,QAAAA,CAAQ,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,IACrC,UAAU,CAAC,CAAA,EAAG,MAAMA,QAAAA,CAAQ,QAAA,CAAS,GAAG,CAAC,CAAA;AAAA,IAEzC,SAAA,EAAW,CAAC,EAAA,KAAOA,QAAAA,CAAQ,UAAU,EAAE,CAAA;AAAA,IAEvC,KAAA,EAAO,CAAC,CAAA,KAAG;AAff,MAAA,IAAA,EAAA,EAAA,EAAA;AAekB,MAAA,OAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAAA,QAAAA,CAAQ,UAAR,IAAA,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,CAAAA,QAAAA,EAAgB,OAAhB,IAAA,GAAA,EAAA,GAAsB,OAAA,CAAQ,QAAQ,IAAI,CAAA;AAAA,IAAA,CAAA;AAAA,IACxD,KAAA,EAAO,CAAC,CA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AA,CAAA,KAAA;AAAA,EAEd,QAAA,EAAU;AACZ,CAAA;AAEA,IAAM,OAAA,GAAU,cAAc,OAAO,CAAA;AACrC,IAAO,WAAA,GAAQ","file":"web.mjs","sourcesContent":["import type { MonitorAdapter, MonitorClient } from \"./types\";\r\n\r\nexport function createMonitor(adapter: MonitorAdapter): MonitorClient {\r\n const base: MonitorClient = {\r\n init: adapter.init,\r\n\r\n captureException: (e, ctx) => adapter.captureException(e, ctx),\r\n captureMessage: (m, ctx) => adapter.captureMessage(m, ctx),\r\n\r\n setUser: (u) => adapter.setUser(u),\r\n setTag: (k, v) => adapter.setTag(k, v),\r\n setExtra: (k, v) => adapter.setExtra(k, v),\r\n\r\n withScope: (cb) => adapter.withScope(cb),\r\n\r\n flush: (t) => adapter.flush?.(t) ?? Promise.resolve(true),\r\n close: (t) => adapter.close?.(t) ?? Promise.resolve(true),\r\n };\r\n\r\n return new Proxy(base as any, {\r\n get(target, prop, receiver) {\r\n if (prop in target) {\r\n return Reflect.get(target, prop, receiver);\r\n }\r\n\r\n const key = prop as string;\r\n\r\n if (adapter.extensions?.[key]) {\r\n return adapter.extensions[key];\r\n }\r\n\r\n const fb = adapter.fallback;\r\n const val = fb?.[key];\r\n\r\n if (typeof val === \"function\") {\r\n return val.bind(fb);\r\n }\r\n return val;\r\n },\r\n }) as MonitorClient & Record<string, any>;\r\n}\r\n","import * as Sentry from \"@sentry/react\";\nimport { createMonitor } from \"../../core/createMonitor\";\nimport type { CaptureContext, MonitorAdapter } from \"../../core/types\";\n\nfunction applyContext(scope: any, ctx?: CaptureContext) {\n if (!ctx) return;\n if (ctx.tags)\n Object.entries(ctx.tags).forEach(([k, v]) => scope.setTag(k, v));\n if (ctx.extra)\n Object.entries(ctx.extra).forEach(([k, v]) => scope.setExtra(k, v));\n if (ctx.user) scope.setUser(ctx.user);\n if (ctx.level) scope.setLevel(ctx.level);\n}\n\nconst adapter: MonitorAdapter = {\n init: Sentry.init,\n\n captureException(err, ctx) {\n Sentry.withScope((scope: any) => {\n applyContext(scope, ctx);\n Sentry.captureException(err);\n });\n },\n\n captureMessage(msg, ctx) {\n Sentry.withScope((scope: any) => {\n applyContext(scope, ctx);\n Sentry.captureMessage(msg);\n });\n },\n\n setUser: Sentry.setUser,\n setTag: Sentry.setTag,\n setExtra: Sentry.setExtra,\n\n withScope: Sentry.withScope,\n\n flush: Sentry.flush,\n close: Sentry.close,\n\n fallback: Sentry,\n};\n\nconst Monitor = createMonitor(adapter);\nexport default Monitor;\n"]}
|
package/package.json
CHANGED
|
@@ -1,49 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@xifan052/monitor",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"@sentry/react": "^
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@xifan052/monitor",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"main": "dist/index.cjs",
|
|
5
|
+
"module": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
"./web": {
|
|
13
|
+
"types": "./dist/web.d.ts",
|
|
14
|
+
"import": "./dist/web.mjs",
|
|
15
|
+
"require": "./dist/web.js"
|
|
16
|
+
},
|
|
17
|
+
"./rn": {
|
|
18
|
+
"types": "./dist/rn.d.ts",
|
|
19
|
+
"import": "./dist/rn.mjs",
|
|
20
|
+
"require": "./dist/rn.js"
|
|
21
|
+
},
|
|
22
|
+
"./metro": {
|
|
23
|
+
"import": "./dist/metro.mjs",
|
|
24
|
+
"require": "./dist/metro.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup --dts",
|
|
29
|
+
"changeset": "changeset",
|
|
30
|
+
"version": "changeset version",
|
|
31
|
+
"release": "changeset publish",
|
|
32
|
+
"test": "vitest",
|
|
33
|
+
"prepublishOnly": "pnpm build"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@sentry/react": "^7",
|
|
37
|
+
"@sentry/react-native": "^5"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@changesets/cli": "^2.27.10",
|
|
41
|
+
"typescript": "^5",
|
|
42
|
+
"vitest": "^1"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"tsup": "^8.5.1"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.js';
|
|
2
|
-
|
|
3
|
-
declare abstract class BaseClient {
|
|
4
|
-
protected sentry: any;
|
|
5
|
-
protected options: any;
|
|
6
|
-
constructor(sentry: any, options: any);
|
|
7
|
-
init(): void;
|
|
8
|
-
captureException(error: Error, ctx?: CaptureContext): void;
|
|
9
|
-
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
10
|
-
setUser(user: MonitorUser): void;
|
|
11
|
-
get ErrorBoundary(): any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { BaseClient as B };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.cjs';
|
|
2
|
-
|
|
3
|
-
declare abstract class BaseClient {
|
|
4
|
-
protected sentry: any;
|
|
5
|
-
protected options: any;
|
|
6
|
-
constructor(sentry: any, options: any);
|
|
7
|
-
init(): void;
|
|
8
|
-
/**
|
|
9
|
-
* 上报异常
|
|
10
|
-
* @param error - 捕获的Error对象
|
|
11
|
-
* @param ctx - 上下文信息,tags:错误分组;extra:错误的参数json信息
|
|
12
|
-
*/
|
|
13
|
-
captureException(error: Error, ctx?: CaptureContext): void;
|
|
14
|
-
/**
|
|
15
|
-
* 上报自定义消息
|
|
16
|
-
* @param message - 文本消息
|
|
17
|
-
* @param ctx - 上下文信息,tags:错误分组;extra:本条消息相关的参数json
|
|
18
|
-
*/
|
|
19
|
-
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
20
|
-
setUser(user: MonitorUser): void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { BaseClient as B };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.js';
|
|
2
|
-
|
|
3
|
-
declare abstract class BaseClient {
|
|
4
|
-
protected sentry: any;
|
|
5
|
-
protected options: any;
|
|
6
|
-
constructor(sentry: any, options: any);
|
|
7
|
-
init(): void;
|
|
8
|
-
/**
|
|
9
|
-
* 上报异常
|
|
10
|
-
* @param error - 捕获的Error对象
|
|
11
|
-
* @param ctx - 上下文信息,tags:错误分组;extra:错误的参数json信息
|
|
12
|
-
*/
|
|
13
|
-
captureException(error: Error, ctx?: CaptureContext): void;
|
|
14
|
-
/**
|
|
15
|
-
* 上报自定义消息
|
|
16
|
-
* @param message - 文本消息
|
|
17
|
-
* @param ctx - 上下文信息,tags:错误分组;extra:本条消息相关的参数json
|
|
18
|
-
*/
|
|
19
|
-
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
20
|
-
setUser(user: MonitorUser): void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { BaseClient as B };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
interface MonitorUser {
|
|
2
|
-
id?: string;
|
|
3
|
-
email?: string;
|
|
4
|
-
username?: string;
|
|
5
|
-
[key: string]: string | undefined;
|
|
6
|
-
}
|
|
7
|
-
interface CaptureContext {
|
|
8
|
-
tags?: Record<string, string>;
|
|
9
|
-
extra?: Record<string, any>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare abstract class BaseClient {
|
|
13
|
-
protected sentry: any;
|
|
14
|
-
protected options: any;
|
|
15
|
-
constructor(sentry: any, options: any);
|
|
16
|
-
init(): void;
|
|
17
|
-
captureException(error: Error, ctx?: CaptureContext): void;
|
|
18
|
-
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
19
|
-
setUser(user: MonitorUser): void;
|
|
20
|
-
get ErrorBoundary(): any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
interface MonitorUser {
|
|
2
|
-
id?: string;
|
|
3
|
-
email?: string;
|
|
4
|
-
username?: string;
|
|
5
|
-
[key: string]: string | undefined;
|
|
6
|
-
}
|
|
7
|
-
interface CaptureContext {
|
|
8
|
-
tags?: Record<string, string>;
|
|
9
|
-
extra?: Record<string, any>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare abstract class BaseClient {
|
|
13
|
-
protected sentry: any;
|
|
14
|
-
protected options: any;
|
|
15
|
-
constructor(sentry: any, options: any);
|
|
16
|
-
init(): void;
|
|
17
|
-
captureException(error: Error, ctx?: CaptureContext): void;
|
|
18
|
-
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
19
|
-
setUser(user: MonitorUser): void;
|
|
20
|
-
get ErrorBoundary(): any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.js';
|
|
2
|
-
|
|
3
|
-
declare abstract class BaseClient {
|
|
4
|
-
protected sentry: any;
|
|
5
|
-
protected options: any;
|
|
6
|
-
constructor(sentry: any, options: any);
|
|
7
|
-
init(): void;
|
|
8
|
-
captureException(error: Error, ctx?: CaptureContext): void;
|
|
9
|
-
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
10
|
-
setUser(user: MonitorUser): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { BaseClient as B };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.cjs';
|
|
2
|
-
|
|
3
|
-
declare abstract class BaseClient {
|
|
4
|
-
protected sentry: any;
|
|
5
|
-
protected options: any;
|
|
6
|
-
constructor(sentry: any, options: any);
|
|
7
|
-
init(): void;
|
|
8
|
-
captureException(error: Error, ctx?: CaptureContext): void;
|
|
9
|
-
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
10
|
-
setUser(user: MonitorUser): void;
|
|
11
|
-
get ErrorBoundary(): any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { BaseClient as B };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.cjs';
|
|
2
|
-
|
|
3
|
-
declare abstract class BaseClient {
|
|
4
|
-
protected sentry: any;
|
|
5
|
-
protected options: any;
|
|
6
|
-
constructor(sentry: any, options: any);
|
|
7
|
-
init(): void;
|
|
8
|
-
captureException(error: Error, ctx?: CaptureContext): void;
|
|
9
|
-
captureMessage(message: string, ctx?: CaptureContext): void;
|
|
10
|
-
setUser(user: MonitorUser): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { BaseClient as B };
|
package/dist/index.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/index.ts
|
|
17
|
-
var src_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(src_exports);
|
package/dist/index.d.cts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface MonitorUser {
|
|
2
|
-
id?: string;
|
|
3
|
-
email?: string;
|
|
4
|
-
username?: string;
|
|
5
|
-
[key: string]: string | undefined;
|
|
6
|
-
}
|
|
7
|
-
interface CaptureContext {
|
|
8
|
-
tags?: Record<string, string>;
|
|
9
|
-
extra?: Record<string, any>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type { CaptureContext, MonitorUser };
|
package/dist/metro.cjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
|
|
17
|
-
// src/adapter/rn/metro.ts
|
|
18
|
-
var metro_exports = {};
|
|
19
|
-
module.exports = __toCommonJS(metro_exports);
|
|
20
|
-
__reExport(metro_exports, require("@sentry/react-native/metro"), module.exports);
|
|
21
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
-
0 && (module.exports = {
|
|
23
|
-
...require("@sentry/react-native/metro")
|
|
24
|
-
});
|
package/dist/rn.cjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/adapter/rn/index.ts
|
|
31
|
-
var rn_exports = {};
|
|
32
|
-
__export(rn_exports, {
|
|
33
|
-
captureException: () => captureException,
|
|
34
|
-
captureMessage: () => captureMessage,
|
|
35
|
-
default: () => rn_default,
|
|
36
|
-
init: () => init,
|
|
37
|
-
setUser: () => setUser
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(rn_exports);
|
|
40
|
-
var Sentry = __toESM(require("@sentry/react-native"), 1);
|
|
41
|
-
|
|
42
|
-
// src/core/createMonitor.ts
|
|
43
|
-
function createMonitor(sentry) {
|
|
44
|
-
const init2 = (options) => {
|
|
45
|
-
return sentry.init(options);
|
|
46
|
-
};
|
|
47
|
-
const captureException2 = (error, ctx) => {
|
|
48
|
-
return sentry.captureException(error, (scope) => {
|
|
49
|
-
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
50
|
-
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
51
|
-
return scope;
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const captureMessage2 = (message, ctx) => {
|
|
55
|
-
return sentry.captureMessage(message, (scope) => {
|
|
56
|
-
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
57
|
-
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
58
|
-
return scope;
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
const setUser2 = (user) => {
|
|
62
|
-
return sentry.setUser(user);
|
|
63
|
-
};
|
|
64
|
-
const Monitor2 = new Proxy(
|
|
65
|
-
{
|
|
66
|
-
init: init2,
|
|
67
|
-
captureException: captureException2,
|
|
68
|
-
captureMessage: captureMessage2,
|
|
69
|
-
setUser: setUser2
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
get(target, key, receiver) {
|
|
73
|
-
if (key in target) {
|
|
74
|
-
return Reflect.get(target, key, receiver);
|
|
75
|
-
}
|
|
76
|
-
const sentryValue = sentry[key];
|
|
77
|
-
if (typeof sentryValue === "function") {
|
|
78
|
-
return sentryValue.bind(sentry);
|
|
79
|
-
}
|
|
80
|
-
return sentryValue;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
return Monitor2;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// src/adapter/rn/index.ts
|
|
88
|
-
var Monitor = createMonitor(Sentry);
|
|
89
|
-
var { init, captureException, captureMessage, setUser } = Monitor;
|
|
90
|
-
var rn_default = Monitor;
|
|
91
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
-
0 && (module.exports = {
|
|
93
|
-
captureException,
|
|
94
|
-
captureMessage,
|
|
95
|
-
init,
|
|
96
|
-
setUser
|
|
97
|
-
});
|
package/dist/rn.d.cts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.cjs';
|
|
2
|
-
import * as Sentry from '@sentry/react-native';
|
|
3
|
-
|
|
4
|
-
declare const Monitor: {
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
init: (options: Sentry.ReactNativeOptions) => any;
|
|
7
|
-
captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
8
|
-
captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
9
|
-
setUser: (user: MonitorUser) => any;
|
|
10
|
-
};
|
|
11
|
-
declare const init: (options: Sentry.ReactNativeOptions) => any;
|
|
12
|
-
declare const captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
13
|
-
declare const captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
14
|
-
declare const setUser: (user: MonitorUser) => any;
|
|
15
|
-
|
|
16
|
-
export { captureException, captureMessage, Monitor as default, init, setUser };
|
package/dist/web.cjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/adapter/web/index.ts
|
|
31
|
-
var web_exports = {};
|
|
32
|
-
__export(web_exports, {
|
|
33
|
-
captureException: () => captureException,
|
|
34
|
-
captureMessage: () => captureMessage,
|
|
35
|
-
default: () => web_default,
|
|
36
|
-
init: () => init,
|
|
37
|
-
setUser: () => setUser
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(web_exports);
|
|
40
|
-
var Sentry = __toESM(require("@sentry/react"), 1);
|
|
41
|
-
|
|
42
|
-
// src/core/createMonitor.ts
|
|
43
|
-
function createMonitor(sentry) {
|
|
44
|
-
const init2 = (options) => {
|
|
45
|
-
return sentry.init(options);
|
|
46
|
-
};
|
|
47
|
-
const captureException2 = (error, ctx) => {
|
|
48
|
-
return sentry.captureException(error, (scope) => {
|
|
49
|
-
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
50
|
-
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
51
|
-
return scope;
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const captureMessage2 = (message, ctx) => {
|
|
55
|
-
return sentry.captureMessage(message, (scope) => {
|
|
56
|
-
(ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
|
|
57
|
-
(ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
|
|
58
|
-
return scope;
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
const setUser2 = (user) => {
|
|
62
|
-
return sentry.setUser(user);
|
|
63
|
-
};
|
|
64
|
-
const Monitor2 = new Proxy(
|
|
65
|
-
{
|
|
66
|
-
init: init2,
|
|
67
|
-
captureException: captureException2,
|
|
68
|
-
captureMessage: captureMessage2,
|
|
69
|
-
setUser: setUser2
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
get(target, key, receiver) {
|
|
73
|
-
if (key in target) {
|
|
74
|
-
return Reflect.get(target, key, receiver);
|
|
75
|
-
}
|
|
76
|
-
const sentryValue = sentry[key];
|
|
77
|
-
if (typeof sentryValue === "function") {
|
|
78
|
-
return sentryValue.bind(sentry);
|
|
79
|
-
}
|
|
80
|
-
return sentryValue;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
return Monitor2;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// src/adapter/web/index.ts
|
|
88
|
-
var Monitor = createMonitor(Sentry);
|
|
89
|
-
var { init, captureException, captureMessage, setUser } = Monitor;
|
|
90
|
-
var web_default = Monitor;
|
|
91
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
-
0 && (module.exports = {
|
|
93
|
-
captureException,
|
|
94
|
-
captureMessage,
|
|
95
|
-
init,
|
|
96
|
-
setUser
|
|
97
|
-
});
|
package/dist/web.d.cts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CaptureContext, MonitorUser } from './index.cjs';
|
|
2
|
-
import * as Sentry from '@sentry/react';
|
|
3
|
-
|
|
4
|
-
declare const Monitor: {
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
init: (options: Sentry.BrowserOptions) => any;
|
|
7
|
-
captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
8
|
-
captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
9
|
-
setUser: (user: MonitorUser) => any;
|
|
10
|
-
};
|
|
11
|
-
declare const init: (options: Sentry.BrowserOptions) => any;
|
|
12
|
-
declare const captureException: (error: Error, ctx?: CaptureContext) => any;
|
|
13
|
-
declare const captureMessage: (message: string, ctx?: CaptureContext) => any;
|
|
14
|
-
declare const setUser: (user: MonitorUser) => any;
|
|
15
|
-
|
|
16
|
-
export { captureException, captureMessage, Monitor as default, init, setUser };
|
|
File without changes
|