Custom Analytics Query
Analytics API
Custom Analytics Query
Flexible analytics querying with custom selections, filters, and aggregations for autocomplete, chat, command, and PCW data.
POST
Custom Analytics Query
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 “Analytics Read” 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 (required): Data source to query
- selections (required): Array of field selections to retrieve
- filters (optional): Array of filters to apply
- aggregations (optional): Array of aggregations to group by
Selections
Selections define which fields to retrieve and how to aggregate them.- field (required): Field name to select
- name (optional): Alias for the field
- aggregation_function (optional): Aggregation function to apply
Selection Example
Filters
Filters narrow down data to elements meeting specific criteria.- name (required): Field name to filter on
- filter (required): Filter operation
- value (required): Value to compare against
Filter Example
Aggregations
Aggregations group data by specified criteria.- field (required): Field name to group by
- name (required): Alias for the aggregation field
Aggregation Example
Available Fields
User Data
All User Data is aggregated per user, per hour.Chat Data
Chat data is separate from Cascade data and represents usage of our legacy, non-agentic plugins
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.
Command Sources
COMMAND_REQUEST_SOURCE_LINE_HINT_CODE_LENSCOMMAND_REQUEST_SOURCE_DEFAULT- Typical command usageCOMMAND_REQUEST_SOURCE_RIGHT_CLICK_REFACTORCOMMAND_REQUEST_SOURCE_FUNCTION_CODE_LENSCOMMAND_REQUEST_SOURCE_FOLLOWUPCOMMAND_REQUEST_SOURCE_CLASS_CODE_LENSCOMMAND_REQUEST_SOURCE_PLANCOMMAND_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.PCW Filters
For date filtering in PCW queries, use
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

