feat: add device_id to flags request payload#407
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 |
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. |
1bebd90 to
95b8110
Compare
95b8110 to
d827d6d
Compare
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>
d827d6d to
53df035
Compare
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.