Define API schema for SDK evaluation data collection #6679
+447
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
docs/if required so people know about the feature.Changes
Implements alpha API endpoint for SDKs to send batch evaluation data to analytics backend.
New endpoint:
POST /api/v2/analytics/evaluations/Authentication: Environment key via
X-Environment-KeyheaderResponse:
202 Accepted(async processing)Schema (
SDKEvaluationDataSerializer)Accepts batch array with per-evaluation fields:
feature_name(string, required)enabled(boolean, required)value(JSON, optional) - feature value at evaluation timeevaluation_timestamp(datetime, required)identity_identifier(string, optional)identity_traits(array, optional) -[{trait_key, trait_value}]segment_names(array, optional) - segment membership at evaluationValidation filters evaluations for non-existent features in the environment.
Example request:
{ "evaluations": [ { "feature_name": "new_dashboard", "enabled": true, "value": "variant_a", "evaluation_timestamp": "2026-02-10T11:00:00Z", "identity_identifier": "user_123", "identity_traits": [ {"trait_key": "email", "trait_value": "user@example.com"} ], "segment_names": ["premium_users"] } ] }Note: Alpha release. Schema may break in future versions. Storage implementation (Postgres/InfluxDB) pending - currently no-op.
Files changed
api/api/urls/v2.py- URL routingapi/app_analytics/serializers.py-SDKEvaluationDataSerializer,SDKTraitSerializer,SDKEvaluationDataDetailapi/app_analytics/views.py-SDKEvaluationDataViewHow did you test this code?
Unit tests covering valid/invalid requests, authentication, validation, and edge cases (9 tests, all passing).
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.