@umituz/react-native-sentry 1.2.2 → 1.3.0

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/README.md CHANGED
@@ -73,6 +73,25 @@ function MyComponent() {
73
73
  }
74
74
  ```
75
75
 
76
+ ### Test Helpers (Production/TestFlight)
77
+
78
+ Verify Sentry is working in production builds:
79
+
80
+ ```typescript
81
+ import { sendTestError, sendTestMessage, runTestSuite } from '@umituz/react-native-sentry';
82
+
83
+ // Send a single test error
84
+ sendTestError();
85
+
86
+ // Send a test message
87
+ sendTestMessage();
88
+
89
+ // Run complete test suite
90
+ runTestSuite('user-123');
91
+ ```
92
+
93
+ Add a debug button in your app (e.g., Settings screen) to trigger these tests in TestFlight builds.
94
+
76
95
  ## License
77
96
 
78
97
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-sentry",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "Production-ready error tracking and performance monitoring for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -48,4 +48,4 @@
48
48
  "README.md",
49
49
  "LICENSE"
50
50
  ]
51
- }
51
+ }
@@ -8,6 +8,7 @@ export interface UserData {
8
8
  email?: string;
9
9
  username?: string;
10
10
  ipAddress?: string;
11
+ extras?: Record<string, any>;
11
12
  }
12
13
 
13
14
  export interface ErrorTags {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Global type declarations for React Native environment
3
+ */
4
+
5
+ declare const __DEV__: boolean;
6
+
7
+ declare const console: {
8
+ log(...args: any[]): void;
9
+ warn(...args: any[]): void;
10
+ error(...args: any[]): void;
11
+ info(...args: any[]): void;
12
+ debug(...args: any[]): void;
13
+ };
package/src/index.ts CHANGED
@@ -45,3 +45,11 @@ export {
45
45
  trackPackageEvent,
46
46
  } from './presentation/utils/sentryTracking';
47
47
  export type { PackageErrorContext } from './presentation/utils/sentryTracking';
48
+
49
+ // Test Helpers (for verifying Sentry in production/TestFlight)
50
+ export {
51
+ sendTestError,
52
+ sendTestMessage,
53
+ setTestUser,
54
+ runTestSuite,
55
+ } from './presentation/utils/testHelpers';
@@ -43,7 +43,7 @@ export const nativeSentryAdapter: NativeSentryAdapter = {
43
43
  integrations: integrations.length > 0 ? integrations : undefined,
44
44
  sendDefaultPii: config.sendDefaultPii ?? false,
45
45
 
46
- beforeSend: (event) => {
46
+ beforeSend: (event: any) => {
47
47
  if (!__DEV__ && !config.sendDefaultPii && event.user?.email) {
48
48
  event.user.email = '***@***.***';
49
49
  }
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Sentry Test Helpers
3
+ * Utilities for testing Sentry integration in production/TestFlight
4
+ */
5
+
6
+ import { SentryClient } from '../../infrastructure/config/SentryClient';
7
+
8
+ /**
9
+ * Send test error to Sentry
10
+ * Use this to verify Sentry is working in production builds
11
+ *
12
+ * @example
13
+ * import { sendTestError } from '@umituz/react-native-sentry';
14
+ * sendTestError(); // In a debug button
15
+ */
16
+ export function sendTestError(): void {
17
+ if (!SentryClient.isInitialized()) {
18
+ /* eslint-disable-next-line no-console */
19
+ if (__DEV__) {
20
+ console.warn('[Sentry Test] Not initialized, cannot send test error');
21
+ }
22
+ return;
23
+ }
24
+
25
+ try {
26
+ SentryClient.addBreadcrumb({
27
+ category: 'test',
28
+ message: 'Test breadcrumb added',
29
+ level: 'info',
30
+ data: { timestamp: new Date().toISOString() },
31
+ });
32
+
33
+ const error = new Error(
34
+ `[TEST] Sentry verification - ${new Date().toISOString()}`
35
+ );
36
+ SentryClient.captureException(error, {
37
+ tags: { test: 'true', type: 'verification' },
38
+ extra: { purpose: 'Testing Sentry integration', timestamp: Date.now() },
39
+ });
40
+
41
+ /* eslint-disable-next-line no-console */
42
+ if (__DEV__) {
43
+ console.log('✅ Test error sent to Sentry');
44
+ }
45
+ } catch (error) {
46
+ /* eslint-disable-next-line no-console */
47
+ if (__DEV__) {
48
+ console.error('[Sentry Test] Failed to send test error:', error);
49
+ }
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Send test message to Sentry
55
+ * Lighter alternative to sendTestError for verification
56
+ *
57
+ * @example
58
+ * import { sendTestMessage } from '@umituz/react-native-sentry';
59
+ * sendTestMessage();
60
+ */
61
+ export function sendTestMessage(): void {
62
+ if (!SentryClient.isInitialized()) {
63
+ /* eslint-disable-next-line no-console */
64
+ if (__DEV__) {
65
+ console.warn('[Sentry Test] Not initialized, cannot send test message');
66
+ }
67
+ return;
68
+ }
69
+
70
+ try {
71
+ const message = `[TEST] Sentry message verification - ${new Date().toISOString()}`;
72
+ SentryClient.captureMessage(message, 'info', {
73
+ tags: { test: 'true', type: 'message' },
74
+ extra: { timestamp: Date.now() },
75
+ });
76
+
77
+ /* eslint-disable-next-line no-console */
78
+ if (__DEV__) {
79
+ console.log('✅ Test message sent to Sentry');
80
+ }
81
+ } catch (error) {
82
+ /* eslint-disable-next-line no-console */
83
+ if (__DEV__) {
84
+ console.error('[Sentry Test] Failed to send test message:', error);
85
+ }
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Set test user context
91
+ * Verify user tracking is working
92
+ *
93
+ * @param userId - User ID to test with
94
+ *
95
+ * @example
96
+ * import { setTestUser } from '@umituz/react-native-sentry';
97
+ * setTestUser('test-user-123');
98
+ */
99
+ export function setTestUser(userId: string): void {
100
+ if (!SentryClient.isInitialized()) {
101
+ /* eslint-disable-next-line no-console */
102
+ if (__DEV__) {
103
+ console.warn('[Sentry Test] Not initialized, cannot set test user');
104
+ }
105
+ return;
106
+ }
107
+
108
+ try {
109
+ SentryClient.setUser({
110
+ id: userId,
111
+ extras: {
112
+ testMode: true,
113
+ testTimestamp: new Date().toISOString(),
114
+ },
115
+ });
116
+
117
+ /* eslint-disable-next-line no-console */
118
+ if (__DEV__) {
119
+ console.log('✅ Test user set in Sentry:', userId);
120
+ }
121
+ } catch (error) {
122
+ /* eslint-disable-next-line no-console */
123
+ if (__DEV__) {
124
+ console.error('[Sentry Test] Failed to set test user:', error);
125
+ }
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Send comprehensive test suite
131
+ * Tests breadcrumbs, user context, message and error tracking
132
+ *
133
+ * @param userId - Optional user ID for testing user context
134
+ *
135
+ * @example
136
+ * import { runTestSuite } from '@umituz/react-native-sentry';
137
+ * runTestSuite('user-123');
138
+ */
139
+ export function runTestSuite(userId?: string): void {
140
+ if (!SentryClient.isInitialized()) {
141
+ /* eslint-disable-next-line no-console */
142
+ if (__DEV__) {
143
+ console.warn('[Sentry Test] Not initialized, cannot run test suite');
144
+ }
145
+ return;
146
+ }
147
+
148
+ /* eslint-disable-next-line no-console */
149
+ if (__DEV__) {
150
+ console.log('🧪 Running Sentry test suite...');
151
+ }
152
+
153
+ if (userId) {
154
+ setTestUser(userId);
155
+ }
156
+
157
+ sendTestMessage();
158
+ sendTestError();
159
+
160
+ /* eslint-disable-next-line no-console */
161
+ if (__DEV__) {
162
+ console.log('✅ Sentry test suite completed. Check Sentry dashboard.');
163
+ }
164
+ }