✨ localStorage strategy for remote configuration#4071
Open
✨ localStorage strategy for remote configuration#4071
localStorage strategy for remote configuration#4071Conversation
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 3da50fb | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
9e8e512 to
94d9a59
Compare
Contributor
Author
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94d9a591b0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
localStorage strategy for remote configuration
c812560 to
a8d262d
Compare
Add 4 new E2E tests for the localStorage strategy: 1. Basic localStorage retrieval - reads simple string values 2. localStorage with regex extractor - parses extracted values 3. Missing key handling - gracefully falls back when key doesn't exist 4. localStorage unavailable - handles access errors and falls back Tests follow the same pattern as the js strategy tests (PR #3766) and validate: - Synchronous value resolution during SDK initialization - Regex extraction functionality - Fallback behavior for missing or inaccessible keys - Integration with both CDN and npm setups Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
When a remote configuration value fails to resolve (e.g., localStorage key is missing or access fails), the system now preserves the initial configuration fallback value instead of overwriting it with undefined. This fixes the issue where the SDK would lose the fallback version when: - localStorage key is not found - localStorage access throws an error - Any other dynamic resolution returns undefined The fix adds an undefined check before assigning resolved values, ensuring that undefined values do not override the initial configuration. Fixes E2E tests: - should resolve to undefined when localStorage key is missing - should handle localStorage access failure gracefully Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…ng comment Restore 'electron' union members removed by the submodule bump (unrelated to the localStorage feature) and add a comment explaining the undefined preservation logic in applyRemoteConfiguration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
961a387 to
d8a54ae
Compare
bcaudan
reviewed
Feb 13, 2026
packages/rum-core/src/domain/configuration/remoteConfiguration.ts
Outdated
Show resolved
Hide resolved
| expect(initConfiguration.version).toBe('fallback-version') | ||
| }) | ||
|
|
||
| createTest('should handle localStorage access failure gracefully') |
packages/rum-core/src/domain/configuration/remoteConfiguration.spec.ts
Outdated
Show resolved
Hide resolved
packages/rum-core/src/domain/configuration/remoteConfiguration.spec.ts
Outdated
Show resolved
Hide resolved
Remove the `if (resolvedValue !== undefined)` guard since no property
currently supports both init config and dynamic config override. Revert
test expectations to `{ version: undefined }`, rename cookie missing
test, and update E2E tests accordingly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Remote configuration lets customers tweak their Browser SDK settings (sample rates, privacy levels, tracing URLs, user context, etc.) from the Datadog UI without redeploying their app. At init, the SDK fetches a JSON config and applies it on top of the
init()options.Dynamic options can resolve values at runtime from different sources using a strategy-based approach — JavaScript variables (
js), cookies (cookie), or DOM elements (dom). ButlocalStoragewasn't supported, even though it's a super common way for apps to store metadata like version strings or user IDs.Changes
Adds
localStorageas a new strategy for remote configuration dynamic options.localStoragestrategy in the remote config types and schemaresolveLocalStorageValue()with error handling for whenlocalStorageaccess throwslocalStorageresolution (success,missing,failure)extractor(same as other strategies)Test instructions
No backend ready for it yet.
Checklist