-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
test.mjs
85 lines (73 loc) · 3.54 KB
/
test.mjs
1
2
3
4
5
6
7
8
9
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { stackParserFromStackParserOptions } from '@sentry/utils';
const UNKNOWN_FUNCTION = undefined;
// function createFrame(filename, func, lineno, colno) {
function createFrame(frame) {
frame.in_app = (frame.filename && !frame.filename.includes('node_modules')) || (!!frame.colno && !!frame.lineno);
frame.platform = frame.filename.endsWith('.js') ? 'javascript' : 'android';
return frame;
}
const nativescriptRegex =
/^\s*at (?:(.*\).*?|.*?) ?\()?((?:file|native|webpack|<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
const nativescriptFunc = line => {
const parts = nativescriptRegex.exec(line);
if (parts) {
return createFrame({
filename:parts[2],
function:parts[1] || UNKNOWN_FUNCTION,
lineno:parts[3] ? +parts[3] : undefined,
colno:parts[4] ? +parts[4] : undefined
});
}
return null;
};
const nativescriptLineParser = [30, nativescriptFunc];
const androidRegex =
/^\s*(?:(.*\).*?|.*?) ?\()?((?:Native Method|[-a-z]+:)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
const androidFunc = line => {
const parts = androidRegex.exec(line);
if (parts) {
let func = UNKNOWN_FUNCTION, mod;
if (parts[1]) {
const splitted = parts[1].split('.');
func = splitted[splitted.length-1];
mod = splitted.slice(0, -1).join('.');
}
return createFrame({
filename:parts[2],
function:func,
module:mod,
lineno:parts[3] ? +parts[3] : undefined,
colno:parts[4] ? +parts[4] : undefined
});
}
return null;
};
const androidLineParser = [50, androidFunc];
const stackParser = stackParserFromStackParserOptions([nativescriptLineParser, androidLineParser]);
console.log('stackParser', stackParser(`at androidNativeCrashTest(file:///data/data/org.nativescript.demovuesentry/files/app/bundle.js:184:92)
at invokeWithErrorHandling(file:///data/data/org.nativescript.demovuesentry/files/app/vendor.js:73859:26)
at invoker(file:///data/data/org.nativescript.demovuesentry/files/app/vendor.js:74513:14)
at _handleEvent(file:///data/data/org.nativescript.demovuesentry/files/app/vendor.js:23374:37)
at notify(file:///data/data/org.nativescript.demovuesentry/files/app/vendor.js:23356:24)
at _emit(file:///data/data/org.nativescript.demovuesentry/files/app/vendor.js:23403:18)
at ClickListenerImpl.onClick(file:///data/data/org.nativescript.demovuesentry/files/app/vendor.js:33101:19)
com.nativescript.sentry.ClassExample.helloWorld(ClassExample.java:5)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
com.tns.Runtime.callJSMethod(Runtime.java:1175)
com.tns.Runtime.callJSMethod(Runtime.java:1153)
com.tns.Runtime.callJSMethod(Runtime.java:1149)
java.lang.Object_vendor_33094_28_ClickListenerImpl.onClick(Unknown Source:10)
android.view.View.performClick(View.java:7441)
android.view.View.performClickInternal(View.java:7418)
android.view.View.access$3700(View.java:835)
android.view.View$PerformClick.run(View.java:28676)
android.os.Handler.handleCallback(Handler.java:938)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loopOnce(Looper.java:201)
android.os.Looper.loop(Looper.java:288)
android.app.ActivityThread.main(ActivityThread.java:7839)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)`));