Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

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-Key header
Response: 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 time
  • evaluation_timestamp (datetime, required)
  • identity_identifier (string, optional)
  • identity_traits (array, optional) - [{trait_key, trait_value}]
  • segment_names (array, optional) - segment membership at evaluation

Validation 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 routing
  • api/app_analytics/serializers.py - SDKEvaluationDataSerializer, SDKTraitSerializer, SDKEvaluationDataDetail
  • api/app_analytics/views.py - SDKEvaluationDataView

How did you test this code?

Unit tests covering valid/invalid requests, authentication, validation, and edge cases (9 tests, all passing).

Original prompt

This section details on the original issue you should resolve

<issue_title>Define an API schema for flagsmith SDKs to send evaluation data</issue_title>
<issue_description>The goal of this issue is to define the API endpoint schema that the SDKs will send data to based on the evaluations that occur on the client side. Bear in mind that this is an alpha release, WE DO EXPECT TO HAVE TO BREAK THIS SCHEMA IN THE FUTURE.

The data that we want to include in this schema are:

  • name of the feature that was evaluated
  • enabled state of the feature evaluated
  • value of the feature evaluated
  • timestamp of the evaluation
  • identity that evaluated the feature
  • traits of the identity that evaluated the feature
  • list of segment names for the identity

Question: One thing to consider is the encapsulation of the data for this endpoint - should this endpoint consume a single atomic evaluation only, or a bulk number of actions compiled by the SDK over a period of time?
Answer: The expectation is that it will consume 'batches' of evaluations, not individual evaluations.

Note 1: we should be able to collect the SDK language / version from the user-agent header which we will need for the schema to the big data platforms.

Note 2: we have an existing endpoint here from a previous attempt based on work around split testing. This may or may not be relevant / helpful here. </issue_description>

<agent_instructions>Don't merge. Demo purposes. Please Copilot do your best!</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Feb 10, 2026 11:20am
flagsmith-frontend-preview Ignored Ignored Preview Feb 10, 2026 11:20am
flagsmith-frontend-staging Ignored Ignored Preview Feb 10, 2026 11:20am

Request Review

Copilot AI and others added 4 commits February 10, 2026 11:05
- Created SDKEvaluationDataSerializer with all required fields
- Added SDKEvaluationDataView for handling batch evaluation data
- Registered new endpoint at /api/v2/analytics/evaluations/
- Added comprehensive unit tests covering valid/invalid cases

Co-authored-by: emyller <22429+emyller@users.noreply.github.com>
Changed expected status codes from 401 to 403 for authentication failures, which is the correct behaviour in this API

Co-authored-by: emyller <22429+emyller@users.noreply.github.com>
- Remove unused imports from test file
- Add type annotation for empty evaluations list

Co-authored-by: emyller <22429+emyller@users.noreply.github.com>
- Document environment kwarg in save() method
- Fix type annotation for empty list to be more accurate

Co-authored-by: emyller <22429+emyller@users.noreply.github.com>
Copilot AI changed the title [WIP] Define API schema for flagsmith SDK evaluation data Define API schema for SDK evaluation data collection Feb 10, 2026
Copilot AI requested a review from emyller February 10, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define an API schema for flagsmith SDKs to send evaluation data

2 participants