@umituz/react-native-sentry 1.1.1 → 1.2.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/package.json
CHANGED
|
@@ -58,4 +58,31 @@ export interface SentryConfig {
|
|
|
58
58
|
* Should be false in production
|
|
59
59
|
*/
|
|
60
60
|
debug?: boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Enable Sentry Logs
|
|
64
|
+
* Default: false
|
|
65
|
+
*/
|
|
66
|
+
enableLogs?: boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Session Replay sample rate (0.0 to 1.0)
|
|
70
|
+
* Percentage of sessions to record for replay
|
|
71
|
+
* Default: 0.1 (10%)
|
|
72
|
+
*/
|
|
73
|
+
replaysSessionSampleRate?: number;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Session Replay on error sample rate (0.0 to 1.0)
|
|
77
|
+
* Percentage of error sessions to record for replay
|
|
78
|
+
* Default: 1.0 (100%)
|
|
79
|
+
*/
|
|
80
|
+
replaysOnErrorSampleRate?: number;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Send default PII (Personally Identifiable Information)
|
|
84
|
+
* Adds more context data to events (IP address, cookies, user, etc.)
|
|
85
|
+
* Default: false
|
|
86
|
+
*/
|
|
87
|
+
sendDefaultPii?: boolean;
|
|
61
88
|
}
|
|
@@ -20,6 +20,13 @@ export interface NativeSentryAdapter {
|
|
|
20
20
|
|
|
21
21
|
export const nativeSentryAdapter: NativeSentryAdapter = {
|
|
22
22
|
init(config: SentryConfig): void {
|
|
23
|
+
const integrations: any[] = [];
|
|
24
|
+
|
|
25
|
+
// Add Session Replay integration if enabled
|
|
26
|
+
if (config.replaysSessionSampleRate || config.replaysOnErrorSampleRate) {
|
|
27
|
+
integrations.push(Sentry.mobileReplayIntegration());
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
Sentry.init({
|
|
24
31
|
dsn: config.dsn,
|
|
25
32
|
environment: config.environment,
|
|
@@ -32,9 +39,21 @@ export const nativeSentryAdapter: NativeSentryAdapter = {
|
|
|
32
39
|
debug: config.debug ?? false,
|
|
33
40
|
enableAutoPerformanceTracing: true,
|
|
34
41
|
enableNativeCrashHandling: true,
|
|
42
|
+
|
|
43
|
+
// Session Replay
|
|
44
|
+
replaysSessionSampleRate: config.replaysSessionSampleRate ?? 0.1,
|
|
45
|
+
replaysOnErrorSampleRate: config.replaysOnErrorSampleRate ?? 1.0,
|
|
46
|
+
integrations: integrations.length > 0 ? integrations : undefined,
|
|
47
|
+
|
|
48
|
+
// Logs
|
|
49
|
+
enableLogs: config.enableLogs ?? false,
|
|
50
|
+
|
|
51
|
+
// PII
|
|
52
|
+
sendDefaultPii: config.sendDefaultPii ?? false,
|
|
53
|
+
|
|
35
54
|
beforeSend: (event) => {
|
|
36
|
-
// Privacy: Mask email in production
|
|
37
|
-
if (!__DEV__ && event.user?.email) {
|
|
55
|
+
// Privacy: Mask email in production unless sendDefaultPii is true
|
|
56
|
+
if (!__DEV__ && !config.sendDefaultPii && event.user?.email) {
|
|
38
57
|
event.user.email = '***@***.***';
|
|
39
58
|
}
|
|
40
59
|
return event;
|
|
@@ -16,7 +16,8 @@ export class SentryConfigValidator {
|
|
|
16
16
|
throw new SentryConfigError('DSN must start with https://');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Support regional Sentry domains: .ingest.sentry.io, .ingest.us.sentry.io, .ingest.de.sentry.io, etc.
|
|
20
|
+
if (!config.dsn.includes('@') || !config.dsn.includes('.sentry.io/')) {
|
|
20
21
|
throw new SentryConfigError('Invalid DSN format');
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -35,5 +36,17 @@ export class SentryConfigValidator {
|
|
|
35
36
|
throw new SentryConfigError('maxBreadcrumbs must be between 0 and 200');
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
|
|
40
|
+
if (config.replaysSessionSampleRate !== undefined) {
|
|
41
|
+
if (config.replaysSessionSampleRate < 0 || config.replaysSessionSampleRate > 1) {
|
|
42
|
+
throw new SentryConfigError('replaysSessionSampleRate must be between 0 and 1');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (config.replaysOnErrorSampleRate !== undefined) {
|
|
47
|
+
if (config.replaysOnErrorSampleRate < 0 || config.replaysOnErrorSampleRate > 1) {
|
|
48
|
+
throw new SentryConfigError('replaysOnErrorSampleRate must be between 0 and 1');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
38
51
|
}
|
|
39
52
|
}
|