From b8c1c43c90656bdaeb40b3630394a8d40873f217 Mon Sep 17 00:00:00 2001
From: farfromrefug <>
Date: Tue, 23 Apr 2024 15:41:42 +0200
Subject: [PATCH] fix: close method fix
---
demo-snippets/vue/Basic.ts | 35 ++++++++++++++++++----------
packages/sentry/wrapper.android.d.ts | 2 +-
src/sentry/client.ts | 6 +++--
src/sentry/wrapper.android.ts | 2 +-
src/sentry/wrapper.ios.ts | 2 +-
5 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/demo-snippets/vue/Basic.ts b/demo-snippets/vue/Basic.ts
index 046539f..390b1b1 100644
--- a/demo-snippets/vue/Basic.ts
+++ b/demo-snippets/vue/Basic.ts
@@ -13,18 +13,21 @@ export default {
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
`,
// data() {
@@ -126,6 +129,14 @@ export default {
},
flush() {
Sentry.flush();
+ },
+ async close() {
+ try {
+ await Sentry.close();
+
+ } catch (error) {
+ console.error(error, error.stack)
+ }
}
}
};
diff --git a/packages/sentry/wrapper.android.d.ts b/packages/sentry/wrapper.android.d.ts
index e94971c..f45f55b 100644
--- a/packages/sentry/wrapper.android.d.ts
+++ b/packages/sentry/wrapper.android.d.ts
@@ -17,7 +17,7 @@ export declare namespace NATIVE {
version: string;
};
function fetchNativeRelease(): any;
- function closeNativeSdk(): void;
+ function closeNativeSdk(): Promise;
function nativeCrash(): void;
function fetchNativeDeviceContexts(): Promise;
function captureScreenshot(fileName?: string): {
diff --git a/src/sentry/client.ts b/src/sentry/client.ts
index 612419c..553c0fb 100755
--- a/src/sentry/client.ts
+++ b/src/sentry/client.ts
@@ -163,9 +163,11 @@ export class NativescriptClient extends BaseClient {
/**
* @inheritDoc
*/
- public close(): PromiseLike {
+ public async close() {
// As super.close() flushes queued events, we wait for that to finish before closing the native SDK.
- return super.close().then((result: boolean) => NATIVE.closeNativeSdk().then(() => result) as PromiseLike);
+ const result = await super.close();
+ await NATIVE.closeNativeSdk();
+ return result;
}
public async flush(timeout?: number): Promise {
diff --git a/src/sentry/wrapper.android.ts b/src/sentry/wrapper.android.ts
index ab0831b..824d35c 100644
--- a/src/sentry/wrapper.android.ts
+++ b/src/sentry/wrapper.android.ts
@@ -673,7 +673,7 @@ export namespace NATIVE {
return nativeRelease;
}
- export function closeNativeSdk() {
+ export async function closeNativeSdk() {
io.sentry.Sentry.close();
}
diff --git a/src/sentry/wrapper.ios.ts b/src/sentry/wrapper.ios.ts
index a81e86e..d61ed5a 100644
--- a/src/sentry/wrapper.ios.ts
+++ b/src/sentry/wrapper.ios.ts
@@ -147,7 +147,7 @@ export namespace NATIVE {
}
return nativeRelease;
}
- export function closeNativeSdk() {
+ export async function closeNativeSdk() {
NSSentrySDK.close();
}