-
Notifications
You must be signed in to change notification settings - Fork 6
fix: support user_id / userId in OF Context #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
...d-client-sdk/src/test/java/com/devcycle/sdk/android/openfeature/DevCycleContextMapperTest.kt
Show resolved
Hide resolved
android-client-sdk/src/main/java/com/devcycle/sdk/android/openfeature/DevCycleContextMapper.kt
Outdated
Show resolved
Hide resolved
| // Use direct asMap method call instead of reflection | ||
| context.asMap().forEach { (key, value) -> | ||
| when (key) { | ||
| "userId", "user_id" -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also skip targeting key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
targetingKey isn't included in the context.asMap()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's interesting - what if you set it as a property on the context instead? does that still hold true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically the targetingKey is stored as a different var: https://github.com/open-feature/kotlin-sdk/blob/d8b58b48ad1a89ab31e1f1c2d553e6c7c516f7a8/android/src/main/java/dev/openfeature/sdk/ImmutableContext.kt#L6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah - found that code; it's odd that it wasn't the same as other sdks
Summary
Enhances
DevCycleContextMapperto support additional user ID sources from OpenFeature evaluation context, allowinguserIdanduser_idcontext attributes to be mapped to the DevCycle user ID field. This matches behaviour of our other SDKs and OF Providers.Changes
Modified
DevCycleContextMapper.ktto check for user ID in the following priority order:context.getTargetingKey()(highest priority - existing behavior)context.getValue("userId")(new)context.getValue("user_id")(new)Added logic to handle these attributes in custom data mapping:
Added comprehensive test coverage for the new functionality