Overview
The Custom Analytics API provides flexible querying capabilities for autocomplete, chat, and command data with customizable selections, filters, aggregations, and orderings.Request
Your service key with “Teams Read-only” permissions
Filter results to users in a specific group (optional)
Array of query request objects defining the data to retrieve
Query Request Structure
Each query request object contains:Data source to query. Options:
QUERY_DATA_SOURCE_USER_DATA
- Autocomplete dataQUERY_DATA_SOURCE_CHAT_DATA
- Chat dataQUERY_DATA_SOURCE_COMMAND_DATA
- Command dataQUERY_DATA_SOURCE_PCW_DATA
- Percent Code Written data
Array of field selections to retrieve (see Selections section)
Array of filters to apply (see Filters section)
Array of aggregations to group by (see Aggregations section)
Selections
Selections define which fields to retrieve and how to aggregate them.Field name to select (see Available Fields section)
Alias for the field. If not specified, defaults to
{aggregation_function}_{field_name}
(lowercase)Aggregation function to apply:
QUERY_AGGREGATION_UNSPECIFIED
(default)QUERY_AGGREGATION_COUNT
QUERY_AGGREGATION_SUM
QUERY_AGGREGATION_AVG
QUERY_AGGREGATION_MAX
QUERY_AGGREGATION_MIN
Selection Example
Filters
Filters narrow down data to elements meeting specific criteria.Field name to filter on
Value to compare against
Filter operation:
QUERY_FILTER_EQUAL
QUERY_FILTER_NOT_EQUAL
QUERY_FILTER_GREATER_THAN
QUERY_FILTER_LESS_THAN
QUERY_FILTER_GE
(greater than or equal)QUERY_FILTER_LE
(less than or equal)
Filter Example
Aggregations
Aggregations group data by specified criteria.Field name to group by
Alias for the aggregation field
Aggregation Example
Available Fields
User Data
All User Data is aggregated per user, per hour.Field Name | Description | Valid Aggregations |
---|---|---|
api_key | Hash of user API key | UNSPECIFIED, COUNT |
date | UTC date of autocompletion | UNSPECIFIED, COUNT |
date UTC-x | Date with timezone offset (e.g., “date UTC-8” for PST) | UNSPECIFIED, COUNT |
hour | UTC hour of autocompletion | UNSPECIFIED, COUNT |
language | Programming language | UNSPECIFIED, COUNT |
ide | IDE being used | UNSPECIFIED, COUNT |
version | Windsurf version | UNSPECIFIED, COUNT |
num_acceptances | Number of autocomplete acceptances | SUM, MAX, MIN, AVG |
num_lines_accepted | Lines of code accepted | SUM, MAX, MIN, AVG |
num_bytes_accepted | Bytes accepted | SUM, MAX, MIN, AVG |
distinct_users | Distinct users | UNSPECIFIED, COUNT |
distinct_developer_days | Distinct (user, day) tuples | UNSPECIFIED, COUNT |
distinct_developer_hours | Distinct (user, hour) tuples | UNSPECIFIED, COUNT |
Chat Data
All Chat Data represents chat model responses, not user questions.Field Name | Description | Valid Aggregations |
---|---|---|
api_key | Hash of user API key | UNSPECIFIED, COUNT |
model_id | Chat model ID | UNSPECIFIED, COUNT |
date | UTC date of chat response | UNSPECIFIED, COUNT |
date UTC-x | Date with timezone offset | UNSPECIFIED, COUNT |
ide | IDE being used | UNSPECIFIED, COUNT |
version | Windsurf version | UNSPECIFIED, COUNT |
latest_intent_type | Chat intent type (see Intent Types below) | UNSPECIFIED, COUNT |
num_chats_received | Number of chat messages received | SUM, MAX, MIN, AVG |
chat_accepted | Whether chat was accepted (thumbs up) | SUM, COUNT |
chat_inserted_at_cursor | Whether “Insert” button was clicked | SUM, COUNT |
chat_applied | Whether “Apply Diff” button was clicked | SUM, COUNT |
chat_loc_used | Lines of code used from chat | SUM, MAX, MIN, AVG |
Chat Intent Types
CHAT_INTENT_GENERIC
- Regular chatCHAT_INTENT_FUNCTION_EXPLAIN
- Function explanation code lensCHAT_INTENT_FUNCTION_DOCSTRING
- Function docstring code lensCHAT_INTENT_FUNCTION_REFACTOR
- Function refactor code lensCHAT_INTENT_CODE_BLOCK_EXPLAIN
- Code block explanation code lensCHAT_INTENT_CODE_BLOCK_REFACTOR
- Code block refactor code lensCHAT_INTENT_PROBLEM_EXPLAIN
- Problem explanation code lensCHAT_INTENT_FUNCTION_UNIT_TESTS
- Function unit tests code lens
Command Data
Command Data includes all commands, including declined ones. Use theaccepted
field to filter for accepted commands only.
Field Name | Description | Valid Aggregations |
---|---|---|
api_key | Hash of user API key | UNSPECIFIED, COUNT |
date | UTC date of command | UNSPECIFIED, COUNT |
timestamp | UTC timestamp of command | UNSPECIFIED, COUNT |
language | Programming language | UNSPECIFIED, COUNT |
ide | IDE being used | UNSPECIFIED, COUNT |
version | Windsurf version | UNSPECIFIED, COUNT |
command_source | Command trigger source (see Command Sources below) | UNSPECIFIED, COUNT |
provider_source | Generation or edit mode | UNSPECIFIED, COUNT |
lines_added | Lines of code added | SUM, MAX, MIN, AVG |
lines_removed | Lines of code removed | SUM, MAX, MIN, AVG |
bytes_added | Bytes added | SUM, MAX, MIN, AVG |
bytes_removed | Bytes removed | SUM, MAX, MIN, AVG |
selection_lines | Lines selected (zero for generations) | SUM, MAX, MIN, AVG |
selection_bytes | Bytes selected (zero for generations) | SUM, MAX, MIN, AVG |
accepted | Whether command was accepted | SUM, COUNT |
Command Sources
COMMAND_REQUEST_SOURCE_LINE_HINT_CODE_LENS
COMMAND_REQUEST_SOURCE_DEFAULT
- Typical command usageCOMMAND_REQUEST_SOURCE_RIGHT_CLICK_REFACTOR
COMMAND_REQUEST_SOURCE_FUNCTION_CODE_LENS
COMMAND_REQUEST_SOURCE_FOLLOWUP
COMMAND_REQUEST_SOURCE_CLASS_CODE_LENS
COMMAND_REQUEST_SOURCE_PLAN
COMMAND_REQUEST_SOURCE_SELECTION_HINT_CODE_LENS
Provider Sources
PROVIDER_SOURCE_COMMAND_GENERATE
- Generation modePROVIDER_SOURCE_COMMAND_EDIT
- Edit mode
PCW Data
Percent Code Written data with separate tracking for autocomplete and command contributions.Field Name | Description | Valid Aggregations |
---|---|---|
percent_code_written | Calculated as codeium_bytes / (codeium_bytes + user_bytes) | UNSPECIFIED |
codeium_bytes | Total Codeium-generated bytes | UNSPECIFIED |
user_bytes | Total user-written bytes | UNSPECIFIED |
total_bytes | codeium_bytes + user_bytes | UNSPECIFIED |
codeium_bytes_by_autocomplete | Codeium bytes from autocomplete | UNSPECIFIED |
codeium_bytes_by_command | Codeium bytes from command | UNSPECIFIED |
PCW Filters
Field Name | Description | Examples |
---|---|---|
language | Programming language | KOTLIN, GO, JAVA |
ide | IDE being used | jetbrains, vscode |
version | Windsurf version | 1.28.0, 130.0 |
start_timestamp
and end_timestamp
in the main request body.
Example Requests
User Data Example
Chat Data Example
Command Data Example
PCW Data Example
Response
Example Responses
User Data Response
Chat Data Response
Command Data Response
PCW Data Response
Important Notes
- PCW (Percent Code Written) has high variance within single days or users - aggregate over weeks for better insights
- All selection fields must either have aggregation functions or none should (cannot mix)
- Fields with “distinct_*” pattern cannot be used in aggregations
- Field aliases must be unique across all selections and aggregations
- If no aggregation function is specified, it defaults to UNSPECIFIED