Repository navigation
feat(analytics): every business event names its company - #538
Merged
Merged
Conversation
Business events now carry companyId, and patch events carry ownerUserId beside patchId. A typed catalogue in Analytics.ts declares each event's properties, so an emitter cannot drift from its documented shape. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…people's names Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…orts A manifest's sdkImports is client supplied free text; analytics now keeps only entries shaped like an SDK entry point. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Owner
Author
Codex review (GPT 6.1 Sol, high)Round 1: not safe to merge. Three findings:
Sol confirmed: company attribution and event-time ownership are accurate on all five events, reporting stays personless with no groups, the catalogue is easy to extend, and the tests are focused. |
Owner
Author
Codex review (GPT 6.1 Sol, high)Round 2: safe to merge. Sol accepted the sdkImports fix and both written dismissals, and found nothing new. |
allisonmahmood
added a commit
that referenced
this pull request
Oct 5, 2026
…every request (#540) We can't tell which coding agent builds patches or which CLI versions are in use. The CLI version is stored on each version row but never reaches PostHog, and the agent isn't recorded anywhere. The CLI now names itself on every request it sends to an instance: `Patchy-Cli: <release> <command> <agent>`, such as `Patchy-Cli: 0.0.1 publish codex`. - **Shared contract** (`packages/api/src/cli.ts`): the release pattern (three numbers, no leading zeros), the closed `CliCommand` list (every command that reaches the instance) and the closed `CodingAgent` list ending in `unknown`, with `formatPatchyCli` and `parsePatchyCli`. `docs/API.md` documents the header in the API's description. No endpoint declares it, so no route requires or refuses it. - **CLI.** `Api.client` adds the header, so it goes only to the instance and never to another host. The command is a required `Api.CurrentCommand` service, provided per command in the tree. A command that reaches the instance without a name fails to typecheck. `CodingAgent.detect` returns the first harness whose variable is present and sends only its id, never the value. Each variable is cited from the harness's docs or source. - **Server.** `RequestEvents` parses the header where non-runtime request events open. Each field is kept only when it matches the pattern or its list, so a newer CLI's new agent still records its release. A header that isn't exactly three fields records nothing. The request event gains `cliVersion`, `cliCommand` and `agent`, and `Analytics.CurrentCli` carries the release and agent to `token.minted`, `patch.created` and `patch.updated`. With no header (an older CLI or a browser), nothing extra is recorded. An older server ignores the header. Agents, in detection order, each from a primary source (repo file, vendor docs or a local run): `codex` (`CODEX_THREAD_ID`, set in every sandbox mode), `cursor`, `gemini-cli`, `kilo-code` (before `opencode`, which Kilo also sets), `opencode`, `copilot-cli`, `grok` (`GROK_AGENT=1` only, because people also set it to pick a profile), `crush`, `qwen-code`, `pi`, `augment`, `roo-code`, `cline`, and `claude-code` (`CLAUDE_CODE_CHILD_SESSION`). For Claude Code, its docs say `CLAUDECODE` is also set in IDE terminals people type in. It comes last because nested harnesses inherit their launcher's variables. Not included, because no harness-specific variable could be confirmed: Amp, Goose, Zed, Aider, Factory Droid, Windsurf, Warp and oh-my-pi. Hit every surface: - **Wire contract:** the shared lists and parser, the regenerated `docs/API.md`, the server and the CLI. - **CLI:** `packages/patchy/README.md` (a new section with the variable table) and ADR-0004 (a header subsection). No command, flag or exit code changed, so the global skill doesn't change. - **Vocabulary:** the Publishing **Agent** term, and one sentence on the Analytics **Request event** term (#538 owns that file). - **Operations:** a paragraph in Wide events, and one sentence in #538's Business events section. Dev loop, migrations, company resources, served pages, reverse states and repo layout don't apply. Touching #538's area: the catalogue adds `Cli` to `token.minted`, `patch.created` and `patch.updated`, without changing `Publication`. Tests: - The parser, field by field and for shapes it rejects. - Detection for each agent, nesting, and a person's IDE terminal or Grok profile. - The bundled CLI sends `<release> whoami unknown` with a clean environment and `codex` with `CODEX_THREAD_ID` set, and never the value. - The request event records the parsed fields, hands its handler the release and agent, and records nothing for a missing or malformed header. - `token.minted` and `patch.created` carry the fields when the request named them, and updates without the header carry none. Privacy page: allisonmahmood/patchy-web#23 (ships in the same release; not merged with this). Closes #537 Made by Claude Opus 5.5 via Claude Code in T3 Code. --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This was referenced Oct 5, 2026
allisonmahmood
added a commit
that referenced
this pull request
Oct 6, 2026
…ease (#556) What's new for this deploy, plus the history since the first production deploy. The thin entries #555 seeded by hand are rewritten from what each deploy actually shipped. This is the first run of `AGENTS.md` › Deploying: a fresh subagent gathered and wrote these releases, and I checked them against the PRs. **Release 4 (this deploy, `4a928f7..8697463`)** - New: **See what's new in Patchy** (#555) **Release 3 (2026-10-06, `aed1454..4a928f7`)** - Fixed: **Creating a company explains a handle it can't use** (#553) **Release 2 (2026-10-05, `48153dc..aed1454`)** - Behind the scenes: key moments are recorded, identifying people by id, never by name or email address (#538, #539, #541) - Behind the scenes: the patchy command reports its version, command and coding agent (#540) **Release 1 (2026-10-05, first production deploy, `48153dc`)** - Behind the scenes: Patchy Cloud's first release went live Made by Claude Opus 5.5 via Claude Code in T3 Code. Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PostHog's business events named who acted but not the company, so every company-level number on the product dashboard had to join through a wide event, and
token.mintedhad nothing to join on. Patch events also didn't say who owns the patch.Every business event now carries
companyId, and every patch event carriesownerUserIdbesidepatchId. A typed catalogue inpackages/analytics/src/Analytics.tsdeclares each event's properties.AnalyticsEventis a union keyed byname, so an emitter that sends the wrong properties, or leaves out its company, fails to typecheck.companyIdsits on the event envelope, so catalogue entries never repeat it.tracksends it as a property, and events stay personless, with no groups.token.mintedreads the user's company in the same transaction that mints the token. Publish uses the caller's company and identity; only the owner can publish, so the publisher is the owner. Delete reads both from the deleted row.purgeDeletednow returns the owner it read under its row lock.docs/OPERATIONS.mdgains a "Business events" section covering what reaches PostHog, the principal rule (patchy-instancewhen nobody acted),companyIdandownerUserId, and a list of events by area.packages/analytics/CONTEXT.mdpoints to the catalogue instead of listing events.Hit every surface: vocabulary (
CONTEXT.md) and operations docs applied. The wire contract, CLI, dev loop, migrations, served pages and repo layout were untouched. Company resources:purgeDeletedreads one more column on the row it already locks, with no lock changes.Closes #534
Made by Claude Opus 5.5 via Claude Code in T3 Code.