Repository navigation
feat(rum): wait for the first remote settings on a page with nothing stored - #50
Merged
Merged
Conversation
…stored A page that has no remote settings stored drew its first session on the values passed to init, and the settings it then fetched only applied to the next session. For a visitor whose storage does not last until then (a one-off visit, a private window, a browser that clears storage) that was every session, so the console's rates never applied to them. Such a page now waits for the first settings answer before it starts, once tracking consent is granted, for at most REMOTE_CONFIGURATION_WAIT (1 s). Any answer ends the wait, a failed one included; an answer arriving later is still stored for the next draw. A page with settings stored never waits, and nothing waits when localStorage cannot be written or under an event bridge. - createRemoteConfiguration (was startRemoteConfiguration) creates the settings fetcher without sending anything; preStart subscribes to its answers, then issues the first request, and startRum connects it to the lifecycle with connectRemoteConfiguration. One request per page, as before. - Consent withdrawn before RUM starts cancels the wait and stops the fetcher, so no retry goes out; a later grant starts afresh. The consent subscription is now dropped only right before RUM starts, so this also holds while the start waits for the first startView. - The wait, in whole milliseconds and at least 1, is kept with the draw it preceded (DrawnConfiguration.wait, persisted in the draw record, also when the draw landed on the init values) and reported as _dd.configuration.rc_wait by every page of that session. - When the session manager starts and storage holds a settings version other than the one the current session was drawn under, it judges that session by them once, as it would on hearing them: a session the page only continued (another subdomain, or drawn before the settings changed) is ended by an emergency stop or a stricter privacy level.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
With remote configuration enabled, a session is drawn on the settings stored by an earlier page, and the settings fetched at start-up only apply to the next session. A page with nothing stored — a first visit, a private window, a browser that clears storage — therefore always drew on the values passed to
init. For visitors whose storage does not last until their next session that is every session, so the rates delivered from the console never applied to them.Changes
localStorage, and no event bridge) waits for the first settings answer, at mostREMOTE_CONFIGURATION_WAIT(1 s). Any answer ends the wait, a failed one included; a late answer is still stored for the next draw. Pages with settings stored start exactly as before.startRemoteConfiguration(configuration, lifeCycle)becomescreateRemoteConfiguration(configuration), which sends nothing on creation.preStartRumsubscribes to its answers, then issues the first request;startRumconnects it to the lifecycle (connectRemoteConfiguration). Still one request per page load.startViewwithtrackViewsManually._dd.configuration.rc_wait. The wait (whole ms, at least 1) is kept with the draw it preceded (DrawnConfiguration.wait, persisted in the draw record even when the draw landed on the init values) and reported by every page of that session, next torc_version.endSessionIfSettingsAreDecisive). A session the page only continued — from another subdomain, or drawn before the settings changed — is ended by an emergency stop or a stricter privacy level, as it would be if the settings had arrived a moment later.remoteConfigurationEnabledandBeforeSamplingContextupdated accordingly.Trade-offs worth a look:
init); API calls are buffered; performance entries are recovered through buffered observers; the initial view still starts at navigation start.beforeSamplingonce more on those pages.Test instructions
yarn test:unit— new and updated specs inpreStartRum.spec.ts,startRum.spec.ts,remoteConfiguration.spec.ts,rumSessionManager.spec.ts,sessionContext.spec.ts.remoteConfigurationEnabled, clear site data, load a page and check thatbeforeSamplingreceives the delivered rate on the first draw and that view events carry_dd.configuration.rc_wait; reload and check that no wait happens; delay the settings response past 1 s and check that the page starts on the init values withrc_wait≈ 1000.Checklist