Repository navigation
Conversation
Bundles Sizes Evolution
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 7703c56 | Docs | View more details | Give us feedback! |
This branch has not been deployed
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
The Logs plugin should build on RUM's state instead of starting its own copy. Today plugins can't do that.
onRumStartonly gives themaddEventandaddError, and calls a plugin makes beforeinit()have nowhere to go.This PR adds what the plugin needs. It has no Logs code, so RUM-only customers download none of it.
Changes
Everything added is
@internal.findTrackedSessiontakes an optionalsampleRate. It replaces the configured rate inisSampledonly when passed, and0counts. Calls without it behave as before.onInitgetsregisterCallQueue(queue). RUM drains every registered queue right after its own pre-start API calls, so plugin calls see the user and account set before start. Each call runs undercallMonitored. A queue registered after start drains right away. Registering the same queue twice does nothing.In the ticket and the RFC, RUM owned the queue. I moved it to the plugin, because calls made before
init()had no queue to go to. The plugin creates and bounds it.onRumStartgets RUM's realtrackingConsentStateandsessionManager.Bundle size:
rumGzip goes from 65.56 KiB to 65.63 KiB (+0.07 KiB),rum_slimfrom 50.16 KiB to 50.23 KiB (+0.07 KiB). I'll confirm with the "Bundles Sizes Evolution" comment.Type changes visible to external code. The plugin API is
@experimentaland its option types are exported from@datadog/browser-rum.registerCallQueueis now required onRumPluginOnInitOptions, andtrackingConsentStateandsessionManagerare required onOnRumStartOptions. Plugins only receive these options, so only code that builds them by hand (tests) has to change. I added a cast in the tests that do.Version skew. A newer plugin that calls
registerCallQueueon an older RUM without it throws inonInit. TheRumPlugindoc already says to use plugins matching the SDK version.#5220 adds a second
onRumStartcall for late plugins. That call needs the two new fields once this lands.This change was written with an AI agent. I'm least sure about the plugin owning the queue instead of RUM. What do you think?
Test instructions
I ran this on a local sandbox page with a plugin that registers a call queue. The queue is a minimal stand-in for
BufferedObservable, since that isn't exposed in the CDN bundle. It queues a call that reads the user, a call that throws, and a call after it.Expected output:
{"order":["plugin call, user={\"id\":\"u1\"}","plugin call after failure"],"hasRegisterCallQueue":"function","onRumStart":{"trackingConsentState":"function","findTrackedSession":"function","sampleRateZero":true}}The plugin call runs after RUM replays
setUser, the throwing call doesn't stop the next one, andonRumStartgets both new fields.Unit tests:
Checklist