@xifan052/monitor 0.0.3 → 0.0.5

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.
@@ -0,0 +1,12 @@
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/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);
package/dist/index.mjs ADDED
File without changes
@@ -0,0 +1 @@
1
+ export * from '@sentry/react-native/metro';
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
- export * from "@sentry/react-native/metro";
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
@@ -0,0 +1,2 @@
1
+ // src/adapter/rn/metro.ts
2
+ export * from "@sentry/react-native/metro";
package/dist/rn.cjs CHANGED
@@ -30,69 +30,68 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/adapter/rn/index.ts
31
31
  var rn_exports = {};
32
32
  __export(rn_exports, {
33
- MonitorClient: () => MonitorClient
33
+ captureException: () => captureException,
34
+ captureMessage: () => captureMessage,
35
+ default: () => rn_default,
36
+ init: () => init,
37
+ setUser: () => setUser
34
38
  });
35
39
  module.exports = __toCommonJS(rn_exports);
36
40
  var Sentry = __toESM(require("@sentry/react-native"), 1);
37
41
 
38
- // src/core/baseClient.ts
39
- var BaseClient = class {
40
- constructor(sentry, options) {
41
- this.sentry = sentry;
42
- this.options = options;
43
- }
44
- init() {
45
- this.sentry.init(this.options);
46
- }
47
- /**
48
- * 上报异常
49
- * @param error - 捕获的Error对象
50
- * @param ctx - 上下文信息,tags:错误分组;extra:错误的参数json信息
51
- */
52
- captureException(error, ctx) {
53
- this.sentry.captureException(error, (scope) => {
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) => {
54
49
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
55
50
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
56
51
  return scope;
57
52
  });
58
- }
59
- /**
60
- * 上报自定义消息
61
- * @param message - 文本消息
62
- * @param ctx - 上下文信息,tags:错误分组;extra:本条消息相关的参数json
63
- */
64
- captureMessage(message, ctx) {
65
- this.sentry.captureMessage(message, (scope) => {
53
+ };
54
+ const captureMessage2 = (message, ctx) => {
55
+ return sentry.captureMessage(message, (scope) => {
66
56
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
67
57
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
68
58
  return scope;
69
59
  });
70
- }
71
- // 设置当前用户信息
72
- setUser(user) {
73
- this.sentry.setUser(user);
74
- }
75
- };
76
-
77
- // src/adapter/rn/index.ts
78
- var MonitorClient = class extends BaseClient {
79
- constructor(options) {
80
- super(Sentry, options);
81
- return new Proxy(this, {
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
+ {
82
72
  get(target, key, receiver) {
83
73
  if (key in target) {
84
74
  return Reflect.get(target, key, receiver);
85
75
  }
86
- const sentryValue = Sentry[key];
76
+ const sentryValue = sentry[key];
87
77
  if (typeof sentryValue === "function") {
88
- return sentryValue.bind(Sentry);
78
+ return sentryValue.bind(sentry);
89
79
  }
90
80
  return sentryValue;
91
81
  }
92
- });
93
- }
94
- };
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;
95
91
  // Annotate the CommonJS export names for ESM import in node:
96
92
  0 && (module.exports = {
97
- MonitorClient
93
+ captureException,
94
+ captureMessage,
95
+ init,
96
+ setUser
98
97
  });
package/dist/rn.d.cts CHANGED
@@ -1,9 +1,16 @@
1
- import { ReactNativeOptions } from '@sentry/react-native';
2
- import { B as BaseClient } from './baseClient-CStLSuih.cjs';
3
- import './index.cjs';
1
+ import { CaptureContext, MonitorUser } from './index.cjs';
2
+ import * as Sentry from '@sentry/react-native';
4
3
 
5
- declare class MonitorClient extends BaseClient {
6
- constructor(options: ReactNativeOptions);
7
- }
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;
8
15
 
9
- export { MonitorClient };
16
+ export { captureException, captureMessage, Monitor as default, init, setUser };
package/dist/rn.d.mts ADDED
@@ -0,0 +1,16 @@
1
+ import { CaptureContext, MonitorUser } from './index.mjs';
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/rn.d.ts CHANGED
@@ -1,9 +1,16 @@
1
- import { ReactNativeOptions } from '@sentry/react-native';
2
- import { B as BaseClient } from './baseClient-Ce8FQx7I.js';
3
- import './index.js';
1
+ import { CaptureContext, MonitorUser } from './index.js';
2
+ import * as Sentry from '@sentry/react-native';
4
3
 
5
- declare class MonitorClient extends BaseClient {
6
- constructor(options: ReactNativeOptions);
7
- }
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;
8
15
 
9
- export { MonitorClient };
16
+ export { captureException, captureMessage, Monitor as default, init, setUser };
package/dist/rn.js CHANGED
@@ -1,63 +1,97 @@
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
- import * as Sentry from "@sentry/react-native";
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
- // src/core/baseClient.ts
5
- var BaseClient = class {
6
- constructor(sentry, options) {
7
- this.sentry = sentry;
8
- this.options = options;
9
- }
10
- init() {
11
- this.sentry.init(this.options);
12
- }
13
- /**
14
- * 上报异常
15
- * @param error - 捕获的Error对象
16
- * @param ctx - 上下文信息,tags:错误分组;extra:错误的参数json信息
17
- */
18
- captureException(error, ctx) {
19
- this.sentry.captureException(error, (scope) => {
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) => {
20
49
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
21
50
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
22
51
  return scope;
23
52
  });
24
- }
25
- /**
26
- * 上报自定义消息
27
- * @param message - 文本消息
28
- * @param ctx - 上下文信息,tags:错误分组;extra:本条消息相关的参数json
29
- */
30
- captureMessage(message, ctx) {
31
- this.sentry.captureMessage(message, (scope) => {
53
+ };
54
+ const captureMessage2 = (message, ctx) => {
55
+ return sentry.captureMessage(message, (scope) => {
32
56
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
33
57
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
34
58
  return scope;
35
59
  });
36
- }
37
- // 设置当前用户信息
38
- setUser(user) {
39
- this.sentry.setUser(user);
40
- }
41
- };
42
-
43
- // src/adapter/rn/index.ts
44
- var MonitorClient = class extends BaseClient {
45
- constructor(options) {
46
- super(Sentry, options);
47
- return new Proxy(this, {
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
+ {
48
72
  get(target, key, receiver) {
49
73
  if (key in target) {
50
74
  return Reflect.get(target, key, receiver);
51
75
  }
52
- const sentryValue = Sentry[key];
76
+ const sentryValue = sentry[key];
53
77
  if (typeof sentryValue === "function") {
54
- return sentryValue.bind(Sentry);
78
+ return sentryValue.bind(sentry);
55
79
  }
56
80
  return sentryValue;
57
81
  }
58
- });
59
- }
60
- };
61
- export {
62
- MonitorClient
63
- };
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.mjs ADDED
@@ -0,0 +1,59 @@
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 init2 = (options) => {
7
+ return sentry.init(options);
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
32
+ },
33
+ {
34
+ get(target, key, receiver) {
35
+ if (key in target) {
36
+ return Reflect.get(target, key, receiver);
37
+ }
38
+ const sentryValue = sentry[key];
39
+ if (typeof sentryValue === "function") {
40
+ return sentryValue.bind(sentry);
41
+ }
42
+ return sentryValue;
43
+ }
44
+ }
45
+ );
46
+ return Monitor2;
47
+ }
48
+
49
+ // src/adapter/rn/index.ts
50
+ var Monitor = createMonitor(Sentry);
51
+ var { init, captureException, captureMessage, setUser } = Monitor;
52
+ var rn_default = Monitor;
53
+ export {
54
+ captureException,
55
+ captureMessage,
56
+ rn_default as default,
57
+ init,
58
+ setUser
59
+ };
package/dist/web.cjs CHANGED
@@ -30,69 +30,68 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/adapter/web/index.ts
31
31
  var web_exports = {};
32
32
  __export(web_exports, {
33
- MonitorClient: () => MonitorClient
33
+ captureException: () => captureException,
34
+ captureMessage: () => captureMessage,
35
+ default: () => web_default,
36
+ init: () => init,
37
+ setUser: () => setUser
34
38
  });
35
39
  module.exports = __toCommonJS(web_exports);
36
40
  var Sentry = __toESM(require("@sentry/react"), 1);
37
41
 
38
- // src/core/baseClient.ts
39
- var BaseClient = class {
40
- constructor(sentry, options) {
41
- this.sentry = sentry;
42
- this.options = options;
43
- }
44
- init() {
45
- this.sentry.init(this.options);
46
- }
47
- /**
48
- * 上报异常
49
- * @param error - 捕获的Error对象
50
- * @param ctx - 上下文信息,tags:错误分组;extra:错误的参数json信息
51
- */
52
- captureException(error, ctx) {
53
- this.sentry.captureException(error, (scope) => {
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) => {
54
49
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
55
50
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
56
51
  return scope;
57
52
  });
58
- }
59
- /**
60
- * 上报自定义消息
61
- * @param message - 文本消息
62
- * @param ctx - 上下文信息,tags:错误分组;extra:本条消息相关的参数json
63
- */
64
- captureMessage(message, ctx) {
65
- this.sentry.captureMessage(message, (scope) => {
53
+ };
54
+ const captureMessage2 = (message, ctx) => {
55
+ return sentry.captureMessage(message, (scope) => {
66
56
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
67
57
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
68
58
  return scope;
69
59
  });
70
- }
71
- // 设置当前用户信息
72
- setUser(user) {
73
- this.sentry.setUser(user);
74
- }
75
- };
76
-
77
- // src/adapter/web/index.ts
78
- var MonitorClient = class extends BaseClient {
79
- constructor(options) {
80
- super(Sentry, options);
81
- return new Proxy(this, {
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
+ {
82
72
  get(target, key, receiver) {
83
73
  if (key in target) {
84
74
  return Reflect.get(target, key, receiver);
85
75
  }
86
- const sentryValue = Sentry[key];
76
+ const sentryValue = sentry[key];
87
77
  if (typeof sentryValue === "function") {
88
- return sentryValue.bind(Sentry);
78
+ return sentryValue.bind(sentry);
89
79
  }
90
80
  return sentryValue;
91
81
  }
92
- });
93
- }
94
- };
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;
95
91
  // Annotate the CommonJS export names for ESM import in node:
96
92
  0 && (module.exports = {
97
- MonitorClient
93
+ captureException,
94
+ captureMessage,
95
+ init,
96
+ setUser
98
97
  });
package/dist/web.d.cts CHANGED
@@ -1,9 +1,16 @@
1
- import { BrowserOptions } from '@sentry/react';
2
- import { B as BaseClient } from './baseClient-CStLSuih.cjs';
3
- import './index.cjs';
1
+ import { CaptureContext, MonitorUser } from './index.cjs';
2
+ import * as Sentry from '@sentry/react';
4
3
 
5
- declare class MonitorClient extends BaseClient {
6
- constructor(options: BrowserOptions);
7
- }
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;
8
15
 
9
- export { MonitorClient };
16
+ export { captureException, captureMessage, Monitor as default, init, setUser };
package/dist/web.d.mts ADDED
@@ -0,0 +1,16 @@
1
+ import { CaptureContext, MonitorUser } from './index.mjs';
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 };
package/dist/web.d.ts CHANGED
@@ -1,9 +1,16 @@
1
- import { BrowserOptions } from '@sentry/react';
2
- import { B as BaseClient } from './baseClient-Ce8FQx7I.js';
3
- import './index.js';
1
+ import { CaptureContext, MonitorUser } from './index.js';
2
+ import * as Sentry from '@sentry/react';
4
3
 
5
- declare class MonitorClient extends BaseClient {
6
- constructor(options: BrowserOptions);
7
- }
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;
8
15
 
9
- export { MonitorClient };
16
+ export { captureException, captureMessage, Monitor as default, init, setUser };
package/dist/web.js CHANGED
@@ -1,63 +1,97 @@
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
- import * as Sentry from "@sentry/react";
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
- // src/core/baseClient.ts
5
- var BaseClient = class {
6
- constructor(sentry, options) {
7
- this.sentry = sentry;
8
- this.options = options;
9
- }
10
- init() {
11
- this.sentry.init(this.options);
12
- }
13
- /**
14
- * 上报异常
15
- * @param error - 捕获的Error对象
16
- * @param ctx - 上下文信息,tags:错误分组;extra:错误的参数json信息
17
- */
18
- captureException(error, ctx) {
19
- this.sentry.captureException(error, (scope) => {
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) => {
20
49
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
21
50
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
22
51
  return scope;
23
52
  });
24
- }
25
- /**
26
- * 上报自定义消息
27
- * @param message - 文本消息
28
- * @param ctx - 上下文信息,tags:错误分组;extra:本条消息相关的参数json
29
- */
30
- captureMessage(message, ctx) {
31
- this.sentry.captureMessage(message, (scope) => {
53
+ };
54
+ const captureMessage2 = (message, ctx) => {
55
+ return sentry.captureMessage(message, (scope) => {
32
56
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
33
57
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
34
58
  return scope;
35
59
  });
36
- }
37
- // 设置当前用户信息
38
- setUser(user) {
39
- this.sentry.setUser(user);
40
- }
41
- };
42
-
43
- // src/adapter/web/index.ts
44
- var MonitorClient = class extends BaseClient {
45
- constructor(options) {
46
- super(Sentry, options);
47
- return new Proxy(this, {
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
+ {
48
72
  get(target, key, receiver) {
49
73
  if (key in target) {
50
74
  return Reflect.get(target, key, receiver);
51
75
  }
52
- const sentryValue = Sentry[key];
76
+ const sentryValue = sentry[key];
53
77
  if (typeof sentryValue === "function") {
54
- return sentryValue.bind(Sentry);
78
+ return sentryValue.bind(sentry);
55
79
  }
56
80
  return sentryValue;
57
81
  }
58
- });
59
- }
60
- };
61
- export {
62
- MonitorClient
63
- };
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.mjs ADDED
@@ -0,0 +1,59 @@
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 init2 = (options) => {
7
+ return sentry.init(options);
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
32
+ },
33
+ {
34
+ get(target, key, receiver) {
35
+ if (key in target) {
36
+ return Reflect.get(target, key, receiver);
37
+ }
38
+ const sentryValue = sentry[key];
39
+ if (typeof sentryValue === "function") {
40
+ return sentryValue.bind(sentry);
41
+ }
42
+ return sentryValue;
43
+ }
44
+ }
45
+ );
46
+ return Monitor2;
47
+ }
48
+
49
+ // src/adapter/web/index.ts
50
+ var Monitor = createMonitor(Sentry);
51
+ var { init, captureException, captureMessage, setUser } = Monitor;
52
+ var web_default = Monitor;
53
+ export {
54
+ captureException,
55
+ captureMessage,
56
+ web_default as default,
57
+ init,
58
+ setUser
59
+ };
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@xifan052/monitor",
3
- "version": "0.0.3",
4
- "type": "module",
3
+ "version": "0.0.5",
5
4
  "main": "dist/index.cjs",
6
5
  "module": "dist/index.js",
7
6
  "types": "dist/index.d.ts",