Skip to content

Commit 3f02271

Browse files
committed
fix: update to latest SDK
1 parent 7c86e16 commit 3f02271

File tree

12 files changed

+4693
-1884
lines changed

12 files changed

+4693
-1884
lines changed

plugin/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
},
3030
"homepage": "https://github.com/Akylas/nativescript-akylas-sentry#readme",
3131
"dependencies": {
32-
"@sentry/browser": "^5.15.4",
33-
"@sentry/core": "^5.15.4",
34-
"@sentry/hub": "^5.15.4",
35-
"@sentry/integrations": "^5.15.4",
36-
"@sentry/minimal": "^5.15.4",
37-
"@sentry/types": "^5.15.4",
38-
"@sentry/utils": "^5.15.4",
39-
"@sentry/wizard": "^1.1.1",
40-
"stacktrace-parser": "0.1.9"
32+
"@sentry/browser": "^5.19.2",
33+
"@sentry/core": "^5.19.2",
34+
"@sentry/hub": "^5.19.2",
35+
"@sentry/integrations": "^5.19.2",
36+
"@sentry/minimal": "^5.19.2",
37+
"@sentry/types": "^5.19.2",
38+
"@sentry/utils": "^5.19.2",
39+
"@sentry/wizard": "^1.1.4",
40+
"stacktrace-parser": "0.1.10"
4141
}
4242
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
repositories {
3+
jcenter()
4+
google()
5+
}
6+
dependencies {
7+
classpath 'io.sentry:sentry-android-gradle-plugin:1.7.28'
8+
}
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
1+
// Add compatibility options to be comptible with Java 1.8
2+
apply plugin: 'io.sentry.android.gradle'
3+
android {
4+
compileOptions {
5+
sourceCompatibility = JavaVersion.VERSION_1_8
6+
targetCompatibility = JavaVersion.VERSION_1_8
7+
}
8+
}
29
dependencies {
3-
api 'io.sentry:sentry-android:2.1.0-alpha.1'
10+
def sentryVersion = project.hasProperty("sentryVersion") ? project.sentryVersion : "2.2.1"
11+
implementation "io.sentry:sentry-android:$sentryVersion"
412
}

plugin/platforms/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '4.5.0'
1+
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '5.1.9'

src/backend.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { BrowserOptions, Transports } from '@sentry/browser';
32
import { BrowserBackend } from '@sentry/browser/dist/backend';
43
import { BaseBackend, NoopTransport } from '@sentry/core';
@@ -23,6 +22,8 @@ export interface NativescriptOptions extends BrowserOptions {
2322
*/
2423
enableNative?: boolean;
2524

25+
enableAutoSessionTracking?: boolean;
26+
2627
/**
2728
* Enables native crashHandling. This only works if `enableNative` is `true`.
2829
* Defaults to `true`.
@@ -77,7 +78,7 @@ export class NativescriptBackend extends BaseBackend<BrowserOptions> {
7778

7879
const transportOptions = {
7980
...this._options.transportOptions,
80-
dsn: this._options.dsn
81+
dsn: this._options.dsn,
8182
};
8283

8384
if (this._options.transport) {

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export {
2020
setTag,
2121
setTags,
2222
setUser,
23-
// Span,
2423
withScope
2524
} from '@sentry/core';
2625

src/nssentry.android.ts

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export namespace NSSentry {
1414
return {
1515
id: packageInfo.packageName,
1616
version: packageInfo.versionName,
17-
build: packageInfo.versionCode
17+
build: packageInfo.versionCode,
1818
};
1919
}
2020
function eventLevel(event) {
@@ -37,7 +37,7 @@ export namespace NSSentry {
3737
return null;
3838
}
3939
const map = new java.util.HashMap<string, string>();
40-
Object.keys(obj).forEach(k => {
40+
Object.keys(obj).forEach((k) => {
4141
map.put(k, obj[k]);
4242
});
4343
return map;
@@ -150,7 +150,7 @@ export namespace NSSentry {
150150
nEvent.setExceptions(exceptions);
151151
}
152152
export function sendEvent(event: Event): Promise<Response> {
153-
return new Promise(resolve => {
153+
return new Promise((resolve) => {
154154
const nEvent = new io.sentry.core.SentryEvent();
155155
if (event.event_id) {
156156
nEvent.setEventId(new io.sentry.core.protocol.SentryId(event.event_id));
@@ -181,7 +181,7 @@ export namespace NSSentry {
181181

182182
try {
183183
if (breadcrumb.data) {
184-
Object.keys(breadcrumb.data).forEach(k => {
184+
Object.keys(breadcrumb.data).forEach((k) => {
185185
const value = breadcrumb.data[k];
186186
// in case a `status_code` entry got accidentally stringified as a float
187187
if (k === 'status_code') {
@@ -222,7 +222,7 @@ export namespace NSSentry {
222222
}
223223

224224
if (event.extra) {
225-
Object.keys(event.extra).forEach(k => {
225+
Object.keys(event.extra).forEach((k) => {
226226
const value = event.extra[k];
227227
nEvent.setExtra(k, typeof value === 'string' ? value : JSON.stringify(value));
228228
});
@@ -238,7 +238,7 @@ export namespace NSSentry {
238238
}
239239

240240
if (event.tags) {
241-
Object.keys(event.tags).forEach(k => {
241+
Object.keys(event.tags).forEach((k) => {
242242
const value = event.tags[k];
243243
nEvent.setTag(k, value || 'INVALID_TAG');
244244
});
@@ -278,7 +278,7 @@ export namespace NSSentry {
278278
nEvent.setLevel(eventLevel(event.level));
279279
}
280280
if (event.contexts) {
281-
Object.keys(event.contexts).forEach(k => {
281+
Object.keys(event.contexts).forEach((k) => {
282282
// const value = event.contexts[k];
283283
// const context = new io.sentry.core.protocol.Contexts();
284284
// nEvent.setTag(k, value || 'INVALID_TAG');
@@ -300,7 +300,7 @@ export namespace NSSentry {
300300
const id = io.sentry.core.Sentry.captureEvent(nEvent);
301301
// io.sentry.core.Sentry.flush(0);
302302
resolve({ status: Status.Success, id });
303-
}).catch(err => {
303+
}).catch((err) => {
304304
console.error('error sending sentry event', err, err.stack);
305305
return Promise.reject(err);
306306
}) as any;
@@ -324,18 +324,15 @@ export namespace NSSentry {
324324
appAndroid.context,
325325
new io.sentry.core.Sentry.OptionsConfiguration({
326326
configure(config) {
327+
config.setLogger(new io.sentry.core.SystemOutLogger());
328+
329+
// config.setDiagnosticLevel(io.sentry.core.SentryLevel.DEBUG);
330+
// io.sentry.core.Sentry.setLevel(io.sentry.core.SentryLevel.DEBUG);
327331
config.setDsn(dsnString);
328332
config.setEnvironment('javascript');
329333
if (!!options.environment) {
330334
config.setEnvironment(options.environment);
331335
}
332-
config.setLogger(
333-
new io.sentry.core.ILogger({
334-
log(param0: io.sentry.core.SentryLevel, param1: any, param2: any, param3?: native.Array<any>) {
335-
console.log('sentry', param0, param1, param2, param3);
336-
}
337-
})
338-
);
339336
if (!!options.debug) {
340337
config.setDebug(options.debug);
341338
}
@@ -345,26 +342,35 @@ export namespace NSSentry {
345342
if (!!options.dist) {
346343
config.setDist(options.dist);
347344
}
345+
if (options.enableAutoSessionTracking !== undefined) {
346+
config.setEnableSessionTracking(options.enableAutoSessionTracking);
347+
}
348348

349349
config.setEnableNdk(true);
350-
351350
const integrations = config.getIntegrations();
352351
const size = integrations.size();
353352
if (options.enableNativeCrashHandling === false) {
354-
let indexToRemove = -1;
355-
for (let index = 0; index < size; index++) {
353+
for (let index = size - 1; index >= 0; index--) {
356354
const inte = integrations.get(index);
357-
if (inte instanceof io.sentry.core.UncaughtExceptionHandlerIntegration) {
358-
indexToRemove = index;
355+
if (
356+
inte instanceof io.sentry.core.UncaughtExceptionHandlerIntegration ||
357+
inte instanceof io.sentry.android.core.AnrIntegration ||
358+
inte instanceof io.sentry.android.core.NdkIntegration
359+
) {
360+
integrations.remove(index);
359361
}
360362
}
361-
if (indexToRemove > -1) {
362-
integrations.remove(indexToRemove);
363-
}
364363
}
365364
config.setBeforeSend(
366365
new io.sentry.core.SentryOptions.BeforeSendCallback({
367366
execute(event, hint) {
367+
if (options.beforeSend) {
368+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
369+
options.beforeSend(event as any, hint);
370+
}
371+
const map = new java.util.HashMap();
372+
map.put('X-Forwarded-Protocol', 'https');
373+
event.getRequest().setHeaders(map);
368374
// we use this callback to actually try and get the JS stack when a native error is catched
369375
try {
370376
const ex: io.sentry.core.protocol.SentryException = event.getExceptions().get(0);
@@ -380,18 +386,18 @@ export namespace NSSentry {
380386
const stack = parseErrorStack({ stack: jsStackTrace } as any);
381387

382388
const convertedFrames = convertNativescriptFramesToSentryFrames(stack as any);
383-
convertedFrames.forEach(frame => rewriteFrameIntegration._iteratee(frame));
389+
convertedFrames.forEach((frame) => rewriteFrameIntegration._iteratee(frame));
384390
addExceptionInterface(event, 'Error', throwable.getMessage(), convertedFrames.reverse());
385391
}
386392
}
387393
}
388394
}
389395
} catch (e) {}
390396
return event;
391-
}
397+
},
392398
})
393399
);
394-
}
400+
},
395401
})
396402
);
397403
initialized = true;
@@ -426,14 +432,11 @@ export namespace NSSentry {
426432
throw new java.lang.RuntimeException('TEST - Sentry Client Crash');
427433
}
428434
export function deviceContexts(): Promise<any> {
429-
return new Promise(resolve => {
435+
return new Promise((resolve) => {
430436
const nEvent = new io.sentry.core.SentryEvent();
431437

432438
const params = {};
433-
const it = nEvent
434-
.getContexts()
435-
.entrySet()
436-
.iterator();
439+
const it = nEvent.getContexts().entrySet().iterator();
437440
let value, pair, key;
438441
while (it.hasNext()) {
439442
pair = it.next();

0 commit comments

Comments
 (0)