Skip to content

chore(test-app): start a second environment when a second key is set - #428

Open
abelonogov-ld wants to merge 14 commits into
andrey/test-app-event-storagefrom
andrey/test-app-two-environments
Open

abelonogov-ld wants to merge 14 commits into
andrey/test-app-event-storagefrom
andrey/test-app-two-environments

Conversation

@abelonogov-ld

@abelonogov-ld abelonogov-ld commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #427.

What

When local.properties sets launchdarkly.secondaryMobileKey, the client is started with that key as a secondary environment through LDConfig.Builder.secondaryMobileKeys. An Env spinner next to Persistence chooses which environment's client the buttons use, through LDClient.getForMobileKey. Without the key the spinner stays hidden and nothing changes.

The selected environment is used by:

  • Evaluate Flag and its flag listener;
  • Track;
  • Eval+Kill 5s, Eval+Kill now, Eval+Crash now, Over-Refresh Eval and Fill 3 Batches;
  • Post 20 MB (which key it posts with);
  • the connection status;
  • the event storage view, which shows that environment's own directory.

These reach both environments whichever is selected, because the SDK applies flush, setOffline, setOnline, identify and close to 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 reading ldClient after 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:

  • The Env spinner appears.
  • Selecting Secondary switches the connection status to that environment's own information.
  • Track wrote a pending log into the secondary environment's directory only, and the storage view showed it.
  • Flush delivered it.
  • Switching back to Primary showed the primary environment's status and directory again.

Note

Overview
Adds payload filter support to the Android SDK so flag data requests can include a validated filter query parameter. LDConfig.Builder gains payloadFilter(String) for the primary environment and secondaryEnvironment(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, and HttpFeatureFlagFetcher for classic FDv1 streaming/polling, plus FDv1 fallback in the data system via DataSourceBuildInputsInternal. Contract tests advertise filtering capabilities and accept stream/poll filter config. 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.

abelonogov-ld and others added 2 commits November 4, 2026 18:03
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>
@abelonogov-ld
abelonogov-ld requested a review from a team as a code owner November 11, 2026 01:46

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

abelonogov-ld and others added 5 commits November 10, 2026 18:23
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
@cursor cursor Bot added the risk:medium label Nov 21, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Open in Web View Automation 

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

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

abelonogov-ld and others added 4 commits November 25, 2026 14:34
…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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant