react-native-test-adx 0.1.16 → 0.1.17
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/lib/module/sdkVersion.js
CHANGED
|
@@ -45,6 +45,14 @@ function sentryLevel(level, target) {
|
|
|
45
45
|
}
|
|
46
46
|
return 'info';
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
/** Sentry Logs (`logger.*`) break Metro on native dev; release + web use Logs. */
|
|
50
|
+
function usesStructuredSentryLogs(platform) {
|
|
51
|
+
if (platform === 'web') {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return typeof __DEV__ !== 'undefined' && !__DEV__;
|
|
55
|
+
}
|
|
48
56
|
function shouldCaptureMessage(input, level, structuredLogSent, platform) {
|
|
49
57
|
if (level === 'debug' || structuredLogSent) {
|
|
50
58
|
return false;
|
|
@@ -55,7 +63,7 @@ function shouldCaptureMessage(input, level, structuredLogSent, platform) {
|
|
|
55
63
|
if (platform === 'web') {
|
|
56
64
|
return MESSAGE_FALLBACK_EVENTS.has(input.eventName);
|
|
57
65
|
}
|
|
58
|
-
// Native dev
|
|
66
|
+
// Native dev: primary Sentry channel (Messages). Release: fallback when Logs fail.
|
|
59
67
|
return true;
|
|
60
68
|
}
|
|
61
69
|
function emitStructuredLog(sentry, level, eventName, metadata) {
|
|
@@ -73,31 +81,40 @@ function emitStructuredLog(sentry, level, eventName, metadata) {
|
|
|
73
81
|
return false;
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
|
-
function sentryInitOptions(dsn, environment) {
|
|
77
|
-
|
|
84
|
+
function sentryInitOptions(dsn, environment, platform) {
|
|
85
|
+
const base = {
|
|
78
86
|
dsn,
|
|
79
87
|
environment,
|
|
80
|
-
enableLogs: true,
|
|
81
88
|
enableAutoConsoleLogs: false,
|
|
82
89
|
tracesSampleRate: 0,
|
|
83
90
|
enableAutoSessionTracking: false,
|
|
84
91
|
sendDefaultPii: false
|
|
85
92
|
};
|
|
93
|
+
if (usesStructuredSentryLogs(platform)) {
|
|
94
|
+
return {
|
|
95
|
+
...base,
|
|
96
|
+
enableLogs: true
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Native dev: JS-only client — captureMessage without Sentry Logs (Metro-safe).
|
|
101
|
+
return {
|
|
102
|
+
...base,
|
|
103
|
+
enableLogs: false,
|
|
104
|
+
enableNative: false,
|
|
105
|
+
autoInitializeNativeSdk: false,
|
|
106
|
+
defaultIntegrations: false,
|
|
107
|
+
integrations: []
|
|
108
|
+
};
|
|
86
109
|
}
|
|
87
110
|
function emitDevActivityMirror(level, eventName, metadata) {
|
|
88
111
|
if (typeof __DEV__ === 'undefined' || !__DEV__) {
|
|
89
112
|
return;
|
|
90
113
|
}
|
|
91
114
|
const consoleFn = level === 'error' ? console.error : level === 'warn' ? console.warn : console.info;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
const sentry = loadSentryModule();
|
|
96
|
-
if (typeof sentry?.consoleSandbox === 'function') {
|
|
97
|
-
sentry.consoleSandbox(write);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
write();
|
|
115
|
+
// Direct console in dev avoids a one-time Metro "unknown module undefined" glitch
|
|
116
|
+
// when Sentry integrations run alongside consoleSandbox after captureMessage.
|
|
117
|
+
consoleFn(`[Adaxon activity] ${eventName}`, metadata);
|
|
101
118
|
}
|
|
102
119
|
function activityTags(eventName, platform) {
|
|
103
120
|
return {
|
|
@@ -144,7 +161,7 @@ class AdaxonLoggerService {
|
|
|
144
161
|
if (!sentry || !this.sentryReady) {
|
|
145
162
|
return;
|
|
146
163
|
}
|
|
147
|
-
const structuredLogSent = emitStructuredLog(sentry, level, input.eventName, metadata);
|
|
164
|
+
const structuredLogSent = usesStructuredSentryLogs(this.platform) ? emitStructuredLog(sentry, level, input.eventName, metadata) : false;
|
|
148
165
|
if (level === 'warn' || level === 'error') {
|
|
149
166
|
sentry.addBreadcrumb({
|
|
150
167
|
category: 'adaxon.sdk',
|
|
@@ -183,7 +200,7 @@ class AdaxonLoggerService {
|
|
|
183
200
|
return;
|
|
184
201
|
}
|
|
185
202
|
const environment = testMode ? 'adaxon-sdk-test' : 'adaxon-sdk';
|
|
186
|
-
sentry.init(sentryInitOptions(dsn.trim(), environment));
|
|
203
|
+
sentry.init(sentryInitOptions(dsn.trim(), environment, this.platform));
|
|
187
204
|
}
|
|
188
205
|
sentry.setTag('adaxon_sdk_version', SDK_VERSION);
|
|
189
206
|
sentry.setTag('adaxon_platform', this.platform);
|
package/package.json
CHANGED