Skip to content

Conversation

sameerank
Copy link
Contributor

@sameerank sameerank commented Jul 18, 2025

🎟️ Fixes issue
πŸ“œ Design Doc: link if applicable

Motivation and Context

Description

  • Holdout splits and logging were already working in the Swift SDK due to it conforming with the UFC framework. I added tests to confirm that:
    • Holdout splits are correctly assigned based on shard ranges
    • Holdout assignments are logged with holdoutKey and holdoutVariation in extraLogging
    • Both "status_quo" and "all_shipped" holdout variations are supported
    • Tests cover scenarios with and without entityId
    • Tests verify that doLog: false prevents assignment logging
  • Verified with tests that eppoClient.getBooleanAssignment does not need to be wrapped with a do-try-catch
  • Verified that doLog is respected and prevents logging when set to false
  • Added entityId support for parity with js/node SDKs (Set entityId on flag evaluationΒ js-sdk-common#234)

How has this been documented?

Eppo-exp/eppo-docs#691

Or alternatively we make the SDKs consistent with the holdout fields at the top-level of the event object, but the challenge there is that the nested extraLogging may already be in use in the SDKs where it was included

How has this been tested?

Added tests in AssignmentLoggerTests.swift:

  • testHoldoutLoggingWithEntityIdAndHoldoutInfo: Verifies holdout logging with entityId and extraLogging
  • testHoldoutLoggingWithoutEntityIdNorHoldoutInfo: Verifies logging without entityId nor extraLogging
  • testHoldoutLoggingWithDoLogFalse: Verifies that doLog: false prevents assignment logging
  • Updated existing tests to use boolean flags and verify getBooleanAssignment works without try-catch

- Add entityId field to Assignment class and constructor
- Add entityId field to FlagEvaluation struct and all factory methods
- Add entityId field to UFC_Flag struct
- Update EppoClient to pass entityId from FlagEvaluation to Assignment
- Update RuleEvaluator to pass entityId from flag config to FlagEvaluation
- Update all test files to include entityId parameter in test configurations
- Fix test assertions to check for empty extraLogging instead of nil
- Add holdout logging tests with entityId scenarios

This change enables tracking of entity IDs throughout the flag evaluation
pipeline, from flag configuration through to assignment logging.
- Remove testAssignmentWithAllFields() - combination test covered by individual tests
- Remove testAssignmentWithNilHoldoutFields() - basic initialization already tested
- Add missing extraLogging.isEmpty assertion to testAssignmentWithEntityId()

Simplifies test file while maintaining adequate coverage of entityId and
extraLogging functionality through focused individual tests.
Remove trailing comma after entityId parameter in Assignment.init() to fix
Swift compilation error. Trailing commas are not allowed after the last
parameter in function signatures.
- Change testHoldoutLoggingWithEntityIdAndHoldoutInfo to use boolean-flag instead of flag-mid-holdout
- Change testHoldoutLoggingWithoutEntityIdNorHoldoutInfo to use boolean-flag instead of flag-mid-holdout
- Update both tests to use getBooleanAssignment() instead of getStringAssignment()
- Remove entityId from second test to verify behavior without entityId
- Update test assertions to match boolean flag variations (true/false instead of control/treatment)
- Verify getBooleanAssignment() works without try-catch wrapper
- Add testHoldoutLoggingWithDoLogFalse() to verify that doLog: false prevents assignment logging
- Remove redundant comments ("Initialize EppoClient with test configuration", "Perform an assignment")
- Remove entityId from testHoldoutLoggingWithoutEntityIdNorHoldoutInfo to properly test without entityId scenario
- Remove extraLogging from doLog: false test since it's not needed for the test
- Change variationKey to "true" in doLog: false test for better test coverage
@sameerank sameerank marked this pull request as ready for review July 18, 2025 21:27
Copy link
Member

@leoromanovsky leoromanovsky left a comment

Choose a reason for hiding this comment

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

Good observation and not taking on a lot of scope on this. Before publishing, bump the minor version since you are adding the entityId tracking.

Update SDK version from 4.3.0 to 4.4.0 in Constants.swift
@sameerank sameerank merged commit 53b311a into main Jul 21, 2025
1 check passed
@sameerank sameerank deleted the sameeran/ffl-420-holdouts branch July 21, 2025 16:36
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