@xifan052/monitor 0.0.3 → 0.0.4

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/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.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,59 @@
1
1
  // src/adapter/rn/index.ts
2
2
  import * as Sentry from "@sentry/react-native";
3
3
 
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) => {
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) => {
20
11
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
21
12
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
22
13
  return scope;
23
14
  });
24
- }
25
- /**
26
- * 上报自定义消息
27
- * @param message - 文本消息
28
- * @param ctx - 上下文信息,tags:错误分组;extra:本条消息相关的参数json
29
- */
30
- captureMessage(message, ctx) {
31
- this.sentry.captureMessage(message, (scope) => {
15
+ };
16
+ const captureMessage2 = (message, ctx) => {
17
+ return sentry.captureMessage(message, (scope) => {
32
18
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
33
19
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
34
20
  return scope;
35
21
  });
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, {
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
+ {
48
34
  get(target, key, receiver) {
49
35
  if (key in target) {
50
36
  return Reflect.get(target, key, receiver);
51
37
  }
52
- const sentryValue = Sentry[key];
38
+ const sentryValue = sentry[key];
53
39
  if (typeof sentryValue === "function") {
54
- return sentryValue.bind(Sentry);
40
+ return sentryValue.bind(sentry);
55
41
  }
56
42
  return sentryValue;
57
43
  }
58
- });
59
- }
60
- };
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;
61
53
  export {
62
- MonitorClient
54
+ captureException,
55
+ captureMessage,
56
+ rn_default as default,
57
+ init,
58
+ setUser
63
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.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,59 @@
1
1
  // src/adapter/web/index.ts
2
2
  import * as Sentry from "@sentry/react";
3
3
 
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) => {
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) => {
20
11
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
21
12
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
22
13
  return scope;
23
14
  });
24
- }
25
- /**
26
- * 上报自定义消息
27
- * @param message - 文本消息
28
- * @param ctx - 上下文信息,tags:错误分组;extra:本条消息相关的参数json
29
- */
30
- captureMessage(message, ctx) {
31
- this.sentry.captureMessage(message, (scope) => {
15
+ };
16
+ const captureMessage2 = (message, ctx) => {
17
+ return sentry.captureMessage(message, (scope) => {
32
18
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
33
19
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
34
20
  return scope;
35
21
  });
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, {
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
+ {
48
34
  get(target, key, receiver) {
49
35
  if (key in target) {
50
36
  return Reflect.get(target, key, receiver);
51
37
  }
52
- const sentryValue = Sentry[key];
38
+ const sentryValue = sentry[key];
53
39
  if (typeof sentryValue === "function") {
54
- return sentryValue.bind(Sentry);
40
+ return sentryValue.bind(sentry);
55
41
  }
56
42
  return sentryValue;
57
43
  }
58
- });
59
- }
60
- };
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;
61
53
  export {
62
- MonitorClient
54
+ captureException,
55
+ captureMessage,
56
+ web_default as default,
57
+ init,
58
+ setUser
63
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xifan052/monitor",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",