react-native-test-adx 0.1.14 → 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,40 +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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
if (platform === 'web') {
|
|
56
|
+
return MESSAGE_FALLBACK_EVENTS.has(input.eventName);
|
|
57
|
+
}
|
|
58
|
+
// Native dev + release: message fallback when Sentry Logs API did not accept the event.
|
|
59
|
+
return true;
|
|
59
60
|
}
|
|
60
61
|
function emitStructuredLog(sentry, level, eventName, metadata) {
|
|
61
|
-
|
|
62
|
-
|
|
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 {
|
|
63
73
|
return false;
|
|
64
74
|
}
|
|
65
|
-
loggerFn.call(sentry.logger, eventName, {
|
|
66
|
-
...metadata,
|
|
67
|
-
event_name: eventName
|
|
68
|
-
});
|
|
69
|
-
return true;
|
|
70
75
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
};
|
|
79
86
|
}
|
|
80
|
-
function
|
|
81
|
-
if (
|
|
87
|
+
function emitDevActivityMirror(level, eventName, metadata) {
|
|
88
|
+
if (typeof __DEV__ === 'undefined' || !__DEV__) {
|
|
82
89
|
return;
|
|
83
90
|
}
|
|
84
91
|
const consoleFn = level === 'error' ? console.error : level === 'warn' ? console.warn : console.info;
|
|
@@ -132,37 +139,28 @@ class AdaxonLoggerService {
|
|
|
132
139
|
timestamp: new Date().toISOString()
|
|
133
140
|
});
|
|
134
141
|
const tags = activityTags(input.eventName, this.platform);
|
|
135
|
-
let deliveredToSentry = false;
|
|
136
142
|
this.safe(() => {
|
|
137
143
|
const sentry = loadSentryModule();
|
|
138
144
|
if (!sentry || !this.sentryReady) {
|
|
139
145
|
return;
|
|
140
146
|
}
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
level: sentryLevel(level, 'breadcrumb'),
|
|
151
|
-
data: metadata,
|
|
152
|
-
timestamp: Date.now() / 1000
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
emitNativeActivityBreadcrumb(sentry, level, input.eventName, metadata);
|
|
157
|
-
deliveredToSentry = true;
|
|
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
|
+
});
|
|
158
156
|
}
|
|
159
|
-
if (
|
|
157
|
+
if (shouldCaptureMessage(input, level, structuredLogSent, this.platform) && typeof sentry.captureMessage === 'function') {
|
|
160
158
|
sentry.captureMessage(input.eventName, {
|
|
161
159
|
level: sentryLevel(level, 'message'),
|
|
162
160
|
tags,
|
|
163
|
-
extra: metadata
|
|
161
|
+
extra: metadata,
|
|
162
|
+
fingerprint: ['adaxon.activity', input.eventName]
|
|
164
163
|
});
|
|
165
|
-
deliveredToSentry = true;
|
|
166
164
|
}
|
|
167
165
|
if (input.captureAsEvent && input.error !== undefined) {
|
|
168
166
|
const captureError = input.error instanceof Error ? input.error : new Error(AdaxonSdkError.messageOf(input.error, `Adaxon SDK activity: ${input.eventName}`));
|
|
@@ -170,10 +168,9 @@ class AdaxonLoggerService {
|
|
|
170
168
|
tags,
|
|
171
169
|
extra: metadata
|
|
172
170
|
});
|
|
173
|
-
deliveredToSentry = true;
|
|
174
171
|
}
|
|
175
172
|
});
|
|
176
|
-
|
|
173
|
+
emitDevActivityMirror(level, input.eventName, metadata);
|
|
177
174
|
}
|
|
178
175
|
ensureSentry(dsn, testMode) {
|
|
179
176
|
this.safe(() => {
|
|
@@ -185,28 +182,8 @@ class AdaxonLoggerService {
|
|
|
185
182
|
if (!dsn?.trim()) {
|
|
186
183
|
return;
|
|
187
184
|
}
|
|
188
|
-
const
|
|
189
|
-
sentry.init(
|
|
190
|
-
dsn: dsn.trim(),
|
|
191
|
-
environment: testMode ? 'adaxon-sdk-test' : 'adaxon-sdk',
|
|
192
|
-
enableLogs: true,
|
|
193
|
-
enableAutoConsoleLogs: false,
|
|
194
|
-
tracesSampleRate: 0,
|
|
195
|
-
enableAutoSessionTracking: false,
|
|
196
|
-
sendDefaultPii: false
|
|
197
|
-
} : {
|
|
198
|
-
dsn: dsn.trim(),
|
|
199
|
-
environment: testMode ? 'adaxon-sdk-test' : 'adaxon-sdk',
|
|
200
|
-
enableLogs: false,
|
|
201
|
-
enableAutoConsoleLogs: false,
|
|
202
|
-
enableNative: false,
|
|
203
|
-
autoInitializeNativeSdk: false,
|
|
204
|
-
defaultIntegrations: false,
|
|
205
|
-
integrations: [],
|
|
206
|
-
tracesSampleRate: 0,
|
|
207
|
-
enableAutoSessionTracking: false,
|
|
208
|
-
sendDefaultPii: false
|
|
209
|
-
});
|
|
185
|
+
const environment = testMode ? 'adaxon-sdk-test' : 'adaxon-sdk';
|
|
186
|
+
sentry.init(sentryInitOptions(dsn.trim(), environment));
|
|
210
187
|
}
|
|
211
188
|
sentry.setTag('adaxon_sdk_version', SDK_VERSION);
|
|
212
189
|
sentry.setTag('adaxon_platform', this.platform);
|
package/package.json
CHANGED