Repository navigation
chore(test-app): start a second environment when a second key is set - #428
abelonogov-ld wants to merge 14 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # contract-tests/src/main/java/com/launchdarkly/sdktest/TestService.java # launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSystemComponentsTest.java
There was a problem hiding this comment.
Risk: medium.
Automated risk review (dry run): Medium
This PR would not be automatically approved. Human approval required.
Why: Versus andrey/test-app-event-storage this PR still brings SDK HTTP and config behavior (usePost, payloadFilter in LDConfig and FDv2 request/streaming paths), contract-test harness changes, and the test-app secondary-environment UI, which is too broad for Low.
If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.
Sent by Cursor Approval Agent: Dry-Run PR Approver
…-environments Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # contract-tests/src/main/java/com/launchdarkly/sdktest/TestService.java # launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSystemComponentsTest.java
There was a problem hiding this comment.
Stale comment
Risk: medium. Not approved (SDK rule 2: Approve only PRs opened by an SDK team member). Cursor Bugbot passed with no unresolved findings that need human review; risk is above the low threshold, so human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver
There was a problem hiding this comment.
Stale comment
Risk: medium. Not approved (SDK rule 2: Approve only PRs opened by an SDK team member). Cursor Bugbot passed with no unresolved findings that need human review; risk is above the low threshold, so human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver
There was a problem hiding this comment.
Stale comment
Risk: medium. Not approved (SDK rule 2: Approve only PRs opened by an SDK team member). Cursor Bugbot passed with no unresolved findings that need human review; risk is above the low threshold, so human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver
There was a problem hiding this comment.
Stale comment
Risk: medium. Not approved (SDK rule 2: Approve only PRs opened by an SDK team member). Cursor Bugbot passed with no unresolved findings that need human review; risk is above the low threshold, so human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver
There was a problem hiding this comment.
Stale comment
Risk: medium. Not approved (SDK rule 2: Approve only PRs opened by an SDK team member). Cursor Bugbot passed with no unresolved findings that need human review; risk is above the low threshold, so human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver
…ry environment payloadFilter stays the filter for the primary environment and the default for every secondary environment. A secondary environment named in secondaryPayloadFilters uses its own key instead, or requests the full environment if the key is null or empty. Names that are not secondary environments are logged when the config is built and ignored. Data sources look up their environment's filter by ClientContext.getEnvironmentName(). Co-authored-by: Cursor <cursoragent@cursor.com>
…nt(name, mobileKey, payloadFilter) A secondary environment's payload filter is now given together with its mobile key, so it can't name an unknown environment or drift from the keys. payloadFilter applies only to the primary environment; secondary environments are unfiltered unless added with a filter. secondaryEnvironment throws IllegalArgumentException on the same name and key conflicts as secondaryMobileKeys. getPayloadFilter(String) returns null for unknown environment names.
FDv2 filters flag data by the views linked to the mobile key, and LaunchDarkly no longer supports payload filters on FDv2 requests. Stop sending the filter from the FDv2 streaming and polling synchronizers, keep it on the FDv1 fallback, and warn when a filter is combined with the data system. Co-authored-by: Cursor <cursoragent@cursor.com>
…ments Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # contract-tests/src/main/java/com/launchdarkly/sdktest/TestService.java # launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSystemComponentsTest.java
There was a problem hiding this comment.
Risk: medium. Not approved (SDK rule 2: Approve only PRs opened by an SDK team member). Cursor Bugbot passed with no unresolved findings that need human review; risk is above the low threshold, so human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver



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
Adds payload filter support to the Android SDK so flag data requests can include a validated
filterquery parameter.LDConfig.BuildergainspayloadFilter(String)for the primary environment andsecondaryEnvironment(name, mobileKey, payloadFilter)for secondaries; invalid keys are dropped with errors, and using filters with FDv2 data system logs that filtering applies only on FDv1 fallback polls (FDv2 native poll/stream paths intentionally omit the parameter).Wiring runs through
LDUtil.withPayloadFilter,StreamingDataSource, andHttpFeatureFlagFetcherfor classic FDv1 streaming/polling, plus FDv1 fallback in the data system viaDataSourceBuildInputsInternal. Contract tests advertisefilteringcapabilities and accept stream/pollfilterconfig. Unit tests cover config validation and HTTP query behavior.The test app can start a secondary environment from
launchdarkly.secondaryMobileKey, with an Env spinner so most actions target the selected client while flush/offline/identify/close still affect all environments.Reviewed by Cursor Bugbot for commit 5ad7b4b. Bugbot is set up for automated code reviews on this repo. Configure here.