Skip to content

feat: Support redacting anonymous context attributes in all events#194

Merged
keelerm84 merged 2 commits into
mainfrom
mk/SDK-2732/redact-anonymous-custom-events
Jul 21, 2026
Merged

feat: Support redacting anonymous context attributes in all events#194
keelerm84 merged 2 commits into
mainfrom
mk/SDK-2732/redact-anonymous-custom-events

Conversation

@keelerm84

@keelerm84 keelerm84 commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

Custom-event (and migration_op) anonymous-context redaction is a server-side behavior: server-side SDKs inline the full context and must redact an anonymous context's attributes into _meta.redactedAttributes. Client-side/mobile SDKs use the current context for custom events and must not redact them (only feature events redact anonymous contexts on the client) — see sdk-test-harness #388.

Because this internal module is shared by both the server SDK and client/mobile SDKs (e.g. Android), the redaction is gated behind a new opt-in flag rather than applied unconditionally. The flag is named redactAnonymousAllEvents to match the js-core convention (js-core #1814).

Scope of this PR (internal module only)

  • EventsConfiguration: new redactAnonymousAllEvents field (default false) + a full constructor overload. The existing constructors default it to false, so client/mobile consumers are unaffected and remain source-compatible.
  • EventOutputFormatter: custom and migration_op events honor the flag (migration_op is only ever produced server-side). Feature-event redaction is unchanged (both client and server).
  • Tests: server-behavior (flag on → redacts, single + multi kind, custom + migration), client-behavior (flag off → full context).

Follow-up (separate PR, after this releases)

Ships as a new launchdarkly-java-sdk-internal release. The server SDK then opts in via a follow-up PR that bumps launchdarklyJavaSdkInternal and sets redactAnonymousAllEvents in ComponentsImpl. That is when the server contract tests go green.

CI note

test-contract-tests builds the server SDK against the released internal, so the custom/migration anonymous-redaction contract tests remain red on this PR until the follow-up server bump — expected, not a regression. The java-sdk-internal checks (unit tests) cover this change.

Verification

  • internal unit tests pass (server-behavior custom + migration, client-behavior no-redaction).
  • Verified end-to-end against the local sdk-test-harness v2 @ 0317ec5 (incl. #388): with the server opting in, events/custom events/*anonymous* and migrations/redacts anonymous context attributes pass; with the flag off, the custom-event context is emitted unredacted (client behavior).

Jira: SDK-2732


Note

Medium Risk
Changes analytics payload shape for anonymous contexts when the flag is enabled; default-off preserves current client behavior but server adopters must enable it deliberately to match harness expectations.

Overview
Adds an opt-in redactAnonymousAllEvents flag on EventsConfiguration (defaults false via existing constructors so client/mobile SDKs stay unchanged). When enabled, EventOutputFormatter redacts anonymous context attributes on custom and migration_op events—the same _meta.redactedAttributes behavior feature events already use—while identify/index and client-default custom events are unchanged.

Unit tests cover server-style redaction (single- and multi-kind) and client-style full context when the flag is off. Contract-test suppressions were added for anonymous custom/migration scenarios until the server SDK opts in in a follow-up release.

Reviewed by Cursor Bugbot for commit 2b89ca1. Bugbot is set up for automated code reviews on this repo. Configure here.

@keelerm84
keelerm84 requested a review from a team as a code owner July 21, 2026 11:11
@keelerm84
keelerm84 force-pushed the mk/SDK-2732/redact-anonymous-custom-events branch from 5454823 to e8164aa Compare July 21, 2026 14:01
@keelerm84 keelerm84 changed the title fix: Redact anonymous context attributes in custom and migration_op events fix: Redact anonymous context attributes in custom events (server-side, opt-in) Jul 21, 2026
…server-side, opt-in)

Server-side SDKs inline the full context in custom and migration_op events and must
redact an anonymous context's attributes into _meta.redactedAttributes. Client-side
SDKs use the current context for custom events and must NOT redact them (only feature
events redact anonymous contexts on the client), per sdk-test-harness #388.

Because this internal module is shared with client/mobile SDKs (e.g. Android), the
redaction is gated behind a new EventsConfiguration flag, redactAnonymousAllEvents
(default false), matching the js-core convention (js-core #1814). The existing
EventsConfiguration constructors default it to false, so client/mobile consumers are
unaffected and remain source-compatible. Server-side SDKs opt in as a follow-up once
this change is released. Feature-event redaction is unchanged (applies to both).

- EventsConfiguration: new redactAnonymousAllEvents flag + full constructor overload
  (older overloads delegate with false).
- EventOutputFormatter: custom and migration_op events honor the flag.
- Tests: server-behavior redacts (custom + migration), client-behavior (flag off) does not.

SDK-2732
@keelerm84 keelerm84 changed the title fix: Redact anonymous context attributes in custom events (server-side, opt-in) feat: Support redacting anonymous context attributes in all events Jul 21, 2026
@keelerm84
keelerm84 merged commit a83a628 into main Jul 21, 2026
25 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-2732/redact-anonymous-custom-events branch July 21, 2026 14:40
keelerm84 pushed a commit that referenced this pull request Jul 21, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.10.0](launchdarkly-java-sdk-internal-1.9.0...launchdarkly-java-sdk-internal-1.10.0)
(2026-07-21)


### Features

* Support redacting anonymous context attributes in all events
([#194](#194))
([a83a628](a83a628))

---
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>
keelerm84 added a commit that referenced this pull request Jul 21, 2026
…ents

Consume the redactAnonymousAllEvents flag added to launchdarkly-java-sdk-internal:
bump the internal dependency and enable the flag when the server SDK constructs its
EventsConfiguration, so anonymous context attributes are redacted in custom and
migration_op events (server-side behavior).

Stacked on #194 (the internal change). Do not merge until
launchdarkly-java-sdk-internal 1.9.1 is released.

SDK-2732
keelerm84 pushed a commit that referenced this pull request Jul 21, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.15.0](launchdarkly-java-server-sdk-7.14.0...launchdarkly-java-server-sdk-7.15.0)
(2026-07-21)


### Features

* Support redacting anonymous context attributes in all events
([#194](#194))
([a83a628](a83a628))


### Bug Fixes

* Enable anonymous context redaction in server custom/migration events
([#195](#195))
([19aa714](19aa714))

---
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants