aws-observability / aws-rum-web

Amazon CloudWatch RUM Web Client
Apache License 2.0
114 stars 65 forks source link

feat: Re-use Cognito identity id #437

Closed qhanam closed 10 months ago

qhanam commented 10 months ago

Cognito identity Ids, which are used to allow unauthenticated users to send RUM data, can be re-used and do not expire.

This change stores identity Ids in localStorage in a similar way to how credentials are stored. Along with using the enhanced authflow, this means in most cases there will be one auth-related request instead of three.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

qhanam commented 10 months ago

I'm skeptical about the "never expires" part. There might be some unintended consequences here.

Perhaps we can fetch a new Id if getCredentialsForIdentity fails because the Id is not recognized.

qhanam commented 10 months ago

question: Will we benefit from storing the identity key as part of the CognitoIdentityClient's class member, similar to this.credentials in the Authentication class?

Yes, but nearly as much. The credential gets accessed every time events get dispatched, while the identity gets accessed only when the credential expires.