✨ localStorage strategy for remote configuration#4071
✨ localStorage strategy for remote configuration#4071
localStorage strategy for remote configuration#4071Conversation
Bundles Sizes Evolution
🚀 CPU PerformancePending... 🧠 Memory PerformancePending... |
|
9e8e512 to
94d9a59
Compare
|
@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
| // Skip undefined values to preserve init config fallbacks when any dynamic strategy | ||
| // (cookie, dom, js, localStorage) fails to resolve. |
There was a problem hiding this comment.
❓ question: do we have a property for which we want to have this behavior? I may miss something but for now I don't think we can configure a property in init that we can override by a dynamic config.
If we can't really achieve that with current system, I'd be in favor of not adding this fallback and the related tests.
| expect(initConfiguration.version).toBe('fallback-version') | ||
| }) | ||
|
|
||
| createTest('should handle localStorage access failure gracefully') |
| it('should resolve to undefined if the cookie is missing', () => { | ||
| expectAppliedRemoteConfigurationToBe( | ||
| { version: { rcSerializedType: 'dynamic', strategy: 'cookie', name: COOKIE_NAME } }, | ||
| { version: undefined } | ||
| {} // version should not be set when resolution fails |
There was a problem hiding this comment.
💬 suggestion: Seems that the title could be updated instead of adding a comment
it('should not be set if the cookie is missing', () => {
| ).toEqual({ | ||
| ...initConfigWithVersion, | ||
| applicationId: 'yyy', | ||
| // version should remain 'init-version', not undefined |
There was a problem hiding this comment.
💬 suggestion: what about making that explicit then, even though it's already implied by ...initConfigWithVersion,:
| // version should remain 'init-version', not undefined | |
| version: 'init-version' |
Motivation
Remote configuration does not support
localStorage, which is beneficial for some customers.Changes
This PR adds the
localStoragestrategy for remote configuration.Test instructions
No backend ready for it yet.
Checklist