aws-observability / aws-rum-web

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

fix: Handle missing PageId in metadata when page is resumed #388

Closed ps863 closed 1 year ago

ps863 commented 1 year ago

This change contains a patch based on customer reported issue, wherein, pageId was missing from the metadata of certain events.

In a previous change we changed the behavior of when a Page View event is recorded. In cases where page views resume (this includes resumed sessions and page being reloaded) but page ID is same were changed from being recorded as a separate page view event for each reload/resume to only creating a new page view event only when there was a change in the pageId. However, the change failed to address the following:

1) In the case when the PageManager's state is restored after being resumed (using the page object stored in cookie), the cookie does not contain PageManager managed attributes which are added as metadata to all events. This means, the PageManager's attributes are not updated from what they were previously and remain null. Therefore, after a page is restored or reloaded, subsequent events don't contain the pageId in the metadata (since pageId is obtained from the PageManager). The pageId is restored in metadata only after a new page view event is generated as that forces the PageManager to update the metadata attributes.

This change addresses this by: 1) Updating the PageManager's attributes when a page is resumed as well. 2) Adding Unit tests to capture this behavior


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