Skip to main content

Current Session ID API

Overview

Embrace SDK’s API enables customers to programmatically obtain the current Embrace Session ID. Depending on your use case, having the ability to obtain the Embrace Session ID will enable you to share that ID with other observability tools in order to build a URL to that specific session in the Embrace dashboard and make that link available on those third-party tools.

When should I call the Current Session ID method?

If you call the method before the SDK has started, it will return null. So, you need to call it once the SDK has been started.

Can I call this method in the background?

You can also call this method when the app is in the background. If Background Activity is enabled for your app, you’ll get the Session ID for that background activity; if it’s disabled, you’ll get null/nil.

Important
  • If you use the Session ID to form a URL that points to the session view in our dashboard, please consider that the URL is suitable to be updated at any time.

Integration Steps

In order to use this feature, you will need to follow two steps:

  1. Make sure your app is using at least version 5.24.0 of the Embrace SDK.
  2. Implement the API call to obtain the current Session ID.
  3. The method will return a String with the SessionId or null if there is no active session.
Embrace.getInstance().currentSessionId
Important

If you call Embrace.getInstance().getCurrentSessionId() within the onForeground() or onBackground() events of your LifecycleObserver; keep in mind that this is the moment when the session is ending, and a new one is starting. Therefore, there is a high chance that you will get the session ID of the session that is still ending. You might need to delay the call or obtain the session ID at any other point of the app lifecycle to make sure the session ID you get is the one you are looking for.

Support

If you have any questions or there’s something that is not working as intended, please reach out to your Customer Success Manager.