@sentry/react-native 5.23.0-alpha.0 → 5.23.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/CHANGELOG.md +62 -18
- package/LICENSE.md +1 -1
- package/RNSentry.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +1 -54
- package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +0 -10
- package/android/src/oldarch/java/io/sentry/react/RNSentryModule.java +0 -10
- package/dist/js/NativeRNSentry.d.ts +0 -2
- package/dist/js/NativeRNSentry.d.ts.map +1 -1
- package/dist/js/NativeRNSentry.js.map +1 -1
- package/dist/js/client.d.ts +0 -8
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +4 -20
- package/dist/js/client.js.map +1 -1
- package/dist/js/index.d.ts +5 -3
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +5 -3
- package/dist/js/index.js.map +1 -1
- package/dist/js/integrations/debugsymbolicator.d.ts +8 -60
- package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
- package/dist/js/integrations/debugsymbolicator.js +137 -209
- package/dist/js/integrations/debugsymbolicator.js.map +1 -1
- package/dist/js/integrations/debugsymbolicatorutils.d.ts +18 -0
- package/dist/js/integrations/debugsymbolicatorutils.d.ts.map +1 -0
- package/dist/js/integrations/debugsymbolicatorutils.js +70 -0
- package/dist/js/integrations/debugsymbolicatorutils.js.map +1 -0
- package/dist/js/integrations/default.d.ts.map +1 -1
- package/dist/js/integrations/default.js +24 -49
- package/dist/js/integrations/default.js.map +1 -1
- package/dist/js/integrations/devicecontext.d.ts +8 -15
- package/dist/js/integrations/devicecontext.d.ts.map +1 -1
- package/dist/js/integrations/devicecontext.js +74 -74
- package/dist/js/integrations/devicecontext.js.map +1 -1
- package/dist/js/integrations/eventorigin.d.ts +8 -15
- package/dist/js/integrations/eventorigin.d.ts.map +1 -1
- package/dist/js/integrations/eventorigin.js +17 -17
- package/dist/js/integrations/eventorigin.js.map +1 -1
- package/dist/js/integrations/expocontext.d.ts +8 -15
- package/dist/js/integrations/expocontext.d.ts.map +1 -1
- package/dist/js/integrations/expocontext.js +28 -32
- package/dist/js/integrations/expocontext.js.map +1 -1
- package/dist/js/integrations/exports.d.ts +16 -0
- package/dist/js/integrations/exports.d.ts.map +1 -0
- package/dist/js/integrations/exports.js +16 -0
- package/dist/js/integrations/exports.js.map +1 -0
- package/dist/js/integrations/index.d.ts +4 -1
- package/dist/js/integrations/index.d.ts.map +1 -1
- package/dist/js/integrations/index.js +5 -1
- package/dist/js/integrations/index.js.map +1 -1
- package/dist/js/integrations/modulesloader.d.ts +8 -15
- package/dist/js/integrations/modulesloader.d.ts.map +1 -1
- package/dist/js/integrations/modulesloader.js +34 -31
- package/dist/js/integrations/modulesloader.js.map +1 -1
- package/dist/js/integrations/nativelinkederrors.d.ts +8 -51
- package/dist/js/integrations/nativelinkederrors.d.ts.map +1 -1
- package/dist/js/integrations/nativelinkederrors.js +112 -124
- package/dist/js/integrations/nativelinkederrors.js.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.d.ts +8 -54
- package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.js +109 -199
- package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlersutils.d.ts +27 -0
- package/dist/js/integrations/reactnativeerrorhandlersutils.d.ts.map +1 -0
- package/dist/js/integrations/reactnativeerrorhandlersutils.js +77 -0
- package/dist/js/integrations/reactnativeerrorhandlersutils.js.map +1 -0
- package/dist/js/integrations/reactnativeinfo.d.ts +8 -15
- package/dist/js/integrations/reactnativeinfo.d.ts.map +1 -1
- package/dist/js/integrations/reactnativeinfo.js +51 -51
- package/dist/js/integrations/reactnativeinfo.js.map +1 -1
- package/dist/js/integrations/release.d.ts +8 -15
- package/dist/js/integrations/release.d.ts.map +1 -1
- package/dist/js/integrations/release.js +55 -57
- package/dist/js/integrations/release.js.map +1 -1
- package/dist/js/integrations/rewriteframes.js +2 -2
- package/dist/js/integrations/rewriteframes.js.map +1 -1
- package/dist/js/integrations/screenshot.d.ts +8 -23
- package/dist/js/integrations/screenshot.d.ts.map +1 -1
- package/dist/js/integrations/screenshot.js +31 -47
- package/dist/js/integrations/screenshot.js.map +1 -1
- package/dist/js/integrations/sdkinfo.d.ts +8 -16
- package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
- package/dist/js/integrations/sdkinfo.js +54 -41
- package/dist/js/integrations/sdkinfo.js.map +1 -1
- package/dist/js/integrations/spotlight.d.ts +10 -2
- package/dist/js/integrations/spotlight.d.ts.map +1 -1
- package/dist/js/integrations/spotlight.js +14 -9
- package/dist/js/integrations/spotlight.js.map +1 -1
- package/dist/js/integrations/viewhierarchy.d.ts +8 -18
- package/dist/js/integrations/viewhierarchy.d.ts.map +1 -1
- package/dist/js/integrations/viewhierarchy.js +46 -43
- package/dist/js/integrations/viewhierarchy.js.map +1 -1
- package/dist/js/options.d.ts +2 -24
- package/dist/js/options.d.ts.map +1 -1
- package/dist/js/options.js.map +1 -1
- package/dist/js/profiling/integration.d.ts +8 -32
- package/dist/js/profiling/integration.d.ts.map +1 -1
- package/dist/js/profiling/integration.js +120 -119
- package/dist/js/profiling/integration.js.map +1 -1
- package/dist/js/tracing/nativeframes.d.ts +0 -4
- package/dist/js/tracing/nativeframes.d.ts.map +1 -1
- package/dist/js/tracing/nativeframes.js +14 -14
- package/dist/js/tracing/nativeframes.js.map +1 -1
- package/dist/js/utils/environment.d.ts +0 -4
- package/dist/js/utils/environment.d.ts.map +1 -1
- package/dist/js/utils/environment.js +0 -8
- package/dist/js/utils/environment.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 -7
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +0 -24
- package/dist/js/wrapper.js.map +1 -1
- package/ios/RNSentry.mm +14 -49
- package/ios/RNSentryDependencyContainer.h +4 -1
- package/ios/RNSentryDependencyContainer.m +4 -0
- package/ios/RNSentryFramesTrackerListener.h +6 -0
- package/ios/RNSentryFramesTrackerListener.m +4 -0
- package/ios/RNSentryOnDrawReporter.h +23 -0
- package/ios/RNSentryOnDrawReporter.m +5 -16
- package/ios/RNSentryRNSScreen.h +6 -0
- package/ios/RNSentryRNSScreen.m +6 -1
- package/package.json +12 -20
- package/src/js/NativeRNSentry.ts +0 -2
- package/ts3.8/dist/js/NativeRNSentry.d.ts +0 -2
- package/ts3.8/dist/js/client.d.ts +0 -8
- package/ts3.8/dist/js/index.d.ts +5 -3
- package/ts3.8/dist/js/integrations/debugsymbolicator.d.ts +8 -60
- package/ts3.8/dist/js/integrations/debugsymbolicatorutils.d.ts +18 -0
- package/ts3.8/dist/js/integrations/devicecontext.d.ts +8 -15
- package/ts3.8/dist/js/integrations/eventorigin.d.ts +8 -15
- package/ts3.8/dist/js/integrations/expocontext.d.ts +8 -15
- package/ts3.8/dist/js/integrations/exports.d.ts +16 -0
- package/ts3.8/dist/js/integrations/index.d.ts +4 -1
- package/ts3.8/dist/js/integrations/modulesloader.d.ts +8 -15
- package/ts3.8/dist/js/integrations/nativelinkederrors.d.ts +8 -51
- package/ts3.8/dist/js/integrations/reactnativeerrorhandlers.d.ts +8 -54
- package/ts3.8/dist/js/integrations/reactnativeerrorhandlersutils.d.ts +27 -0
- package/ts3.8/dist/js/integrations/reactnativeinfo.d.ts +8 -15
- package/ts3.8/dist/js/integrations/release.d.ts +8 -15
- package/ts3.8/dist/js/integrations/screenshot.d.ts +8 -23
- package/ts3.8/dist/js/integrations/sdkinfo.d.ts +8 -16
- package/ts3.8/dist/js/integrations/spotlight.d.ts +10 -2
- package/ts3.8/dist/js/integrations/viewhierarchy.d.ts +8 -18
- package/ts3.8/dist/js/options.d.ts +2 -24
- package/ts3.8/dist/js/profiling/integration.d.ts +8 -32
- package/ts3.8/dist/js/tracing/nativeframes.d.ts +0 -4
- package/ts3.8/dist/js/utils/environment.d.ts +0 -4
- package/ts3.8/dist/js/version.d.ts +1 -1
- package/ts3.8/dist/js/wrapper.d.ts +1 -7
- package/dist/js/integrations/mobilereplay.d.ts +0 -36
- package/dist/js/integrations/mobilereplay.d.ts.map +0 -1
- package/dist/js/integrations/mobilereplay.js +0 -97
- package/dist/js/integrations/mobilereplay.js.map +0 -1
- package/dist/js/utils/clientutils.d.ts +0 -8
- package/dist/js/utils/clientutils.d.ts.map +0 -1
- package/dist/js/utils/clientutils.js +0 -7
- package/dist/js/utils/clientutils.js.map +0 -1
- package/ts3.8/dist/js/integrations/mobilereplay.d.ts +0 -36
- package/ts3.8/dist/js/utils/clientutils.d.ts +0 -8
|
@@ -1,229 +1,157 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { convertIntegrationFnToClass } from '@sentry/core';
|
|
2
3
|
import { addContextToFrame, logger } from '@sentry/utils';
|
|
3
4
|
import { getFramesToPop, isErrorLike } from '../utils/error';
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import { fetchSourceContext, getDevServer, parseErrorStack, symbolicateStackTrace } from './debugsymbolicatorutils';
|
|
6
|
+
const INTEGRATION_NAME = 'DebugSymbolicator';
|
|
6
7
|
// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor
|
|
7
8
|
const INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\.js$', 'MessageQueue\\.js$'].join('|'));
|
|
8
9
|
/** Tries to symbolicate the JS stack trace on the device. */
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// RN JS doesn't have threads
|
|
38
|
-
// syntheticException is used for Sentry.captureMessage() threads
|
|
39
|
-
symbolicatedFrames && this._replaceThreadFramesInEvent(event, symbolicatedFrames);
|
|
40
|
-
}
|
|
10
|
+
export const debugSymbolicatorIntegration = () => {
|
|
11
|
+
return {
|
|
12
|
+
name: INTEGRATION_NAME,
|
|
13
|
+
setupOnce: () => {
|
|
14
|
+
/* noop */
|
|
15
|
+
},
|
|
16
|
+
processEvent,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Tries to symbolicate the JS stack trace on the device.
|
|
21
|
+
*
|
|
22
|
+
* @deprecated Use `debugSymbolicatorIntegration()` instead.
|
|
23
|
+
*/
|
|
24
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
25
|
+
export const DebugSymbolicator = convertIntegrationFnToClass(INTEGRATION_NAME, debugSymbolicatorIntegration);
|
|
26
|
+
function processEvent(event, hint) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
if (event.exception && isErrorLike(hint.originalException)) {
|
|
29
|
+
// originalException is ErrorLike object
|
|
30
|
+
const symbolicatedFrames = yield symbolicate(hint.originalException.stack, getFramesToPop(hint.originalException));
|
|
31
|
+
symbolicatedFrames && replaceExceptionFramesInEvent(event, symbolicatedFrames);
|
|
32
|
+
}
|
|
33
|
+
else if (hint.syntheticException && isErrorLike(hint.syntheticException)) {
|
|
34
|
+
// syntheticException is Error object
|
|
35
|
+
const symbolicatedFrames = yield symbolicate(hint.syntheticException.stack, getFramesToPop(hint.syntheticException));
|
|
36
|
+
if (event.exception) {
|
|
37
|
+
symbolicatedFrames && replaceExceptionFramesInEvent(event, symbolicatedFrames);
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Symbolicates the stack on the device talking to local dev server.
|
|
47
|
-
* Mutates the passed event.
|
|
48
|
-
*/
|
|
49
|
-
_symbolicate(rawStack, skipFirstFrames = 0) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
try {
|
|
52
|
-
const parsedStack = this._parseErrorStack(rawStack);
|
|
53
|
-
const prettyStack = yield this._symbolicateStackTrace(parsedStack);
|
|
54
|
-
if (!prettyStack) {
|
|
55
|
-
logger.error('React Native DevServer could not symbolicate the stack trace.');
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
// This has been changed in an react-native version so stack is contained in here
|
|
59
|
-
const newStack = prettyStack.stack || prettyStack;
|
|
60
|
-
// https://github.com/getsentry/sentry-javascript/blob/739d904342aaf9327312f409952f14ceff4ae1ab/packages/utils/src/stacktrace.ts#L23
|
|
61
|
-
// Match SentryParser which counts lines of stack (-1 for first line with the Error message)
|
|
62
|
-
const skipFirstAdjustedToSentryStackParser = Math.max(skipFirstFrames - 1, 0);
|
|
63
|
-
const stackWithoutPoppedFrames = skipFirstAdjustedToSentryStackParser
|
|
64
|
-
? newStack.slice(skipFirstAdjustedToSentryStackParser)
|
|
65
|
-
: newStack;
|
|
66
|
-
const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter((frame) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null);
|
|
67
|
-
return yield this._convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);
|
|
39
|
+
else if (event.threads) {
|
|
40
|
+
// RN JS doesn't have threads
|
|
41
|
+
symbolicatedFrames && replaceThreadFramesInEvent(event, symbolicatedFrames);
|
|
68
42
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
43
|
+
}
|
|
44
|
+
return event;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Symbolicates the stack on the device talking to local dev server.
|
|
49
|
+
* Mutates the passed event.
|
|
50
|
+
*/
|
|
51
|
+
function symbolicate(rawStack, skipFirstFrames = 0) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
try {
|
|
54
|
+
const parsedStack = parseErrorStack(rawStack);
|
|
55
|
+
const prettyStack = yield symbolicateStackTrace(parsedStack);
|
|
56
|
+
if (!prettyStack) {
|
|
57
|
+
logger.error('React Native DevServer could not symbolicate the stack trace.');
|
|
73
58
|
return null;
|
|
74
59
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
inApp =
|
|
86
|
-
inApp &&
|
|
87
|
-
frame.file !== undefined &&
|
|
88
|
-
!frame.file.includes('node_modules') &&
|
|
89
|
-
!frame.file.includes('native code');
|
|
90
|
-
const newFrame = {
|
|
91
|
-
lineno: frame.lineNumber,
|
|
92
|
-
colno: frame.column,
|
|
93
|
-
filename: frame.file,
|
|
94
|
-
function: frame.methodName,
|
|
95
|
-
in_app: inApp,
|
|
96
|
-
};
|
|
97
|
-
if (inApp) {
|
|
98
|
-
yield this._addSourceContext(newFrame);
|
|
99
|
-
}
|
|
100
|
-
return newFrame;
|
|
101
|
-
})));
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Replaces the frames in the exception of a error.
|
|
106
|
-
* @param event Event
|
|
107
|
-
* @param frames StackFrame[]
|
|
108
|
-
*/
|
|
109
|
-
_replaceExceptionFramesInEvent(event, frames) {
|
|
110
|
-
if (event.exception &&
|
|
111
|
-
event.exception.values &&
|
|
112
|
-
event.exception.values[0] &&
|
|
113
|
-
event.exception.values[0].stacktrace) {
|
|
114
|
-
event.exception.values[0].stacktrace.frames = frames.reverse();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Replaces the frames in the thread of a message.
|
|
119
|
-
* @param event Event
|
|
120
|
-
* @param frames StackFrame[]
|
|
121
|
-
*/
|
|
122
|
-
_replaceThreadFramesInEvent(event, frames) {
|
|
123
|
-
if (event.threads && event.threads.values && event.threads.values[0] && event.threads.values[0].stacktrace) {
|
|
124
|
-
event.threads.values[0].stacktrace.frames = frames.reverse();
|
|
60
|
+
// This has been changed in an react-native version so stack is contained in here
|
|
61
|
+
const newStack = prettyStack.stack || prettyStack;
|
|
62
|
+
// https://github.com/getsentry/sentry-javascript/blob/739d904342aaf9327312f409952f14ceff4ae1ab/packages/utils/src/stacktrace.ts#L23
|
|
63
|
+
// Match SentryParser which counts lines of stack (-1 for first line with the Error message)
|
|
64
|
+
const skipFirstAdjustedToSentryStackParser = Math.max(skipFirstFrames - 1, 0);
|
|
65
|
+
const stackWithoutPoppedFrames = skipFirstAdjustedToSentryStackParser
|
|
66
|
+
? newStack.slice(skipFirstAdjustedToSentryStackParser)
|
|
67
|
+
: newStack;
|
|
68
|
+
const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter((frame) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null);
|
|
69
|
+
return yield convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);
|
|
125
70
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*
|
|
130
|
-
* @param frame StackFrame
|
|
131
|
-
* @param getDevServer function from RN to get DevServer URL
|
|
132
|
-
*/
|
|
133
|
-
_addSourceContext(frame) {
|
|
134
|
-
var _a, _b, _c;
|
|
135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
let sourceContext = null;
|
|
137
|
-
const segments = (_b = (_a = frame.filename) === null || _a === void 0 ? void 0 : _a.split('/')) !== null && _b !== void 0 ? _b : [];
|
|
138
|
-
const serverUrl = (_c = this._getDevServer()) === null || _c === void 0 ? void 0 : _c.url;
|
|
139
|
-
if (!serverUrl) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
for (const idx in segments) {
|
|
143
|
-
if (!Object.prototype.hasOwnProperty.call(segments, idx)) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
sourceContext = yield this._fetchSourceContext(serverUrl, segments, -idx);
|
|
147
|
-
if (sourceContext) {
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error instanceof Error) {
|
|
73
|
+
logger.warn(`Unable to symbolicate stack trace: ${error.message}`);
|
|
150
74
|
}
|
|
151
|
-
|
|
152
|
-
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Converts ReactNativeFrames to frames in the Sentry format
|
|
81
|
+
* @param frames ReactNativeFrame[]
|
|
82
|
+
*/
|
|
83
|
+
function convertReactNativeFramesToSentryFrames(frames) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
return Promise.all(frames.map((frame) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
let inApp = !!frame.column && !!frame.lineNumber;
|
|
87
|
+
inApp =
|
|
88
|
+
inApp &&
|
|
89
|
+
frame.file !== undefined &&
|
|
90
|
+
!frame.file.includes('node_modules') &&
|
|
91
|
+
!frame.file.includes('native code');
|
|
92
|
+
const newFrame = {
|
|
93
|
+
lineno: frame.lineNumber,
|
|
94
|
+
colno: frame.column,
|
|
95
|
+
filename: frame.file,
|
|
96
|
+
function: frame.methodName,
|
|
97
|
+
in_app: inApp,
|
|
98
|
+
};
|
|
99
|
+
if (inApp) {
|
|
100
|
+
yield addSourceContext(newFrame);
|
|
153
101
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (!xhr) {
|
|
167
|
-
resolve(null);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
xhr.open('GET', fullUrl, true);
|
|
171
|
-
xhr.send();
|
|
172
|
-
xhr.onreadystatechange = () => {
|
|
173
|
-
if (xhr.readyState === XHR_READYSTATE_DONE) {
|
|
174
|
-
if (xhr.status !== 200) {
|
|
175
|
-
resolve(null);
|
|
176
|
-
}
|
|
177
|
-
const response = xhr.responseText;
|
|
178
|
-
if (typeof response !== 'string' ||
|
|
179
|
-
// Expo Dev Server responses with status 200 and config JSON
|
|
180
|
-
// when web support not enabled and requested file not found
|
|
181
|
-
response.startsWith('{')) {
|
|
182
|
-
resolve(null);
|
|
183
|
-
}
|
|
184
|
-
resolve(response);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
xhr.onerror = () => {
|
|
188
|
-
resolve(null);
|
|
189
|
-
};
|
|
190
|
-
});
|
|
191
|
-
});
|
|
102
|
+
return newFrame;
|
|
103
|
+
})));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Replaces the frames in the exception of a error.
|
|
108
|
+
* @param event Event
|
|
109
|
+
* @param frames StackFrame[]
|
|
110
|
+
*/
|
|
111
|
+
function replaceExceptionFramesInEvent(event, frames) {
|
|
112
|
+
if (event.exception && event.exception.values && event.exception.values[0] && event.exception.values[0].stacktrace) {
|
|
113
|
+
event.exception.values[0].stacktrace.frames = frames.reverse();
|
|
192
114
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Replaces the frames in the thread of a message.
|
|
118
|
+
* @param event Event
|
|
119
|
+
* @param frames StackFrame[]
|
|
120
|
+
*/
|
|
121
|
+
function replaceThreadFramesInEvent(event, frames) {
|
|
122
|
+
if (event.threads && event.threads.values && event.threads.values[0] && event.threads.values[0].stacktrace) {
|
|
123
|
+
event.threads.values[0].stacktrace.frames = frames.reverse();
|
|
201
124
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* This tries to add source context for in_app Frames
|
|
128
|
+
*
|
|
129
|
+
* @param frame StackFrame
|
|
130
|
+
* @param getDevServer function from RN to get DevServer URL
|
|
131
|
+
*/
|
|
132
|
+
function addSourceContext(frame) {
|
|
133
|
+
var _a, _b, _c;
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
let sourceContext = null;
|
|
136
|
+
const segments = (_b = (_a = frame.filename) === null || _a === void 0 ? void 0 : _a.split('/')) !== null && _b !== void 0 ? _b : [];
|
|
137
|
+
const serverUrl = (_c = getDevServer()) === null || _c === void 0 ? void 0 : _c.url;
|
|
138
|
+
if (!serverUrl) {
|
|
139
|
+
return;
|
|
208
140
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return (_a = ReactNativeLibraries.Devtools) === null || _a === void 0 ? void 0 : _a.getDevServer();
|
|
141
|
+
for (const idx in segments) {
|
|
142
|
+
if (!Object.prototype.hasOwnProperty.call(segments, idx)) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
sourceContext = yield fetchSourceContext(serverUrl, segments, -idx);
|
|
146
|
+
if (sourceContext) {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
218
149
|
}
|
|
219
|
-
|
|
220
|
-
|
|
150
|
+
if (!sourceContext) {
|
|
151
|
+
return;
|
|
221
152
|
}
|
|
222
|
-
|
|
223
|
-
|
|
153
|
+
const lines = sourceContext.split('\n');
|
|
154
|
+
addContextToFrame(lines, frame);
|
|
155
|
+
});
|
|
224
156
|
}
|
|
225
|
-
/**
|
|
226
|
-
* @inheritDoc
|
|
227
|
-
*/
|
|
228
|
-
DebugSymbolicator.id = 'DebugSymbolicator';
|
|
229
157
|
//# sourceMappingURL=debugsymbolicator.js.map
|
|
@@ -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;AAE1D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGrE,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,OAAO,iBAAiB;IAA9B;QAKE;;WAEG;QACI,SAAI,GAAW,iBAAiB,CAAC,EAAE,CAAC;IAoP7C,CAAC;IAlPC;;OAEG;IACI,SAAS,CAAC,uBAA2D,EAAE,aAAwB;QACpG,uBAAuB,CAAC,CAAO,KAAY,EAAE,IAAe,EAAE,EAAE;YAC9D,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YAE/D,IAAI,CAAC,IAAI,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;YAED,IAAI,KAAK,CAAC,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;gBAC1D,wCAAwC;gBACxC,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,YAAY,CAChD,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAC5B,cAAc,CAAC,IAAI,CAAC,iBAA0B,CAAC,CAChD,CAAC;gBACF,kBAAkB,IAAI,IAAI,CAAC,8BAA8B,CAAC,KAAK,EAAE,kBA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xB;4BACA,OAAO,CAAC,IAAI,CAAC,CAAC;yBACf;wBAED,OAAO,CAAC,QAAQ,CAAC,CAAC;qBACnB;gBACH,CAAC,CAAC;gBACF,GAAG,CAAC,OAAO,GAAG,GAAS,EAAE;oBACvB,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;OAEG;IACK,gBAAgB,CAAC,UAAkB;QACzC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACzD;QACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACK,sBAAsB,CAC5B,KAAoC,EACpC,SAAmC;QAEnC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACzD;QACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAED;;OAEG;IACK,aAAa;;QACnB,IAAI;YACF,OAAO,MAAA,oBAAoB,CAAC,QAAQ,0CAAE,YAAY,EAAE,CAAC;SACtD;QAAC,OAAO,GAAG,EAAE;YACZ,8BAA8B;SAC/B;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;;AA1PD;;GAEG;AACW,oBAAE,GAAW,mBAAmB,CAAC","sourcesContent":["import type { Event, EventHint, EventProcessor, Hub, Integration, StackFrame as SentryStackFrame } from '@sentry/types';\nimport { addContextToFrame, logger } from '@sentry/utils';\n\nimport { getFramesToPop, isErrorLike } from '../utils/error';\nimport { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';\nimport type * as ReactNative from '../vendor/react-native';\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 class DebugSymbolicator implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'DebugSymbolicator';\n /**\n * @inheritDoc\n */\n public name: string = DebugSymbolicator.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n addGlobalEventProcessor(async (event: Event, hint: EventHint) => {\n const self = getCurrentHub().getIntegration(DebugSymbolicator);\n\n if (!self) {\n return event;\n }\n\n if (event.exception && isErrorLike(hint.originalException)) {\n // originalException is ErrorLike object\n const symbolicatedFrames = await this._symbolicate(\n hint.originalException.stack,\n getFramesToPop(hint.originalException as Error),\n );\n symbolicatedFrames && this._replaceExceptionFramesInEvent(event, symbolicatedFrames);\n } else if (hint.syntheticException && isErrorLike(hint.syntheticException)) {\n // syntheticException is Error object\n const symbolicatedFrames = await this._symbolicate(\n hint.syntheticException.stack,\n getFramesToPop(hint.syntheticException),\n );\n\n if (event.exception) {\n symbolicatedFrames && this._replaceExceptionFramesInEvent(event, symbolicatedFrames);\n } else if (event.threads) {\n // RN JS doesn't have threads\n // syntheticException is used for Sentry.captureMessage() threads\n symbolicatedFrames && this._replaceThreadFramesInEvent(event, symbolicatedFrames);\n }\n }\n\n return event;\n });\n }\n\n /**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\n private async _symbolicate(rawStack: string, skipFirstFrames: number = 0): Promise<SentryStackFrame[] | null> {\n try {\n const parsedStack = this._parseErrorStack(rawStack);\n\n const prettyStack = await this._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 = 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 this._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 */\n private async _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 this._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 */\n private _replaceExceptionFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (\n event.exception &&\n event.exception.values &&\n event.exception.values[0] &&\n event.exception.values[0].stacktrace\n ) {\n event.exception.values[0].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 */\n private _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 */\n private async _addSourceContext(frame: SentryStackFrame): Promise<void> {\n let sourceContext: string | null = null;\n\n const segments = frame.filename?.split('/') ?? [];\n\n const serverUrl = this._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 this._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 * Get source context for segment\n */\n private async _fetchSourceContext(url: string, segments: Array<string>, start: number): Promise<string | null> {\n return new Promise(resolve => {\n const fullUrl = `${url}${segments.slice(start).join('/')}`;\n\n const xhr = createStealthXhr();\n if (!xhr) {\n resolve(null);\n return;\n }\n\n xhr.open('GET', fullUrl, true);\n xhr.send();\n\n xhr.onreadystatechange = (): void => {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n if (xhr.status !== 200) {\n resolve(null);\n }\n const response = xhr.responseText;\n if (\n typeof response !== 'string' ||\n // Expo Dev Server responses with status 200 and config JSON\n // when web support not enabled and requested file not found\n response.startsWith('{')\n ) {\n resolve(null);\n }\n\n resolve(response);\n }\n };\n xhr.onerror = (): void => {\n resolve(null);\n };\n });\n }\n\n /**\n * Loads and calls RN Core Devtools parseErrorStack function.\n */\n private _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 */\n private _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 */\n private _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}\n"]}
|
|
1
|
+
{"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAS3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1D,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,GAAwB,EAAE;IACpE,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,GAAG,EAAE;YACd,UAAU;QACZ,CAAC;QACD,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,mDAAmD;AACnD,MAAM,CAAC,MAAM,iBAAiB,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AE,KAAK,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;QAElD,MAAM,SAAS,GAAG,MAAA,YAAY,EAAE,0CAAE,GAAG,CAAC;QACtC,IAAI,CAAC,SAAS,EAAE;YACd,OAAO;SACR;QAED,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;YAC1B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE;gBACxD,SAAS;aACV;YAED,aAAa,GAAG,MAAM,kBAAkB,CAAC,SAAS,EAAE,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","sourcesContent":["import { convertIntegrationFnToClass } from '@sentry/core';\nimport type {\n Event,\n EventHint,\n Integration,\n IntegrationClass,\n IntegrationFnResult,\n StackFrame as SentryStackFrame,\n} from '@sentry/types';\nimport { addContextToFrame, logger } from '@sentry/utils';\n\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 = (): IntegrationFnResult => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n /* noop */\n },\n processEvent,\n };\n};\n\n/**\n * Tries to symbolicate the JS stack trace on the device.\n *\n * @deprecated Use `debugSymbolicatorIntegration()` instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport const DebugSymbolicator = convertIntegrationFnToClass(\n INTEGRATION_NAME,\n debugSymbolicatorIntegration,\n) as IntegrationClass<Integration>;\n\nasync function processEvent(event: Event, hint: EventHint): Promise<Event> {\n if (event.exception && isErrorLike(hint.originalException)) {\n // originalException is ErrorLike object\n const symbolicatedFrames = await symbolicate(\n hint.originalException.stack,\n getFramesToPop(hint.originalException as Error),\n );\n symbolicatedFrames && replaceExceptionFramesInEvent(event, symbolicatedFrames);\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 && replaceExceptionFramesInEvent(event, 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 = 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 replaceExceptionFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (event.exception && event.exception.values && event.exception.values[0] && event.exception.values[0].stacktrace) {\n event.exception.values[0].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"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as ReactNative from '../vendor/react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Get source context for segment
|
|
4
|
+
*/
|
|
5
|
+
export declare function fetchSourceContext(url: string, segments: Array<string>, start: number): Promise<string | null>;
|
|
6
|
+
/**
|
|
7
|
+
* Loads and calls RN Core Devtools parseErrorStack function.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseErrorStack(errorStack: string): Array<ReactNative.StackFrame>;
|
|
10
|
+
/**
|
|
11
|
+
* Loads and calls RN Core Devtools symbolicateStackTrace function.
|
|
12
|
+
*/
|
|
13
|
+
export declare function symbolicateStackTrace(stack: Array<ReactNative.StackFrame>, extraData?: Record<string, unknown>): Promise<ReactNative.SymbolicatedStackTrace>;
|
|
14
|
+
/**
|
|
15
|
+
* Loads and returns the RN DevServer URL.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getDevServer(): ReactNative.DevServerInfo | undefined;
|
|
18
|
+
//# sourceMappingURL=debugsymbolicatorutils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugsymbolicatorutils.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicatorutils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,WAAW,MAAM,wBAAwB,CAAC;AAE3D;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmCpH;AAED;;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"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { ReactNativeLibraries } from '../utils/rnlibraries';
|
|
3
|
+
import { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';
|
|
4
|
+
/**
|
|
5
|
+
* Get source context for segment
|
|
6
|
+
*/
|
|
7
|
+
export function fetchSourceContext(url, segments, start) {
|
|
8
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
return new Promise(resolve => {
|
|
10
|
+
const fullUrl = `${url}${segments.slice(start).join('/')}`;
|
|
11
|
+
const xhr = createStealthXhr();
|
|
12
|
+
if (!xhr) {
|
|
13
|
+
resolve(null);
|
|
14
|
+
return;
|
|
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);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
xhr.onerror = () => {
|
|
34
|
+
resolve(null);
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Loads and calls RN Core Devtools parseErrorStack function.
|
|
41
|
+
*/
|
|
42
|
+
export function parseErrorStack(errorStack) {
|
|
43
|
+
if (!ReactNativeLibraries.Devtools) {
|
|
44
|
+
throw new Error('React Native Devtools not available.');
|
|
45
|
+
}
|
|
46
|
+
return ReactNativeLibraries.Devtools.parseErrorStack(errorStack);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Loads and calls RN Core Devtools symbolicateStackTrace function.
|
|
50
|
+
*/
|
|
51
|
+
export function symbolicateStackTrace(stack, extraData) {
|
|
52
|
+
if (!ReactNativeLibraries.Devtools) {
|
|
53
|
+
throw new Error('React Native Devtools not available.');
|
|
54
|
+
}
|
|
55
|
+
return ReactNativeLibraries.Devtools.symbolicateStackTrace(stack, extraData);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Loads and returns the RN DevServer URL.
|
|
59
|
+
*/
|
|
60
|
+
export function getDevServer() {
|
|
61
|
+
var _a;
|
|
62
|
+
try {
|
|
63
|
+
return (_a = ReactNativeLibraries.Devtools) === null || _a === void 0 ? void 0 : _a.getDevServer();
|
|
64
|
+
}
|
|
65
|
+
catch (_oO) {
|
|
66
|
+
// We can't load devserver URL
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=debugsymbolicatorutils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugsymbolicatorutils.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicatorutils.ts"],"names":[],"mapp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,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAoC,EACpC,SAAmC;IAEnC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,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 { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';\nimport type * as ReactNative from '../vendor/react-native';\n\n/**\n * Get source context for segment\n */\nexport async function fetchSourceContext(url: string, segments: Array<string>, start: number): Promise<string | null> {\n return new Promise(resolve => {\n const fullUrl = `${url}${segments.slice(start).join('/')}`;\n\n const xhr = createStealthXhr();\n if (!xhr) {\n resolve(null);\n return;\n }\n\n xhr.open('GET', fullUrl, true);\n xhr.send();\n\n xhr.onreadystatechange = (): void => {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n if (xhr.status !== 200) {\n resolve(null);\n }\n const response = xhr.responseText;\n if (\n typeof response !== 'string' ||\n // Expo Dev Server responses with status 200 and config JSON\n // when web support not enabled and requested file not found\n response.startsWith('{')\n ) {\n resolve(null);\n }\n\n resolve(response);\n }\n };\n xhr.onerror = (): void => {\n resolve(null);\n };\n });\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":"
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AA8B3D;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,EAAE,CA4EvF"}
|