Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support setting userId and sessionId manually #354

Open
crowecawcaw opened this issue Feb 7, 2023 · 5 comments
Open

feat: Support setting userId and sessionId manually #354

crowecawcaw opened this issue Feb 7, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@crowecawcaw
Copy link

crowecawcaw commented Feb 7, 2023

I am working on adding CloudWatch RUM to a web app. Our users will authenticate with AWS Identity Center (IDC) which assigns each user a UUID already. I'd like to use that same UUID as the userId RUM instead of letting RUM generate a new UUID for me. Having consistent userIds will make it easier to connect RUM data with our backend events. We could pass in the IDC user ID as event metadata but it makes sifting through data more confusing and error prone.

Passing in user and session IDs could look like:

const config: AwsRumConfig = {
  userId: 'bd33b2a2-4b14-4ea6-aaeb-ee85c2062f5d',
  sessionId: '40af9b9a-6fa2-45f8-a437-67d2566380d9'
};
@qhanam
Copy link
Member

qhanam commented Feb 27, 2023

Hi @crowecawcaw thanks for this; I like your proposal. Would you ever dynamically change the sessionId, or would it be sufficient to set the session Id only on initializing AwsRum?

@crowecawcaw
Copy link
Author

For our specific use case, we would only want to set the sessionId at initialization time.

@qhanam qhanam added the enhancement New feature or request label Jul 17, 2023
@jffrenc
Copy link

jffrenc commented Oct 3, 2023

For a different use case, we need to dynamically set both sessionId and userId:

We'd like to use RUM for a kiosk use case. In the idle state, no user is logged in. Users can authenticate, take some set of actions, and then log out. The page is never reloaded except after a deployment.

We'd like to have the RUM client initialized the entire time, capturing any errors, events, timings, etc. even when logged out (without associating those with the session/user before or after). We'd also like to set the userId and a new sessionId programmatically every time a user logs in (and reset them when they log out).

We'd like to avoid having to manage multiple instances of the RUM client and possibly lose events or get some other bad behavior because we didn't realize we had to call flush() and disable() (we haven't tested this route yet though, so might not even be correct - just trying to point out there's some danger in using multiple instances since most of the docs assume you'd only create one instance of the client) to destruct the previous instance before creating a new one to avoid duplicate or lost events.

@jakob-lj
Copy link

@jffrenc From our point of view: the session in AWS RUM is one user session, which may contain that the user is logged in via various users during that session. The session lifecycle might be:

  • logged out
  • logged into userId: A
  • logged out
  • logged into userId: B

Then we would like to catch errors in this lifecycle and put them in relation to each other. We use the metadata feature when adding our custom user identities, and like the fact that we can abstract away in such a matter ^

@williazz
Copy link
Contributor

williazz commented Mar 5, 2024

To summarize, we need the following to close out:

  • Statically set user id at initialization time
  • Statically set session id at initialization time

In addition, I have also received feedback for

  • Dynamically set user id at runtime
  • Dynamically set session id at runtime
  • Dynamically start, stop, and get current session at runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants