Skip to content

Conversation

@jonathannorris
Copy link
Member

@jonathannorris jonathannorris commented Jul 18, 2025

Summary

Enhances DevCycleContextMapper to support additional user ID sources from OpenFeature evaluation context, allowing userId and user_id context attributes to be mapped to the DevCycle user ID field. This matches behaviour of our other SDKs and OF Providers.

Changes

  • Modified DevCycleContextMapper.kt to check for user ID in the following priority order:

    1. context.getTargetingKey() (highest priority - existing behavior)
    2. context.getValue("userId") (new)
    3. context.getValue("user_id") (new)
  • Added logic to handle these attributes in custom data mapping:

    • When used as user ID: excluded from custom data
    • When not used (wrong type or lower priority): included in custom data
  • Added comprehensive test coverage for the new functionality

@jonathannorris jonathannorris requested a review from a team as a code owner July 18, 2025 21:06
// Use direct asMap method call instead of reflection
context.asMap().forEach { (key, value) ->
when (key) {
"userId", "user_id" -> {
Copy link
Member

Choose a reason for hiding this comment

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

also skip targeting key?

Copy link
Member Author

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()

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

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

@jonathannorris jonathannorris merged commit ad953e3 into main Jul 23, 2025
5 checks passed
@jonathannorris jonathannorris deleted the chore-of-provider-support-userId branch July 23, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants