Skip to content

Commit 235db7f

Browse files
committed
demo: update
1 parent 83094cd commit 235db7f

File tree

6 files changed

+63
-65
lines changed

6 files changed

+63
-65
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.nativescript.sentry;
2+
3+
public class ClassExample {
4+
public static String helloWorld(String message) throws CustomException {
5+
throw new CustomException(message);
6+
// return "helloWorld";
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.nativescript.sentry;
2+
3+
public class CustomException extends Exception
4+
{
5+
public CustomException (String str)
6+
{
7+
super(str);
8+
}
9+
}

demo-vue/app/main.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,6 @@ if (!__ANDROID__ || Application.android.context) {
3838

3939
}
4040

41-
// let typedArray;
42-
// const textDecoder = new TextDecoder();
43-
// const textEncoder = new TextEncoder();
44-
// const strTest = '';
45-
// if (__IOS__){
46-
// let startTime = Date.now();
47-
// const testNSData = NSString.stringWithString(strTest).dataUsingEncoding(NSUTF8StringEncoding);
48-
// typedArray = new Uint8Array(interop.bufferFromData(testNSData));
49-
// console.log('typedArray encoded', Date.now() - startTime, 'ms');
50-
// startTime = Date.now();
51-
// let decoded = NSString.alloc().initWithDataEncoding(typedArray.buffer, NSUTF8StringEncoding) + '';
52-
// console.log('typedArray decoded', decoded === strTest, Date.now() - startTime, 'ms');
53-
54-
// startTime = Date.now();
55-
// typedArray = textEncoder.encode(strTest);
56-
// console.log('textDecoder encoded', Date.now() - startTime, 'ms');
57-
// startTime = Date.now();
58-
// decoded= textDecoder.decode(typedArray);
59-
// console.log('textDecoder decoded', decoded === strTest, Date.now() - startTime, 'ms');
60-
// }
61-
// if (__ANDROID__){
62-
// const charset = java.nio.charset.Charset.forName('UTF-8');
63-
// const nencoder = charset.newEncoder();
64-
// const ndecoder = charset.newDecoder();
65-
// let startTime = Date.now();
66-
// // @ts-ignore
67-
// const testByteArray = new Uint8Array(ArrayBuffer.from(nencoder.encode(java.nio.CharBuffer.wrap(strTest))));
68-
// console.log('typedArray encoded', Date.now() - startTime, 'ms');
69-
// let decoded = ndecoder.decode(testByteArray.buffer as any).toString();
70-
// console.log('typedArray decoded', decoded === strTest, Date.now() - startTime, 'ms');
71-
72-
// startTime = Date.now();
73-
// typedArray = textEncoder.encode(strTest);
74-
// console.log('textDecoder encoded', Date.now() - startTime, 'ms');
75-
// startTime = Date.now();
76-
// decoded= textDecoder.decode(typedArray);
77-
// console.log('textDecoder decoded', decoded === strTest, Date.now() - startTime, 'ms');
78-
// }
7941
new Vue({
8042
render: h => h('frame', [h(Home)])
8143
}).$start();

demo-vue/app/views/Home.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export default {
2020
<Button text="throwError" @tap="throwError"/>
2121
<Button text="crashTest" @tap="crashTest"/>
2222
<Button text="nativeCrashTest" @tap="nativeCrashTest"/>
23+
<Button text="androidNativeCrashTest" @tap="androidNativeCrashTest"/>
24+
<Button text="androidNativeCrashCatchedTest" @tap="androidNativeCrashCatchedTest"/>
2325
<Button text="flush" @tap="flush"/>
2426
</StackLayout>
2527
</Page>
@@ -83,6 +85,7 @@ export default {
8385
});
8486
},
8587
throwError() {
88+
8689
Sentry.captureException(new Error('test_notify_error' + Date.now()));
8790
},
8891
leaveBreadcrumb() {
@@ -94,6 +97,24 @@ export default {
9497
nativeCrashTest() {
9598
TestClass.someMethod();
9699
},
100+
androidNativeCrashCatchedTest() {
101+
try {
102+
console.log('androidNativeCrashTest', (com as any).nativescript.sentry.ClassExample.helloWorld('test3'));
103+
104+
} catch (error) {
105+
// console.error('error', error);
106+
// console.error('keys', Object.keys(error));
107+
// console.error('nativeExceptio', error.nativeException);
108+
console.error('stackTrace', error.stackTrace);
109+
console.error('stack', error.stack);
110+
// console.error('stack', error.stack);
111+
// console.error('stacktrace', error.stacktrace);
112+
Sentry.captureException(error);
113+
}
114+
},
115+
androidNativeCrashTest() {
116+
console.log('androidNativeCrashTest', (com as any).nativescript.sentry.ClassExample.helloWorld('test3'));
117+
},
97118
flush() {
98119
Sentry.flush();
99120
}

demo-vue/package.json

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,27 @@
44
"readme": "README.md",
55
"repository": "http://www.github.com/nativescript-community/sentry.git",
66
"dependencies": {
7-
"@nativescript-community/sentry": "link:../plugin",
8-
"@nativescript/core": "8.3.5",
7+
"@nativescript-community/sentry": "4.6.2",
8+
"@nativescript/core": "8.4.1",
99
"nativescript-vue": "2.9.3"
1010
},
1111
"devDependencies": {
12-
"@babel/core": "~7.19.3",
13-
"@babel/preset-env": "~7.19.4",
14-
"@nativescript/android": "8.4.0-alpha.4",
15-
"@nativescript/ios": "8.3.3",
16-
"@nativescript/webpack": "~5.0.9",
17-
"@sentry/browser": "7.15.0",
18-
"@sentry/cli": "2.7.0",
19-
"@sentry/core": "7.15.0",
20-
"@sentry/hub": "7.15.0",
21-
"@sentry/integrations": "7.15.0",
22-
"@sentry/tracing": "7.15.0",
23-
"@sentry/types": "7.15.0",
24-
"@sentry/utils": "7.15.0",
25-
"@sentry/webpack-plugin": "1.19.1",
26-
"babel-loader": "~8.2.5",
12+
"@babel/core": "~7.20.5",
13+
"@babel/preset-env": "~7.20.2",
14+
"@nativescript/android": "8.4.0",
15+
"@nativescript/ios": "8.4.0",
16+
"@nativescript/webpack": "~5.0.12",
17+
"@sentry/cli": "2.10.0",
18+
"@sentry/webpack-plugin": "1.20.0",
19+
"babel-loader": "~9.1.0",
2720
"cross-var": "^1.1.0",
2821
"nativescript-vue-template-compiler": "~2.9.3",
29-
"node-sass": "^7.0.3",
22+
"node-sass": "^8.0.0",
3023
"vue": "~2.6.14",
3124
"vue-loader": "~15.9.8"
3225
},
33-
"scripts": {},
34-
"main": "app/main"
35-
}
26+
"main": "app/main",
27+
"resolutions": {
28+
"@nativescript-community/sentry": "portal:../plugin"
29+
}
30+
}

demo-vue/webpack.config.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ module.exports = (env, params = {}) => {
99
config.entry('bundle').prepend('@nativescript-community/sentry/process');
1010
});
1111
const config = nsWebpack.resolveConfig();
12-
12+
// Object.assign(config, {
13+
// snapshot: {
14+
// // detect changes in "node_modules"
15+
// managedPaths: [],
16+
// }
17+
// });
1318
const definitions =config.plugins.find((p) => p.constructor.name === 'DefinePlugin').definitions;
1419
delete definitions['process'];
1520
const SENTRY_PREFIX = 'app:///';
1621
Object.assign(definitions, {
17-
'SENTRY_DSN': '"https://466438c5b21b4f5fa3b9278ae7baafac@bugs.akylas.fr/14"',
22+
'SENTRY_DSN': '"https://3e5220672ff5463f9a0c5bb18bcac1fd@bugs.akylas.fr/2"',
1823
'SENTRY_PREFIX': `"${SENTRY_PREFIX}"`,
1924
});
2025

@@ -38,21 +43,19 @@ module.exports = (env, params = {}) => {
3843
buildNumber = plistData.match(/<key>CFBundleVersion<\/key>[\s\n]*<string>([0-9]*)<\/string>/)[1];
3944
}
4045
config.resolve.symlinks = false;
41-
config.devtool = 'inline-nosources-cheap-module-source-map';
46+
config.devtool = false;
4247
config.plugins.push(
4348
new webpack.SourceMapDevToolPlugin({
4449
append: `\n//# sourceMappingURL=${SENTRY_PREFIX}[file].map`,
4550
filename: join(SOURCEMAP_REL_DIR, '[file].map')
4651
})
4752
);
48-
const release = `${nconfig.id}@${appVersion}+${buildNumber}`;
4953
// config.plugins.push(
5054
// new SentryCliPlugin({
5155
// release: appVersion,
5256
// urlPrefix: SENTRY_PREFIX,
5357
// rewrite: true,
54-
// // cleanArtifacts: true,
55-
// release,
58+
// release: `${nconfig.id}@${appVersion}+${buildNumber}`,
5659
// dist: `${buildNumber}.${platform}`,
5760
// ignoreFile: '.sentrycliignore',
5861
// include: [dist, join(dist, SOURCEMAP_REL_DIR)]

0 commit comments

Comments
 (0)