@sentry/react-native 6.6.0 → 6.7.0-alpha.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/RNSentry.podspec +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryCompositeOptionsConfiguration.java +25 -0
- package/android/src/main/java/io/sentry/react/RNSentryJsonConverter.java +76 -0
- package/android/src/main/java/io/sentry/react/RNSentryJsonUtils.java +41 -0
- package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +2 -280
- package/android/src/main/java/io/sentry/react/RNSentrySDK.java +68 -0
- package/android/src/main/java/io/sentry/react/RNSentryStart.java +365 -0
- package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +21 -10
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/tools/metroconfig.d.ts +9 -1
- package/dist/js/tools/metroconfig.d.ts.map +1 -1
- package/dist/js/tools/metroconfig.js +9 -2
- package/dist/js/tools/metroconfig.js.map +1 -1
- package/dist/js/tools/sentryMetroSerializer.d.ts.map +1 -1
- package/dist/js/tools/sentryMetroSerializer.js +1 -0
- package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
- package/dist/js/tools/sentryOptionsSerializer.d.ts +6 -0
- package/dist/js/tools/sentryOptionsSerializer.d.ts.map +1 -0
- package/dist/js/tools/sentryOptionsSerializer.js +91 -0
- package/dist/js/tools/sentryOptionsSerializer.js.map +1 -0
- package/dist/js/tools/utils.d.ts +2 -1
- package/dist/js/tools/utils.d.ts.map +1 -1
- package/dist/js/tools/utils.js.map +1 -1
- package/dist/js/utils/worldwide.d.ts +2 -0
- package/dist/js/utils/worldwide.d.ts.map +1 -1
- package/dist/js/utils/worldwide.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.d.ts.map +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/ios/RNSentry.h +3 -5
- package/ios/RNSentry.mm +2 -169
- package/ios/RNSentrySDK.h +31 -0
- package/ios/RNSentrySDK.m +71 -0
- package/ios/RNSentryStart.h +26 -0
- package/ios/RNSentryStart.m +222 -0
- package/ios/RNSentryVersion.m +1 -1
- package/package.json +10 -10
- package/scripts/sentry-xcode.sh +19 -0
- package/sentry.gradle +52 -1
- package/ts3.8/dist/js/utils/worldwide.d.ts +2 -0
- package/ts3.8/dist/js/version.d.ts +1 -1
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
package io.sentry.react;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
+
import com.facebook.react.bridge.ReadableType;
|
|
7
|
+
import com.facebook.react.common.JavascriptException;
|
|
8
|
+
import io.sentry.ILogger;
|
|
9
|
+
import io.sentry.Integration;
|
|
10
|
+
import io.sentry.Sentry;
|
|
11
|
+
import io.sentry.SentryEvent;
|
|
12
|
+
import io.sentry.SentryLevel;
|
|
13
|
+
import io.sentry.SentryOptions.BeforeSendCallback;
|
|
14
|
+
import io.sentry.SentryReplayOptions;
|
|
15
|
+
import io.sentry.UncaughtExceptionHandlerIntegration;
|
|
16
|
+
import io.sentry.android.core.AnrIntegration;
|
|
17
|
+
import io.sentry.android.core.BuildConfig;
|
|
18
|
+
import io.sentry.android.core.CurrentActivityHolder;
|
|
19
|
+
import io.sentry.android.core.NdkIntegration;
|
|
20
|
+
import io.sentry.android.core.SentryAndroid;
|
|
21
|
+
import io.sentry.android.core.SentryAndroidOptions;
|
|
22
|
+
import io.sentry.protocol.SdkVersion;
|
|
23
|
+
import io.sentry.protocol.SentryPackage;
|
|
24
|
+
import io.sentry.react.replay.RNSentryReplayMask;
|
|
25
|
+
import io.sentry.react.replay.RNSentryReplayUnmask;
|
|
26
|
+
import java.net.URI;
|
|
27
|
+
import java.net.URISyntaxException;
|
|
28
|
+
import java.util.List;
|
|
29
|
+
import org.jetbrains.annotations.NotNull;
|
|
30
|
+
import org.jetbrains.annotations.Nullable;
|
|
31
|
+
|
|
32
|
+
final class RNSentryStart {
|
|
33
|
+
|
|
34
|
+
private RNSentryStart() {
|
|
35
|
+
throw new AssertionError("Utility class should not be instantiated");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static void startWithConfiguration(
|
|
39
|
+
@NotNull final Context context,
|
|
40
|
+
@NotNull Sentry.OptionsConfiguration<SentryAndroidOptions> configuration) {
|
|
41
|
+
Sentry.OptionsConfiguration<SentryAndroidOptions> defaults =
|
|
42
|
+
options -> updateWithReactDefaults(options, null);
|
|
43
|
+
RNSentryCompositeOptionsConfiguration compositeConfiguration =
|
|
44
|
+
new RNSentryCompositeOptionsConfiguration(
|
|
45
|
+
defaults, configuration, RNSentryStart::updateWithReactFinals);
|
|
46
|
+
SentryAndroid.init(context, compositeConfiguration);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static void startWithOptions(
|
|
50
|
+
@NotNull final Context context,
|
|
51
|
+
@NotNull final ReadableMap rnOptions,
|
|
52
|
+
@NotNull Sentry.OptionsConfiguration<SentryAndroidOptions> configuration,
|
|
53
|
+
@NotNull ILogger logger) {
|
|
54
|
+
Sentry.OptionsConfiguration<SentryAndroidOptions> defaults =
|
|
55
|
+
options -> updateWithReactDefaults(options, null);
|
|
56
|
+
Sentry.OptionsConfiguration<SentryAndroidOptions> rnConfigurationOptions =
|
|
57
|
+
options -> getSentryAndroidOptions(options, rnOptions, logger);
|
|
58
|
+
RNSentryCompositeOptionsConfiguration compositeConfiguration =
|
|
59
|
+
new RNSentryCompositeOptionsConfiguration(
|
|
60
|
+
rnConfigurationOptions, defaults, configuration, RNSentryStart::updateWithReactFinals);
|
|
61
|
+
SentryAndroid.init(context, compositeConfiguration);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static void startWithOptions(
|
|
65
|
+
@NotNull final Context context,
|
|
66
|
+
@NotNull final ReadableMap rnOptions,
|
|
67
|
+
@Nullable Activity currentActivity,
|
|
68
|
+
@NotNull ILogger logger) {
|
|
69
|
+
Sentry.OptionsConfiguration<SentryAndroidOptions> defaults =
|
|
70
|
+
options -> updateWithReactDefaults(options, currentActivity);
|
|
71
|
+
Sentry.OptionsConfiguration<SentryAndroidOptions> rnConfigurationOptions =
|
|
72
|
+
options -> getSentryAndroidOptions(options, rnOptions, logger);
|
|
73
|
+
RNSentryCompositeOptionsConfiguration compositeConfiguration =
|
|
74
|
+
new RNSentryCompositeOptionsConfiguration(
|
|
75
|
+
rnConfigurationOptions, defaults, RNSentryStart::updateWithReactFinals);
|
|
76
|
+
SentryAndroid.init(context, compositeConfiguration);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static void getSentryAndroidOptions(
|
|
80
|
+
@NotNull SentryAndroidOptions options,
|
|
81
|
+
@NotNull ReadableMap rnOptions,
|
|
82
|
+
@NotNull ILogger logger) {
|
|
83
|
+
if (rnOptions.hasKey("debug") && rnOptions.getBoolean("debug")) {
|
|
84
|
+
options.setDebug(true);
|
|
85
|
+
}
|
|
86
|
+
if (rnOptions.hasKey("dsn") && rnOptions.getString("dsn") != null) {
|
|
87
|
+
String dsn = rnOptions.getString("dsn");
|
|
88
|
+
logger.log(SentryLevel.INFO, String.format("Starting with DSN: '%s'", dsn));
|
|
89
|
+
options.setDsn(dsn);
|
|
90
|
+
} else {
|
|
91
|
+
// SentryAndroid needs an empty string fallback for the dsn.
|
|
92
|
+
options.setDsn("");
|
|
93
|
+
}
|
|
94
|
+
if (rnOptions.hasKey("sampleRate")) {
|
|
95
|
+
options.setSampleRate(rnOptions.getDouble("sampleRate"));
|
|
96
|
+
}
|
|
97
|
+
if (rnOptions.hasKey("sendClientReports")) {
|
|
98
|
+
options.setSendClientReports(rnOptions.getBoolean("sendClientReports"));
|
|
99
|
+
}
|
|
100
|
+
if (rnOptions.hasKey("maxBreadcrumbs")) {
|
|
101
|
+
options.setMaxBreadcrumbs(rnOptions.getInt("maxBreadcrumbs"));
|
|
102
|
+
}
|
|
103
|
+
if (rnOptions.hasKey("maxCacheItems")) {
|
|
104
|
+
options.setMaxCacheItems(rnOptions.getInt("maxCacheItems"));
|
|
105
|
+
}
|
|
106
|
+
if (rnOptions.hasKey("environment") && rnOptions.getString("environment") != null) {
|
|
107
|
+
options.setEnvironment(rnOptions.getString("environment"));
|
|
108
|
+
}
|
|
109
|
+
if (rnOptions.hasKey("release") && rnOptions.getString("release") != null) {
|
|
110
|
+
options.setRelease(rnOptions.getString("release"));
|
|
111
|
+
}
|
|
112
|
+
if (rnOptions.hasKey("dist") && rnOptions.getString("dist") != null) {
|
|
113
|
+
options.setDist(rnOptions.getString("dist"));
|
|
114
|
+
}
|
|
115
|
+
if (rnOptions.hasKey("enableAutoSessionTracking")) {
|
|
116
|
+
options.setEnableAutoSessionTracking(rnOptions.getBoolean("enableAutoSessionTracking"));
|
|
117
|
+
}
|
|
118
|
+
if (rnOptions.hasKey("sessionTrackingIntervalMillis")) {
|
|
119
|
+
options.setSessionTrackingIntervalMillis(rnOptions.getInt("sessionTrackingIntervalMillis"));
|
|
120
|
+
}
|
|
121
|
+
if (rnOptions.hasKey("shutdownTimeout")) {
|
|
122
|
+
options.setShutdownTimeoutMillis(rnOptions.getInt("shutdownTimeout"));
|
|
123
|
+
}
|
|
124
|
+
if (rnOptions.hasKey("enableNdkScopeSync")) {
|
|
125
|
+
options.setEnableScopeSync(rnOptions.getBoolean("enableNdkScopeSync"));
|
|
126
|
+
}
|
|
127
|
+
if (rnOptions.hasKey("attachStacktrace")) {
|
|
128
|
+
options.setAttachStacktrace(rnOptions.getBoolean("attachStacktrace"));
|
|
129
|
+
}
|
|
130
|
+
if (rnOptions.hasKey("attachThreads")) {
|
|
131
|
+
// JS use top level stacktrace and android attaches Threads which hides them so
|
|
132
|
+
// by default we hide.
|
|
133
|
+
options.setAttachThreads(rnOptions.getBoolean("attachThreads"));
|
|
134
|
+
}
|
|
135
|
+
if (rnOptions.hasKey("attachScreenshot")) {
|
|
136
|
+
options.setAttachScreenshot(rnOptions.getBoolean("attachScreenshot"));
|
|
137
|
+
}
|
|
138
|
+
if (rnOptions.hasKey("attachViewHierarchy")) {
|
|
139
|
+
options.setAttachViewHierarchy(rnOptions.getBoolean("attachViewHierarchy"));
|
|
140
|
+
}
|
|
141
|
+
if (rnOptions.hasKey("sendDefaultPii")) {
|
|
142
|
+
options.setSendDefaultPii(rnOptions.getBoolean("sendDefaultPii"));
|
|
143
|
+
}
|
|
144
|
+
if (rnOptions.hasKey("maxQueueSize")) {
|
|
145
|
+
options.setMaxQueueSize(rnOptions.getInt("maxQueueSize"));
|
|
146
|
+
}
|
|
147
|
+
if (rnOptions.hasKey("enableNdk")) {
|
|
148
|
+
options.setEnableNdk(rnOptions.getBoolean("enableNdk"));
|
|
149
|
+
}
|
|
150
|
+
if (rnOptions.hasKey("spotlight")) {
|
|
151
|
+
if (rnOptions.getType("spotlight") == ReadableType.Boolean) {
|
|
152
|
+
options.setEnableSpotlight(rnOptions.getBoolean("spotlight"));
|
|
153
|
+
options.setSpotlightConnectionUrl(rnOptions.getString("defaultSidecarUrl"));
|
|
154
|
+
} else if (rnOptions.getType("spotlight") == ReadableType.String) {
|
|
155
|
+
options.setEnableSpotlight(true);
|
|
156
|
+
options.setSpotlightConnectionUrl(rnOptions.getString("spotlight"));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
SentryReplayOptions replayOptions = getReplayOptions(rnOptions);
|
|
161
|
+
options.setSessionReplay(replayOptions);
|
|
162
|
+
if (isReplayEnabled(replayOptions)) {
|
|
163
|
+
options.getReplayController().setBreadcrumbConverter(new RNSentryReplayBreadcrumbConverter());
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Exclude Dev Server and Sentry Dsn request from Breadcrumbs
|
|
167
|
+
String dsn = getURLFromDSN(rnOptions.getString("dsn"));
|
|
168
|
+
String devServerUrl = rnOptions.getString("devServerUrl");
|
|
169
|
+
options.setBeforeBreadcrumb(
|
|
170
|
+
(breadcrumb, hint) -> {
|
|
171
|
+
Object urlObject = breadcrumb.getData("url");
|
|
172
|
+
String url = urlObject instanceof String ? (String) urlObject : "";
|
|
173
|
+
if ("http".equals(breadcrumb.getType())
|
|
174
|
+
&& ((dsn != null && url.startsWith(dsn))
|
|
175
|
+
|| (devServerUrl != null && url.startsWith(devServerUrl)))) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return breadcrumb;
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
if (rnOptions.hasKey("enableNativeCrashHandling")
|
|
182
|
+
&& !rnOptions.getBoolean("enableNativeCrashHandling")) {
|
|
183
|
+
final List<Integration> integrations = options.getIntegrations();
|
|
184
|
+
for (final Integration integration : integrations) {
|
|
185
|
+
if (integration instanceof UncaughtExceptionHandlerIntegration
|
|
186
|
+
|| integration instanceof AnrIntegration
|
|
187
|
+
|| integration instanceof NdkIntegration) {
|
|
188
|
+
integrations.remove(integration);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
logger.log(
|
|
193
|
+
SentryLevel.INFO, String.format("Native Integrations '%s'", options.getIntegrations()));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* This function updates the options with RNSentry defaults. These default can be overwritten by
|
|
198
|
+
* users during manual native initialization.
|
|
199
|
+
*/
|
|
200
|
+
static void updateWithReactDefaults(
|
|
201
|
+
@NotNull SentryAndroidOptions options, @Nullable Activity currentActivity) {
|
|
202
|
+
@Nullable SdkVersion sdkVersion = options.getSdkVersion();
|
|
203
|
+
if (sdkVersion == null) {
|
|
204
|
+
sdkVersion = new SdkVersion(RNSentryVersion.ANDROID_SDK_NAME, BuildConfig.VERSION_NAME);
|
|
205
|
+
} else {
|
|
206
|
+
sdkVersion.setName(RNSentryVersion.ANDROID_SDK_NAME);
|
|
207
|
+
}
|
|
208
|
+
sdkVersion.addPackage(
|
|
209
|
+
RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_NAME,
|
|
210
|
+
RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_VERSION);
|
|
211
|
+
|
|
212
|
+
options.setSentryClientName(sdkVersion.getName() + "/" + sdkVersion.getVersion());
|
|
213
|
+
options.setNativeSdkName(RNSentryVersion.NATIVE_SDK_NAME);
|
|
214
|
+
options.setSdkVersion(sdkVersion);
|
|
215
|
+
|
|
216
|
+
// Tracing is only enabled in JS to avoid duplicate navigation spans
|
|
217
|
+
options.setTracesSampleRate(null);
|
|
218
|
+
options.setTracesSampler(null);
|
|
219
|
+
options.setEnableTracing(false);
|
|
220
|
+
|
|
221
|
+
// React native internally throws a JavascriptException.
|
|
222
|
+
// we want to ignore it on the native side to avoid sending it twice.
|
|
223
|
+
options.addIgnoredExceptionForType(JavascriptException.class);
|
|
224
|
+
|
|
225
|
+
setCurrentActivity(currentActivity);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* This function updates options with changes RNSentry users should not change and so this is
|
|
230
|
+
* applied after the configureOptions callback during manual native initialization.
|
|
231
|
+
*/
|
|
232
|
+
static void updateWithReactFinals(@NotNull SentryAndroidOptions options) {
|
|
233
|
+
BeforeSendCallback userBeforeSend = options.getBeforeSend();
|
|
234
|
+
options.setBeforeSend(
|
|
235
|
+
(event, hint) -> {
|
|
236
|
+
setEventOriginTag(event);
|
|
237
|
+
addPackages(event, options.getSdkVersion());
|
|
238
|
+
if (userBeforeSend != null) {
|
|
239
|
+
return userBeforeSend.execute(event, hint);
|
|
240
|
+
}
|
|
241
|
+
return event;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
private static void setCurrentActivity(Activity currentActivity) {
|
|
246
|
+
final CurrentActivityHolder currentActivityHolder = CurrentActivityHolder.getInstance();
|
|
247
|
+
if (currentActivity != null) {
|
|
248
|
+
currentActivityHolder.setActivity(currentActivity);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private static boolean isReplayEnabled(SentryReplayOptions replayOptions) {
|
|
253
|
+
return replayOptions.getSessionSampleRate() != null
|
|
254
|
+
|| replayOptions.getOnErrorSampleRate() != null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
private static SentryReplayOptions getReplayOptions(@NotNull ReadableMap rnOptions) {
|
|
258
|
+
final SdkVersion replaySdkVersion =
|
|
259
|
+
new SdkVersion(
|
|
260
|
+
RNSentryVersion.REACT_NATIVE_SDK_NAME,
|
|
261
|
+
RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_VERSION);
|
|
262
|
+
@NotNull
|
|
263
|
+
final SentryReplayOptions androidReplayOptions =
|
|
264
|
+
new SentryReplayOptions(false, replaySdkVersion);
|
|
265
|
+
|
|
266
|
+
if (!(rnOptions.hasKey("replaysSessionSampleRate")
|
|
267
|
+
|| rnOptions.hasKey("replaysOnErrorSampleRate"))) {
|
|
268
|
+
return androidReplayOptions;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
androidReplayOptions.setSessionSampleRate(
|
|
272
|
+
rnOptions.hasKey("replaysSessionSampleRate")
|
|
273
|
+
? rnOptions.getDouble("replaysSessionSampleRate")
|
|
274
|
+
: null);
|
|
275
|
+
androidReplayOptions.setOnErrorSampleRate(
|
|
276
|
+
rnOptions.hasKey("replaysOnErrorSampleRate")
|
|
277
|
+
? rnOptions.getDouble("replaysOnErrorSampleRate")
|
|
278
|
+
: null);
|
|
279
|
+
|
|
280
|
+
if (!rnOptions.hasKey("mobileReplayOptions")) {
|
|
281
|
+
return androidReplayOptions;
|
|
282
|
+
}
|
|
283
|
+
@Nullable final ReadableMap rnMobileReplayOptions = rnOptions.getMap("mobileReplayOptions");
|
|
284
|
+
if (rnMobileReplayOptions == null) {
|
|
285
|
+
return androidReplayOptions;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
androidReplayOptions.setMaskAllText(
|
|
289
|
+
!rnMobileReplayOptions.hasKey("maskAllText")
|
|
290
|
+
|| rnMobileReplayOptions.getBoolean("maskAllText"));
|
|
291
|
+
androidReplayOptions.setMaskAllImages(
|
|
292
|
+
!rnMobileReplayOptions.hasKey("maskAllImages")
|
|
293
|
+
|| rnMobileReplayOptions.getBoolean("maskAllImages"));
|
|
294
|
+
|
|
295
|
+
final boolean redactVectors =
|
|
296
|
+
!rnMobileReplayOptions.hasKey("maskAllVectors")
|
|
297
|
+
|| rnMobileReplayOptions.getBoolean("maskAllVectors");
|
|
298
|
+
if (redactVectors) {
|
|
299
|
+
androidReplayOptions.addMaskViewClass("com.horcrux.svg.SvgView"); // react-native-svg
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
androidReplayOptions.setMaskViewContainerClass(RNSentryReplayMask.class.getName());
|
|
303
|
+
androidReplayOptions.setUnmaskViewContainerClass(RNSentryReplayUnmask.class.getName());
|
|
304
|
+
|
|
305
|
+
return androidReplayOptions;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private static void setEventOriginTag(SentryEvent event) {
|
|
309
|
+
// We hardcode native-java as only java events are processed by the Android SDK.
|
|
310
|
+
SdkVersion sdk = event.getSdk();
|
|
311
|
+
if (sdk != null) {
|
|
312
|
+
switch (sdk.getName()) {
|
|
313
|
+
case RNSentryVersion.NATIVE_SDK_NAME:
|
|
314
|
+
setEventEnvironmentTag(event, "native");
|
|
315
|
+
break;
|
|
316
|
+
case RNSentryVersion.ANDROID_SDK_NAME:
|
|
317
|
+
setEventEnvironmentTag(event, "java");
|
|
318
|
+
break;
|
|
319
|
+
default:
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private static void setEventEnvironmentTag(SentryEvent event, String environment) {
|
|
326
|
+
event.setTag("event.origin", "android");
|
|
327
|
+
event.setTag("event.environment", environment);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private static void addPackages(SentryEvent event, SdkVersion sdk) {
|
|
331
|
+
SdkVersion eventSdk = event.getSdk();
|
|
332
|
+
if (eventSdk != null
|
|
333
|
+
&& "sentry.javascript.react-native".equals(eventSdk.getName())
|
|
334
|
+
&& sdk != null) {
|
|
335
|
+
List<SentryPackage> sentryPackages = sdk.getPackages();
|
|
336
|
+
if (sentryPackages != null) {
|
|
337
|
+
for (SentryPackage sentryPackage : sentryPackages) {
|
|
338
|
+
eventSdk.addPackage(sentryPackage.getName(), sentryPackage.getVersion());
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
List<String> integrations = sdk.getIntegrations();
|
|
343
|
+
if (integrations != null) {
|
|
344
|
+
for (String integration : integrations) {
|
|
345
|
+
eventSdk.addIntegration(integration);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
event.setSdk(eventSdk);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
private static @Nullable String getURLFromDSN(@Nullable String dsn) {
|
|
354
|
+
if (dsn == null) {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
URI uri = null;
|
|
358
|
+
try {
|
|
359
|
+
uri = new URI(dsn);
|
|
360
|
+
} catch (URISyntaxException e) {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
return uri.getScheme() + "://" + uri.getHost();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
@@ -2,7 +2,7 @@ package io.sentry.react;
|
|
|
2
2
|
|
|
3
3
|
class RNSentryVersion {
|
|
4
4
|
static final String REACT_NATIVE_SDK_PACKAGE_NAME = "npm:@sentry/react-native";
|
|
5
|
-
static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "6.
|
|
5
|
+
static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "6.7.0-alpha.0";
|
|
6
6
|
static final String NATIVE_SDK_NAME = "sentry.native.android.react-native";
|
|
7
7
|
static final String ANDROID_SDK_NAME = "sentry.java.android.react-native";
|
|
8
8
|
static final String REACT_NATIVE_SDK_NAME = "sentry.javascript.react-native";
|
package/dist/js/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2C,KAAK,EAAsB,YAAY,EAAE,MAAM,cAAc,CAAC;AAMrH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAA4B,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2C,KAAK,EAAsB,YAAY,EAAE,MAAM,cAAc,CAAC;AAMrH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAA4B,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA8BzG;;GAEG;AACH,wBAAgB,IAAI,CAAC,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAwH5D;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpD,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACrC,OAAO,CAAC,EAAE,yBAAyB,GAClC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAiBxB;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAED;;;GAGG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAe9C;AAED;;GAEG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAQhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAUzE;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAE9D"}
|
package/dist/js/sdk.js
CHANGED
|
@@ -13,6 +13,7 @@ import { useEncodePolyfill } from './transports/encodePolyfill';
|
|
|
13
13
|
import { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';
|
|
14
14
|
import { getDefaultEnvironment, isExpoGo, isRunningInMetroDevServer } from './utils/environment';
|
|
15
15
|
import { safeFactory, safeTracesSampler } from './utils/safe';
|
|
16
|
+
import { RN_GLOBAL_OBJ } from './utils/worldwide';
|
|
16
17
|
import { NATIVE } from './wrapper';
|
|
17
18
|
const DEFAULT_OPTIONS = {
|
|
18
19
|
enableNativeCrashHandling: true,
|
|
@@ -39,8 +40,9 @@ export function init(passedOptions) {
|
|
|
39
40
|
if (isRunningInMetroDevServer()) {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
const
|
|
43
|
-
const
|
|
43
|
+
const userOptions = Object.assign(Object.assign({}, RN_GLOBAL_OBJ.__SENTRY_OPTIONS__), passedOptions);
|
|
44
|
+
const maxQueueSize = (_c = (_a = userOptions.maxQueueSize) !== null && _a !== void 0 ? _a : (_b = userOptions.transportOptions) === null || _b === void 0 ? void 0 : _b.bufferSize) !== null && _c !== void 0 ? _c : DEFAULT_OPTIONS.maxQueueSize;
|
|
45
|
+
const enableNative = userOptions.enableNative === undefined || userOptions.enableNative
|
|
44
46
|
? NATIVE.isNativeAvailable()
|
|
45
47
|
: false;
|
|
46
48
|
useEncodePolyfill();
|
|
@@ -60,10 +62,10 @@ export function init(passedOptions) {
|
|
|
60
62
|
const port = dsnComponents.port ? `:${dsnComponents.port}` : '';
|
|
61
63
|
return `${dsnComponents.protocol}://${dsnComponents.host}${port}`;
|
|
62
64
|
};
|
|
63
|
-
const userBeforeBreadcrumb = safeFactory(
|
|
65
|
+
const userBeforeBreadcrumb = safeFactory(userOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' });
|
|
64
66
|
// Exclude Dev Server and Sentry Dsn request from Breadcrumbs
|
|
65
67
|
const devServerUrl = (_d = getDevServer()) === null || _d === void 0 ? void 0 : _d.url;
|
|
66
|
-
const dsn = getURLFromDSN(
|
|
68
|
+
const dsn = getURLFromDSN(userOptions.dsn);
|
|
67
69
|
const defaultBeforeBreadcrumb = (breadcrumb, _hint) => {
|
|
68
70
|
var _a;
|
|
69
71
|
const type = breadcrumb.type || '';
|
|
@@ -84,24 +86,30 @@ export function init(passedOptions) {
|
|
|
84
86
|
}
|
|
85
87
|
return defaultBeforeBreadcrumb(modifiedBreadcrumb, hint);
|
|
86
88
|
};
|
|
87
|
-
const options = Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS),
|
|
89
|
+
const options = Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS), userOptions), { enableNative, enableNativeNagger: shouldEnableNativeNagger(userOptions.enableNativeNagger),
|
|
88
90
|
// If custom transport factory fails the SDK won't initialize
|
|
89
|
-
transport:
|
|
91
|
+
transport: userOptions.transport
|
|
90
92
|
|| makeNativeTransportFactory({
|
|
91
93
|
enableNative,
|
|
92
94
|
})
|
|
93
|
-
|| makeFetchTransport, transportOptions: Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS.transportOptions), ((_e =
|
|
95
|
+
|| makeFetchTransport, transportOptions: Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS.transportOptions), ((_e = userOptions.transportOptions) !== null && _e !== void 0 ? _e : {})), { bufferSize: maxQueueSize }), maxQueueSize, integrations: [], stackParser: stackParserFromStackParserOptions(userOptions.stackParser || defaultStackParser), beforeBreadcrumb: chainedBeforeBreadcrumb, initialScope: safeFactory(userOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }) });
|
|
96
|
+
if (!('autoInitializeNativeSdk' in userOptions) && RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {
|
|
97
|
+
// We expect users to use the file options only in combination with manual native initialization
|
|
98
|
+
// eslint-disable-next-line no-console
|
|
99
|
+
console.info('Initializing Sentry JS with the options file. Expecting manual native initialization before JS. Native will not be initialized automatically.');
|
|
100
|
+
options.autoInitializeNativeSdk = false;
|
|
101
|
+
}
|
|
94
102
|
if ('tracesSampler' in options) {
|
|
95
103
|
options.tracesSampler = safeTracesSampler(options.tracesSampler);
|
|
96
104
|
}
|
|
97
105
|
if (!('environment' in options)) {
|
|
98
106
|
options.environment = getDefaultEnvironment();
|
|
99
107
|
}
|
|
100
|
-
const defaultIntegrations =
|
|
108
|
+
const defaultIntegrations = userOptions.defaultIntegrations === undefined
|
|
101
109
|
? getDefaultIntegrations(options)
|
|
102
|
-
:
|
|
110
|
+
: userOptions.defaultIntegrations;
|
|
103
111
|
options.integrations = getIntegrationsToSetup({
|
|
104
|
-
integrations: safeFactory(
|
|
112
|
+
integrations: safeFactory(userOptions.integrations, { loggerMessage: 'The integrations threw an error' }),
|
|
105
113
|
defaultIntegrations,
|
|
106
114
|
});
|
|
107
115
|
initAndBind(ReactNativeClient, options);
|
|
@@ -109,6 +117,9 @@ export function init(passedOptions) {
|
|
|
109
117
|
logger.info('Offline caching, native errors features are not available in Expo Go.');
|
|
110
118
|
logger.info('Use EAS Build / Native Release Build to test these features.');
|
|
111
119
|
}
|
|
120
|
+
if (RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {
|
|
121
|
+
logger.info('Sentry JS initialized with options from the options file.');
|
|
122
|
+
}
|
|
112
123
|
}
|
|
113
124
|
/**
|
|
114
125
|
* Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.
|
package/dist/js/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,EAAE,iBAAiB,E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UAAU,mBAAmB,CAAC,QAAsB;IACxD,MAAM,cAAc,GAAuB;QACzC,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,OAAO,EAAE,QAAQ,CAAC,QAAQ;QAC1B,iBAAiB,EAAE,QAAQ,CAAC,QAAQ;KACrC,CAAC;IACF,eAAe,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAI,QAA6B;IACxD,MAAM,YAAY,GAAG,CAAC,KAAY,EAAiB,EAAE;QACnD,IAAI;YACF,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;YAC1D,OAAO,SAAS,CAAC;SAClB;IACH,CAAC,CAAC;IACF,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAgB,cAAc;;QAClC,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;CAAA","sourcesContent":["/* eslint-disable complexity */\nimport type { Breadcrumb, BreadcrumbHint, Integration, Scope, SendFeedbackParams, UserFeedback } from '@sentry/core';\nimport { captureFeedback, getClient, getGlobalScope, getIntegrationsToSetup, getIsolationScope, initAndBind, logger, makeDsn, stackParserFromStackParserOptions, withScope as coreWithScope } from '@sentry/core';\nimport {\n defaultStackParser,\n makeFetchTransport,\n} from '@sentry/react';\nimport * as React from 'react';\n\nimport { ReactNativeClient } from './client';\nimport { getDevServer } from './integrations/debugsymbolicatorutils';\nimport { getDefaultIntegrations } from './integrations/default';\nimport type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { shouldEnableNativeNagger } from './options';\nimport { enableSyncToNative } from './scopeSync';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler } from './tracing';\nimport { useEncodePolyfill } from './transports/encodePolyfill';\nimport { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';\nimport { getDefaultEnvironment, isExpoGo, isRunningInMetroDevServer } from './utils/environment';\nimport { safeFactory, safeTracesSampler } from './utils/safe';\nimport { NATIVE } from './wrapper';\n\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracing: true,\n enableWatchdogTerminationTracking: true,\n patchGlobalPromise: true,\n sendClientReports: true,\n maxQueueSize: DEFAULT_BUFFER_SIZE,\n attachStacktrace: true,\n enableCaptureFailedRequests: false,\n enableNdk: true,\n enableAppStartTracking: true,\n enableNativeFramesTracking: true,\n enableStallTracking: true,\n enableUserInteractionTracing: false,\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n if (isRunningInMetroDevServer()) {\n return;\n }\n\n const maxQueueSize = passedOptions.maxQueueSize\n // eslint-disable-next-line deprecation/deprecation\n ?? passedOptions.transportOptions?.bufferSize\n ?? DEFAULT_OPTIONS.maxQueueSize;\n\n const enableNative = passedOptions.enableNative === undefined || passedOptions.enableNative\n ? NATIVE.isNativeAvailable()\n : false;\n\n useEncodePolyfill();\n if (enableNative) {\n enableSyncToNative(getGlobalScope());\n enableSyncToNative(getIsolationScope());\n }\n\n const getURLFromDSN = (dsn: string | null): string | undefined => {\n if (!dsn) {\n return undefined;\n }\n const dsnComponents = makeDsn(dsn);\n if (!dsnComponents) {\n logger.error('Failed to extract url from DSN: ', dsn);\n return undefined;\n }\n const port = dsnComponents.port ? `:${dsnComponents.port}` : '';\n return `${dsnComponents.protocol}://${dsnComponents.host}${port}`;\n };\n\n const userBeforeBreadcrumb = safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' });\n\n // Exclude Dev Server and Sentry Dsn request from Breadcrumbs\n const devServerUrl = getDevServer()?.url;\n const dsn = getURLFromDSN(passedOptions.dsn);\n const defaultBeforeBreadcrumb = (breadcrumb: Breadcrumb, _hint?: BreadcrumbHint): Breadcrumb | null => {\n const type = breadcrumb.type || '';\n const url = typeof breadcrumb.data?.url === 'string' ? breadcrumb.data.url : '';\n if (type === 'http' && ((devServerUrl && url.startsWith(devServerUrl)) || (dsn && url.startsWith(dsn)))) {\n return null;\n }\n return breadcrumb;\n };\n\n const chainedBeforeBreadcrumb = (breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Breadcrumb | null => {\n let modifiedBreadcrumb = breadcrumb;\n if (userBeforeBreadcrumb) {\n const result = userBeforeBreadcrumb(breadcrumb, hint);\n if (result === null) {\n return null;\n }\n modifiedBreadcrumb = result;\n }\n return defaultBeforeBreadcrumb(modifiedBreadcrumb, hint);\n };\n\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...passedOptions,\n enableNative,\n enableNativeNagger: shouldEnableNativeNagger(passedOptions.enableNativeNagger),\n // If custom transport factory fails the SDK won't initialize\n transport: passedOptions.transport\n || makeNativeTransportFactory({\n enableNative,\n })\n || makeFetchTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(passedOptions.transportOptions ?? {}),\n bufferSize: maxQueueSize,\n },\n maxQueueSize,\n integrations: [],\n stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser),\n beforeBreadcrumb: chainedBeforeBreadcrumb,\n initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),\n };\n if ('tracesSampler' in options) {\n options.tracesSampler = safeTracesSampler(options.tracesSampler);\n }\n\n if (!('environment' in options)) {\n options.environment = getDefaultEnvironment();\n }\n\n const defaultIntegrations: false | Integration[] = passedOptions.defaultIntegrations === undefined\n ? getDefaultIntegrations(options)\n : passedOptions.defaultIntegrations;\n\n options.integrations = getIntegrationsToSetup({\n integrations: safeFactory(passedOptions.integrations, { loggerMessage: 'The integrations threw an error' }),\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n\n if (isExpoGo()) {\n logger.info('Offline caching, native errors features are not available in Expo Go.');\n logger.info('Use EAS Build / Native Release Build to test these features.');\n }\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P extends Record<string, unknown>>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const profilerProps = {\n ...(options?.profilerProps ?? {}),\n name: RootComponent.displayName ?? 'Root',\n };\n\n const RootApp: React.FC<P> = (appProps) => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ReactNativeProfiler {...profilerProps}>\n <RootComponent {...appProps} />\n </ReactNativeProfiler>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n NATIVE.nativeCrash();\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getClient();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n logger.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getClient();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n logger.error('Failed to close the SDK');\n }\n}\n\n/**\n * Captures user feedback and sends it to Sentry.\n * @deprecated Use `Sentry.captureFeedback` instead.\n */\nexport function captureUserFeedback(feedback: UserFeedback): void {\n const feedbackParams: SendFeedbackParams = {\n name: feedback.name,\n email: feedback.email,\n message: feedback.comments,\n associatedEventId: feedback.event_id,\n };\n captureFeedback(feedbackParams);\n}\n\n/**\n * Creates a new scope with and executes the given operation within.\n * The scope is automatically removed once the operation\n * finishes or throws.\n *\n * This is essentially a convenience function for:\n *\n * pushScope();\n * callback();\n * popScope();\n *\n * @param callback that will be enclosed into push/popScope.\n */\nexport function withScope<T>(callback: (scope: Scope) => T): T | undefined {\n const safeCallback = (scope: Scope): T | undefined => {\n try {\n return callback(scope);\n } catch (e) {\n logger.error('Error while running withScope callback', e);\n return undefined;\n }\n };\n return coreWithScope(safeCallback);\n}\n\n/**\n * Returns if the app crashed in the last run.\n */\nexport async function crashedLastRun(): Promise<boolean | null> {\n return NATIVE.crashedLastRun();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,iCAAiC,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,cAAc,CAAC;AAClN,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC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M,YAAY,GAAG,CAAC,KAAY,EAAiB,EAAE;QACnD,IAAI;YACF,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;YAC1D,OAAO,SAAS,CAAC;SAClB;IACH,CAAC,CAAC;IACF,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAgB,cAAc;;QAClC,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;CAAA","sourcesContent":["/* eslint-disable complexity */\nimport type { Breadcrumb, BreadcrumbHint, Integration, Scope, SendFeedbackParams, UserFeedback } from '@sentry/core';\nimport { captureFeedback, getClient, getGlobalScope, getIntegrationsToSetup, getIsolationScope, initAndBind, logger, makeDsn, stackParserFromStackParserOptions, withScope as coreWithScope } from '@sentry/core';\nimport {\n defaultStackParser,\n makeFetchTransport,\n} from '@sentry/react';\nimport * as React from 'react';\n\nimport { ReactNativeClient } from './client';\nimport { getDevServer } from './integrations/debugsymbolicatorutils';\nimport { getDefaultIntegrations } from './integrations/default';\nimport type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { shouldEnableNativeNagger } from './options';\nimport { enableSyncToNative } from './scopeSync';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler } from './tracing';\nimport { useEncodePolyfill } from './transports/encodePolyfill';\nimport { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';\nimport { getDefaultEnvironment, isExpoGo, isRunningInMetroDevServer } from './utils/environment';\nimport { safeFactory, safeTracesSampler } from './utils/safe';\nimport { RN_GLOBAL_OBJ } from './utils/worldwide';\nimport { NATIVE } from './wrapper';\n\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracing: true,\n enableWatchdogTerminationTracking: true,\n patchGlobalPromise: true,\n sendClientReports: true,\n maxQueueSize: DEFAULT_BUFFER_SIZE,\n attachStacktrace: true,\n enableCaptureFailedRequests: false,\n enableNdk: true,\n enableAppStartTracking: true,\n enableNativeFramesTracking: true,\n enableStallTracking: true,\n enableUserInteractionTracing: false,\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n if (isRunningInMetroDevServer()) {\n return;\n }\n\n const userOptions = {\n ...RN_GLOBAL_OBJ.__SENTRY_OPTIONS__,\n ...passedOptions,\n };\n\n const maxQueueSize = userOptions.maxQueueSize\n // eslint-disable-next-line deprecation/deprecation\n ?? userOptions.transportOptions?.bufferSize\n ?? DEFAULT_OPTIONS.maxQueueSize;\n\n const enableNative = userOptions.enableNative === undefined || userOptions.enableNative\n ? NATIVE.isNativeAvailable()\n : false;\n\n useEncodePolyfill();\n if (enableNative) {\n enableSyncToNative(getGlobalScope());\n enableSyncToNative(getIsolationScope());\n }\n\n const getURLFromDSN = (dsn: string | null): string | undefined => {\n if (!dsn) {\n return undefined;\n }\n const dsnComponents = makeDsn(dsn);\n if (!dsnComponents) {\n logger.error('Failed to extract url from DSN: ', dsn);\n return undefined;\n }\n const port = dsnComponents.port ? `:${dsnComponents.port}` : '';\n return `${dsnComponents.protocol}://${dsnComponents.host}${port}`;\n };\n\n const userBeforeBreadcrumb = safeFactory(userOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' });\n\n // Exclude Dev Server and Sentry Dsn request from Breadcrumbs\n const devServerUrl = getDevServer()?.url;\n const dsn = getURLFromDSN(userOptions.dsn);\n const defaultBeforeBreadcrumb = (breadcrumb: Breadcrumb, _hint?: BreadcrumbHint): Breadcrumb | null => {\n const type = breadcrumb.type || '';\n const url = typeof breadcrumb.data?.url === 'string' ? breadcrumb.data.url : '';\n if (type === 'http' && ((devServerUrl && url.startsWith(devServerUrl)) || (dsn && url.startsWith(dsn)))) {\n return null;\n }\n return breadcrumb;\n };\n\n const chainedBeforeBreadcrumb = (breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Breadcrumb | null => {\n let modifiedBreadcrumb = breadcrumb;\n if (userBeforeBreadcrumb) {\n const result = userBeforeBreadcrumb(breadcrumb, hint);\n if (result === null) {\n return null;\n }\n modifiedBreadcrumb = result;\n }\n return defaultBeforeBreadcrumb(modifiedBreadcrumb, hint);\n };\n\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...userOptions,\n enableNative,\n enableNativeNagger: shouldEnableNativeNagger(userOptions.enableNativeNagger),\n // If custom transport factory fails the SDK won't initialize\n transport: userOptions.transport\n || makeNativeTransportFactory({\n enableNative,\n })\n || makeFetchTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(userOptions.transportOptions ?? {}),\n bufferSize: maxQueueSize,\n },\n maxQueueSize,\n integrations: [],\n stackParser: stackParserFromStackParserOptions(userOptions.stackParser || defaultStackParser),\n beforeBreadcrumb: chainedBeforeBreadcrumb,\n initialScope: safeFactory(userOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),\n };\n\n if (!('autoInitializeNativeSdk' in userOptions) && RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {\n // We expect users to use the file options only in combination with manual native initialization\n // eslint-disable-next-line no-console\n console.info('Initializing Sentry JS with the options file. Expecting manual native initialization before JS. Native will not be initialized automatically.');\n options.autoInitializeNativeSdk = false;\n }\n\n if ('tracesSampler' in options) {\n options.tracesSampler = safeTracesSampler(options.tracesSampler);\n }\n\n if (!('environment' in options)) {\n options.environment = getDefaultEnvironment();\n }\n\n const defaultIntegrations: false | Integration[] = userOptions.defaultIntegrations === undefined\n ? getDefaultIntegrations(options)\n : userOptions.defaultIntegrations;\n\n options.integrations = getIntegrationsToSetup({\n integrations: safeFactory(userOptions.integrations, { loggerMessage: 'The integrations threw an error' }),\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n\n if (isExpoGo()) {\n logger.info('Offline caching, native errors features are not available in Expo Go.');\n logger.info('Use EAS Build / Native Release Build to test these features.');\n }\n\n if (RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {\n logger.info('Sentry JS initialized with options from the options file.');\n }\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P extends Record<string, unknown>>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const profilerProps = {\n ...(options?.profilerProps ?? {}),\n name: RootComponent.displayName ?? 'Root',\n };\n\n const RootApp: React.FC<P> = (appProps) => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ReactNativeProfiler {...profilerProps}>\n <RootComponent {...appProps} />\n </ReactNativeProfiler>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n NATIVE.nativeCrash();\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getClient();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n logger.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getClient();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n logger.error('Failed to close the SDK');\n }\n}\n\n/**\n * Captures user feedback and sends it to Sentry.\n * @deprecated Use `Sentry.captureFeedback` instead.\n */\nexport function captureUserFeedback(feedback: UserFeedback): void {\n const feedbackParams: SendFeedbackParams = {\n name: feedback.name,\n email: feedback.email,\n message: feedback.comments,\n associatedEventId: feedback.event_id,\n };\n captureFeedback(feedbackParams);\n}\n\n/**\n * Creates a new scope with and executes the given operation within.\n * The scope is automatically removed once the operation\n * finishes or throws.\n *\n * This is essentially a convenience function for:\n *\n * pushScope();\n * callback();\n * popScope();\n *\n * @param callback that will be enclosed into push/popScope.\n */\nexport function withScope<T>(callback: (scope: Scope) => T): T | undefined {\n const safeCallback = (scope: Scope): T | undefined => {\n try {\n return callback(scope);\n } catch (e) {\n logger.error('Error while running withScope callback', e);\n return undefined;\n }\n };\n return coreWithScope(safeCallback);\n}\n\n/**\n * Returns if the app crashed in the last run.\n */\nexport async function crashedLastRun(): Promise<boolean | null> {\n return NATIVE.crashedLastRun();\n}\n"]}
|
|
@@ -18,6 +18,14 @@ export interface SentryMetroConfigOptions {
|
|
|
18
18
|
* @default true
|
|
19
19
|
*/
|
|
20
20
|
enableSourceContextInDevelopment?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Load Sentry Options from a file. If `true` it will use the default path.
|
|
23
|
+
* If `false` it will not load any options from a file. Only options provided in the code will be used.
|
|
24
|
+
* If `string` it will use the provided path.
|
|
25
|
+
*
|
|
26
|
+
* @default '{projectRoot}/sentry.options.json'
|
|
27
|
+
*/
|
|
28
|
+
optionsFile?: string | boolean;
|
|
21
29
|
}
|
|
22
30
|
export interface SentryExpoConfigOptions {
|
|
23
31
|
/**
|
|
@@ -31,7 +39,7 @@ export interface SentryExpoConfigOptions {
|
|
|
31
39
|
* Adds Debug ID to the output bundle and source maps.
|
|
32
40
|
* Collapses Sentry frames from the stack trace view in LogBox.
|
|
33
41
|
*/
|
|
34
|
-
export declare function withSentryConfig(config: MetroConfig, { annotateReactComponents, includeWebReplay, enableSourceContextInDevelopment, }?: SentryMetroConfigOptions): MetroConfig;
|
|
42
|
+
export declare function withSentryConfig(config: MetroConfig, { annotateReactComponents, includeWebReplay, enableSourceContextInDevelopment, optionsFile, }?: SentryMetroConfigOptions): MetroConfig;
|
|
35
43
|
/**
|
|
36
44
|
* This function returns Default Expo configuration with Sentry plugins.
|
|
37
45
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metroconfig.d.ts","sourceRoot":"","sources":["../../../src/js/tools/metroconfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAsC,MAAM,OAAO,CAAC;AAQ7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,cAAc,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"metroconfig.d.ts","sourceRoot":"","sources":["../../../src/js/tools/metroconfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAsC,MAAM,OAAO,CAAC;AAQ7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AAOxC,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,mBAAmB,CAAC;CAC/C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,EACnB,EACE,uBAA+B,EAC/B,gBAAuB,EACvB,gCAAuC,EACvC,WAAkB,GACnB,GAAE,wBAA6B,GAC/B,WAAW,CAqBb;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,oBAAoB,GAAG,uBAAuB,GAAG,wBAA6B,GACtF,WAAW,CA8Bb;AAsBD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAwB3E;AA0BD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CA+C1G;AAQD;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAiC1E"}
|
|
@@ -9,6 +9,7 @@ const sentryBabelTransformerUtils_1 = require("./sentryBabelTransformerUtils");
|
|
|
9
9
|
const sentryMetroSerializer_1 = require("./sentryMetroSerializer");
|
|
10
10
|
tslib_1.__exportStar(require("./sentryMetroSerializer"), exports);
|
|
11
11
|
const metroMiddleware_1 = require("./metroMiddleware");
|
|
12
|
+
const sentryOptionsSerializer_1 = require("./sentryOptionsSerializer");
|
|
12
13
|
(0, enableLogger_1.enableLogger)();
|
|
13
14
|
/**
|
|
14
15
|
* Adds Sentry to the Metro config.
|
|
@@ -16,7 +17,7 @@ const metroMiddleware_1 = require("./metroMiddleware");
|
|
|
16
17
|
* Adds Debug ID to the output bundle and source maps.
|
|
17
18
|
* Collapses Sentry frames from the stack trace view in LogBox.
|
|
18
19
|
*/
|
|
19
|
-
function withSentryConfig(config, { annotateReactComponents = false, includeWebReplay = true, enableSourceContextInDevelopment = true, } = {}) {
|
|
20
|
+
function withSentryConfig(config, { annotateReactComponents = false, includeWebReplay = true, enableSourceContextInDevelopment = true, optionsFile = true, } = {}) {
|
|
20
21
|
setSentryMetroDevServerEnvFlag();
|
|
21
22
|
let newConfig = config;
|
|
22
23
|
newConfig = withSentryDebugId(newConfig);
|
|
@@ -30,6 +31,9 @@ function withSentryConfig(config, { annotateReactComponents = false, includeWebR
|
|
|
30
31
|
if (enableSourceContextInDevelopment) {
|
|
31
32
|
newConfig = (0, metroMiddleware_1.withSentryMiddleware)(newConfig);
|
|
32
33
|
}
|
|
34
|
+
if (optionsFile) {
|
|
35
|
+
newConfig = (0, sentryOptionsSerializer_1.withSentryOptionsFromFile)(newConfig, optionsFile);
|
|
36
|
+
}
|
|
33
37
|
return newConfig;
|
|
34
38
|
}
|
|
35
39
|
exports.withSentryConfig = withSentryConfig;
|
|
@@ -37,7 +41,7 @@ exports.withSentryConfig = withSentryConfig;
|
|
|
37
41
|
* This function returns Default Expo configuration with Sentry plugins.
|
|
38
42
|
*/
|
|
39
43
|
function getSentryExpoConfig(projectRoot, options = {}) {
|
|
40
|
-
var _a;
|
|
44
|
+
var _a, _b, _c;
|
|
41
45
|
setSentryMetroDevServerEnvFlag();
|
|
42
46
|
const getDefaultConfig = options.getDefaultConfig || loadExpoMetroConfigModule().getDefaultConfig;
|
|
43
47
|
const config = getDefaultConfig(projectRoot, Object.assign(Object.assign({}, options), { unstable_beforeAssetSerializationPlugins: [
|
|
@@ -54,6 +58,9 @@ function getSentryExpoConfig(projectRoot, options = {}) {
|
|
|
54
58
|
if ((_a = options.enableSourceContextInDevelopment) !== null && _a !== void 0 ? _a : true) {
|
|
55
59
|
newConfig = (0, metroMiddleware_1.withSentryMiddleware)(newConfig);
|
|
56
60
|
}
|
|
61
|
+
if ((_b = options.optionsFile) !== null && _b !== void 0 ? _b : true) {
|
|
62
|
+
newConfig = (0, sentryOptionsSerializer_1.withSentryOptionsFromFile)(newConfig, (_c = options.optionsFile) !== null && _c !== void 0 ? _c : true);
|
|
63
|
+
}
|
|
57
64
|
return newConfig;
|
|
58
65
|
}
|
|
59
66
|
exports.getSentryExpoConfig = getSentryExpoConfig;
|