getsentry / sentry-capacitor

The official Sentry SDK for Capacitor

Home Page:https://sentry.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getCurrentHub: Incorrect deprecation notice?

Senexis opened this issue · comments

Hey all!

I'm currently trying to close the Sentry connection on runtime whenever we detect an app update is available and the user has been prompted. As I'm lead to believe the current way to do so is as below, however, this prompts a deprecation notice to use Sentry.getClient() instead. This method does not exist, thus it seems this deprecation notice is incorrect.

Sentry.getCurrentHub().getClient().close(0); // deprecated, but works
Sentry.getClient().close(0); // Sentry.getClient is not a function

In contrast it does seem to work correctly when trying to close a Vue-specific instance of Sentry. In other words, this following prompts (correctly) to use the alternative:

SentryVue.getCurrentHub().getClient().close(0); // deprecated, but works
SentryVue.getClient().close(0); // works just fine

While having to go through this many hoops to simply disable Sentry seems like a drag, that is a separate issue, though I would like to know whether this is correct, or whether only Sentry or SentryVue needs to be closed.

I'm currently using the following Sentry-relevant packages:

"@sentry/capacitor": "0.18.0",
"@sentry/vite-plugin": "2.18.0",
"@sentry/vue": "7.114.0",

Thank you for opening this issue, currently getClient isn't exposed but we'll expose it on the next release.
Also in regard to your issue we will also expose a close function on Capacitor that allows it to close both native and JavaScript SDKs.