@sentry/react-native 6.2.0 → 6.3.0-beta.1
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/android/src/main/java/io/sentry/react/RNSentryBreadcrumb.java +6 -0
- package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +52 -3
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +3 -1
- package/dist/js/client.js.map +1 -1
- package/dist/js/integrations/debugsymbolicator.js +4 -37
- package/dist/js/integrations/debugsymbolicator.js.map +1 -1
- package/dist/js/integrations/debugsymbolicatorutils.d.ts +6 -2
- package/dist/js/integrations/debugsymbolicatorutils.d.ts.map +1 -1
- package/dist/js/integrations/debugsymbolicatorutils.js +44 -27
- package/dist/js/integrations/debugsymbolicatorutils.js.map +1 -1
- package/dist/js/integrations/default.d.ts.map +1 -1
- package/dist/js/integrations/default.js +11 -7
- package/dist/js/integrations/default.js.map +1 -1
- package/dist/js/integrations/devicecontext.d.ts.map +1 -1
- package/dist/js/integrations/devicecontext.js +7 -3
- package/dist/js/integrations/devicecontext.js.map +1 -1
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +40 -2
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/tools/metroMiddleware.d.ts +15 -0
- package/dist/js/tools/metroMiddleware.d.ts.map +1 -0
- package/dist/js/tools/metroMiddleware.js +105 -0
- package/dist/js/tools/metroMiddleware.js.map +1 -0
- package/dist/js/tools/metroconfig.d.ts +7 -1
- package/dist/js/tools/metroconfig.d.ts.map +1 -1
- package/dist/js/tools/metroconfig.js +9 -1
- package/dist/js/tools/metroconfig.js.map +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
- package/dist/js/tracing/reactnativetracing.js +17 -1
- package/dist/js/tracing/reactnativetracing.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/dist/js/wrapper.d.ts +1 -0
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js.map +1 -1
- package/ios/RNSentry.mm +35 -0
- package/ios/RNSentryBreadcrumb.m +6 -0
- package/package.json +10 -10
- package/scripts/expo-upload-sourcemaps.js +16 -0
- package/scripts/sentry-xcode-debug-files.sh +4 -0
- package/scripts/sentry-xcode.sh +4 -0
- package/sentry.gradle +3 -0
- package/ts3.8/dist/js/integrations/debugsymbolicatorutils.d.ts +6 -2
- package/ts3.8/dist/js/version.d.ts +1 -1
- package/ts3.8/dist/js/wrapper.d.ts +1 -0
|
@@ -51,6 +51,12 @@ public final class RNSentryBreadcrumb {
|
|
|
51
51
|
breadcrumb.setCategory(from.getString("category"));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
if (from.hasKey("origin")) {
|
|
55
|
+
breadcrumb.setOrigin(from.getString("origin"));
|
|
56
|
+
} else {
|
|
57
|
+
breadcrumb.setOrigin("react-native");
|
|
58
|
+
}
|
|
59
|
+
|
|
54
60
|
if (from.hasKey("level")) {
|
|
55
61
|
switch (from.getString("level")) {
|
|
56
62
|
case "fatal":
|
|
@@ -28,6 +28,7 @@ import com.facebook.react.bridge.WritableNativeArray;
|
|
|
28
28
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
29
29
|
import com.facebook.react.common.JavascriptException;
|
|
30
30
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
31
|
+
import io.sentry.Breadcrumb;
|
|
31
32
|
import io.sentry.HubAdapter;
|
|
32
33
|
import io.sentry.ILogger;
|
|
33
34
|
import io.sentry.IScope;
|
|
@@ -74,8 +75,11 @@ import java.io.FileNotFoundException;
|
|
|
74
75
|
import java.io.FileReader;
|
|
75
76
|
import java.io.IOException;
|
|
76
77
|
import java.io.InputStream;
|
|
78
|
+
import java.net.URI;
|
|
79
|
+
import java.net.URISyntaxException;
|
|
77
80
|
import java.nio.charset.Charset;
|
|
78
81
|
import java.util.HashMap;
|
|
82
|
+
import java.util.Iterator;
|
|
79
83
|
import java.util.List;
|
|
80
84
|
import java.util.Map;
|
|
81
85
|
import java.util.Properties;
|
|
@@ -275,6 +279,21 @@ public class RNSentryModuleImpl {
|
|
|
275
279
|
options.getReplayController().setBreadcrumbConverter(new RNSentryReplayBreadcrumbConverter());
|
|
276
280
|
}
|
|
277
281
|
|
|
282
|
+
// Exclude Dev Server and Sentry Dsn request from Breadcrumbs
|
|
283
|
+
String dsn = getURLFromDSN(rnOptions.getString("dsn"));
|
|
284
|
+
String devServerUrl = rnOptions.getString("devServerUrl");
|
|
285
|
+
options.setBeforeBreadcrumb(
|
|
286
|
+
(breadcrumb, hint) -> {
|
|
287
|
+
Object urlObject = breadcrumb.getData("url");
|
|
288
|
+
String url = urlObject instanceof String ? (String) urlObject : "";
|
|
289
|
+
if ("http".equals(breadcrumb.getType())
|
|
290
|
+
&& ((dsn != null && url.startsWith(dsn))
|
|
291
|
+
|| (devServerUrl != null && url.startsWith(devServerUrl)))) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
return breadcrumb;
|
|
295
|
+
});
|
|
296
|
+
|
|
278
297
|
// React native internally throws a JavascriptException.
|
|
279
298
|
// we want to ignore it on the native side to avoid sending it twice.
|
|
280
299
|
options.addIgnoredExceptionForType(JavascriptException.class);
|
|
@@ -886,18 +905,35 @@ public class RNSentryModuleImpl {
|
|
|
886
905
|
|
|
887
906
|
public void fetchNativeDeviceContexts(Promise promise) {
|
|
888
907
|
final @NotNull SentryOptions options = HubAdapter.getInstance().getOptions();
|
|
908
|
+
final @Nullable Context context = this.getReactApplicationContext().getApplicationContext();
|
|
909
|
+
final @Nullable IScope currentScope = InternalSentrySdk.getCurrentScope();
|
|
910
|
+
fetchNativeDeviceContexts(promise, options, context, currentScope);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
protected void fetchNativeDeviceContexts(
|
|
914
|
+
Promise promise,
|
|
915
|
+
final @NotNull SentryOptions options,
|
|
916
|
+
final @Nullable Context context,
|
|
917
|
+
final @Nullable IScope currentScope) {
|
|
889
918
|
if (!(options instanceof SentryAndroidOptions)) {
|
|
890
919
|
promise.resolve(null);
|
|
891
920
|
return;
|
|
892
921
|
}
|
|
893
|
-
|
|
894
|
-
final @Nullable Context context = this.getReactApplicationContext().getApplicationContext();
|
|
895
922
|
if (context == null) {
|
|
896
923
|
promise.resolve(null);
|
|
897
924
|
return;
|
|
898
925
|
}
|
|
926
|
+
if (currentScope != null) {
|
|
927
|
+
// Remove react-native breadcrumbs
|
|
928
|
+
Iterator<Breadcrumb> breadcrumbsIterator = currentScope.getBreadcrumbs().iterator();
|
|
929
|
+
while (breadcrumbsIterator.hasNext()) {
|
|
930
|
+
Breadcrumb breadcrumb = breadcrumbsIterator.next();
|
|
931
|
+
if ("react-native".equals(breadcrumb.getOrigin())) {
|
|
932
|
+
breadcrumbsIterator.remove();
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
899
936
|
|
|
900
|
-
final @Nullable IScope currentScope = InternalSentrySdk.getCurrentScope();
|
|
901
937
|
final @NotNull Map<String, Object> serialized =
|
|
902
938
|
InternalSentrySdk.serializeScope(context, (SentryAndroidOptions) options, currentScope);
|
|
903
939
|
final @Nullable Object deviceContext = RNSentryMapConverter.convertToWritable(serialized);
|
|
@@ -982,4 +1018,17 @@ public class RNSentryModuleImpl {
|
|
|
982
1018
|
private boolean isFrameMetricsAggregatorAvailable() {
|
|
983
1019
|
return androidXAvailable && frameMetricsAggregator != null;
|
|
984
1020
|
}
|
|
1021
|
+
|
|
1022
|
+
public static @Nullable String getURLFromDSN(@Nullable String dsn) {
|
|
1023
|
+
if (dsn == null) {
|
|
1024
|
+
return null;
|
|
1025
|
+
}
|
|
1026
|
+
URI uri = null;
|
|
1027
|
+
try {
|
|
1028
|
+
uri = new URI(dsn);
|
|
1029
|
+
} catch (URISyntaxException e) {
|
|
1030
|
+
return null;
|
|
1031
|
+
}
|
|
1032
|
+
return uri.getScheme() + "://" + uri.getHost();
|
|
1033
|
+
}
|
|
985
1034
|
}
|
package/dist/js/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAGV,QAAQ,EACR,KAAK,EACL,SAAS,EAET,aAAa,EACb,4BAA4B,EAC5B,YAAY,EACb,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAGV,QAAQ,EACR,KAAK,EACL,SAAS,EAET,aAAa,EACb,4BAA4B,EAC5B,YAAY,EACb,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAS1D;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,wBAAwB,CAAC;IACzE,OAAO,CAAC,eAAe,CAAY;IAEnC;;;OAGG;gBACgB,OAAO,EAAE,wBAAwB;IAYpD;;OAEG;IACI,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,GAAE,SAAc,GAAG,WAAW,CAAC,KAAK,CAAC;IAIvF;;OAEG;IACI,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC;IAIrG;;;OAGG;IACI,WAAW,IAAI,IAAI;IAI1B;;OAEG;IACI,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC;IAOpC;;OAEG;IACI,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAUxD;;OAEG;IACI,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAAC,4BAA4B,CAAC;IAiClF;;OAEG;IACI,IAAI,IAAI,IAAI;IAKnB;;OAEG;IACH,OAAO,CAAC,cAAc;IA4BtB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAShC;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAa9B"}
|
package/dist/js/client.js
CHANGED
|
@@ -2,6 +2,7 @@ import { eventFromException, eventFromMessage } from '@sentry/browser';
|
|
|
2
2
|
import { BaseClient } from '@sentry/core';
|
|
3
3
|
import { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';
|
|
4
4
|
import { Alert } from 'react-native';
|
|
5
|
+
import { getDevServer } from './integrations/debugsymbolicatorutils';
|
|
5
6
|
import { defaultSdkInfo } from './integrations/sdkinfo';
|
|
6
7
|
import { getDefaultSidecarUrl } from './integrations/spotlight';
|
|
7
8
|
import { MOBILE_REPLAY_INTEGRATION_NAME } from './replay/mobilereplay';
|
|
@@ -115,7 +116,8 @@ export class ReactNativeClient extends BaseClient {
|
|
|
115
116
|
* Starts native client with dsn and options
|
|
116
117
|
*/
|
|
117
118
|
_initNativeSdk() {
|
|
118
|
-
|
|
119
|
+
var _a;
|
|
120
|
+
NATIVE.initNativeSdk(Object.assign(Object.assign({}, this._options), { defaultSidecarUrl: getDefaultSidecarUrl(), devServerUrl: ((_a = getDevServer()) === null || _a === void 0 ? void 0 : _a.url) || '', mobileReplayOptions: this._integrations[MOBILE_REPLAY_INTEGRATION_NAME] &&
|
|
119
121
|
'options' in this._integrations[MOBILE_REPLAY_INTEGRATION_NAME]
|
|
120
122
|
? this._integrations[MOBILE_REPLAY_INTEGRATION_NAME].options
|
|
121
123
|
: undefined }))
|
package/dist/js/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OA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D,CAAC,OAAO;gBAC5G,CAAC,CAAC,SAAS,IACf;aACC,IAAI,CACH,CAAC,MAAe,EAAE,EAAE;YAClB,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,GAAG,EAAE;YACH,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC;QACf,CAAC,CACF;aACA,IAAI,CAAC,CAAC,iBAA0B,EAAE,EAAE;;YACnC,MAAA,MAAA,IAAI,CAAC,QAAQ,EAAC,OAAO,mDAAG,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACjD,CAAC,CAAC;aACD,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YACvB,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE;YAC/C,KAAK,CAAC,KAAK,CACT,QAAQ,EACR,6NAA6N,CAC9N,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,QAAmB,EAAE,QAA8B;QAC/E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,gBAAgB,GAAqB;gBACzC,EAAE,IAAI,EAAE,eAAe,EAAE;gBACzB;oBACE,SAAS,EAAE,sBAAsB,EAAE;oBACnC,gBAAgB,EAAE,QAAQ;iBAC3B;aACF,CAAC;YAEF,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACxC;IACH,CAAC;CACF","sourcesContent":["import { eventFromException, eventFromMessage } from '@sentry/browser';\nimport { BaseClient } from '@sentry/core';\nimport type {\n ClientReportEnvelope,\n ClientReportItem,\n Envelope,\n Event,\n EventHint,\n Outcome,\n SeverityLevel,\n TransportMakeRequestResponse,\n UserFeedback,\n} from '@sentry/types';\nimport { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';\nimport { Alert } from 'react-native';\n\nimport { defaultSdkInfo } from './integrations/sdkinfo';\nimport { getDefaultSidecarUrl } from './integrations/spotlight';\nimport type { ReactNativeClientOptions } from './options';\nimport type { mobileReplayIntegration } from './replay/mobilereplay';\nimport { MOBILE_REPLAY_INTEGRATION_NAME } from './replay/mobilereplay';\nimport { createUserFeedbackEnvelope, items } from './utils/envelope';\nimport { ignoreRequireCycleLogs } from './utils/ignorerequirecyclelogs';\nimport { mergeOutcomes } from './utils/outcome';\nimport { ReactNativeLibraries } from './utils/rnlibraries';\nimport { NATIVE } from './wrapper';\n\n/**\n * The Sentry React Native SDK Client.\n *\n * @see ReactNativeClientOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {\n private _outcomesBuffer: Outcome[];\n\n /**\n * Creates a new React Native SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: ReactNativeClientOptions) {\n ignoreRequireCycleLogs(ReactNativeLibraries.ReactNativeVersion?.version);\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || defaultSdkInfo;\n // We default this to true, as it is the safer scenario\n options.parentSpanIsAlwaysRootSpan =\n options.parentSpanIsAlwaysRootSpan === undefined ? true : options.parentSpanIsAlwaysRootSpan;\n super(options);\n\n this._outcomesBuffer = [];\n }\n\n /**\n * @inheritDoc\n */\n public eventFromException(exception: unknown, hint: EventHint = {}): PromiseLike<Event> {\n return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(message: string, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event> {\n return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);\n }\n\n /**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\n public nativeCrash(): void {\n NATIVE.nativeCrash();\n }\n\n /**\n * @inheritDoc\n */\n public close(): PromiseLike<boolean> {\n // As super.close() flushes queued events, we wait for that to finish before closing the native SDK.\n return super.close().then((result: boolean) => {\n return NATIVE.closeNativeSdk().then(() => result) as PromiseLike<boolean>;\n });\n }\n\n /**\n * Sends user feedback to Sentry.\n */\n public captureUserFeedback(feedback: UserFeedback): void {\n const envelope = createUserFeedbackEnvelope(feedback, {\n metadata: this._options._metadata,\n dsn: this.getDsn(),\n tunnel: undefined,\n });\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.sendEnvelope(envelope);\n }\n\n /**\n * @inheritdoc\n */\n public sendEnvelope(envelope: Envelope): PromiseLike<TransportMakeRequestResponse> {\n const outcomes = this._clearOutcomes();\n this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes);\n\n if (this._options.sendClientReports) {\n this._attachClientReportTo(this._outcomesBuffer, envelope as ClientReportEnvelope);\n }\n\n let shouldClearOutcomesBuffer = true;\n if (this._isEnabled() && this._transport && this._dsn) {\n this.emit('beforeEnvelope', envelope);\n\n this._transport.send(envelope).then(null, reason => {\n if (reason instanceof SentryError) {\n // SentryError is thrown by SyncPromise\n shouldClearOutcomesBuffer = false;\n // If this is called asynchronously we want the _outcomesBuffer to be cleared\n logger.error('SentryError while sending event, keeping outcomes buffer:', reason);\n } else {\n logger.error('Error while sending event:', reason);\n }\n });\n } else {\n logger.error('Transport disabled');\n }\n\n if (shouldClearOutcomesBuffer) {\n this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact\n }\n\n return Promise.resolve({});\n }\n\n /**\n * @inheritDoc\n */\n public init(): void {\n super.init();\n this._initNativeSdk();\n }\n\n /**\n * Starts native client with dsn and options\n */\n private _initNativeSdk(): void {\n NATIVE.initNativeSdk({\n ...this._options,\n defaultSidecarUrl: getDefaultSidecarUrl(),\n mobileReplayOptions:\n this._integrations[MOBILE_REPLAY_INTEGRATION_NAME] &&\n 'options' in this._integrations[MOBILE_REPLAY_INTEGRATION_NAME]\n ? (this._integrations[MOBILE_REPLAY_INTEGRATION_NAME] as ReturnType<typeof mobileReplayIntegration>).options\n : undefined,\n })\n .then(\n (result: boolean) => {\n return result;\n },\n () => {\n this._showCannotConnectDialog();\n return false;\n },\n )\n .then((didCallNativeInit: boolean) => {\n this._options.onReady?.({ didCallNativeInit });\n })\n .then(undefined, error => {\n logger.error('The OnReady callback threw an error: ', error);\n });\n }\n\n /**\n * If the user is in development mode, and the native nagger is enabled then it will show an alert.\n */\n private _showCannotConnectDialog(): void {\n if (__DEV__ && this._options.enableNativeNagger) {\n Alert.alert(\n 'Sentry',\n 'Warning, could not connect to Sentry native SDK.\\nIf you do not want to use the native component please pass `enableNative: false` in the options.\\nVisit: https://docs.sentry.io/platforms/react-native/ for more details.',\n );\n }\n }\n\n /**\n * Attaches a client report from outcomes to the envelope.\n */\n private _attachClientReportTo(outcomes: Outcome[], envelope: ClientReportEnvelope): void {\n if (outcomes.length > 0) {\n const clientReportItem: ClientReportItem = [\n { type: 'client_report' },\n {\n timestamp: dateTimestampInSeconds(),\n discarded_events: outcomes,\n },\n ];\n\n envelope[items].push(clientReportItem);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE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AAC,QAAQ,EAAC,OAAO,mDAAG,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACjD,CAAC,CAAC;aACD,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YACvB,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE;YAC/C,KAAK,CAAC,KAAK,CACT,QAAQ,EACR,6NAA6N,CAC9N,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,QAAmB,EAAE,QAA8B;QAC/E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,gBAAgB,GAAqB;gBACzC,EAAE,IAAI,EAAE,eAAe,EAAE;gBACzB;oBACE,SAAS,EAAE,sBAAsB,EAAE;oBACnC,gBAAgB,EAAE,QAAQ;iBAC3B;aACF,CAAC;YAEF,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACxC;IACH,CAAC;CACF","sourcesContent":["import { eventFromException, eventFromMessage } from '@sentry/browser';\nimport { BaseClient } from '@sentry/core';\nimport type {\n ClientReportEnvelope,\n ClientReportItem,\n Envelope,\n Event,\n EventHint,\n Outcome,\n SeverityLevel,\n TransportMakeRequestResponse,\n UserFeedback,\n} from '@sentry/types';\nimport { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';\nimport { Alert } from 'react-native';\n\nimport { getDevServer } from './integrations/debugsymbolicatorutils';\nimport { defaultSdkInfo } from './integrations/sdkinfo';\nimport { getDefaultSidecarUrl } from './integrations/spotlight';\nimport type { ReactNativeClientOptions } from './options';\nimport type { mobileReplayIntegration } from './replay/mobilereplay';\nimport { MOBILE_REPLAY_INTEGRATION_NAME } from './replay/mobilereplay';\nimport { createUserFeedbackEnvelope, items } from './utils/envelope';\nimport { ignoreRequireCycleLogs } from './utils/ignorerequirecyclelogs';\nimport { mergeOutcomes } from './utils/outcome';\nimport { ReactNativeLibraries } from './utils/rnlibraries';\nimport { NATIVE } from './wrapper';\n\n/**\n * The Sentry React Native SDK Client.\n *\n * @see ReactNativeClientOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {\n private _outcomesBuffer: Outcome[];\n\n /**\n * Creates a new React Native SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: ReactNativeClientOptions) {\n ignoreRequireCycleLogs(ReactNativeLibraries.ReactNativeVersion?.version);\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || defaultSdkInfo;\n // We default this to true, as it is the safer scenario\n options.parentSpanIsAlwaysRootSpan =\n options.parentSpanIsAlwaysRootSpan === undefined ? true : options.parentSpanIsAlwaysRootSpan;\n super(options);\n\n this._outcomesBuffer = [];\n }\n\n /**\n * @inheritDoc\n */\n public eventFromException(exception: unknown, hint: EventHint = {}): PromiseLike<Event> {\n return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(message: string, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event> {\n return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);\n }\n\n /**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\n public nativeCrash(): void {\n NATIVE.nativeCrash();\n }\n\n /**\n * @inheritDoc\n */\n public close(): PromiseLike<boolean> {\n // As super.close() flushes queued events, we wait for that to finish before closing the native SDK.\n return super.close().then((result: boolean) => {\n return NATIVE.closeNativeSdk().then(() => result) as PromiseLike<boolean>;\n });\n }\n\n /**\n * Sends user feedback to Sentry.\n */\n public captureUserFeedback(feedback: UserFeedback): void {\n const envelope = createUserFeedbackEnvelope(feedback, {\n metadata: this._options._metadata,\n dsn: this.getDsn(),\n tunnel: undefined,\n });\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.sendEnvelope(envelope);\n }\n\n /**\n * @inheritdoc\n */\n public sendEnvelope(envelope: Envelope): PromiseLike<TransportMakeRequestResponse> {\n const outcomes = this._clearOutcomes();\n this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes);\n\n if (this._options.sendClientReports) {\n this._attachClientReportTo(this._outcomesBuffer, envelope as ClientReportEnvelope);\n }\n\n let shouldClearOutcomesBuffer = true;\n if (this._isEnabled() && this._transport && this._dsn) {\n this.emit('beforeEnvelope', envelope);\n\n this._transport.send(envelope).then(null, reason => {\n if (reason instanceof SentryError) {\n // SentryError is thrown by SyncPromise\n shouldClearOutcomesBuffer = false;\n // If this is called asynchronously we want the _outcomesBuffer to be cleared\n logger.error('SentryError while sending event, keeping outcomes buffer:', reason);\n } else {\n logger.error('Error while sending event:', reason);\n }\n });\n } else {\n logger.error('Transport disabled');\n }\n\n if (shouldClearOutcomesBuffer) {\n this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact\n }\n\n return Promise.resolve({});\n }\n\n /**\n * @inheritDoc\n */\n public init(): void {\n super.init();\n this._initNativeSdk();\n }\n\n /**\n * Starts native client with dsn and options\n */\n private _initNativeSdk(): void {\n NATIVE.initNativeSdk({\n ...this._options,\n defaultSidecarUrl: getDefaultSidecarUrl(),\n devServerUrl: getDevServer()?.url || '',\n mobileReplayOptions:\n this._integrations[MOBILE_REPLAY_INTEGRATION_NAME] &&\n 'options' in this._integrations[MOBILE_REPLAY_INTEGRATION_NAME]\n ? (this._integrations[MOBILE_REPLAY_INTEGRATION_NAME] as ReturnType<typeof mobileReplayIntegration>).options\n : undefined,\n })\n .then(\n (result: boolean) => {\n return result;\n },\n () => {\n this._showCannotConnectDialog();\n return false;\n },\n )\n .then((didCallNativeInit: boolean) => {\n this._options.onReady?.({ didCallNativeInit });\n })\n .then(undefined, error => {\n logger.error('The OnReady callback threw an error: ', error);\n });\n }\n\n /**\n * If the user is in development mode, and the native nagger is enabled then it will show an alert.\n */\n private _showCannotConnectDialog(): void {\n if (__DEV__ && this._options.enableNativeNagger) {\n Alert.alert(\n 'Sentry',\n 'Warning, could not connect to Sentry native SDK.\\nIf you do not want to use the native component please pass `enableNative: false` in the options.\\nVisit: https://docs.sentry.io/platforms/react-native/ for more details.',\n );\n }\n }\n\n /**\n * Attaches a client report from outcomes to the envelope.\n */\n private _attachClientReportTo(outcomes: Outcome[], envelope: ClientReportEnvelope): void {\n if (outcomes.length > 0) {\n const clientReportItem: ClientReportItem = [\n { type: 'client_report' },\n {\n timestamp: dateTimestampInSeconds(),\n discarded_events: outcomes,\n },\n ];\n\n envelope[items].push(clientReportItem);\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { logger } from '@sentry/utils';
|
|
3
3
|
import { getFramesToPop, isErrorLike } from '../utils/error';
|
|
4
|
-
import { fetchSourceContext,
|
|
4
|
+
import { fetchSourceContext, parseErrorStack, symbolicateStackTrace } from './debugsymbolicatorutils';
|
|
5
5
|
const INTEGRATION_NAME = 'DebugSymbolicator';
|
|
6
6
|
// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor
|
|
7
7
|
const INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\.js$', 'MessageQueue\\.js$'].join('|'));
|
|
@@ -64,7 +64,8 @@ function symbolicate(rawStack, skipFirstFrames = 0) {
|
|
|
64
64
|
? newStack.slice(skipFirstAdjustedToSentryStackParser)
|
|
65
65
|
: newStack;
|
|
66
66
|
const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter((frame) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null);
|
|
67
|
-
|
|
67
|
+
const sentryFrames = yield convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);
|
|
68
|
+
return yield fetchSourceContext(sentryFrames);
|
|
68
69
|
}
|
|
69
70
|
catch (error) {
|
|
70
71
|
if (error instanceof Error) {
|
|
@@ -94,9 +95,6 @@ function convertReactNativeFramesToSentryFrames(frames) {
|
|
|
94
95
|
function: frame.methodName,
|
|
95
96
|
in_app: inApp,
|
|
96
97
|
};
|
|
97
|
-
if (inApp) {
|
|
98
|
-
yield addSourceContext(newFrame);
|
|
99
|
-
}
|
|
100
98
|
return newFrame;
|
|
101
99
|
})));
|
|
102
100
|
});
|
|
@@ -121,37 +119,6 @@ function replaceThreadFramesInEvent(event, frames) {
|
|
|
121
119
|
event.threads.values[0].stacktrace.frames = frames.reverse();
|
|
122
120
|
}
|
|
123
121
|
}
|
|
124
|
-
/**
|
|
125
|
-
* This tries to add source context for in_app Frames
|
|
126
|
-
*
|
|
127
|
-
* @param frame StackFrame
|
|
128
|
-
* @param getDevServer function from RN to get DevServer URL
|
|
129
|
-
*/
|
|
130
|
-
function addSourceContext(frame) {
|
|
131
|
-
var _a, _b, _c;
|
|
132
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
let sourceContext = null;
|
|
134
|
-
const segments = (_b = (_a = frame.filename) === null || _a === void 0 ? void 0 : _a.split('/')) !== null && _b !== void 0 ? _b : [];
|
|
135
|
-
const serverUrl = (_c = getDevServer()) === null || _c === void 0 ? void 0 : _c.url;
|
|
136
|
-
if (!serverUrl) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
for (const idx in segments) {
|
|
140
|
-
if (!Object.prototype.hasOwnProperty.call(segments, idx)) {
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
sourceContext = yield fetchSourceContext(serverUrl, segments, -idx);
|
|
144
|
-
if (sourceContext) {
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (!sourceContext) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const lines = sourceContext.split('\n');
|
|
152
|
-
addContextToFrame(lines, frame);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
122
|
/**
|
|
156
123
|
* Return a list containing the original exception and also the cause if found.
|
|
157
124
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEpH,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C,sEAAsE;AACtE,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,CAAC,+BAA+B,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAY/G,6DAA6D;AAC7D,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAgB,EAAE;IAC5D,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,GAAG,EAAE;YACd,UAAU;QACZ,CAAC;QACD,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAEF,SAAe,YAAY,CAAC,KAAY,EAAE,IAAe;;;QACvD,IAAI,CAAA,MAAA,KAAK,CAAC,SAAS,0CAAE,MAAM,KAAI,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;YAClE,wCAAwC;YACxC,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC7D,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE;gBACjD,MAAM,kBAAkB,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;gBAEjF,kBAAkB,IAAI,iCAA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QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;YACpE,IAAI,aAAa,EAAE;gBACjB,MAAM;aACP;SACF;QAED,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO;SACR;QAED,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;;CACjC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,iBAA0B;IACnD,MAAM,GAAG,GAAG,iBAAkC,CAAC;IAC/C,MAAM,UAAU,GAAkC,EAAE,CAAC;IACrD,KAAK,IAAI,KAAK,GAA8B,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE;QACxF,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACxB;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { Event, EventHint, Exception, Integration, StackFrame as SentryStackFrame } from '@sentry/types';\nimport { addContextToFrame, logger } from '@sentry/utils';\n\nimport type { ExtendedError } from '../utils/error';\nimport { getFramesToPop, isErrorLike } from '../utils/error';\nimport type * as ReactNative from '../vendor/react-native';\nimport { fetchSourceContext, getDevServer, parseErrorStack, symbolicateStackTrace } from './debugsymbolicatorutils';\n\nconst INTEGRATION_NAME = 'DebugSymbolicator';\n\n// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\nconst INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|'));\n\n/**\n * React Native Error\n */\nexport type ReactNativeError = Error & {\n framesToPop?: number;\n jsEngine?: string;\n preventSymbolication?: boolean;\n componentStack?: string;\n};\n\n/** Tries to symbolicate the JS stack trace on the device. */\nexport const debugSymbolicatorIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n /* noop */\n },\n processEvent,\n };\n};\n\nasync function processEvent(event: Event, hint: EventHint): Promise<Event> {\n if (event.exception?.values && isErrorLike(hint.originalException)) {\n // originalException is ErrorLike object\n const errorGroup = getExceptionGroup(hint.originalException);\n for (const [index, error] of errorGroup.entries()) {\n const symbolicatedFrames = await symbolicate(error.stack, getFramesToPop(error));\n\n symbolicatedFrames && replaceExceptionFramesInException(event.exception.values[index], symbolicatedFrames);\n }\n } else if (hint.syntheticException && isErrorLike(hint.syntheticException)) {\n // syntheticException is Error object\n const symbolicatedFrames = await symbolicate(\n hint.syntheticException.stack,\n getFramesToPop(hint.syntheticException),\n );\n\n if (event.exception) {\n symbolicatedFrames &&\n event.exception.values &&\n replaceExceptionFramesInException(event.exception.values[0], symbolicatedFrames);\n } else if (event.threads) {\n // RN JS doesn't have threads\n symbolicatedFrames && replaceThreadFramesInEvent(event, symbolicatedFrames);\n }\n }\n\n return event;\n}\n\n/**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\nasync function symbolicate(rawStack: string, skipFirstFrames: number = 0): Promise<SentryStackFrame[] | null> {\n try {\n const parsedStack = parseErrorStack(rawStack);\n\n const prettyStack = await symbolicateStackTrace(parsedStack);\n if (!prettyStack) {\n logger.error('React Native DevServer could not symbolicate the stack trace.');\n return null;\n }\n\n // This has been changed in an react-native version so stack is contained in here\n const newStack = 'stack' in prettyStack ? prettyStack.stack : prettyStack;\n\n // https://github.com/getsentry/sentry-javascript/blob/739d904342aaf9327312f409952f14ceff4ae1ab/packages/utils/src/stacktrace.ts#L23\n // Match SentryParser which counts lines of stack (-1 for first line with the Error message)\n const skipFirstAdjustedToSentryStackParser = Math.max(skipFirstFrames - 1, 0);\n const stackWithoutPoppedFrames = skipFirstAdjustedToSentryStackParser\n ? newStack.slice(skipFirstAdjustedToSentryStackParser)\n : newStack;\n\n const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter(\n (frame: { file?: string }) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null,\n );\n\n return await convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n return null;\n }\n}\n\n/**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\nasync function convertReactNativeFramesToSentryFrames(frames: ReactNative.StackFrame[]): Promise<SentryStackFrame[]> {\n return Promise.all(\n frames.map(async (frame: ReactNative.StackFrame): Promise<SentryStackFrame> => {\n let inApp = !!frame.column && !!frame.lineNumber;\n inApp =\n inApp &&\n frame.file !== undefined &&\n !frame.file.includes('node_modules') &&\n !frame.file.includes('native code');\n\n const newFrame: SentryStackFrame = {\n lineno: frame.lineNumber,\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n };\n\n if (inApp) {\n await addSourceContext(newFrame);\n }\n\n return newFrame;\n }),\n );\n}\n\n/**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\nfunction replaceExceptionFramesInException(exception: Exception, frames: SentryStackFrame[]): void {\n if (exception?.stacktrace) {\n exception.stacktrace.frames = frames.reverse();\n }\n}\n\n/**\n * Replaces the frames in the thread of a message.\n * @param event Event\n * @param frames StackFrame[]\n */\nfunction replaceThreadFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (event.threads && event.threads.values && event.threads.values[0] && event.threads.values[0].stacktrace) {\n event.threads.values[0].stacktrace.frames = frames.reverse();\n }\n}\n\n/**\n * This tries to add source context for in_app Frames\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\nasync function addSourceContext(frame: SentryStackFrame): Promise<void> {\n let sourceContext: string | null = null;\n\n const segments = frame.filename?.split('/') ?? [];\n\n const serverUrl = getDevServer()?.url;\n if (!serverUrl) {\n return;\n }\n\n for (const idx in segments) {\n if (!Object.prototype.hasOwnProperty.call(segments, idx)) {\n continue;\n }\n\n sourceContext = await fetchSourceContext(serverUrl, segments, -idx);\n if (sourceContext) {\n break;\n }\n }\n\n if (!sourceContext) {\n return;\n }\n\n const lines = sourceContext.split('\\n');\n addContextToFrame(lines, frame);\n}\n\n/**\n * Return a list containing the original exception and also the cause if found.\n *\n * @param originalException The original exception.\n */\nfunction getExceptionGroup(originalException: unknown): (Error & { stack: string })[] {\n const err = originalException as ExtendedError;\n const errorGroup: (Error & { stack: string })[] = [];\n for (let cause: ExtendedError | undefined = err; isErrorLike(cause); cause = cause.cause) {\n errorGroup.push(cause);\n }\n return errorGroup;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtG,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C,sEAAsE;AACtE,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,CAAC,+BAA+B,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAY/G,6DAA6D;AAC7D,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAgB,EAAE;IAC5D,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,GAAG,EAAE;YACd,UAAU;QACZ,CAAC;QACD,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAEF,SAAe,YAAY,CAAC,KAAY,EAAE,IAAe;;;QACvD,IAAI,CAAA,MAAA,KAAK,CAAC,SAAS,0CAAE,MAAM,KAAI,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;YAClE,wCAAwC;YACxC,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC7D,KAAK,MAAM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AC","sourcesContent":["import type { Event, EventHint, Exception, Integration, StackFrame as SentryStackFrame } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport type { ExtendedError } from '../utils/error';\nimport { getFramesToPop, isErrorLike } from '../utils/error';\nimport type * as ReactNative from '../vendor/react-native';\nimport { fetchSourceContext, parseErrorStack, symbolicateStackTrace } from './debugsymbolicatorutils';\n\nconst INTEGRATION_NAME = 'DebugSymbolicator';\n\n// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\nconst INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|'));\n\n/**\n * React Native Error\n */\nexport type ReactNativeError = Error & {\n framesToPop?: number;\n jsEngine?: string;\n preventSymbolication?: boolean;\n componentStack?: string;\n};\n\n/** Tries to symbolicate the JS stack trace on the device. */\nexport const debugSymbolicatorIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n /* noop */\n },\n processEvent,\n };\n};\n\nasync function processEvent(event: Event, hint: EventHint): Promise<Event> {\n if (event.exception?.values && isErrorLike(hint.originalException)) {\n // originalException is ErrorLike object\n const errorGroup = getExceptionGroup(hint.originalException);\n for (const [index, error] of errorGroup.entries()) {\n const symbolicatedFrames = await symbolicate(error.stack, getFramesToPop(error));\n\n symbolicatedFrames && replaceExceptionFramesInException(event.exception.values[index], symbolicatedFrames);\n }\n } else if (hint.syntheticException && isErrorLike(hint.syntheticException)) {\n // syntheticException is Error object\n const symbolicatedFrames = await symbolicate(\n hint.syntheticException.stack,\n getFramesToPop(hint.syntheticException),\n );\n\n if (event.exception) {\n symbolicatedFrames &&\n event.exception.values &&\n replaceExceptionFramesInException(event.exception.values[0], symbolicatedFrames);\n } else if (event.threads) {\n // RN JS doesn't have threads\n symbolicatedFrames && replaceThreadFramesInEvent(event, symbolicatedFrames);\n }\n }\n\n return event;\n}\n\n/**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\nasync function symbolicate(rawStack: string, skipFirstFrames: number = 0): Promise<SentryStackFrame[] | null> {\n try {\n const parsedStack = parseErrorStack(rawStack);\n\n const prettyStack = await symbolicateStackTrace(parsedStack);\n if (!prettyStack) {\n logger.error('React Native DevServer could not symbolicate the stack trace.');\n return null;\n }\n\n // This has been changed in an react-native version so stack is contained in here\n const newStack = 'stack' in prettyStack ? prettyStack.stack : prettyStack;\n\n // https://github.com/getsentry/sentry-javascript/blob/739d904342aaf9327312f409952f14ceff4ae1ab/packages/utils/src/stacktrace.ts#L23\n // Match SentryParser which counts lines of stack (-1 for first line with the Error message)\n const skipFirstAdjustedToSentryStackParser = Math.max(skipFirstFrames - 1, 0);\n const stackWithoutPoppedFrames = skipFirstAdjustedToSentryStackParser\n ? newStack.slice(skipFirstAdjustedToSentryStackParser)\n : newStack;\n\n const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter(\n (frame: { file?: string }) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null,\n );\n\n const sentryFrames = await convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);\n return await fetchSourceContext(sentryFrames);\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n return null;\n }\n}\n\n/**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\nasync function convertReactNativeFramesToSentryFrames(frames: ReactNative.StackFrame[]): Promise<SentryStackFrame[]> {\n return Promise.all(\n frames.map(async (frame: ReactNative.StackFrame): Promise<SentryStackFrame> => {\n let inApp = !!frame.column && !!frame.lineNumber;\n inApp =\n inApp &&\n frame.file !== undefined &&\n !frame.file.includes('node_modules') &&\n !frame.file.includes('native code');\n\n const newFrame: SentryStackFrame = {\n lineno: frame.lineNumber,\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n };\n\n return newFrame;\n }),\n );\n}\n\n/**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\nfunction replaceExceptionFramesInException(exception: Exception, frames: SentryStackFrame[]): void {\n if (exception?.stacktrace) {\n exception.stacktrace.frames = frames.reverse();\n }\n}\n\n/**\n * Replaces the frames in the thread of a message.\n * @param event Event\n * @param frames StackFrame[]\n */\nfunction replaceThreadFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (event.threads && event.threads.values && event.threads.values[0] && event.threads.values[0].stacktrace) {\n event.threads.values[0].stacktrace.frames = frames.reverse();\n }\n}\n\n/**\n * Return a list containing the original exception and also the cause if found.\n *\n * @param originalException The original exception.\n */\nfunction getExceptionGroup(originalException: unknown): (Error & { stack: string })[] {\n const err = originalException as ExtendedError;\n const errorGroup: (Error & { stack: string })[] = [];\n for (let cause: ExtendedError | undefined = err; isErrorLike(cause); cause = cause.cause) {\n errorGroup.push(cause);\n }\n return errorGroup;\n}\n"]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import type { StackFrame as SentryStackFrame } from '@sentry/types';
|
|
1
2
|
import type * as ReactNative from '../vendor/react-native';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Fetches source context for the Sentry Middleware (/__sentry/context)
|
|
5
|
+
*
|
|
6
|
+
* @param frame StackFrame
|
|
7
|
+
* @param getDevServer function from RN to get DevServer URL
|
|
4
8
|
*/
|
|
5
|
-
export declare function fetchSourceContext(
|
|
9
|
+
export declare function fetchSourceContext(frames: SentryStackFrame[]): Promise<SentryStackFrame[]>;
|
|
6
10
|
/**
|
|
7
11
|
* Loads and calls RN Core Devtools parseErrorStack function.
|
|
8
12
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugsymbolicatorutils.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicatorutils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debugsymbolicatorutils.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicatorutils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKpE,OAAO,KAAK,KAAK,WAAW,MAAM,wBAAwB,CAAC;AAE3D;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAuChG;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,CAKjF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,EACpC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAK7C;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,WAAW,CAAC,aAAa,GAAG,SAAS,CAOpE"}
|
|
@@ -1,41 +1,58 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { logger } from '@sentry/utils';
|
|
2
3
|
import { ReactNativeLibraries } from '../utils/rnlibraries';
|
|
3
4
|
import { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* Fetches source context for the Sentry Middleware (/__sentry/context)
|
|
7
|
+
*
|
|
8
|
+
* @param frame StackFrame
|
|
9
|
+
* @param getDevServer function from RN to get DevServer URL
|
|
6
10
|
*/
|
|
7
|
-
export function fetchSourceContext(
|
|
11
|
+
export function fetchSourceContext(frames) {
|
|
8
12
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9
13
|
return new Promise(resolve => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
xhr.open('GET', fullUrl, true);
|
|
17
|
-
xhr.send();
|
|
18
|
-
xhr.onreadystatechange = () => {
|
|
19
|
-
if (xhr.readyState === XHR_READYSTATE_DONE) {
|
|
20
|
-
if (xhr.status !== 200) {
|
|
21
|
-
resolve(null);
|
|
22
|
-
}
|
|
23
|
-
const response = xhr.responseText;
|
|
24
|
-
if (typeof response !== 'string' ||
|
|
25
|
-
// Expo Dev Server responses with status 200 and config JSON
|
|
26
|
-
// when web support not enabled and requested file not found
|
|
27
|
-
response.startsWith('{')) {
|
|
28
|
-
resolve(null);
|
|
29
|
-
}
|
|
30
|
-
resolve(response);
|
|
14
|
+
try {
|
|
15
|
+
const xhr = createStealthXhr();
|
|
16
|
+
if (!xhr) {
|
|
17
|
+
resolve(frames);
|
|
18
|
+
return;
|
|
31
19
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
xhr.open('POST', getSentryMetroSourceContextUrl(), true);
|
|
21
|
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
22
|
+
xhr.send(JSON.stringify({ stack: frames }));
|
|
23
|
+
xhr.onreadystatechange = () => {
|
|
24
|
+
if (xhr.readyState === XHR_READYSTATE_DONE) {
|
|
25
|
+
if (xhr.status !== 200) {
|
|
26
|
+
resolve(frames);
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const response = JSON.parse(xhr.responseText);
|
|
30
|
+
if (Array.isArray(response.stack)) {
|
|
31
|
+
resolve(response.stack);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
resolve(frames);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
resolve(frames);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
xhr.onerror = () => {
|
|
43
|
+
resolve(frames);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger.error('Could not fetch source context.', error);
|
|
48
|
+
resolve(frames);
|
|
49
|
+
}
|
|
36
50
|
});
|
|
37
51
|
});
|
|
38
52
|
}
|
|
53
|
+
function getSentryMetroSourceContextUrl() {
|
|
54
|
+
return `${getDevServer().url}__sentry/context`;
|
|
55
|
+
}
|
|
39
56
|
/**
|
|
40
57
|
* Loads and calls RN Core Devtools parseErrorStack function.
|
|
41
58
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugsymbolicatorutils.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicatorutils.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"debugsymbolicatorutils.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicatorutils.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGrE;;;;;GAKG;AACH,MAAM,UAAgB,kBAAkB,CAAC,MAA0B;;QACjE,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,IAAI;gBACF,MAAM,GAAG,GAAG,gBAAgB,EAAE,CAAC;gBAC/B,IAAI,CAAC,GAAG,EAAE;oBACR,OAAO,CAAC,MAAM,CAAC,CAAC;oBAChB,OAAO;iBACR;gBAED,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,8BAA8B,EAAE,EAAE,IAAI,CAAC,CAAC;gBACzD,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;gBACzD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;gBAE5C,GAAG,CAAC,kBAAkB,GAAG,GAAS,EAAE;oBAClC,IAAI,GAAG,CAAC,UAAU,KAAK,mBAAmB,EAAE;wBAC1C,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;4BACtB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SAAS,CAAC,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;;IAC1B,IAAI;QACF,OAAO,MAAA,oBAAoB,CAAC,QAAQ,0CAAE,YAAY,EAAE,CAAC;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,8BAA8B;KAC/B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { StackFrame as SentryStackFrame } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';\nimport type * as ReactNative from '../vendor/react-native';\n\n/**\n * Fetches source context for the Sentry Middleware (/__sentry/context)\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\nexport async function fetchSourceContext(frames: SentryStackFrame[]): Promise<SentryStackFrame[]> {\n return new Promise(resolve => {\n try {\n const xhr = createStealthXhr();\n if (!xhr) {\n resolve(frames);\n return;\n }\n\n xhr.open('POST', getSentryMetroSourceContextUrl(), true);\n xhr.setRequestHeader('Content-Type', 'application/json');\n xhr.send(JSON.stringify({ stack: frames }));\n\n xhr.onreadystatechange = (): void => {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n if (xhr.status !== 200) {\n resolve(frames);\n }\n\n try {\n const response: { stack?: SentryStackFrame[] } = JSON.parse(xhr.responseText);\n if (Array.isArray(response.stack)) {\n resolve(response.stack);\n } else {\n resolve(frames);\n }\n } catch (error) {\n resolve(frames);\n }\n }\n };\n xhr.onerror = (): void => {\n resolve(frames);\n };\n } catch (error) {\n logger.error('Could not fetch source context.', error);\n resolve(frames);\n }\n });\n}\n\nfunction getSentryMetroSourceContextUrl(): string {\n return `${getDevServer().url}__sentry/context`;\n}\n\n/**\n * Loads and calls RN Core Devtools parseErrorStack function.\n */\nexport function parseErrorStack(errorStack: string): Array<ReactNative.StackFrame> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.parseErrorStack(errorStack);\n}\n\n/**\n * Loads and calls RN Core Devtools symbolicateStackTrace function.\n */\nexport function symbolicateStackTrace(\n stack: Array<ReactNative.StackFrame>,\n extraData?: Record<string, unknown>,\n): Promise<ReactNative.SymbolicatedStackTrace> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.symbolicateStackTrace(stack, extraData);\n}\n\n/**\n * Loads and returns the RN DevServer URL.\n */\nexport function getDevServer(): ReactNative.DevServerInfo | undefined {\n try {\n return ReactNativeLibraries.Devtools?.getDevServer();\n } catch (_oO) {\n // We can't load devserver URL\n }\n return undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/default.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/default.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAmC3D;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,EAAE,CAsGvF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { reactNativeTracingIntegration } from '../tracing';
|
|
2
|
-
import { isExpoGo, notWeb } from '../utils/environment';
|
|
3
|
-
import { appStartIntegration, breadcrumbsIntegration, browserApiErrorsIntegration, browserGlobalHandlersIntegration, browserLinkedErrorsIntegration,
|
|
2
|
+
import { isExpoGo, isWeb, notWeb } from '../utils/environment';
|
|
3
|
+
import { appStartIntegration, breadcrumbsIntegration, browserApiErrorsIntegration, browserGlobalHandlersIntegration, browserLinkedErrorsIntegration, createNativeFramesIntegrations, createReactNativeRewriteFrames, debugSymbolicatorIntegration, dedupeIntegration, deviceContextIntegration, eventOriginIntegration, expoContextIntegration, functionToStringIntegration, hermesProfilingIntegration, httpClientIntegration, httpContextIntegration, inboundFiltersIntegration, mobileReplayIntegration, modulesLoaderIntegration, nativeLinkedErrorsIntegration, nativeReleaseIntegration, reactNativeErrorHandlersIntegration, reactNativeInfoIntegration, screenshotIntegration, sdkInfoIntegration, spotlightIntegration, stallTrackingIntegration, userInteractionIntegration, viewHierarchyIntegration, } from './exports';
|
|
4
4
|
/**
|
|
5
5
|
* Returns the default ReactNative integrations based on the current environment.
|
|
6
6
|
*
|
|
@@ -32,9 +32,6 @@ export function getDefaultIntegrations(options) {
|
|
|
32
32
|
integrations.push(eventOriginIntegration());
|
|
33
33
|
integrations.push(sdkInfoIntegration());
|
|
34
34
|
integrations.push(reactNativeInfoIntegration());
|
|
35
|
-
if (__DEV__ && notWeb()) {
|
|
36
|
-
integrations.push(debugSymbolicatorIntegration());
|
|
37
|
-
}
|
|
38
35
|
integrations.push(createReactNativeRewriteFrames());
|
|
39
36
|
if (options.enableNative) {
|
|
40
37
|
integrations.push(deviceContextIntegration());
|
|
@@ -83,11 +80,18 @@ export function getDefaultIntegrations(options) {
|
|
|
83
80
|
}
|
|
84
81
|
if ((options._experiments && typeof options._experiments.replaysOnErrorSampleRate === 'number') ||
|
|
85
82
|
(options._experiments && typeof options._experiments.replaysSessionSampleRate === 'number')) {
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
if (isWeb()) {
|
|
84
|
+
// We can't create and add browserReplayIntegration as it overrides the users supplied one
|
|
85
|
+
// The browser replay integration works differently than the rest of default integrations
|
|
88
86
|
options.replaysOnErrorSampleRate = options._experiments.replaysOnErrorSampleRate;
|
|
89
87
|
options.replaysSessionSampleRate = options._experiments.replaysSessionSampleRate;
|
|
90
88
|
}
|
|
89
|
+
else {
|
|
90
|
+
integrations.push(mobileReplayIntegration());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (__DEV__ && notWeb()) {
|
|
94
|
+
integrations.push(debugSymbolicatorIntegration());
|
|
91
95
|
}
|
|
92
96
|
return integrations;
|
|
93
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/js/integrations/default.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/js/integrations/default.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,gCAAgC,EAChC,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B,EAC9B,4BAA4B,EAC5B,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,wBAAwB,EACxB,mCAAmC,EACnC,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,WAAW,CAAC;AAEnB;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAiC;IACtE,MAAM,YAAY,GAAkB,EAAE,CAAC;IAEvC,IAAI,MAAM,EAAE,EAAE;QACZ,YAAY,CAAC,IAAI,CACf,mCA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GAAG,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QACzF,YAAY,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;KACzD;IAED,IACE,CAAC,OAAO,CAAC,YAAY,IAAI,OAAO,OAAO,CAAC,YAAY,CAAC,wBAAwB,KAAK,QAAQ,CAAC;QAC3F,CAAC,OAAO,CAAC,YAAY,IAAI,OAAO,OAAO,CAAC,YAAY,CAAC,wBAAwB,KAAK,QAAQ,CAAC,EAC3F;QACA,IAAI,KAAK,EAAE,EAAE;YACX,0FAA0F;YAC1F,yFAAyF;YACxF,OAA0B,CAAC,wBAAwB,GAAG,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC;YACpG,OAA0B,CAAC,wBAAwB,GAAG,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC;SACtG;aAAM;YACL,YAAY,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC;SAC9C;KACF;IAED,IAAI,OAAO,IAAI,MAAM,EAAE,EAAE;QACvB,YAAY,CAAC,IAAI,CAAC,4BAA4B,EAAE,CAAC,CAAC;KACnD;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { BrowserOptions } from '@sentry/react';\nimport type { Integration } from '@sentry/types';\n\nimport type { ReactNativeClientOptions } from '../options';\nimport { reactNativeTracingIntegration } from '../tracing';\nimport { isExpoGo, isWeb, notWeb } from '../utils/environment';\nimport {\n appStartIntegration,\n breadcrumbsIntegration,\n browserApiErrorsIntegration,\n browserGlobalHandlersIntegration,\n browserLinkedErrorsIntegration,\n createNativeFramesIntegrations,\n createReactNativeRewriteFrames,\n debugSymbolicatorIntegration,\n dedupeIntegration,\n deviceContextIntegration,\n eventOriginIntegration,\n expoContextIntegration,\n functionToStringIntegration,\n hermesProfilingIntegration,\n httpClientIntegration,\n httpContextIntegration,\n inboundFiltersIntegration,\n mobileReplayIntegration,\n modulesLoaderIntegration,\n nativeLinkedErrorsIntegration,\n nativeReleaseIntegration,\n reactNativeErrorHandlersIntegration,\n reactNativeInfoIntegration,\n screenshotIntegration,\n sdkInfoIntegration,\n spotlightIntegration,\n stallTrackingIntegration,\n userInteractionIntegration,\n viewHierarchyIntegration,\n} from './exports';\n\n/**\n * Returns the default ReactNative integrations based on the current environment.\n *\n * Native integrations are only returned when native is enabled.\n *\n * Web integrations are only returned when running on web.\n */\nexport function getDefaultIntegrations(options: ReactNativeClientOptions): Integration[] {\n const integrations: Integration[] = [];\n\n if (notWeb()) {\n integrations.push(\n reactNativeErrorHandlersIntegration({\n patchGlobalPromise: options.patchGlobalPromise,\n }),\n );\n integrations.push(nativeLinkedErrorsIntegration());\n } else {\n integrations.push(browserApiErrorsIntegration());\n integrations.push(browserGlobalHandlersIntegration());\n integrations.push(browserLinkedErrorsIntegration());\n }\n\n // @sentry/react default integrations\n integrations.push(inboundFiltersIntegration());\n integrations.push(functionToStringIntegration());\n integrations.push(breadcrumbsIntegration());\n integrations.push(dedupeIntegration());\n integrations.push(httpContextIntegration());\n // end @sentry/react-native default integrations\n\n integrations.push(nativeReleaseIntegration());\n integrations.push(eventOriginIntegration());\n integrations.push(sdkInfoIntegration());\n integrations.push(reactNativeInfoIntegration());\n\n integrations.push(createReactNativeRewriteFrames());\n\n if (options.enableNative) {\n integrations.push(deviceContextIntegration());\n integrations.push(modulesLoaderIntegration());\n if (options.attachScreenshot) {\n integrations.push(screenshotIntegration());\n }\n if (options.attachViewHierarchy) {\n integrations.push(viewHierarchyIntegration());\n }\n if (typeof options.profilesSampleRate === 'number') {\n integrations.push(hermesProfilingIntegration());\n }\n }\n\n // hasTracingEnabled from `@sentry/core` only check if tracesSampler or tracesSampleRate keys are present\n // that's different from prev imp here and might lead misconfiguration\n // `tracesSampleRate: undefined` should not enable tracing\n const hasTracingEnabled =\n options.enableTracing ||\n typeof options.tracesSampleRate === 'number' ||\n typeof options.tracesSampler === 'function';\n if (hasTracingEnabled && options.enableAppStartTracking) {\n integrations.push(appStartIntegration());\n }\n const nativeFramesIntegrationInstance = createNativeFramesIntegrations(\n hasTracingEnabled && options.enableNativeFramesTracking,\n );\n if (nativeFramesIntegrationInstance) {\n integrations.push(nativeFramesIntegrationInstance);\n }\n if (hasTracingEnabled && options.enableStallTracking) {\n integrations.push(stallTrackingIntegration());\n }\n if (hasTracingEnabled && options.enableUserInteractionTracing) {\n integrations.push(userInteractionIntegration());\n }\n if (hasTracingEnabled && options.enableAutoPerformanceTracing) {\n integrations.push(reactNativeTracingIntegration());\n }\n if (options.enableCaptureFailedRequests) {\n integrations.push(httpClientIntegration());\n }\n\n if (isExpoGo()) {\n integrations.push(expoContextIntegration());\n }\n\n if (options.spotlight) {\n const sidecarUrl = typeof options.spotlight === 'string' ? options.spotlight : undefined;\n integrations.push(spotlightIntegration({ sidecarUrl }));\n }\n\n if (\n (options._experiments && typeof options._experiments.replaysOnErrorSampleRate === 'number') ||\n (options._experiments && typeof options._experiments.replaysSessionSampleRate === 'number')\n ) {\n if (isWeb()) {\n // We can't create and add browserReplayIntegration as it overrides the users supplied one\n // The browser replay integration works differently than the rest of default integrations\n (options as BrowserOptions).replaysOnErrorSampleRate = options._experiments.replaysOnErrorSampleRate;\n (options as BrowserOptions).replaysSessionSampleRate = options._experiments.replaysSessionSampleRate;\n } else {\n integrations.push(mobileReplayIntegration());\n }\n }\n\n if (__DEV__ && notWeb()) {\n integrations.push(debugSymbolicatorIntegration());\n }\n\n return integrations;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devicecontext.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"devicecontext.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA4B,WAAW,EAAE,MAAM,eAAe,CAAC;AAU3E,uCAAuC;AACvC,eAAO,MAAM,wBAAwB,QAAO,WAQ3C,CAAC"}
|
|
@@ -14,8 +14,8 @@ export const deviceContextIntegration = () => {
|
|
|
14
14
|
processEvent,
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
function processEvent(event) {
|
|
18
|
-
var _a;
|
|
17
|
+
function processEvent(event, _hint, client) {
|
|
18
|
+
var _a, _b;
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
let native = null;
|
|
21
21
|
try {
|
|
@@ -66,7 +66,11 @@ function processEvent(event) {
|
|
|
66
66
|
? native['breadcrumbs'].map(breadcrumbFromObject)
|
|
67
67
|
: undefined;
|
|
68
68
|
if (nativeBreadcrumbs) {
|
|
69
|
-
|
|
69
|
+
const maxBreadcrumbs = (_b = client === null || client === void 0 ? void 0 : client.getOptions().maxBreadcrumbs) !== null && _b !== void 0 ? _b : 100; // Default is 100.
|
|
70
|
+
event.breadcrumbs = nativeBreadcrumbs
|
|
71
|
+
.concat(event.breadcrumbs || []) // concatenate the native and js breadcrumbs
|
|
72
|
+
.sort((a, b) => { var _a, _b; return ((_a = a.timestamp) !== null && _a !== void 0 ? _a : 0) - ((_b = b.timestamp) !== null && _b !== void 0 ? _b : 0); }) // sort by timestamp
|
|
73
|
+
.slice(-maxBreadcrumbs); // keep the last maxBreadcrumbs
|
|
70
74
|
}
|
|
71
75
|
return event;
|
|
72
76
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devicecontext.js","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM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nimport { logger, severityLevelFromString } from '@sentry/utils';\nimport { AppState } from 'react-native';\n\nimport { breadcrumbFromObject } from '../breadcrumb';\nimport type { NativeDeviceContextsResponse } from '../NativeRNSentry';\nimport { NATIVE } from '../wrapper';\n\nconst INTEGRATION_NAME = 'DeviceContext';\n\n/** Load device context from native. */\nexport const deviceContextIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n /* noop */\n },\n processEvent,\n };\n};\n\nasync function processEvent(event: Event, _hint: EventHint, client: Client): Promise<Event> {\n let native: NativeDeviceContextsResponse | null = null;\n try {\n native = await NATIVE.fetchNativeDeviceContexts();\n } catch (e) {\n logger.log(`Failed to get device context from native: ${e}`);\n }\n\n if (!native) {\n return event;\n }\n\n const nativeUser = native.user;\n if (!event.user && nativeUser) {\n event.user = nativeUser;\n }\n\n let nativeContexts = native.contexts;\n if (AppState.currentState !== 'unknown') {\n nativeContexts = nativeContexts || {};\n nativeContexts.app = {\n ...nativeContexts.app,\n in_foreground: AppState.currentState === 'active',\n };\n }\n if (nativeContexts) {\n event.contexts = { ...nativeContexts, ...event.contexts };\n if (nativeContexts.app) {\n event.contexts.app = { ...nativeContexts.app, ...event.contexts.app };\n }\n }\n\n const nativeTags = native.tags;\n if (nativeTags) {\n event.tags = { ...nativeTags, ...event.tags };\n }\n\n const nativeExtra = native.extra;\n if (nativeExtra) {\n event.extra = { ...nativeExtra, ...event.extra };\n }\n\n const nativeFingerprint = native.fingerprint;\n if (nativeFingerprint) {\n event.fingerprint = (event.fingerprint ?? []).concat(\n nativeFingerprint.filter(item => (event.fingerprint ?? []).indexOf(item) < 0),\n );\n }\n\n const nativeLevel = typeof native['level'] === 'string' ? severityLevelFromString(native['level']) : undefined;\n if (!event.level && nativeLevel) {\n event.level = nativeLevel;\n }\n\n const nativeEnvironment = native['environment'];\n if (!event.environment && nativeEnvironment) {\n event.environment = nativeEnvironment;\n }\n\n const nativeBreadcrumbs = Array.isArray(native['breadcrumbs'])\n ? native['breadcrumbs'].map(breadcrumbFromObject)\n : undefined;\n if (nativeBreadcrumbs) {\n const maxBreadcrumbs = client?.getOptions().maxBreadcrumbs ?? 100; // Default is 100.\n event.breadcrumbs = nativeBreadcrumbs\n .concat(event.breadcrumbs || []) // concatenate the native and js breadcrumbs\n .sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0)) // sort by timestamp\n .slice(-maxBreadcrumbs); // keep the last maxBreadcrumbs\n }\n\n return event;\n}\n"]}
|
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":"AAMA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAA2C,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAA4B,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA6BzG;;GAEG;AACH,wBAAgB,IAAI,CAAC,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAuG5D;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;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAEhE;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"}
|