@xifan052/monitor 0.1.2 → 0.1.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.
@@ -0,0 +1,5 @@
1
+ import * as Sentry from "@sentry/react-native";
2
+ import { BaseClient } from "../../core/baseClient";
3
+ export declare class RNMonitorClient extends BaseClient {
4
+ constructor(options: Sentry.ReactNativeOptions);
5
+ }
@@ -0,0 +1,7 @@
1
+ import * as Sentry from "@sentry/react-native";
2
+ import { BaseClient } from "../../core/baseClient";
3
+ export class RNMonitorClient extends BaseClient {
4
+ constructor(options) {
5
+ super(Sentry, options);
6
+ }
7
+ }
@@ -0,0 +1,5 @@
1
+ import * as Sentry from "@sentry/browser";
2
+ import { BaseClient } from "../../core/baseClient";
3
+ export declare class WebMonitorClient extends BaseClient {
4
+ constructor(options: Sentry.BrowserOptions);
5
+ }
@@ -0,0 +1,7 @@
1
+ import * as Sentry from "@sentry/browser";
2
+ import { BaseClient } from "../../core/baseClient";
3
+ export class WebMonitorClient extends BaseClient {
4
+ constructor(options) {
5
+ super(Sentry, options);
6
+ }
7
+ }
@@ -0,0 +1,27 @@
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
+ /**
13
+ * 通用的 Sentry 客户端实现
14
+ * 接受 Sentry 实例和初始化选项作为参数
15
+ */
16
+ declare class BaseClient {
17
+ private sentry;
18
+ private options;
19
+ constructor(sentry: any, options: any);
20
+ init(): void;
21
+ captureException(error: Error, ctx?: CaptureContext): void;
22
+ captureMessage1(message: string, ctx?: CaptureContext): void;
23
+ setUser(user: MonitorUser): void;
24
+ get ErrorBoundary(): any;
25
+ }
26
+
27
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,27 @@
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
+ /**
13
+ * 通用的 Sentry 客户端实现
14
+ * 接受 Sentry 实例和初始化选项作为参数
15
+ */
16
+ declare class BaseClient {
17
+ private sentry;
18
+ private options;
19
+ constructor(sentry: any, options: any);
20
+ init(): void;
21
+ captureException(error: Error, ctx?: CaptureContext): void;
22
+ captureMessage1(message: string, ctx?: CaptureContext): void;
23
+ setUser(user: MonitorUser): void;
24
+ get ErrorBoundary(): any;
25
+ }
26
+
27
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,24 @@
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
+ protected initialized: boolean;
16
+ constructor(sentry: any, options: any);
17
+ init(): void;
18
+ captureException(error: Error, ctx?: CaptureContext): void;
19
+ captureMessage(message: string, ctx?: CaptureContext): void;
20
+ setUser(user: MonitorUser): void;
21
+ get ErrorBoundary(): any;
22
+ }
23
+
24
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,24 @@
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
+ protected initialized: boolean;
16
+ constructor(sentry: any, options: any);
17
+ init(): void;
18
+ captureException(error: Error, ctx?: CaptureContext): void;
19
+ captureMessage(message: string, ctx?: CaptureContext): void;
20
+ setUser(user: MonitorUser): void;
21
+ get ErrorBoundary(): any;
22
+ }
23
+
24
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,27 @@
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
+ /**
13
+ * 通用的 Sentry 客户端实现
14
+ * 接受 Sentry 实例和初始化选项作为参数
15
+ */
16
+ declare class BaseClient {
17
+ private sentry;
18
+ private options;
19
+ constructor(sentry: any, options: any);
20
+ init(): void;
21
+ captureException(error: Error, ctx?: CaptureContext): void;
22
+ captureMessage1(message: string, ctx?: CaptureContext): void;
23
+ setUser(user: MonitorUser): void;
24
+ ErrorBoundary(): any;
25
+ }
26
+
27
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,27 @@
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
+ /**
13
+ * 通用的 Sentry 客户端实现
14
+ * 接受 Sentry 实例和初始化选项作为参数
15
+ */
16
+ declare class BaseClient {
17
+ private sentry;
18
+ private options;
19
+ constructor(sentry: any, options: any);
20
+ init(): void;
21
+ captureException(error: Error, ctx?: CaptureContext): void;
22
+ captureMessage1(message: string, ctx?: CaptureContext): void;
23
+ setUser(user: MonitorUser): void;
24
+ ErrorBoundary(): any;
25
+ }
26
+
27
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,27 @@
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
+ /**
13
+ * 通用的 Sentry 客户端实现
14
+ * 接受 Sentry 实例和初始化选项作为参数
15
+ */
16
+ declare class BaseClient {
17
+ private sentry;
18
+ private options;
19
+ constructor(sentry: any, options: any);
20
+ init(): void;
21
+ captureException(error: Error, ctx?: CaptureContext): void;
22
+ captureMessage(message: string, ctx?: CaptureContext): void;
23
+ setUser(user: MonitorUser): void;
24
+ ErrorBoundary(): any;
25
+ }
26
+
27
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,27 @@
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
+ /**
13
+ * 通用的 Sentry 客户端实现
14
+ * 接受 Sentry 实例和初始化选项作为参数
15
+ */
16
+ declare class BaseClient {
17
+ private sentry;
18
+ private options;
19
+ constructor(sentry: any, options: any);
20
+ init(): void;
21
+ captureException(error: Error, ctx?: CaptureContext): void;
22
+ captureMessage(message: string, ctx?: CaptureContext): void;
23
+ setUser(user: MonitorUser): void;
24
+ ErrorBoundary(): any;
25
+ }
26
+
27
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,26 @@
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
+ /**
13
+ * 通用的 Sentry 客户端实现
14
+ * 接受 Sentry 实例和初始化选项作为参数
15
+ */
16
+ declare class BaseClient {
17
+ private sentry;
18
+ private options;
19
+ constructor(sentry: any, options: any);
20
+ init(): void;
21
+ captureException(error: Error, ctx?: CaptureContext): void;
22
+ captureMessage1(message: string, ctx?: CaptureContext): void;
23
+ setUser(user: MonitorUser): void;
24
+ }
25
+
26
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,26 @@
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
+ /**
13
+ * 通用的 Sentry 客户端实现
14
+ * 接受 Sentry 实例和初始化选项作为参数
15
+ */
16
+ declare class BaseClient {
17
+ private sentry;
18
+ private options;
19
+ constructor(sentry: any, options: any);
20
+ init(): void;
21
+ captureException(error: Error, ctx?: CaptureContext): void;
22
+ captureMessage1(message: string, ctx?: CaptureContext): void;
23
+ setUser(user: MonitorUser): void;
24
+ }
25
+
26
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,25 @@
1
+ interface MonitorUser {
2
+ id?: string;
3
+ email?: string;
4
+ username?: string;
5
+ }
6
+ interface CaptureContext {
7
+ tags?: Record<string, string>;
8
+ extra?: Record<string, any>;
9
+ }
10
+
11
+ /**
12
+ * 通用的 Sentry 客户端实现
13
+ * 接受 Sentry 实例和初始化选项作为参数
14
+ */
15
+ declare class BaseClient {
16
+ private sentry;
17
+ private options;
18
+ constructor(sentry: any, options: any);
19
+ init(): void;
20
+ captureException(error: Error, ctx?: CaptureContext): void;
21
+ captureMessage(message: string, ctx?: CaptureContext): void;
22
+ setUser(user: MonitorUser | null): void;
23
+ }
24
+
25
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,25 @@
1
+ interface MonitorUser {
2
+ id?: string;
3
+ email?: string;
4
+ username?: string;
5
+ }
6
+ interface CaptureContext {
7
+ tags?: Record<string, string>;
8
+ extra?: Record<string, any>;
9
+ }
10
+
11
+ /**
12
+ * 通用的 Sentry 客户端实现
13
+ * 接受 Sentry 实例和初始化选项作为参数
14
+ */
15
+ declare class BaseClient {
16
+ private sentry;
17
+ private options;
18
+ constructor(sentry: any, options: any);
19
+ init(): void;
20
+ captureException(error: Error, ctx?: CaptureContext): void;
21
+ captureMessage(message: string, ctx?: CaptureContext): void;
22
+ setUser(user: MonitorUser | null): void;
23
+ }
24
+
25
+ export { BaseClient as B, type CaptureContext as C, type MonitorUser as M };
@@ -0,0 +1,14 @@
1
+ import type { CaptureContext, MonitorUser } from "./types";
2
+ /**
3
+ * 通用的 Sentry 客户端实现
4
+ * 接受 Sentry 实例和初始化选项作为参数
5
+ */
6
+ export declare class BaseClient {
7
+ private sentry;
8
+ private options;
9
+ constructor(sentry: any, options: any);
10
+ init(): void;
11
+ captureException(error: Error, ctx?: CaptureContext): void;
12
+ captureMessage(message: string, ctx?: CaptureContext): void;
13
+ setUser(user: MonitorUser | null): void;
14
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 通用的 Sentry 客户端实现
3
+ * 接受 Sentry 实例和初始化选项作为参数
4
+ */
5
+ export class BaseClient {
6
+ constructor(sentry, options) {
7
+ this.sentry = sentry;
8
+ this.options = options;
9
+ }
10
+ init() {
11
+ this.sentry.init(this.options);
12
+ }
13
+ captureException(error, ctx) {
14
+ this.sentry.captureException(error, (scope) => {
15
+ (ctx === null || ctx === void 0 ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
16
+ (ctx === null || ctx === void 0 ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
17
+ return scope;
18
+ });
19
+ }
20
+ captureMessage(message, ctx) {
21
+ this.sentry.captureMessage(message, (scope) => {
22
+ (ctx === null || ctx === void 0 ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
23
+ (ctx === null || ctx === void 0 ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
24
+ return scope;
25
+ });
26
+ }
27
+ setUser(user) {
28
+ this.sentry.setUser(user);
29
+ }
30
+ }
@@ -0,0 +1,9 @@
1
+ export interface MonitorUser {
2
+ id?: string;
3
+ email?: string;
4
+ username?: string;
5
+ }
6
+ export interface CaptureContext {
7
+ tags?: Record<string, string>;
8
+ extra?: Record<string, any>;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.cjs CHANGED
@@ -30,45 +30,64 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- BaseMonitorClient: () => BaseMonitorClient,
34
- WebSentryClient: () => WebSentryClient
33
+ RNMonitorClient: () => RNMonitorClient,
34
+ WebMonitorClient: () => WebMonitorClient
35
35
  });
36
36
  module.exports = __toCommonJS(src_exports);
37
37
 
38
- // src/core/baseClient.ts
39
- var BaseMonitorClient = class {
40
- };
41
-
42
38
  // src/adapter/web/index.ts
43
- var Sentry = __toESM(require("@sentry/browser"), 1);
44
- var WebSentryClient = class extends BaseMonitorClient {
45
- constructor(options) {
46
- super();
39
+ var Sentry = __toESM(require("@sentry/react"), 1);
40
+
41
+ // src/core/baseClient.ts
42
+ var BaseClient = class {
43
+ constructor(sentry, options) {
44
+ this.sentry = sentry;
47
45
  this.options = options;
46
+ this.initialized = false;
48
47
  }
49
48
  init() {
50
- Sentry.init(this.options);
49
+ if (this.initialized) return;
50
+ this.sentry.init(this.options);
51
+ this.initialized = true;
51
52
  }
52
53
  captureException(error, ctx) {
53
- Sentry.captureException(error, (scope) => {
54
+ this.sentry.captureException(error, (scope) => {
54
55
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
55
56
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
56
57
  return scope;
57
58
  });
58
59
  }
59
60
  captureMessage(message, ctx) {
60
- Sentry.captureMessage(message, (scope) => {
61
+ this.sentry.captureMessage(message, (scope) => {
61
62
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
62
63
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
63
64
  return scope;
64
65
  });
65
66
  }
66
67
  setUser(user) {
67
- Sentry.setUser(user);
68
+ this.sentry.setUser(user);
69
+ }
70
+ get ErrorBoundary() {
71
+ return this.sentry.ErrorBoundary;
72
+ }
73
+ };
74
+
75
+ // src/adapter/web/index.ts
76
+ var WebMonitorClient = class extends BaseClient {
77
+ constructor(options) {
78
+ super(Sentry, options);
79
+ }
80
+ };
81
+
82
+ // src/adapter/rn/index.ts
83
+ var Sentry2 = __toESM(require("@sentry/react-native"), 1);
84
+ var RNMonitorClient = class extends BaseClient {
85
+ constructor(options) {
86
+ super(Sentry2, options);
68
87
  }
69
88
  };
70
89
  // Annotate the CommonJS export names for ESM import in node:
71
90
  0 && (module.exports = {
72
- BaseMonitorClient,
73
- WebSentryClient
91
+ RNMonitorClient,
92
+ WebMonitorClient
74
93
  });
package/dist/index.d.cts CHANGED
@@ -1,3 +1,5 @@
1
- export { B as BaseMonitorClient, C as CaptureContext, a as MonitorClient, M as MonitorUser } from './baseClient-COsZhsZf.cjs';
2
- export { WebSentryClient } from './web.cjs';
3
- import '@sentry/browser';
1
+ export { C as CaptureContext, M as MonitorUser } from './baseClient-C7eELcmN.cjs';
2
+ export { WebMonitorClient } from './web.cjs';
3
+ export { RNMonitorClient } from './rn.cjs';
4
+ import '@sentry/react';
5
+ import '@sentry/react-native';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export { B as BaseMonitorClient, C as CaptureContext, a as MonitorClient, M as MonitorUser } from './baseClient-COsZhsZf.js';
2
- export { WebSentryClient } from './web.js';
3
- import '@sentry/browser';
1
+ export { C as CaptureContext, M as MonitorUser } from './baseClient-C7eELcmN.js';
2
+ export { WebMonitorClient } from './web.js';
3
+ export { RNMonitorClient } from './rn.js';
4
+ import '@sentry/react';
5
+ import '@sentry/react-native';
package/dist/index.js CHANGED
@@ -1,36 +1,55 @@
1
- // src/core/baseClient.ts
2
- var BaseMonitorClient = class {
3
- };
4
-
5
1
  // src/adapter/web/index.ts
6
- import * as Sentry from "@sentry/browser";
7
- var WebSentryClient = class extends BaseMonitorClient {
8
- constructor(options) {
9
- super();
2
+ import * as Sentry from "@sentry/react";
3
+
4
+ // src/core/baseClient.ts
5
+ var BaseClient = class {
6
+ constructor(sentry, options) {
7
+ this.sentry = sentry;
10
8
  this.options = options;
9
+ this.initialized = false;
11
10
  }
12
11
  init() {
13
- Sentry.init(this.options);
12
+ if (this.initialized) return;
13
+ this.sentry.init(this.options);
14
+ this.initialized = true;
14
15
  }
15
16
  captureException(error, ctx) {
16
- Sentry.captureException(error, (scope) => {
17
+ this.sentry.captureException(error, (scope) => {
17
18
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
18
19
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
19
20
  return scope;
20
21
  });
21
22
  }
22
23
  captureMessage(message, ctx) {
23
- Sentry.captureMessage(message, (scope) => {
24
+ this.sentry.captureMessage(message, (scope) => {
24
25
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
25
26
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
26
27
  return scope;
27
28
  });
28
29
  }
29
30
  setUser(user) {
30
- Sentry.setUser(user);
31
+ this.sentry.setUser(user);
32
+ }
33
+ get ErrorBoundary() {
34
+ return this.sentry.ErrorBoundary;
35
+ }
36
+ };
37
+
38
+ // src/adapter/web/index.ts
39
+ var WebMonitorClient = class extends BaseClient {
40
+ constructor(options) {
41
+ super(Sentry, options);
42
+ }
43
+ };
44
+
45
+ // src/adapter/rn/index.ts
46
+ import * as Sentry2 from "@sentry/react-native";
47
+ var RNMonitorClient = class extends BaseClient {
48
+ constructor(options) {
49
+ super(Sentry2, options);
31
50
  }
32
51
  };
33
52
  export {
34
- BaseMonitorClient,
35
- WebSentryClient
53
+ RNMonitorClient,
54
+ WebMonitorClient
36
55
  };
package/dist/rn.cjs CHANGED
@@ -30,43 +30,52 @@ 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
- RNSentryClient: () => RNSentryClient
33
+ RNMonitorClient: () => RNMonitorClient
34
34
  });
35
35
  module.exports = __toCommonJS(rn_exports);
36
36
  var Sentry = __toESM(require("@sentry/react-native"), 1);
37
37
 
38
38
  // src/core/baseClient.ts
39
- var BaseMonitorClient = class {
40
- };
41
-
42
- // src/adapter/rn/index.ts
43
- var RNSentryClient = class extends BaseMonitorClient {
44
- constructor(options) {
45
- super();
39
+ var BaseClient = class {
40
+ constructor(sentry, options) {
41
+ this.sentry = sentry;
46
42
  this.options = options;
43
+ this.initialized = false;
47
44
  }
48
45
  init() {
49
- Sentry.init(this.options);
46
+ if (this.initialized) return;
47
+ this.sentry.init(this.options);
48
+ this.initialized = true;
50
49
  }
51
50
  captureException(error, ctx) {
52
- Sentry.captureException(error, (scope) => {
51
+ this.sentry.captureException(error, (scope) => {
53
52
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
54
53
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
55
54
  return scope;
56
55
  });
57
56
  }
58
57
  captureMessage(message, ctx) {
59
- Sentry.captureMessage(message, (scope) => {
58
+ this.sentry.captureMessage(message, (scope) => {
60
59
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
61
60
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
62
61
  return scope;
63
62
  });
64
63
  }
65
64
  setUser(user) {
66
- Sentry.setUser(user);
65
+ this.sentry.setUser(user);
66
+ }
67
+ get ErrorBoundary() {
68
+ return this.sentry.ErrorBoundary;
69
+ }
70
+ };
71
+
72
+ // src/adapter/rn/index.ts
73
+ var RNMonitorClient = class extends BaseClient {
74
+ constructor(options) {
75
+ super(Sentry, options);
67
76
  }
68
77
  };
69
78
  // Annotate the CommonJS export names for ESM import in node:
70
79
  0 && (module.exports = {
71
- RNSentryClient
80
+ RNMonitorClient
72
81
  });
package/dist/rn.d.cts CHANGED
@@ -1,13 +1,8 @@
1
1
  import * as Sentry from '@sentry/react-native';
2
- import { B as BaseMonitorClient, C as CaptureContext, M as MonitorUser } from './baseClient-COsZhsZf.cjs';
2
+ import { B as BaseClient } from './baseClient-C7eELcmN.cjs';
3
3
 
4
- declare class RNSentryClient extends BaseMonitorClient {
5
- private options;
4
+ declare class RNMonitorClient extends BaseClient {
6
5
  constructor(options: Sentry.ReactNativeOptions);
7
- init(): void;
8
- captureException(error: Error, ctx?: CaptureContext): void;
9
- captureMessage(message: string, ctx?: CaptureContext): void;
10
- setUser(user: MonitorUser | null): void;
11
6
  }
12
7
 
13
- export { RNSentryClient };
8
+ export { RNMonitorClient };
package/dist/rn.d.ts CHANGED
@@ -1,13 +1,8 @@
1
1
  import * as Sentry from '@sentry/react-native';
2
- import { B as BaseMonitorClient, C as CaptureContext, M as MonitorUser } from './baseClient-COsZhsZf.js';
2
+ import { B as BaseClient } from './baseClient-C7eELcmN.js';
3
3
 
4
- declare class RNSentryClient extends BaseMonitorClient {
5
- private options;
4
+ declare class RNMonitorClient extends BaseClient {
6
5
  constructor(options: Sentry.ReactNativeOptions);
7
- init(): void;
8
- captureException(error: Error, ctx?: CaptureContext): void;
9
- captureMessage(message: string, ctx?: CaptureContext): void;
10
- setUser(user: MonitorUser | null): void;
11
6
  }
12
7
 
13
- export { RNSentryClient };
8
+ export { RNMonitorClient };
package/dist/rn.js CHANGED
@@ -2,36 +2,45 @@
2
2
  import * as Sentry from "@sentry/react-native";
3
3
 
4
4
  // src/core/baseClient.ts
5
- var BaseMonitorClient = class {
6
- };
7
-
8
- // src/adapter/rn/index.ts
9
- var RNSentryClient = class extends BaseMonitorClient {
10
- constructor(options) {
11
- super();
5
+ var BaseClient = class {
6
+ constructor(sentry, options) {
7
+ this.sentry = sentry;
12
8
  this.options = options;
9
+ this.initialized = false;
13
10
  }
14
11
  init() {
15
- Sentry.init(this.options);
12
+ if (this.initialized) return;
13
+ this.sentry.init(this.options);
14
+ this.initialized = true;
16
15
  }
17
16
  captureException(error, ctx) {
18
- Sentry.captureException(error, (scope) => {
17
+ this.sentry.captureException(error, (scope) => {
19
18
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
20
19
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
21
20
  return scope;
22
21
  });
23
22
  }
24
23
  captureMessage(message, ctx) {
25
- Sentry.captureMessage(message, (scope) => {
24
+ this.sentry.captureMessage(message, (scope) => {
26
25
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
27
26
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
28
27
  return scope;
29
28
  });
30
29
  }
31
30
  setUser(user) {
32
- Sentry.setUser(user);
31
+ this.sentry.setUser(user);
32
+ }
33
+ get ErrorBoundary() {
34
+ return this.sentry.ErrorBoundary;
35
+ }
36
+ };
37
+
38
+ // src/adapter/rn/index.ts
39
+ var RNMonitorClient = class extends BaseClient {
40
+ constructor(options) {
41
+ super(Sentry, options);
33
42
  }
34
43
  };
35
44
  export {
36
- RNSentryClient
45
+ RNMonitorClient
37
46
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { BaseClient } from "../core/baseClient";
3
+ class MockClient extends BaseClient {
4
+ constructor() {
5
+ super({
6
+ init: () => { },
7
+ captureException: () => { },
8
+ captureMessage: () => { },
9
+ setUser: () => { },
10
+ }, {});
11
+ }
12
+ }
13
+ describe("SentryMonitorClient", () => {
14
+ it("should instantiate", () => {
15
+ const client = new MockClient();
16
+ expect(client).toBeInstanceOf(BaseClient);
17
+ });
18
+ });
package/dist/web.cjs CHANGED
@@ -30,43 +30,52 @@ 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
- WebSentryClient: () => WebSentryClient
33
+ WebMonitorClient: () => WebMonitorClient
34
34
  });
35
35
  module.exports = __toCommonJS(web_exports);
36
- var Sentry = __toESM(require("@sentry/browser"), 1);
36
+ var Sentry = __toESM(require("@sentry/react"), 1);
37
37
 
38
38
  // src/core/baseClient.ts
39
- var BaseMonitorClient = class {
40
- };
41
-
42
- // src/adapter/web/index.ts
43
- var WebSentryClient = class extends BaseMonitorClient {
44
- constructor(options) {
45
- super();
39
+ var BaseClient = class {
40
+ constructor(sentry, options) {
41
+ this.sentry = sentry;
46
42
  this.options = options;
43
+ this.initialized = false;
47
44
  }
48
45
  init() {
49
- Sentry.init(this.options);
46
+ if (this.initialized) return;
47
+ this.sentry.init(this.options);
48
+ this.initialized = true;
50
49
  }
51
50
  captureException(error, ctx) {
52
- Sentry.captureException(error, (scope) => {
51
+ this.sentry.captureException(error, (scope) => {
53
52
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
54
53
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
55
54
  return scope;
56
55
  });
57
56
  }
58
57
  captureMessage(message, ctx) {
59
- Sentry.captureMessage(message, (scope) => {
58
+ this.sentry.captureMessage(message, (scope) => {
60
59
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
61
60
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
62
61
  return scope;
63
62
  });
64
63
  }
65
64
  setUser(user) {
66
- Sentry.setUser(user);
65
+ this.sentry.setUser(user);
66
+ }
67
+ get ErrorBoundary() {
68
+ return this.sentry.ErrorBoundary;
69
+ }
70
+ };
71
+
72
+ // src/adapter/web/index.ts
73
+ var WebMonitorClient = class extends BaseClient {
74
+ constructor(options) {
75
+ super(Sentry, options);
67
76
  }
68
77
  };
69
78
  // Annotate the CommonJS export names for ESM import in node:
70
79
  0 && (module.exports = {
71
- WebSentryClient
80
+ WebMonitorClient
72
81
  });
package/dist/web.d.cts CHANGED
@@ -1,13 +1,8 @@
1
- import { B as BaseMonitorClient, C as CaptureContext, M as MonitorUser } from './baseClient-COsZhsZf.cjs';
2
- import * as Sentry from '@sentry/browser';
1
+ import * as Sentry from '@sentry/react';
2
+ import { B as BaseClient } from './baseClient-C7eELcmN.cjs';
3
3
 
4
- declare class WebSentryClient extends BaseMonitorClient {
5
- private options;
4
+ declare class WebMonitorClient extends BaseClient {
6
5
  constructor(options: Sentry.BrowserOptions);
7
- init(): void;
8
- captureException(error: Error, ctx?: CaptureContext): void;
9
- captureMessage(message: string, ctx?: CaptureContext): void;
10
- setUser(user: MonitorUser | null): void;
11
6
  }
12
7
 
13
- export { WebSentryClient };
8
+ export { WebMonitorClient };
package/dist/web.d.ts CHANGED
@@ -1,13 +1,8 @@
1
- import { B as BaseMonitorClient, C as CaptureContext, M as MonitorUser } from './baseClient-COsZhsZf.js';
2
- import * as Sentry from '@sentry/browser';
1
+ import * as Sentry from '@sentry/react';
2
+ import { B as BaseClient } from './baseClient-C7eELcmN.js';
3
3
 
4
- declare class WebSentryClient extends BaseMonitorClient {
5
- private options;
4
+ declare class WebMonitorClient extends BaseClient {
6
5
  constructor(options: Sentry.BrowserOptions);
7
- init(): void;
8
- captureException(error: Error, ctx?: CaptureContext): void;
9
- captureMessage(message: string, ctx?: CaptureContext): void;
10
- setUser(user: MonitorUser | null): void;
11
6
  }
12
7
 
13
- export { WebSentryClient };
8
+ export { WebMonitorClient };
package/dist/web.js CHANGED
@@ -1,37 +1,46 @@
1
1
  // src/adapter/web/index.ts
2
- import * as Sentry from "@sentry/browser";
2
+ import * as Sentry from "@sentry/react";
3
3
 
4
4
  // src/core/baseClient.ts
5
- var BaseMonitorClient = class {
6
- };
7
-
8
- // src/adapter/web/index.ts
9
- var WebSentryClient = class extends BaseMonitorClient {
10
- constructor(options) {
11
- super();
5
+ var BaseClient = class {
6
+ constructor(sentry, options) {
7
+ this.sentry = sentry;
12
8
  this.options = options;
9
+ this.initialized = false;
13
10
  }
14
11
  init() {
15
- Sentry.init(this.options);
12
+ if (this.initialized) return;
13
+ this.sentry.init(this.options);
14
+ this.initialized = true;
16
15
  }
17
16
  captureException(error, ctx) {
18
- Sentry.captureException(error, (scope) => {
17
+ this.sentry.captureException(error, (scope) => {
19
18
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
20
19
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
21
20
  return scope;
22
21
  });
23
22
  }
24
23
  captureMessage(message, ctx) {
25
- Sentry.captureMessage(message, (scope) => {
24
+ this.sentry.captureMessage(message, (scope) => {
26
25
  (ctx == null ? void 0 : ctx.tags) && scope.setTags(ctx.tags);
27
26
  (ctx == null ? void 0 : ctx.extra) && scope.setExtras(ctx.extra);
28
27
  return scope;
29
28
  });
30
29
  }
31
30
  setUser(user) {
32
- Sentry.setUser(user);
31
+ this.sentry.setUser(user);
32
+ }
33
+ get ErrorBoundary() {
34
+ return this.sentry.ErrorBoundary;
35
+ }
36
+ };
37
+
38
+ // src/adapter/web/index.ts
39
+ var WebMonitorClient = class extends BaseClient {
40
+ constructor(options) {
41
+ super(Sentry, options);
33
42
  }
34
43
  };
35
44
  export {
36
- WebSentryClient
45
+ WebMonitorClient
37
46
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xifan052/monitor",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -26,20 +26,23 @@
26
26
  "require": "./dist/rn.cjs"
27
27
  }
28
28
  },
29
- "scripts": {
30
- "build": "tsup --dts",
31
- "test": "vitest",
32
- "prepublishOnly": "pnpm build"
33
- },
34
29
  "peerDependencies": {
35
- "@sentry/browser": "^7",
30
+ "@sentry/react": "^7",
36
31
  "@sentry/react-native": "^5"
37
32
  },
38
33
  "devDependencies": {
34
+ "@changesets/cli": "^2.27.10",
39
35
  "typescript": "^5",
40
36
  "vitest": "^1"
41
37
  },
42
38
  "dependencies": {
43
39
  "tsup": "^8.5.1"
40
+ },
41
+ "scripts": {
42
+ "build": "tsup --dts",
43
+ "changeset": "changeset",
44
+ "version": "changeset version",
45
+ "release": "changeset publish",
46
+ "test": "vitest"
44
47
  }
45
- }
48
+ }
@@ -1,24 +0,0 @@
1
- interface MonitorUser {
2
- id?: string;
3
- email?: string;
4
- username?: string;
5
- }
6
- interface CaptureContext {
7
- tags?: Record<string, string>;
8
- extra?: Record<string, any>;
9
- }
10
- interface MonitorClient {
11
- init(): void;
12
- captureException(error: Error, ctx?: CaptureContext): void;
13
- captureMessage(message: string, ctx?: CaptureContext): void;
14
- setUser(user: MonitorUser | null): void;
15
- }
16
-
17
- declare abstract class BaseMonitorClient implements MonitorClient {
18
- abstract init(): void;
19
- abstract captureException(error: Error, ctx?: CaptureContext): void;
20
- abstract captureMessage(message: string, ctx?: CaptureContext): void;
21
- abstract setUser(user: MonitorUser | null): void;
22
- }
23
-
24
- export { BaseMonitorClient as B, type CaptureContext as C, type MonitorUser as M, type MonitorClient as a };
@@ -1,24 +0,0 @@
1
- interface MonitorUser {
2
- id?: string;
3
- email?: string;
4
- username?: string;
5
- }
6
- interface CaptureContext {
7
- tags?: Record<string, string>;
8
- extra?: Record<string, any>;
9
- }
10
- interface MonitorClient {
11
- init(): void;
12
- captureException(error: Error, ctx?: CaptureContext): void;
13
- captureMessage(message: string, ctx?: CaptureContext): void;
14
- setUser(user: MonitorUser | null): void;
15
- }
16
-
17
- declare abstract class BaseMonitorClient implements MonitorClient {
18
- abstract init(): void;
19
- abstract captureException(error: Error, ctx?: CaptureContext): void;
20
- abstract captureMessage(message: string, ctx?: CaptureContext): void;
21
- abstract setUser(user: MonitorUser | null): void;
22
- }
23
-
24
- export { BaseMonitorClient as B, type CaptureContext as C, type MonitorUser as M, type MonitorClient as a };