react-native-test-adx 0.1.15 → 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,60 +45,76 @@ function sentryLevel(level, target) {
|
|
|
45
45
|
}
|
|
46
46
|
return 'info';
|
|
47
47
|
}
|
|
48
|
-
function shouldCaptureMessage(input, level, structuredLogsUsed) {
|
|
49
|
-
if (structuredLogsUsed || level === 'debug') {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
if (input.captureAsEvent && input.error === undefined) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
return MESSAGE_FALLBACK_EVENTS.has(input.eventName);
|
|
56
|
-
}
|
|
57
48
|
|
|
58
|
-
/** Sentry Logs
|
|
49
|
+
/** Sentry Logs (`logger.*`) break Metro on native dev; release + web use Logs. */
|
|
59
50
|
function usesStructuredSentryLogs(platform) {
|
|
60
51
|
if (platform === 'web') {
|
|
61
52
|
return true;
|
|
62
53
|
}
|
|
63
54
|
return typeof __DEV__ !== 'undefined' && !__DEV__;
|
|
64
55
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
function emitStructuredLog(sentry, level, eventName, metadata) {
|
|
69
|
-
const loggerFn = sentry.logger?.[level];
|
|
70
|
-
if (typeof loggerFn !== 'function') {
|
|
56
|
+
function shouldCaptureMessage(input, level, structuredLogSent, platform) {
|
|
57
|
+
if (level === 'debug' || structuredLogSent) {
|
|
71
58
|
return false;
|
|
72
59
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
if (input.captureAsEvent && input.error === undefined) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
if (platform === 'web') {
|
|
64
|
+
return MESSAGE_FALLBACK_EVENTS.has(input.eventName);
|
|
65
|
+
}
|
|
66
|
+
// Native dev: primary Sentry channel (Messages). Release: fallback when Logs fail.
|
|
77
67
|
return true;
|
|
78
68
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
69
|
+
function emitStructuredLog(sentry, level, eventName, metadata) {
|
|
70
|
+
try {
|
|
71
|
+
const loggerFn = sentry.logger?.[level];
|
|
72
|
+
if (typeof loggerFn !== 'function') {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
loggerFn.call(sentry.logger, eventName, {
|
|
76
|
+
...metadata,
|
|
77
|
+
event_name: eventName
|
|
78
|
+
});
|
|
79
|
+
return true;
|
|
80
|
+
} catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
87
83
|
}
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
function sentryInitOptions(dsn, environment, platform) {
|
|
85
|
+
const base = {
|
|
86
|
+
dsn,
|
|
87
|
+
environment,
|
|
88
|
+
enableAutoConsoleLogs: false,
|
|
89
|
+
tracesSampleRate: 0,
|
|
90
|
+
enableAutoSessionTracking: false,
|
|
91
|
+
sendDefaultPii: false
|
|
92
|
+
};
|
|
93
|
+
if (usesStructuredSentryLogs(platform)) {
|
|
94
|
+
return {
|
|
95
|
+
...base,
|
|
96
|
+
enableLogs: true
|
|
97
|
+
};
|
|
91
98
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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: []
|
|
95
108
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
109
|
+
}
|
|
110
|
+
function emitDevActivityMirror(level, eventName, metadata) {
|
|
111
|
+
if (typeof __DEV__ === 'undefined' || !__DEV__) {
|
|
99
112
|
return;
|
|
100
113
|
}
|
|
101
|
-
|
|
114
|
+
const consoleFn = level === 'error' ? console.error : level === 'warn' ? console.warn : console.info;
|
|
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);
|
|
102
118
|
}
|
|
103
119
|
function activityTags(eventName, platform) {
|
|
104
120
|
return {
|
|
@@ -140,36 +156,28 @@ class AdaxonLoggerService {
|
|
|
140
156
|
timestamp: new Date().toISOString()
|
|
141
157
|
});
|
|
142
158
|
const tags = activityTags(input.eventName, this.platform);
|
|
143
|
-
let deliveredToSentry = false;
|
|
144
159
|
this.safe(() => {
|
|
145
160
|
const sentry = loadSentryModule();
|
|
146
161
|
if (!sentry || !this.sentryReady) {
|
|
147
162
|
return;
|
|
148
163
|
}
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
level: sentryLevel(level, 'breadcrumb'),
|
|
159
|
-
data: metadata,
|
|
160
|
-
timestamp: Date.now() / 1000
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
} else {
|
|
164
|
-
emitNativeActivityBreadcrumb(sentry, level, input.eventName, metadata);
|
|
164
|
+
const structuredLogSent = usesStructuredSentryLogs(this.platform) ? emitStructuredLog(sentry, level, input.eventName, metadata) : false;
|
|
165
|
+
if (level === 'warn' || level === 'error') {
|
|
166
|
+
sentry.addBreadcrumb({
|
|
167
|
+
category: 'adaxon.sdk',
|
|
168
|
+
message: input.eventName,
|
|
169
|
+
level: sentryLevel(level, 'breadcrumb'),
|
|
170
|
+
data: metadata,
|
|
171
|
+
timestamp: Date.now() / 1000
|
|
172
|
+
});
|
|
165
173
|
}
|
|
166
|
-
if (
|
|
174
|
+
if (shouldCaptureMessage(input, level, structuredLogSent, this.platform) && typeof sentry.captureMessage === 'function') {
|
|
167
175
|
sentry.captureMessage(input.eventName, {
|
|
168
176
|
level: sentryLevel(level, 'message'),
|
|
169
177
|
tags,
|
|
170
|
-
extra: metadata
|
|
178
|
+
extra: metadata,
|
|
179
|
+
fingerprint: ['adaxon.activity', input.eventName]
|
|
171
180
|
});
|
|
172
|
-
deliveredToSentry = true;
|
|
173
181
|
}
|
|
174
182
|
if (input.captureAsEvent && input.error !== undefined) {
|
|
175
183
|
const captureError = input.error instanceof Error ? input.error : new Error(AdaxonSdkError.messageOf(input.error, `Adaxon SDK activity: ${input.eventName}`));
|
|
@@ -177,10 +185,9 @@ class AdaxonLoggerService {
|
|
|
177
185
|
tags,
|
|
178
186
|
extra: metadata
|
|
179
187
|
});
|
|
180
|
-
deliveredToSentry = true;
|
|
181
188
|
}
|
|
182
189
|
});
|
|
183
|
-
|
|
190
|
+
emitDevActivityMirror(level, input.eventName, metadata);
|
|
184
191
|
}
|
|
185
192
|
ensureSentry(dsn, testMode) {
|
|
186
193
|
this.safe(() => {
|
|
@@ -193,34 +200,7 @@ class AdaxonLoggerService {
|
|
|
193
200
|
return;
|
|
194
201
|
}
|
|
195
202
|
const environment = testMode ? 'adaxon-sdk-test' : 'adaxon-sdk';
|
|
196
|
-
|
|
197
|
-
if (usesMinimalNativeSentryInit(this.platform)) {
|
|
198
|
-
// Dev / Metro: avoid Sentry Logs + default integrations (Metro "unknown module undefined").
|
|
199
|
-
sentry.init({
|
|
200
|
-
dsn: trimmedDsn,
|
|
201
|
-
environment,
|
|
202
|
-
enableLogs: false,
|
|
203
|
-
enableAutoConsoleLogs: false,
|
|
204
|
-
enableNative: false,
|
|
205
|
-
autoInitializeNativeSdk: false,
|
|
206
|
-
defaultIntegrations: false,
|
|
207
|
-
integrations: [],
|
|
208
|
-
tracesSampleRate: 0,
|
|
209
|
-
enableAutoSessionTracking: false,
|
|
210
|
-
sendDefaultPii: false
|
|
211
|
-
});
|
|
212
|
-
} else {
|
|
213
|
-
// Web + release native: structured logs reach Sentry (Logs product / logger API).
|
|
214
|
-
sentry.init({
|
|
215
|
-
dsn: trimmedDsn,
|
|
216
|
-
environment,
|
|
217
|
-
enableLogs: true,
|
|
218
|
-
enableAutoConsoleLogs: false,
|
|
219
|
-
tracesSampleRate: 0,
|
|
220
|
-
enableAutoSessionTracking: false,
|
|
221
|
-
sendDefaultPii: false
|
|
222
|
-
});
|
|
223
|
-
}
|
|
203
|
+
sentry.init(sentryInitOptions(dsn.trim(), environment, this.platform));
|
|
224
204
|
}
|
|
225
205
|
sentry.setTag('adaxon_sdk_version', SDK_VERSION);
|
|
226
206
|
sentry.setTag('adaxon_platform', this.platform);
|
package/package.json
CHANGED