-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Update OpenFeature User ID Mapping to Support userId
Attribute
#91
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
Changes from all commits
330a3d6
12c04b2
fb2408f
4c0eee6
ac20967
3110860
46771d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,30 +101,42 @@ def create_user_from_context( | |
) -> "DevCycleUser": | ||
""" | ||
Builds a DevCycleUser instance from the evaluation context. Will raise a TargetingKeyMissingError if | ||
the context does not contain a valid targeting key or user_id attribute | ||
the context does not contain a valid targeting key, user_id, or userId attribute | ||
|
||
:param context: The evaluation context to build the user from | ||
:return: A DevCycleUser instance | ||
""" | ||
user_id = None | ||
user_id_source = None | ||
|
||
if context: | ||
if context.targeting_key: | ||
user_id = context.targeting_key | ||
user_id_source = "targeting_key" | ||
elif context.attributes and "user_id" in context.attributes.keys(): | ||
user_id = context.attributes["user_id"] | ||
user_id_source = "user_id" | ||
elif context.attributes and "userId" in context.attributes.keys(): | ||
user_id = context.attributes["userId"] | ||
user_id_source = "userId" | ||
jonathannorris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if not user_id or not isinstance(user_id, str): | ||
if not user_id: | ||
raise TargetingKeyMissingError( | ||
"DevCycle: Evaluation context does not contain a valid targeting key or user_id attribute" | ||
"DevCycle: Evaluation context does not contain a valid targeting key, user_id, or userId attribute" | ||
) | ||
|
||
Comment on lines
109
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
if not isinstance(user_id, str): | ||
raise TargetingKeyMissingError( | ||
f"DevCycle: {user_id_source} must be a string, got {type(user_id).__name__}" | ||
) | ||
|
||
user = DevCycleUser(user_id=user_id) | ||
custom_data: Dict[str, Any] = {} | ||
private_custom_data: Dict[str, Any] = {} | ||
if context and context.attributes: | ||
for key, value in context.attributes.items(): | ||
if key == "user_id": | ||
# Skip user_id, userId, and targeting_key - these are reserved for user ID mapping | ||
if key in ("user_id", "userId", "targeting_key"): | ||
continue | ||
|
||
if value is not None: | ||
|
Uh oh!
There was an error while loading. Please reload this page.