Product analytics
First implementation set
The integration targets the PostHog ref project, ID 655174, in US Cloud.
The project token is a public ingestion token, not a personal API key.
The source configuration disables collection in local development.
The npm run deploy command enables collection on the production Worker through a variable override.
Deploy only after review. Keep collection disabled in test environments.
Running wrangler deploy without the override disables collection again.
Account events
| Event | Trigger | Allowed event properties |
|---|---|---|
account.signed_up |
Account creation succeeds | entry_path: waitlist, admin, or invitation |
account.approved |
Account activation succeeds | approval_path: waitlist, admin, or invitation |
account.signed_in |
An active account receives a login session | None |
member.joined |
An invitation adds the account to a namespace | namespace_id, role, join_path: new_account or existing_account |
All events use human:<immutable user ID> as their distinct ID.
Common properties are schema_version, subject_kind, is_user_activity, and $geoip_disable.
The subject is the account holder. Approval is not activity by that person.
Admin signup includes automatic approval and login. Separate admin signups from external pilot cohorts.
An invitation signup sends signup, approval, membership, and login together. Approval by invitation is not activity by that person.
An existing account that accepts an invitation sends only member.joined. A join is not proof of team use.
Use signup, approval, and login as separate steps. Approval delay is not user abandonment. Login is not product activation. Activation requires a completed human-reviewed agent work cycle.
Delivery and privacy
The Worker sends events through the PostHog capture API using waitUntil.
Delivery has a five-second timeout. Failures produce a fixed warning without payloads or error details.
Delivery is best-effort, without retries or an outbox. Analytics is not an audit log.
Each capture has a UUID and a timestamp. Separate business calls remain separate events.
Only the listed properties leave the backend. Inputs, emails, handles, passwords, tokens, and IP addresses do not. Raw URLs, repository content, and reasoning do not leave the backend. Replay, browser tracking, and automatic exception capture are not enabled by this set.
Repository adoption events
| Event | Trigger | Entry path |
|---|---|---|
repo.created |
Storage creation and the domain event write succeed | new_project |
repo.imported |
Storage import and the domain event write succeed | import |
repo.forked |
Storage fork and the domain event write succeed | fork |
repo.provision_failed |
Provisioning returns a name conflict or storage failure | The attempted path |
Repository events include immutable namespace and repository IDs, where available.
They include namespace_kind, visibility, actor_kind, subject_kind, auth_method, and is_user_activity.
Failures omit the repository ID and include failure_reason: conflict or storage_unavailable.
Imports include import_provider: github, gitlab, bitbucket, or other.
Provider classification never exports the source hostname, URL, owner, or repository name.
Self-hosted providers use other. Validation and permission failures are not provisioning attempts in this set.
Human actors retain their human:<immutable user ID> identity.
Agent actors use agent:<session ID>, with owner_id linking to their human owner.
Agent events set is_user_activity and $process_person_profile to false.
Do not count agent activity as human engagement. Agent identity is session-level, not a persistent agent identity.
A personal namespace does not prove solo use. An organization namespace does not prove team adoption.
Workspace groups
Each namespace is a PostHog group of type workspace, keyed by the namespace ID.
Repository, work, and member.joined events carry $groups: { workspace: <namespace ID> }.
A successful repository event also sends $groupidentify, which sets the group property kind: user or org.
The group carries no name, slug, or handle. Map workspace IDs to pilot members outside PostHog.
The north-star count is unique workspaces with work.landed per week. Agent events count toward their workspace, not toward human activity.
Group analytics is a paid PostHog add-on. Without it, PostHog ignores $groups, so $group_0 stays empty.
The dashboard counts workspaces with namespace_id instead. The groups start to work if the add-on is enabled.
No event in this set proves that GitHub was replaced, that review happened, or that the user returned.
Agent work-cycle events
| Event | Trigger | Actor |
|---|---|---|
agent.connected |
refs_connect starts a new agent session |
Agent |
task.taken |
refs_take gives the session a pull request or a branch |
Agent |
agent.push_accepted |
refs accepts an agent push to its branch | Agent |
work.landed |
A person merges a pull request | Human |
agent.directed |
A person mentions or assigns a live agent on a pull request or review thread | Human |
review.thread_resolved |
A person resolves a review thread on a pull request | Human |
work.corrected |
A person pushes to a branch a live agent session works on | Human |
work.rejected |
A person closes a pull request without a merge | Human |
commits.recorded |
refs finishes processing a push that added commits to a branch | Human or agent |
All work events include repo_id and namespace_id. Every work event except agent.connected also includes work_key. work_key is the first 16 hex characters of SHA-256 over the repository id and the branch name, so one branch's work can be followed without its name. task.taken keeps its name and is sent for every refs_take.
Events from before the task decoupling also carry task_number. Events after it do not. Tasks are a plain tracker and play no part in agent work.
work.landed includes merge_method: web for the merge button, or push for a merge that a person pushed.
A reconnect to a live session does not send agent.connected.
A merge that refs finds through its reconciliation sweep has no known person, so it sends no event.
Queue retries do not repeat work.landed, because a merged pull request is no longer a merge candidate.
work.landed is the activation event: a person reviewed and landed work.
A pull request does not prove that an agent wrote every commit. Join on repo_id and work_key with agent events to confirm agent work.
Task text, branch names, commit content, and runtime names do not leave the backend.
commits.recorded includes commit_count and decision_count: the commits the push added, and the valid decision records in them.
The counts come from the commits, not from new database rows, so a queue retry after a partial failure sends one event with the same counts.
A queue that delivers a fully processed push twice sends the event twice. Pushes that refs finds through its sweep send no event.
Reading a work cycle
A work cycle is the work on one branch: repo_id with work_key. Order its events by timestamp. Events from before 2026-10-10 have no work_key: key those by task_number, since their branch was always tasks/<task_number>. Events from after the decoupling have no task_number, so use work_key.
- Review rounds:
agent.directedevents after the firstagent.push_accepted. - Human intervention:
work.correctedevents and resolved threads. - Outcome:
work.landedorwork.rejected. A reopened pull request sends no event, so a laterwork.landedoverrides a rejection.
agent.directed includes channel: pull or thread, and assigned. The first direction on a branch is usually the assignment, not a redirect. Older events can have the channel task.
It sends no event when the mention names no live agent session. Mention and comment text never leave the backend.
work.corrected counts a push, not the amount of rewritten code. A person can also push to a branch that no agent touched, so join with agent events.
work.rejected means closed without a merge. The reason can be a duplicate or superseded work, so confirm rejections with the pilot member.
Instructions sent through the session API are not captured in this set.
Live testing after deployment
- Sign in to an approved account on
https://useref.dev. - Create a real repository, or import a public GitHub repository.
- Check the PostHog
refproject's live events for the corresponding account and repository events. - Confirm
entry_path,namespace_id, andrepo_idmatch the intended workflow. - Confirm payloads omit private inputs and source URLs.
- Connect an agent, take a branch, push to it, and merge its pull request.
- Confirm
agent.connected,task.taken,agent.push_accepted, andwork.landedarrive with the samerepo_id.
Use a test account when possible. Mark its identity for exclusion from pilot metrics. Do not create test repositories or accounts automatically in production.
Pilot dashboard
The refs pilot adoption dashboard in the ref project has ten tiles:
| Tile | Type | Measures |
|---|---|---|
| Work-cycle reach (90 days) | SQL | People who reached each step, from signup to work.landed |
| Activated workspaces and people per week | Trend | North star: unique namespace_id values with work.landed, and the people who landed it |
| Repeated landed work | Retention | People who land work again in later weeks |
| Signups by entry path | Trend | account.signed_up by entry_path |
| Repository adoption by path | Trend | Repository events, including provisioning failures |
| Agent work volume | Trend | Agent connections, takes, and accepted pushes |
| Commits and decisions per week | Trend | Sum of commit_count against sum of decision_count |
| Workspace history | SQL table | Per workspace: kind, hours to first landed work, landed and rejected cycles, directions, corrections, weeks with landed work |
| Work-cycle history | SQL table | Per branch: outcome, agent pushes, redirects, corrections, resolved threads, hours from first push to outcome |
| Work after import | SQL table | Per imported repository: agent pushes and landed work after the import |
The reach tile is SQL because agent events use agent:<session> identities. It counts agent steps for the human in owner_id.
The reach tile counts each step independently, not in strict order. Accounts created before collection started have no signup step.
The trend and retention tiles apply the project test-account filter. The SQL tiles do not apply that filter.
With a small pilot, read the history tables as counts and per-workspace stories, not as rates.
Next implementation sets
- Add safe browser navigation and anonymous attribution, after deciding consent and retention rules.
- Add solo and team cohorts from
namespace_kindafter the pilot has enough accounts. - Add application errors and restricted replay after privacy review.
Measure solo developers and small teams separately. Exclude internal, demo, and assisted work when testing unassisted adoption. An import does not prove migration. Repeated real work in refs provides stronger evidence.