sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Matching API for iOS to Android Sentry.getLastEventId and Installation ID

Open JohannesPtaszyk opened this issue 2 years ago • 4 comments

Problem Statement

In our App we have a button which allows the user to report issues. For that, we would love to add some optional information like the installation ID and ID of last event from Sentry, so we can use that to analyse the user issues.

Solution Brainstorm So what I would love to have:

Sentry.getInstallationId() which would return the installation DI or Sentry.getUser(), which would return a default User, with the installation ID as user id.

Solution Brainstorm

Add an equivalent to Sentry.getInstallationId() from Android SDK, which would return the installation DI or Sentry.getUser(), which would return a default User, with the installation ID as user id. Also add an equivalent to Sentry.getLastEventId() from Android SDK.

Related issues in Android SDK: https://github.com/getsentry/sentry-java/issues/2932 https://github.com/getsentry/sentry-java/issues/2933

Are you willing to submit a PR?

No response

JohannesPtaszyk avatar Sep 13 '23 07:09 JohannesPtaszyk

Thanks for the suggestions @JohannesPtaszyk

We will add this to our backlog.

brustolin avatar Sep 18 '23 06:09 brustolin

Additional Use Case for the mobile/cross platform SDK: Login/Logout

  • When a user logs in, the SDK provides a way to set the user id, username, etc.
  • When a user logs out, the SDK does not provide an interface to reset the user id back to its original user id (i.e. the installationId)

In the absence of "resetUser" type of functionality, the ability to get the installationId would allow apps to implement login/logout and the ability to associate events prior to login and events after logout to a single installation id.

Note: Currently, the way to implement this in iOS is to read the installation id from the INSTALLATION file from the caches directory but this is not ideal because:

  1. It's not possible to benefit from Sentry's internal caching of the file content
  2. It relies on internal knowledge of how the SDK is implemented (and may break if the internal implementation is changed in the future)

(similar comment made here https://github.com/getsentry/sentry-java/issues/2932#issuecomment-1958538589)

wcwynn avatar Feb 22 '24 02:02 wcwynn

Additional Use Case for the mobile/cross platform SDK: Login/Logout

After further testing, it appears that:

  • SentrySDK.setUser(nil) does restore the installation id
  • SentrySDK.setUser(User()) does not restore the installation id -- it appears to use the IP

Its subtle enough that it may be helpful to others if the documentation more clearly indicated that providing nil restored the original installation id. The logout use case is not clearly demarcated even though the ip_address explanation refers to "unauthenticated user".

Anyways, it seems this use case is currently supported 👍

wcwynn avatar Feb 22 '24 05:02 wcwynn

I don't see any problem why we shouldn't add these APIs. We only need to align across SDKs.

philipphofmann avatar Feb 22 '24 13:02 philipphofmann