Skip to content

refactor(events): name the event directory from a name the caller hashes - #430

Open
abelonogov-ld wants to merge 1 commit into
andrey/event-durability-tier3-persistencefrom
andrey/event-directory-name
Open

abelonogov-ld wants to merge 1 commit into
andrey/event-durability-tier3-persistencefrom
andrey/event-directory-name

Conversation

@abelonogov-ld

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

Copy link
Copy Markdown
Contributor

EventDirectory.defaultDirectory now takes a name that is already hashed and uses it as it is. The hashing moves out to LDUtil.hashedStorageName(mobileKey), which the EventStore factories call. This follows the review on iOS (ios-client-sdk#538), where EventDirectory.defaultUrl now takes an already hashed name in the same way.

Stacked on #408 (tier 3).

  • The directory name is unchanged. hashedStorageName is the same hexDigest(mobileKey, 16) that EventDirectory used privately, so events stored by tier 3 are found where they were.
  • EventDirectory no longer knows about mobile keys. It places a store under noBackupFilesDir/com.launchdarkly.events/<name>, and whoever supplies the name decides how it is hashed.
  • chore(test-app): show what the SDK has stored for events #427 needs a one-line follow-up. Its test-app EventStorageLocation calls EventDirectory.defaultDirectory(noBackupFilesDir, mobileKey), which would still compile after this change but would point at a directory named for the raw key. Whichever of the two merges second should call LDUtil.hashedStorageName(mobileKey) there.

Tests:

  • LDUtilTest pins hashedStorageName("mob-12345") to 3a4f14b3feba38b362ad80b504238faa and checks that it does not hold the key.
  • EventStoreTest checks that defaultDirectory uses the name it is given without hashing it again.
  • DirectEventProcessorTest builds the directory through one environmentDirectory() helper instead of five copies of the call.

./gradlew :launchdarkly-android-client-sdk:testDebugUnitTest: 1259 tests, 0 failures (25 skipped).


Note

Overview
Event persistence paths are unchanged on disk, but who hashes the mobile key moved: EventDirectory.defaultDirectory now takes an environmentName and uses it verbatim under com.launchdarkly.events/, instead of hashing the mobile key inside EventDirectory.

EventStore factory methods now call LDUtil.hashedStorageName(mobileKey) (16-byte SHA-256 hex, same as before) before resolving the directory. EventDirectory no longer depends on mobile keys.

Tests add coverage for hashedStorageName and for defaultDirectory not re-hashing; integration tests use a shared environmentDirectory() helper.

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

…n hashing the mobile key in EventDirectory

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld
abelonogov-ld requested a review from a team as a code owner November 13, 2026 19:41
@cursor cursor Bot added the risk:low label Nov 13, 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.

Automated risk review (dry run): Low

This PR would be automatically approved.

Why: This is a small, test-covered refactor that moves event-directory hashing from EventDirectory to LDUtil.hashedStorageName and updates EventStore factories so the on-disk path stays the same. Production callers still hash the mobile key, and new tests pin that hash plus that defaultDirectory does not hash again.

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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant