-
Notifications
You must be signed in to change notification settings - Fork 53
feat: add device_id to flags request payload #407
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
base: master
Are you sure you want to change the base?
Conversation
Greptile SummaryOverviewThis PR adds support for What Works Well✅ Client methods: All Critical Issue Found❌ Missing device_id in module-level functions: All module-level feature flag functions in
While users can work around this by using RecommendationAdd the optional |
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.
1 file reviewed, 1 comment
Additional Comments (1)
While users can use The same issue applies to:
All these module-level functions should be updated to accept an optional Prompt To Fix With AIThis is a comment left during a code review.
Path: posthog/__init__.py
Line: 500:548
Comment:
The `feature_enabled()` function is missing the `device_id` parameter. According to the PR description, "device_id parameter should be added to all feature flag methods."
While users can use `set_context_device_id()` to set device_id via context, this creates an inconsistency: the function requires `distinct_id` as an explicit parameter even though `distinct_id` can also come from context in Client methods. For consistency with the Client implementation and to fully support the stated goal, this function should accept an optional `device_id` parameter.
The same issue applies to:
- `get_feature_flag()` (line 551)
- `get_all_flags()` (line 601)
- `get_feature_flag_result()` (line 643)
- `get_feature_flag_payload()` (line 686)
- `get_all_flags_and_payloads()` (line 731)
All these module-level functions should be updated to accept an optional `device_id` parameter and pass it through to the underlying Client methods via `_proxy()`.
How can I resolve this? If you propose a fix, please make it concise. |
Add device_id parameter to all feature flag methods, similar to how distinct_id is handled. The device_id is included in the flags request payload sent to the server. - Add device_id parameter to Client methods and module-level functions - Add context support via set_context_device_id() for automatic fallback - Add tests for explicit device_id and context-based device_id - Bump version to 7.6.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1bebd90 to
95b8110
Compare
haacked
left a comment
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.
This looks good!
Add device_id parameter to all feature flag methods, similar to how
distinct_id is handled. The device_id is included in the flags request
payload sent to the server.
This is required for supporting
device_idas bucketing identifier.