Skip to content

Calling DatadogSdk.instance.setUserInfo doesn't update ongoing RUM sessions #623

@mbtodorov

Description

@mbtodorov

Describe the bug

For context, we have a flutter application with a standard JWT auth setup. We have configured to call DatadogSdk.instance.setUserInfo whenever we get the first access token for our session in order to distinguish anonymous vs user RUM sessions. This can either be:

  • when a new user first logs in
  • when an existing user opens the app, and we verify the validity of their token in local storage

When doing analysis of our onboarding flow dropoff, we noticed that our user IDs are not attached to the first session of newly created accounts. Here is a screenshot:
Screenshot 2024-06-11 at 14 11 29

So you can see that the upper half of that session is for an anonymous user who hasn't craeted an account yet. After the tap on log_in button we have a token so the app would've called DatadogSdk.instance.setUserInfo. However the session does not have any user attached to its attributes

Screenshot 2024-06-11 at 14 17 02

Here is what a session with a user looks like:

Screenshot 2024-06-11 at 14 17 17

I am not sure what the expected behaviour here is? I would assume either the session gets split in two, or the user gets attributed to the anonymous events as well. But currently we are losing all data altogether, which makes it harder to measure onboarding flow drop off for those first user sessions, does that make sense?

If this is expected behaviour, is there a way to work around it? Perhaps some method in the SDK that restarts the session when the user has been identified?

Reproduction steps

Start a session as an anonymous user, and subsequently authenticate. Observe that the user attributes are not applied to the session

SDK logs

No response

Expected behavior

No response

Affected SDK versions

2.4.0, 2.5.0

Latest working SDK version

Did you confirm if the latest SDK version fixes the bug?

Yes

Flutter Version

3.19.6

Setup Type

Flutter Application

Device Information

seems to be device-agnostic. We've seen this happening on Android & iOS devices alike

Other relevant information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions