react-native-test-adx 0.1.15 → 0.1.16
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,48 +45,47 @@ function sentryLevel(level, target) {
|
|
|
45
45
|
}
|
|
46
46
|
return 'info';
|
|
47
47
|
}
|
|
48
|
-
function shouldCaptureMessage(input, level,
|
|
49
|
-
if (
|
|
48
|
+
function shouldCaptureMessage(input, level, structuredLogSent, platform) {
|
|
49
|
+
if (level === 'debug' || structuredLogSent) {
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
52
|
if (input.captureAsEvent && input.error === undefined) {
|
|
53
53
|
return true;
|
|
54
54
|
}
|
|
55
|
-
return MESSAGE_FALLBACK_EVENTS.has(input.eventName);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Sentry Logs + logger.* break Metro in dev; release native builds can use them. */
|
|
59
|
-
function usesStructuredSentryLogs(platform) {
|
|
60
55
|
if (platform === 'web') {
|
|
61
|
-
return
|
|
56
|
+
return MESSAGE_FALLBACK_EVENTS.has(input.eventName);
|
|
62
57
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
function usesMinimalNativeSentryInit(platform) {
|
|
66
|
-
return platform !== 'web' && (typeof __DEV__ === 'undefined' || __DEV__);
|
|
58
|
+
// Native dev + release: message fallback when Sentry Logs API did not accept the event.
|
|
59
|
+
return true;
|
|
67
60
|
}
|
|
68
61
|
function emitStructuredLog(sentry, level, eventName, metadata) {
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
try {
|
|
63
|
+
const loggerFn = sentry.logger?.[level];
|
|
64
|
+
if (typeof loggerFn !== 'function') {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
loggerFn.call(sentry.logger, eventName, {
|
|
68
|
+
...metadata,
|
|
69
|
+
event_name: eventName
|
|
70
|
+
});
|
|
71
|
+
return true;
|
|
72
|
+
} catch {
|
|
71
73
|
return false;
|
|
72
74
|
}
|
|
73
|
-
loggerFn.call(sentry.logger, eventName, {
|
|
74
|
-
...metadata,
|
|
75
|
-
event_name: eventName
|
|
76
|
-
});
|
|
77
|
-
return true;
|
|
78
75
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
function sentryInitOptions(dsn, environment) {
|
|
77
|
+
return {
|
|
78
|
+
dsn,
|
|
79
|
+
environment,
|
|
80
|
+
enableLogs: true,
|
|
81
|
+
enableAutoConsoleLogs: false,
|
|
82
|
+
tracesSampleRate: 0,
|
|
83
|
+
enableAutoSessionTracking: false,
|
|
84
|
+
sendDefaultPii: false
|
|
85
|
+
};
|
|
87
86
|
}
|
|
88
|
-
function
|
|
89
|
-
if (
|
|
87
|
+
function emitDevActivityMirror(level, eventName, metadata) {
|
|
88
|
+
if (typeof __DEV__ === 'undefined' || !__DEV__) {
|
|
90
89
|
return;
|
|
91
90
|
}
|
|
92
91
|
const consoleFn = level === 'error' ? console.error : level === 'warn' ? console.warn : console.info;
|
|
@@ -140,36 +139,28 @@ class AdaxonLoggerService {
|
|
|
140
139
|
timestamp: new Date().toISOString()
|
|
141
140
|
});
|
|
142
141
|
const tags = activityTags(input.eventName, this.platform);
|
|
143
|
-
let deliveredToSentry = false;
|
|
144
142
|
this.safe(() => {
|
|
145
143
|
const sentry = loadSentryModule();
|
|
146
144
|
if (!sentry || !this.sentryReady) {
|
|
147
145
|
return;
|
|
148
146
|
}
|
|
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);
|
|
147
|
+
const structuredLogSent = emitStructuredLog(sentry, level, input.eventName, metadata);
|
|
148
|
+
if (level === 'warn' || level === 'error') {
|
|
149
|
+
sentry.addBreadcrumb({
|
|
150
|
+
category: 'adaxon.sdk',
|
|
151
|
+
message: input.eventName,
|
|
152
|
+
level: sentryLevel(level, 'breadcrumb'),
|
|
153
|
+
data: metadata,
|
|
154
|
+
timestamp: Date.now() / 1000
|
|
155
|
+
});
|
|
165
156
|
}
|
|
166
|
-
if (
|
|
157
|
+
if (shouldCaptureMessage(input, level, structuredLogSent, this.platform) && typeof sentry.captureMessage === 'function') {
|
|
167
158
|
sentry.captureMessage(input.eventName, {
|
|
168
159
|
level: sentryLevel(level, 'message'),
|
|
169
160
|
tags,
|
|
170
|
-
extra: metadata
|
|
161
|
+
extra: metadata,
|
|
162
|
+
fingerprint: ['adaxon.activity', input.eventName]
|
|
171
163
|
});
|
|
172
|
-
deliveredToSentry = true;
|
|
173
164
|
}
|
|
174
165
|
if (input.captureAsEvent && input.error !== undefined) {
|
|
175
166
|
const captureError = input.error instanceof Error ? input.error : new Error(AdaxonSdkError.messageOf(input.error, `Adaxon SDK activity: ${input.eventName}`));
|
|
@@ -177,10 +168,9 @@ class AdaxonLoggerService {
|
|
|
177
168
|
tags,
|
|
178
169
|
extra: metadata
|
|
179
170
|
});
|
|
180
|
-
deliveredToSentry = true;
|
|
181
171
|
}
|
|
182
172
|
});
|
|
183
|
-
|
|
173
|
+
emitDevActivityMirror(level, input.eventName, metadata);
|
|
184
174
|
}
|
|
185
175
|
ensureSentry(dsn, testMode) {
|
|
186
176
|
this.safe(() => {
|
|
@@ -193,34 +183,7 @@ class AdaxonLoggerService {
|
|
|
193
183
|
return;
|
|
194
184
|
}
|
|
195
185
|
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
|
-
}
|
|
186
|
+
sentry.init(sentryInitOptions(dsn.trim(), environment));
|
|
224
187
|
}
|
|
225
188
|
sentry.setTag('adaxon_sdk_version', SDK_VERSION);
|
|
226
189
|
sentry.setTag('adaxon_platform', this.platform);
|
package/package.json
CHANGED