-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Add experimental debug override functionality. #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add experimental debug override functionality. #132
Conversation
This update introduces a new interface for plugins to register debug capabilities, allowing for temporary flag value overrides during local development.
…options This update adds two new methods, `removeOverride` and `clearAllOverrides`, to the debug override capabilities, allowing for more flexible management of flag value overrides during local development. It also improves the `setOverride` method to prevent race condition by checking if the same value is already set.
This update introduces the `getAllOverrides` method to retrieve all currently active flag overrides. It also refines the handling of flag overrides in the `setOverride`, `removeOverride`, and `clearAllOverrides` methods, ensuring that the current effective values are accurately managed.
Ensures consistent property validation.
Includes expanding plugin tests to check for registration with debug override capabilities.
bb2324f
to
6a44cc5
Compare
6a44cc5
to
ce4a44f
Compare
02d876b
to
c40f020
Compare
src/index.js
Outdated
const flagStore = { | ||
get(key) { | ||
// Check overrides first, then real flags | ||
if (flagOverrides && utils.objectHasOwnProperty(flagOverrides, key) && flagOverrides[key]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to be able to override a flag to appear deleted? Versus just setting the value. It seems useful to be able to force an evaluation to use the default by masking out the real flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kinyoklion Interesting thought 🤔 In that case, do you see the API for overrides working something like setOverride("flag", { deleted: true })
and setOverride("flag", { value: true })
? And are there any other flag properties that you think might be useful to override?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most other properties would not influence the application in the same way that a deleted flag would. Maybe this is something we can defer for now and just let overrides be set.
Initialize flagOverrides as undefined until needed, optimize getAll() iteration, and simplify setOverride() logic. Improves performance for common case where no overrides are used while maintaining full compatibility.
b8f581e
to
11f992a
Compare
Introduced a new FlagStore module to encapsulate flag management logic.
11f992a
to
40a34b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think things are looking pretty good. I added some minor comments and I have two overall comments.
I think we maybe want to be able to experiment with this interface. So I would add a comment to registerDebug to indicate that it is experimental, and for use by LaunchDarkly tools at this time.
I would also update the title of the PR, which will become a release note.
feat: Add experimental debug override functionality.
I would also like if you could add your updates to the plugin interface to our specification: https://github.com/launchdarkly/sdk-specs/tree/main/specs/PLUGIN-sdk-plugin-support
I think we could tag this as being client-side only for the time being.
Added experimental annotations to LDPlugin and LDDebugOverride interfaces in typings.d.ts. Add JSDoc comments to all FlagStore functions
🤖 I have created a release *beep* *boop* --- ## [5.8.0](5.7.1...5.8.0) (2025-09-05) ### Features * Add experimental debug override functionality. ([#132](#132)) ([8b2f757](8b2f757)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Requirements
Describe the solution you've provided
This PR adds debug override capability to the LaunchDarkly SDK, allowing developers to override flag values during local development and testing without affecting production flag configurations.
Key features:
LDDebugOverride
interface with methods to set, remove, and manage flag overrides.LDPlugin
interface with optionalregisterDebug
method for plugins to access override functionality.Additional context
This feature is designed primarily for development and testing workflows where developers need to:
The implementation maintains backward compatibility and follows the existing plugin architecture patterns. Override functionality is only available when explicitly enabled through plugins, ensuring it doesn't impact production performance or security.