Linking Cody as a source
This source is currently in alpha. The interface and available tables may change.
The Cody connector syncs your team's Sourcegraph Analytics data into the PostHog Data warehouse: per-user usage reports for Cody and Code Search (chats, completions, acceptance rates, searches, code navigation) plus credit consumption. Use it to analyze AI coding assistant adoption and seat utilization alongside your product data.
Prerequisites
- Cody and Sourcegraph Analytics are available to Sourcegraph Enterprise customers.
- Your Sourcegraph account needs access to Sourcegraph Analytics for your instance. If you can't sign in there, ask your Sourcegraph contact to link your account to your instance's usage metrics.
Adding a data source
- In PostHog, go to the Sources tab of the data pipeline section.
- Click + New source and click Link next to this source.
- Enter your credentials (see Configuration below) and click Next.
- Select the tables you want to sync, choose a sync method and frequency, then click Import.
Once the syncs are complete, you can start querying this data in PostHog.
You need two values to connect:
- Instance URL – your Sourcegraph instance's host, e.g.
example.sourcegraphcloud.com. - Access token – create one on the Sourcegraph Analytics access tokens page. Tokens are long-lived with an optional expiry.
Sync modes
Each table can be synced in one of several modes, depending on what the source supports:
- Webhook (when available) – the source pushes changes to PostHog in real time. Fastest freshness, lowest ongoing cost, and the only mode that reliably captures updates and deletes.
- Incremental – only new or updated rows are synced on each run, using a cursor field (such as an
updated_attimestamp). Cheaper than a full refresh, but deletes aren't captured. - Append only – new rows are appended using a cursor field; existing rows are never updated. Ideal for immutable, append-only tables like event logs.
- Full refresh – the whole table is reloaded on every sync. Use it when a table has no reliable cursor or when you need deletions reflected.
See sync methods for a full explanation of how each mode works and how to choose between them.
All Cody tables currently sync as full refresh. Sourcegraph refreshes analytics data about once an hour, so recent activity can take up to an hour to appear in a sync.
Configuration
| Option | Type | Required |
|---|---|---|
Instance URL | text | Yes |
Access token | password | Yes |
Supported tables
| Table | Description | Sync method | Incremental field | Primary key |
|---|---|---|---|---|
usage_by_user | All-time usage totals per user (searches, chats, completions, acceptance rates). Full refresh only | Full refresh | — | — |
usage_by_user_month | Monthly usage totals per user. Full refresh only | Full refresh | — | — |
usage_by_user_day | Daily usage totals per user. Full refresh only | Full refresh | — | — |
usage_by_user_day_client_language | Daily usage per user, split by client/editor and programming language (the most detailed report). Full refresh only | Full refresh | — | — |
credits | Credit bucket allocations and consumption for the instance. Full refresh only | Full refresh | — | — |
Troubleshooting
- "Your Sourcegraph Analytics access token is invalid or has expired" – create a new token on the access tokens page and update the source.
- Empty tables – check that the instance URL matches your Sourcegraph instance's host exactly, and that usage telemetry is enabled on your instance (self-hosted instances need Sourcegraph 5.9 or later with telemetry fully enabled).
If your sync is failing or data looks wrong, see the Data warehouse troubleshooting guide. If that doesn't help, contact support – we're happy to help.