feat(flags): send the split serial ID on iOS exposure events (EX-3422) - #1410
Draft
danyal002 wants to merge 1 commit into
Draft
feat(flags): send the split serial ID on iOS exposure events (EX-3422)#1410danyal002 wants to merge 1 commit into
danyal002 wants to merge 1 commit into
Conversation
Bump the iOS SDK to 3.17.0, which adds serialID to FlagAssignment, and send the value through the React Native bridge. The iOS bridge converts FlagAssignment to an NSDictionary with a fixed key list, and converts it back for exposure tracking. The key list omitted the serial ID, so the value was dropped in both directions. The code still compiled, so nothing reported the loss. The serial ID crosses the bridge as a string, for parity with Android, which sends a string because React Native converts integers to Double. An assignment with no serial ID omits the key instead of sending NSNull. The reader accepts a string only. NSNumber and Bool bridge into each other on Apple platforms, so a numeric branch would read a boolean true as serial ID 1. Int(String) rejects that. A malformed serial ID yields no serial ID and never rejects the assignment, because that would drop the exposure event for the whole flag.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The iOS bridge now sends the split serial ID on feature flag exposure events.
packages/core/DatadogSDKReactNative.podspecand 2 other podspecs3.17.0.packages/core/ios/Sources/DdFlagsImplementation.swiftserialIdin both bridge directions.packages/core/ios/Tests/DdFlagsTests.swiftiOS SDK
3.17.0addsserialIDtoFlagAssignment, reads it on the exposure event, and includes it in the exposure deduplication cache. The React Native bridge supplies the value.The bridge converts a
FlagAssignmentto anNSDictionarywith a fixed key list, and converts the dictionary back for exposure tracking. The key list omitted the serial ID. The value was therefore dropped in both directions, and the code still compiled.The serial ID crosses the bridge as a string. Android does the same, because React Native converts integers to
Double. An assignment with no serial ID omits the key instead of sendingNSNull.The reader accepts a string only.
NSNumberandBoolbridge into each other on Apple platforms, so a numeric branch would read a booleantrueas serial ID1.Int(String)rejects a boolean, and rejects any other value that is not an integer. A malformed serial ID yields no serial ID. It never rejects the assignment, because that would drop the exposure event for the whole flag.Serial IDs are zero-based for each org.
0is therefore a real value, and two tests pin it.Motivation
The UFC compiler rewrites a holdout into an ordinary allocation before any SDK reads the flag configuration. An exposure event therefore records no holdout. The split serial ID is the only link back to it. An exposure event without the serial ID cannot be resolved to a holdout.
Additional Notes
Testing. The new tests cover the string form, serial ID
0in both directions, an absent serial ID omitting the key, four malformed values, and a round trip through both conversions.Risks. The iOS SDK bump from
3.16.0to3.17.0carries every other change in that release.The bridge ignores a numeric serial ID, whereas the Android bridge accepts a string or a number. Both JavaScript producers send a string, so no current caller depends on the numeric shape. A test pins the numeric case as ignored, so the difference is deliberate and visible.
The offline path also needs the serial ID. PR #1409 covers that, and covers Android.