Skip to main content
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

service_key
string
required
Your service key with “Analytics Read” permissions
group_name
string
Filter results to users in a specific group (optional)
query_requests
array
required
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
All Chat Data represents chat model responses, not user questions.

Chat Intent Types

  • CHAT_INTENT_GENERIC - Regular chat
  • CHAT_INTENT_FUNCTION_EXPLAIN - Function explanation code lens
  • CHAT_INTENT_FUNCTION_DOCSTRING - Function docstring code lens
  • CHAT_INTENT_FUNCTION_REFACTOR - Function refactor code lens
  • CHAT_INTENT_CODE_BLOCK_EXPLAIN - Code block explanation code lens
  • CHAT_INTENT_CODE_BLOCK_REFACTOR - Code block refactor code lens
  • CHAT_INTENT_PROBLEM_EXPLAIN - Problem explanation code lens
  • CHAT_INTENT_FUNCTION_UNIT_TESTS - Function unit tests code lens

Command Data

Command Data includes all commands, including declined ones. Use the accepted field to filter for accepted commands only.

Command Sources

  • COMMAND_REQUEST_SOURCE_LINE_HINT_CODE_LENS
  • COMMAND_REQUEST_SOURCE_DEFAULT - Typical command usage
  • COMMAND_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 mode
  • PROVIDER_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

queryResults
array
Array of query results, one for each query request
responseItems
array
Array of result items
item
object
Object containing the selected fields and their values

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