-
Notifications
You must be signed in to change notification settings - Fork 31
feat: adding support for debug override plugins #1033
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
base: main
Are you sure you want to change the base?
Conversation
- Added `LDDebugOverride` interface to manage flag value overrides during development. - Introduced `safeRegisterDebugOverridePlugins` function to register plugins with debug capabilities. - Updated `FlagManager` to support debug overrides, including methods to set, remove, and clear overrides. - Enhanced `LDClientImpl` to utilize debug overrides during client initialization. - Refactored `LDPlugin` interface to include optional `registerDebug` method for plugins. This commit will enable `@launchdarkly/toolbar` to use 4.x
|
@launchdarkly/browser size report |
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
| * Unregister a flag change callback. | ||
| */ | ||
| off(callback: FlagsChangeCallback): void; | ||
|
|
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.
Blocking until we have some eyes on this - ultimately want to make sure we are fine with having the flag override functionality handled by the flag manager. I think this makes sense, but I can also see how having this implemented as part of the client impl give us a bit more flexibility.
| * This event does not include the value of the flag. It is expected that you | ||
| * will call a variation method for flag values which you require. | ||
| */ | ||
| export type FlagsChangeCallback = ( |
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.
Blocking until we get some eyes on this - main reason to add null as a valid context to pass in for these events is to support flag changes that are triggered by an override... An alternative is to somehow designate a special context for the override event?
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 we should just include whatever context is associated with the currently active payload. Because this would propagate all the way to the events emitted by the LD client.
this._flagManager.on((context, flagKeys, type) => {
this._handleInspectionChanged(flagKeys, type);
const ldContext = Context.toLDContext(context);
this.emitter.emit('change', ldContext, flagKeys);
flagKeys.forEach((it) => {
this.emitter.emit(`change:${it}`, ldContext);
});
});
From a consuming standpoint the override changing is changing the value for the current context.
Requirements
Describe the solution you've provided
LDDebugOverrideinterface to manage flag value overrides during development.safeRegisterDebugOverridePluginsfunction to register plugins with debug capabilities.FlagManagerto support debug overrides, including methods to set, remove, and clear overrides.LDClientImplto utilize debug overrides during client initialization.LDPlugininterface to include optionalregisterDebugmethod for plugins.This PR will enable
@launchdarkly/toolbarto use 4.xAdditional context
waitForInitializationfor browser sdk 4.x #1028 (will need to do some rebase magic later)REVIEWERthat I would like some additional discussions before merging