Repository navigation
chore(test-app): start a second environment when a second key is set - #428
Open
abelonogov-ld wants to merge 1 commit into
Open
abelonogov-ld wants to merge 1 commit into
abelonogov-ld wants to merge 1 commit into
Conversation
launchdarkly.secondaryMobileKey in local.properties adds a secondary mobile key to the client's LDConfig. An Env spinner then chooses which environment's client the buttons, the connection status, Post 20 MB and the event storage view use. Flush, Offline, Identify and the persistence restart still reach both, as the SDK applies them to every environment. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 186c9f1. Configure here.
| setupStorageInspector(); | ||
| storageInspector.startWatching(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Flag listeners ignore environment switches
Low Severity
Switching the Env spinner refreshes connection status, the storage view, and the status line, but String Evaluate Flag listeners stay on the environment where they were registered. A later change on that other environment still overwrites the result view, so it can show the unselected environment's value.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 186c9f1. Configure here.
This branch has not been deployed
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.


Stacked on #427.
What
When
local.propertiessetslaunchdarkly.secondaryMobileKey, the client is started with that key as a secondary environment throughLDConfig.Builder.secondaryMobileKeys. An Env spinner next to Persistence chooses which environment's client the buttons use, throughLDClient.getForMobileKey. Without the key the spinner stays hidden and nothing changes.The selected environment is used by:
These reach both environments whichever is selected, because the SDK applies
flush,setOffline,setOnline,identifyandcloseto every environment it started: Flush, Offline, Identify, and the restart a persistence change makes. The status line says so.The buttons now get their client through
doSafeClientAction(client -> ...)instead of readingldClientafter a null check. Status and flag listeners are registered on every environment and show the selected one's connection. The choice is saved in shared preferences like the persistence choice.Testing
On the API 23 emulator with both keys set:
Note
Overview
The internal test app can start two LaunchDarkly environments from one
LDConfigwhenlaunchdarkly.secondaryMobileKeyis set inlocal.properties(wired throughBuildConfig.SECONDARY_MOBILE_KEYandsecondaryMobileKeys).An Env spinner appears beside Persistence (hidden without a distinct second key). The choice is persisted so post-kill relaunches match the environment used when the button was pressed. Evaluations, track, kill/crash/over-refresh/fill-batches, Post 20 MB, connection status, and on-disk event storage all follow the selected environment via
LDClient.getForMobileKey. Flush, Offline, Identify, and client restarts still fan out to every started environment, matching SDK behavior.Button and listener paths were refactored so
doSafeClientAction/doSafeClientGettake the active client instead of always using the primaryldClient. README documents the new property and UI behavior.Reviewed by Cursor Bugbot for commit 186c9f1. Bugbot is set up for automated code reviews on this repo. Configure here.