Skip to content

Conversation

@joker23
Copy link
Contributor

@joker23 joker23 commented Dec 22, 2025

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues
sdk-569

Describe the solution you've provided
- Introduced getLegacyStorageKeys method to as an optional internal option that could be configured per SDK.
- Updated LDClientImpl to support cleaning old persistent data based on the new option cleanOldPersistentData.
- Implemented getLegacyStorageKeys in Browser SDK so the feature is fully available there.
- Added a test to verify that old persistent data is cleaned while retaining current keys.

Additional context

Additionally I've added some refactors that would address the following:
- changing Flagstore + FlagUpdater classes to interface (starting SDK-1686) which saves us a few bytes
- Added a comment in LDClientImpl.ts to clarify that "override" changes are not being tracked as they are currently used only for debugging and not persisted. This may change in the future. (left over comment from a previous PR)


Note

Introduces optional removal of legacy persisted data and refactors flag management internals.

  • New option: LDOptions.cleanOldPersistentData (validated in validators.ts); when enabled, LDClientImpl clears keys returned by internalOptions.getLegacyStorageKeys via platform storage with error-tolerant logging
  • Browser support: BrowserClient provides getLegacyStorageKeys using getAllStorageKeys from platform/LocalStorage (filters ld:${clientSideId}:*)
  • Platform util: Adds getAllStorageKeys() to LocalStorage.ts
  • Refactors: Convert DefaultFlagStore and FlagUpdater classes to interface + factory (createDefaultFlagStore, createFlagUpdater); update usages in FlagManager, FlagPersistence, and tests
  • Tests: Add coverage for legacy key cleanup and update existing tests to new factories; minor comment clarifying that "override" changes are not tracked in inspectors

Written by Cursor Bugbot for commit 8289e33. This will update automatically on new commits. Configure here.

- Introduced `getLegacyStorageKeys` method to as an optional internal option that could be configured per SDK.
- Updated `LDClientImpl` to support cleaning old persistent data based on the new option `cleanOldPersistentData`.
- Implemented `getLegacyStorageKeys` in Browser SDK so the feature is fully available there.
- Added a test to verify that old persistent data is cleaned while retaining current keys.
- Added a comment in `LDClientImpl.ts` to clarify that "override" changes are not being tracked as they are currently used only for debugging and not persisted. This may change in the future.
@joker23 joker23 requested a review from a team as a code owner December 22, 2025 22:48
@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2025

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 171128 bytes
Compressed size limit: 200000
Uncompressed size: 798044 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25394 bytes
Compressed size limit: 26000
Uncompressed size: 124693 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 18730 bytes
Compressed size limit: 20000
Uncompressed size: 96409 bytes

@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2025

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 23295 bytes
Compressed size limit: 25000
Uncompressed size: 80935 bytes

if (!isLocalStorageSupported()) {
return [];
}
return Object.keys(localStorage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not very comfortable with this approach to using local storage. While it can work it can have pitfalls if someone has, for example, done some monkey patching and only uses the local storage API instead of using it as POD.

I think we should use .length and .key()

const keys = [];
for (let i = 0; i < localStorage.length; i++) {
  keys.push(localStorage.key(i);
}
return keys;

@joker23 joker23 merged commit fe4725e into main Jan 6, 2026
37 checks passed
@joker23 joker23 deleted the skz/sdk-569/ensure-localstorage-data branch January 6, 2026 22:17
@github-actions github-actions bot mentioned this pull request Jan 6, 2026
joker23 pushed a commit that referenced this pull request Jan 7, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>browser-telemetry: 1.0.16</summary>

##
[1.0.16](browser-telemetry-v1.0.15...browser-telemetry-v1.0.16)
(2026-01-06)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/js-client-sdk bumped from 0.11.0 to 0.12.0
</details>

<details><summary>jest: 0.2.0</summary>

##
[0.2.0](jest-v0.1.15...jest-v0.2.0)
(2026-01-06)


### Features

* add waitForInitialization to RN SDK
([#1048](#1048))
([13ce456](13ce456))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/react-native-client-sdk bumped from ~10.12.3 to ~10.12.4
</details>

<details><summary>js-client-sdk: 0.12.0</summary>

##
[0.12.0](js-client-sdk-v0.11.0...js-client-sdk-v0.12.0)
(2026-01-06)


### Features

* add legacy storage key cleanup functionality
([#1043](#1043))
([fe4725e](fe4725e))
* add waitForInitialization to RN SDK
([#1048](#1048))
([13ce456](13ce456))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.16.0 to 1.17.0
</details>

<details><summary>js-client-sdk-common: 1.17.0</summary>

##
[1.17.0](js-client-sdk-common-v1.16.0...js-client-sdk-common-v1.17.0)
(2026-01-06)


### Features

* add legacy storage key cleanup functionality
([#1043](#1043))
([fe4725e](fe4725e))
* add waitForInitialization to RN SDK
([#1048](#1048))
([13ce456](13ce456))
</details>

<details><summary>react-native-client-sdk: 10.12.4</summary>

##
[10.12.4](react-native-client-sdk-v10.12.3...react-native-client-sdk-v10.12.4)
(2026-01-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.16.0 to 1.17.0
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Releases multiple packages and aligns versions/dependencies across the
workspace.
> 
> - Publish `@launchdarkly/js-client-sdk` 0.12.0 (adds legacy storage
key cleanup); `@launchdarkly/js-client-sdk-common` 1.17.0;
`@launchdarkly/react-native-client-sdk` 10.12.4;
`@launchdarkly/browser-telemetry` 1.0.16; `@launchdarkly/jest` 0.2.0
(notes RN waitForInitialization)
> - Bump deps to `@launchdarkly/[email protected]` in
browser/RN SDKs and devDep `@launchdarkly/[email protected]` in
telemetry; update `@launchdarkly/react-native-client-sdk` dep in
`@launchdarkly/jest`
> - Update version metadata in code (`BrowserInfo.ts`,
`PlatformInfo.ts`) and `.release-please-manifest.json`
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2d4e276. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants