✨ [RUM-10144] apply context defined just after init to View event generated during init - #3597
✨ [RUM-10144] apply context defined just after init to View event generated during init#3597BenoitZugmeyer wants to merge 9 commits into
Conversation
e28ba32 to
2b6121e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3597 +/- ##
==========================================
+ Coverage 92.37% 92.39% +0.01%
==========================================
Files 323 323
Lines 8135 8148 +13
Branches 1841 1842 +1
==========================================
+ Hits 7515 7528 +13
Misses 620 620 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundles Sizes Evolution
|
|
/to-staging |
|
View all feedbacks in Devflow UI.
Commit 2b6121e26e will soon be integrated into staging-23.
Commit 2b6121e26e has been merged into staging-23 in merge commit 6826f9d5e7. Check out the triggered pipeline on Gitlab 🦊 If you need to revert this integration, you can use the following command: |
Integrated commit sha: 2b6121e Co-authored-by: BenoitZugmeyer <benoit.zugmeyer@datadoghq.com>
2b6121e to
bbf879f
Compare
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 303932c | Docs | Datadog PR Page | Give us feedback! |
Safari processes buffered PerformanceObserver resource entries when the mock clock ticks, so assert only on view events.
Motivation
Usually, context (global/user/account/feature flags etc.) is defined just after calling
RUM.init(), which is an issue because events that are generated duringinit()will not have this context.This is only problematic for View events: RUM.init() generates a first View event that is missing the context defined right after. It is usually fine, as we can expect a RUM View Update to be generated at some point later. But sometimes no View Update happen for some reason (connectivity error, browser exiting abruptly...). In those cases, it is unexpected that the View isn't including the context.
Fixes #3935
Changes
This PR fixes this issue by slightly delaying the first View update. It uses
Promise.resolve()to schedule a view update in the next micro task. It should not impact reliability as usingPromise.resolve().then()to schedule a micro task is not impacted by timers throttling.Please review commit by commit.
Test instructions
In the sandbox, define a user just after
init():Using the devtools extension, look at individual View events by unchecking
Show only the latest View eventin the "Events" tab.When loading the sandbox URL, all View events should contain the
@usr.id, even the very first View.Checklist