mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use tools through connectors: catalog connectors, custom MCP
servers, and aggregator gateways (Composio, Arcade, Executor) that reach
many apps
> - Connector telemetry sends every custom MCP connector as
`connector_key: "custom"`, and it sends nothing about apps behind an
aggregator
> - The team cannot see which services people add as custom servers, or
which aggregator apps people try to connect and which ones they finish
> - This pull request adds a reduced `server_domain` to the connection
events for custom connectors, and two aggregator app events
> - The benefit is a privacy-safe view of connector demand: no URL, no
subdomain, and no provider-controlled string leaves the installation
## Linked Issues or Issue Description
No issue exists. This follows the feature request template
(`.github/ISSUE_TEMPLATE/feature_request.yml`).
**Subsystem affected**
Server connector telemetry
(`server/src/services/connector-telemetry.ts`), the aggregator app sync
and setup paths
(`server/src/services/tool-access/catalog/aggregator-accounts.ts`), the
tool gateway, and the shared telemetry contract
(`packages/shared/src/telemetry`).
**Problem or motivation**
Connector telemetry sends every connector outside the first-party
catalog as `connector_key: "custom"`, and every app behind Composio as
the `composio` connector. Arcade and Executor apps are hidden the same
way. This hides which servers and apps people actually connect to. It
also hides what they try to connect and fail to connect. The team cannot
use telemetry to decide which connectors to add to the catalog or where
setup fails.
**Proposed solution**
For custom connectors only, send the registrable domain of the server
(`server_domain`), with IP, private, and local hosts reduced to
`private` and stdio servers to `stdio`. Send `connection.app_requested`
when a person or agent asks an aggregator to add an app, with the
result, and `connection.app_linked` when that app becomes connected. The
app is a slug from the checked-in aggregator catalog, or `other`. No
user-controlled string leaves the process.
**Alternatives considered**
Sending the full host was rejected: subdomains can name a customer or
tenant. Hashing the host was rejected: it cannot be read in an insight,
and short domains are easy to reverse. Sending the provider's toolkit
name was rejected: Executor and custom integrations use names that
people choose.
## What Changed
- Sync the generated telemetry contract. The telemetry backend registers
`server_domain` and the two new events first, so nothing is dropped as
unregistered.
- `server/src/services/connector-telemetry.ts`:
- `serverDomainForUrl()` reduces a configured address to its registrable
domain (ICANN public suffix plus one label, from `tldts`).
`mcp.smithery.ai/sse?token=…` becomes `smithery.ai`. IPs, loopback,
single-label hosts, non-ICANN or special-use suffixes (`.local`,
`.internal`, `.home.arpa`, `.onion`), non-HTTP schemes, and unparsable
values become `private`. A final pattern check makes sure nothing
URL-shaped can pass.
- `server_domain` goes on `connection.created`, `connection.updated`,
and `connection.invoked` only when `connector_key` is `custom`. Local
stdio servers send `stdio`. A remote connection with no address yet
omits it.
- `aggregatorAppTelemetrySlug()` returns a slug from the shared
aggregator catalog, or `other`. This is the same rule as
`connector_key`.
- `newlyLinkedToolkits()`, `emitAggregatorAppsLinked()`,
`emitAggregatorAppsRequested()`, and
`emitAggregatorAppRequestsFromToolCall()`. All are best-effort and never
throw.
- `aggregator-accounts.ts`: the Composio list check and the
Arcade/Executor inventory sync read the previous snapshot status before
the write. They send `connection.app_linked` only for a change to
`connected`. The Composio check sends it right after each saved row, so
a later app that fails in the same check does not lose it, and it
updates the stored status after each write, so an app named twice in one
check sends one event. The Composio upsert now returns its row, so a
write that loses to a newer observation sends nothing. App setup `start`
and account `add` send `connection.app_requested` (`origin: user`) with
`succeeded`, `needs_auth`, or `failed`.
- `tool-gateway.ts`: one call after the remote MCP response is parsed.
An agent's `COMPOSIO_MANAGE_CONNECTIONS` call with `add` sends one
`connection.app_requested` (`origin: agent`) per app.
`composioAddOutcomes()` parses the response once and reads each app's
own result node: connected is `succeeded`, its own sign-in link is
`needs_auth`, an error or no node is `failed`. A sibling's link never
counts; the response-wide link counts only when one app was added. An
Arcade tool call that answers with an authorization step sends
`needs_auth`.
- `connection-methods.ts`: `remoteEndpointValue()` shares the `url` →
`endpoint` → `remoteUrl` order with `remoteEndpoint()`.
- `server/package.json`: add `tldts` 7.4.10 as a direct dependency. It
is already in the lockfile through `tough-cookie`. The lockfile is left
to CI.
- Shared telemetry: typed helpers `trackConnectionAppLinked` and
`trackConnectionAppRequested`, `server_domain` on the three connection
helpers, retention class `operational_enum_count` for the new events,
and a "Connector Events" section in the telemetry README.
## New Dependency
`tldts` 7.4.10 (MIT) is added to `server/package.json`.
- Why: `server_domain` must be the registrable domain (eTLD+1), so
`mcp.example.co.uk` gives `example.co.uk` and not `co.uk`. That needs
the Public Suffix List. No runtime dependency in the repo parses it.
`new URL()` and `node:net` give only the hostname and IP detection.
Splitting on the last two labels is wrong for multi-part suffixes such
as `co.uk` and would leak or merge domains.
- Already in the tree: `tldts` 7.4.10 is in `pnpm-lock.yaml` through
`jsdom` → `tough-cookie`, a dev-only path. This PR makes it a direct
server dependency at the same version, so no new package is downloaded.
- Size: about 125 KB minified (`dist/index.cjs.min.js`), with one
dependency, `tldts-core` (same author). It bundles the suffix list, so
it does no network or file reads at run time.
- Maintenance: actively maintained (latest release this month), widely
used (it is the suffix parser in `tough-cookie`), with typed exports.
## Verification
- `pnpm exec vitest run src/services/connector-telemetry.test.ts`
(server): 65 pass, including a sibling's link, a top-level link with
several apps, and the one-app fallback. New cases cover domain reduction
(paths with tokens, userinfo, ports, uppercase, trailing dot, IDN,
`github.io` and `vercel.app` subdomains dropped), `private` for IPv4,
IPv6, loopback, `.local`, `.internal`, `.home.arpa`, `.onion`,
single-label, unknown suffix, `ftp:`, and non-strings, a payload check
that no part of a secret-bearing URL appears in any of the three events,
catalog-or-`other` for every provider, a check that every catalog slug
matches the registered `app` pattern, and the transition rule.
- `pnpm exec vitest run src/__tests__/composio-app-setup.test.ts
src/__tests__/aggregator-app-sync.test.ts` (embedded Postgres): 36 pass,
including an app named twice in one check (fails without the fix).
Composio: setup `start` sends one `needs_auth` request; refreshes while
the account is only initiated send nothing; activation sends exactly one
`app_linked` over three refreshes and a `complete`; an app saved before
a later app fails in the same check keeps its `app_linked`; an
unconfirmed `add` sends `failed`. Executor: two syncs send one
`app_linked`; a disconnect sends nothing. Agent requests: mixed per-app
results give `succeeded`, `needs_auth`, and `failed` separately.
- Red check: with the previous-status check or the domain reduction
removed, 13 of these tests fail.
- `pnpm exec vitest run src/telemetry` (shared): 46 pass, including the
real client sending `server_domain` and both new events.
- Related suites still pass: connector telemetry for tool access and the
gateway, Circleback parity, aggregator fallback, connection intents, MCP
protocol versions, MCP tasks, remote MCP connectors, remote MCP pending
(265 tests).
- `tsc --noEmit` reports no errors in the changed files.
- `tests/runner-e2e/source-sdk-public-inputs.json` is regenerated with
`node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --write`,
because it pins the shared telemetry files. `--check` and
`source-sdk-public-inputs.test.mjs` (13) pass.
- CI note: on d501fe5272, `General tests (server (5/12))` failed on a 15
s timeout in
`src/services/native-runtime/provider-pack-archive.test.ts`. That test
does not touch this change, and it passes locally (52/52). `Build` and
`e2e shard (2/8)` were cancelled by a runner shutdown. The next push
re-ran all three.
## Privacy Review
Privacy review: approved by repo owner (@cryppadotta) on 2026-11-23, for
sending the registrable domain of custom MCP servers, with domains seen
in fewer than 3 workspaces hidden in dashboards.
Privacy review requested. This is a Telemetry change under
`rules/data-paths.mdc`: it updates the generated contract and the
telemetry README, and it adds one reduced host value. Please confirm:
- `server_domain` is sent only for `connector_key: "custom"`. It holds
only the registrable domain. The path, query, port, credentials, and
subdomains are dropped in the app, and the registered schema pattern
rejects them too.
- IP, loopback, private, single-label, and special-use hosts send the
fixed value `private`. Local servers send `stdio`.
- `app` on the two new events is a slug from the checked-in aggregator
catalog, or `other`. The provider's toolkit string, app name, and
account name are never sent.
- `provider`, `origin`, and `outcome` are closed enums.
- Retention for the two new events is `operational_enum_count` (90
days).
- Analyses must hide domains seen in fewer than 3 workspaces.
## Risks
- Low product risk. Every emitter catches its own errors, and the
gateway call sits before existing control flow without changing it.
- Privacy: a self-hosted MCP server on a personal domain still sends
that domain. Analyses hide domains seen in fewer than 3 workspaces.
- `connection.app_linked` is best-effort. Two syncs for the same person
that run at the same time can both read the old status and send twice.
- Agent requests that fail before a response is parsed (HTTP error,
timeout) are not counted. Executor approval steps are not counted as app
requests.
- Each agent retry of a call that needs authorization sends one more
`needs_auth` request.
## Model Used
Claude Opus 5.5 (`claude-opus-5-5`) via Claude Code, with tool use and
code execution.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
411 lines
23 KiB
Markdown
411 lines
23 KiB
Markdown
# Telemetry Data Contract
|
|
|
|
This document explains how contributors should use Paperclip's public telemetry
|
|
contract. It does not duplicate the full list of individual events or
|
|
dimensions. It documents extra semantic and privacy rules where the generated
|
|
shape is not sufficient.
|
|
|
|
The canonical source for first-party event names, dimensions, optionality,
|
|
allowed primitive value types, and enum descriptions is
|
|
`packages/shared/src/telemetry/generated/paperclip-telemetry.ts`.
|
|
|
|
Shared enum constants live in `packages/shared/src/constants.ts`. Use those
|
|
constants when code needs a reusable domain, but treat the generated telemetry
|
|
types as the final authority for emitted first-party telemetry shapes.
|
|
|
|
## Public Sources
|
|
|
|
Use these files when reviewing or changing telemetry code:
|
|
|
|
| Contract item | Public source |
|
|
| --------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
| First-party event names | `PaperclipEventName` in `generated/paperclip-telemetry.ts` |
|
|
| Per-event dimensions and optionality | `EventDimensionsMap` in `generated/paperclip-telemetry.ts` |
|
|
| Enum descriptions for telemetry dimensions | `PAPERCLIP_ENUM_DESCRIPTIONS` in `generated/paperclip-telemetry.ts` |
|
|
| Schema version and event envelope helpers | `SCHEMA_VERSION`, `makeEvent()`, and `makeBatch()` in `generated/paperclip-telemetry.ts` |
|
|
| Runtime-safe event names and dimensions | `TelemetryEventName` and `TelemetryEventDimensions` in `types.ts` |
|
|
| Allowed primitive dimension values | `TelemetryDimensionValue` in `types.ts` |
|
|
| Shared reusable enum domains | Named exports in `constants.ts` |
|
|
| First-party typed emit helpers | `events.ts` |
|
|
| Generic client behavior | `client.ts` |
|
|
| Retention windows and event class assignments | `RETENTION_DAYS` and `EVENT_RETENTION_CLASS` in `retention.ts` |
|
|
|
|
Do not copy generated event lists or dimension tables into this README. They
|
|
will drift as the generated contract changes.
|
|
|
|
## Emission Boundary
|
|
|
|
Paperclip telemetry uses named events with explicit dimension fields. Treat
|
|
open-ended string dimensions as public contract values, not as a place for user
|
|
content or private operational data. Do not send PII, secrets, credentials,
|
|
private paths, prompts, model output, or other sensitive values through
|
|
telemetry dimensions.
|
|
|
|
Telemetry emitters send raw dimension values. They must not pre-normalize
|
|
enum-like values into a reporting form just to match today's known domain.
|
|
|
|
The receiving layer owns canonicalization. Keeping canonicalization in one place
|
|
means emitters can stay simple and accurate: emit what the product observed, use
|
|
the generated contract for required and optional fields, and let the receiving
|
|
layer decide how legacy spellings, aliases, unknown names, and future values map
|
|
to a stable reporting shape.
|
|
|
|
Do not add client-side lowercasing, alias mapping, or fallback mapping unless
|
|
the generated telemetry contract specifically requires that emitted value.
|
|
|
|
The `adapter_type` dimension on `agent.task_run` and `agent.task_completed` is
|
|
not an alias map. For a Paperclip runner agent, the server sends the harness
|
|
that `agentHarnessType()` resolves from the agent configuration. The receiving
|
|
layer does not get that configuration, so it cannot derive the harness from
|
|
`paperclip_runner`. The emitter sends the resolved value raw. It does not fall
|
|
back to `other`.
|
|
|
|
If a dimension is privacy-protected before emission, emit only the protected
|
|
value and its matching public marker as defined by the typed helper or generated
|
|
contract. Do not emit private source material in telemetry dimensions.
|
|
|
|
Credential-bearing chat setup failures replace provider-controlled error names,
|
|
messages, and stacks with a fresh generic error before the HTTP error handler
|
|
reports the crash. The existing `error.handler_crash` event still uses its
|
|
generated `error_code: string` contract; this path emits only `Error`, never a
|
|
provider-supplied error name that may contain a credential. This is a privacy
|
|
boundary, not enum canonicalization. Test the value reaching the telemetry
|
|
helper as well as the separate crash-reporting and local logging sinks.
|
|
|
|
## Server Startup Privacy
|
|
|
|
The startup helper emits the raw Node.js operating system family once when an
|
|
enabled server telemetry client initializes. It omits OS versions, CPU
|
|
architecture, hostnames, and other machine details. The usual telemetry opt-out
|
|
and CI suppression apply before client initialization. If state storage fails
|
|
at startup, the server disables telemetry for that process and continues to run.
|
|
The warning contains no storage path or underlying error. Container and WSL servers
|
|
report their runtime platform; this does not identify the underlying physical
|
|
host's OS. Count distinct installation identifiers by platform to compare
|
|
installations, since restart event counts also reflect restart frequency.
|
|
|
|
Contract syncs may also register existing proposals. Remove each adopted
|
|
proposal marker and update its helper and transport tests in the same change.
|
|
The connector helpers preserve raw enum values and send only catalog connector
|
|
keys and the approved lifecycle and invocation dimensions. Connection names,
|
|
credentials, tool arguments, and tool results stay out of those events.
|
|
|
|
## Interaction Resolver Events
|
|
|
|
`interaction.created` records the interaction kind and whether the create
|
|
request used a deprecated resolver-policy alias. It does not record the prompt,
|
|
title, options, questions, target identifier, creator identifier, or resolver
|
|
identifier.
|
|
|
|
`interaction.resolved` records the low-cardinality interaction outcome defined
|
|
in the generated contract. Its `legacy_inherited_restriction` dimension is
|
|
`true` only when stored migration provenance preserves a legacy resolver-policy
|
|
restriction. It is `false` for canonical new writes. This dimension describes
|
|
policy provenance. It does not contain user content or an identifier.
|
|
|
|
Emit `interaction.resolved` only after the complete decision transaction commits.
|
|
Conversational answers include the card outcome, source-message reference, and
|
|
activity audit in that transaction. A rollback or matching retry must not emit
|
|
a resolution event. This changes emission timing only: message text, comment IDs,
|
|
and user IDs remain in the instance database and are not added to telemetry.
|
|
|
|
Use `trackInteractionCreated()` and `trackInteractionResolved()` from
|
|
`events.ts` to emit these events. The generated contract remains the authority
|
|
for their exact dimensions and optionality.
|
|
|
|
## Agent Task Run Events
|
|
|
|
`agent.task_run` records one terminal state for one agent run: `succeeded`,
|
|
`interrupted`, `failed`, `cancelled`, or `timed_out`. Emit it once per run, at
|
|
the run's terminal transition. Do not emit it for a run that is still active.
|
|
|
|
The event's `task_id` dimension is optional and privacy-protected. Never emit
|
|
the raw task id. Pass the raw id to `trackAgentTaskRun()` in `events.ts`. The
|
|
helper calls `hashPrivateRef()` on `client.ts`, which derives the emitted
|
|
value with a salted hash of the per-installation secret.
|
|
|
|
Use `trackAgentTaskRun()` to emit this event. The generated contract remains
|
|
the authority for its exact dimensions and optionality.
|
|
|
|
Failed, timed-out, and interrupted runs also carry `failure_cause`. The server
|
|
picks this code from the run's stored error code and its provider failure
|
|
category, in `server/src/services/agent-task-run-telemetry.ts`. The code is a
|
|
fixed enum. It never contains error text, provider messages, or SQL. An error
|
|
code that the mapping does not know is sent as `unknown`. The provider failure
|
|
category decides the code only for the generic `adapter_failed` and
|
|
`provider_failed` codes, or when there is no error code. The mapping reuses the
|
|
run failure code sets in `server/src/services/continuation-cause.ts`, and a
|
|
test fails when a code in those sets has no telemetry code.
|
|
|
|
The `adapter_type` dimension on `agent.task_run` and `agent.task_completed`
|
|
reports the harness the agent runs, as `agentHarnessType()` resolves it. A
|
|
Paperclip runner agent therefore reports its underlying harness (for example
|
|
`claude_local` or `codex_local`), not `paperclip_runner`. The one rename is the
|
|
Copilot harness: `agentHarnessType()` returns `acpx:copilot`, and telemetry
|
|
sends `copilot_runtime`, the name `agentRuntimeSettingsHarness()` also uses.
|
|
Every runner harness is in the generated `adapter_type` enum. A test in
|
|
`server/src/__tests__/agent-task-run-telemetry.test.ts` fails when a runner
|
|
harness is missing from the contract. Add it to the telemetry-backend schema
|
|
first, then copy the regenerated contract here.
|
|
|
|
## Product Lifecycle Events
|
|
|
|
`model.connected`, `task.created`, `task.completed`, `task.blocked`,
|
|
`plan.created`, `plan.approved`, and `artifact.created` describe the main
|
|
product path. Their dimensions are enums, booleans, and counts only. They never
|
|
contain a task title, a document body, a plan step, a connection or account
|
|
name, an email, a URL, a repository name, or an endpoint address.
|
|
|
|
The server emits these events through
|
|
`server/src/services/product-telemetry.ts`. Each emit site runs inside the
|
|
transaction that writes the change, and the helper sends the event only after
|
|
that transaction commits (`afterTransactionCommit` in `@paperclipai/db`). A
|
|
rolled-back write sends nothing. This includes a write in a savepoint that
|
|
rolls back while the outer transaction commits. The
|
|
helper also wraps the track call in `withTelemetryCompany()`, so Cloud direct
|
|
delivery gets the company for background writes.
|
|
|
|
These rules keep one event per real change:
|
|
|
|
- `task.created` is sent for a newly inserted task only. Chat conversations,
|
|
company imports, and create requests that return an existing task do not send
|
|
it. `created_by_kind` is `routine` for a routine-run task and `onboarding` for
|
|
the first task from the onboarding wizard. Otherwise it is the acting kind.
|
|
- `task.completed` and `task.blocked` are sent when a task's status changes
|
|
from another value to `done` or `blocked`. Writing the same status again
|
|
sends nothing. `issueService.update` covers most writers. The two direct
|
|
writers that block a task (the dispatch check for unrunnable workspace
|
|
settings and execution recovery) call the same helper as a system write.
|
|
A new direct status writer must call it too.
|
|
- `blocked_reason` is derived at the transition. A blocking task that is not
|
|
done gives `waiting_on_task`. A cancelled blocker counts, because it stays
|
|
unresolved until someone changes the relation. Otherwise, the unblock owner gives `waiting_for_person` or
|
|
`waiting_for_agent`. A system write with neither gives `needs_recovery`. A
|
|
person or agent write with neither gives `unspecified`.
|
|
- `plan.created` is sent for the first revision of a task's `plan` document
|
|
only.
|
|
- `plan.approved` is sent when a person or agent accepts a confirmation request
|
|
whose target is the task's `plan` document.
|
|
- `model.connected` is sent for a new AI provider connection. A reconnect of an
|
|
existing connection does not send it.
|
|
- `artifact.created` is sent for a new task work product. A work product
|
|
provider outside `paperclip`, `github`, `vercel`, and `s3` is sent as
|
|
`custom`, so a private service name never leaves the installation.
|
|
|
|
The actor kind is `agent` when an agent acts, `user` when a person acts, and
|
|
`system` when neither does.
|
|
|
|
On Cloud direct delivery, each of these events also names the responsible
|
|
person with `withTelemetryActor()` and `resolveTelemetryPerson()`: the task
|
|
creator, else the task's responsible user, else the run owner (the acting
|
|
person, the plan author, or the user who owns the model connection). A live
|
|
request still wins. The self-hosted collector envelope does not change.
|
|
|
|
## Connector Events
|
|
|
|
`connection.created`, `connection.updated`, and `connection.invoked` describe
|
|
tool connectors. `connection.app_linked` and `connection.app_requested`
|
|
describe apps reached through the Composio, Arcade, and Executor aggregator
|
|
gateways. The server emits all of them through
|
|
`server/src/services/connector-telemetry.ts`.
|
|
|
|
- `connector_key` is a slug from the shared connector catalog. Every other
|
|
connection, including custom MCP servers and plugin connectors, sends the
|
|
literal `custom`.
|
|
- `server_domain` is sent only when `connector_key` is `custom`. It is the
|
|
registrable domain of the remote server (the ICANN public suffix plus one
|
|
label, from `tldts`), so `mcp.example.com/sse?token=...` sends `example.com`.
|
|
The path, query, port, credentials, and subdomains are never sent. IP
|
|
addresses, loopback, single-label hosts, non-ICANN or special-use suffixes
|
|
(such as `.local`, `.internal`, `.home.arpa`, `.onion`), non-HTTP schemes,
|
|
and unparsable addresses send `private`. Local stdio servers send `stdio`. A
|
|
remote connection with no address yet omits the field.
|
|
- `app` is a slug from the shared aggregator app catalog
|
|
(`aggregator-app-catalog.ts`), resolved from the provider's toolkit name.
|
|
Every other toolkit, including Executor custom integrations, sends `other`.
|
|
The provider's own app name or account name is never sent.
|
|
- `connection.app_linked` is sent when a person's cached app observation
|
|
changes to `connected` from any other status or from no observation. A
|
|
re-sync that finds the app still connected sends nothing.
|
|
- `connection.app_requested` is sent once per request to add an app: from
|
|
the app setup screens (`origin: user`), or from the tool gateway when an
|
|
agent calls `COMPOSIO_MANAGE_CONNECTIONS` with `add`, or when an Arcade tool
|
|
call answers with an authorization step (`origin: agent`). `outcome` is
|
|
read from each app's own result: `needs_auth` when the provider returns a
|
|
sign-in step for that app, `succeeded` when the app is connected, and
|
|
`failed` otherwise. A sign-in link for another app in the same request
|
|
never counts.
|
|
|
|
## Cloud Direct Delivery
|
|
|
|
Self-hosted installs are unchanged. They post every batch to the collector,
|
|
private references stay hashed by `hashPrivateRef()`, and the collector and
|
|
its loader apply their anonymization. A self-hosted server never loads
|
|
`posthog-node`.
|
|
|
|
A Paperclip Cloud stack can send telemetry straight to PostHog instead. The
|
|
server turns this on only when the instance is Cloud-managed and
|
|
`PAPERCLIP_POSTHOG_PROJECT_TOKEN`, `PAPERCLIP_CLOUD_STACK_ID`, and
|
|
`PAPERCLIP_POSTHOG_ENVIRONMENT` are set.
|
|
`PAPERCLIP_POSTHOG_DIRECT=0` sends through the collector again. The server owns
|
|
this transport (`server/src/services/posthog-direct/`). This package only
|
|
exposes the `TelemetryTransport` seam on `TelemetryClient`:
|
|
|
|
- With a transport, each flushed batch goes to the transport and never to the
|
|
collector. One batch has exactly one sender.
|
|
- A transport with `hashesPrivateRefs: false` makes the typed helpers emit raw
|
|
task ids. Private source refs (for example a private repository name) are
|
|
customer content, not identifiers, so they stay hashed on every path and
|
|
`source_ref_hashed` stays `true` for them.
|
|
- The transport can capture per-event context at track time. That context is
|
|
never added to the collector envelope.
|
|
- Background work (heartbeat runs, routine runs, connection invocations, and
|
|
interactions) has no request. The server emit site wraps the track call in
|
|
`withTelemetryCompany(companyId, fn)` from
|
|
`server/src/telemetry-company-scope.ts`, with the company of the entity it
|
|
reports on. Only the direct transport reads this scope, and it uses it only
|
|
when no live request supplies a company. The collector envelope and the
|
|
dimensions do not change.
|
|
- Agent-driven events (`agent.task_run`, `agent.task_completed`, and
|
|
`agent.first_heartbeat`) also name the person responsible for the work, with
|
|
`withTelemetryActor({ companyId, person }, fn)` and
|
|
`resolveTelemetryPerson()` from the same file. The person is the user who
|
|
created the task, else the task's responsible user (who assigned or
|
|
delegated it), else the user who owns the run (for `agent.first_heartbeat`,
|
|
the user who created the agent). The emit site reads these ids from rows it
|
|
already loads; the transport does no database reads. A signed-in user on a
|
|
live request always wins over this scope. With no person, the event stays on
|
|
`workspace:<stackId>` with `$process_person_profile: false`. Every direct
|
|
event carries `attributed_via`: `request`, `task_creator`, `task_assigner`,
|
|
`run_owner`, or `none`. The collector path never reads this scope, so the
|
|
self-hosted envelope does not change.
|
|
|
|
Cloud is Paperclip's own service under the Cloud terms, so its events carry
|
|
real identifiers: raw agent and task ids, the stack id, and the company and
|
|
acting user ids when known. Event names, dimension names, metadata keys, the
|
|
deterministic event uuid, and enum fallback normalization stay the same as the
|
|
collector path, so existing insights keep working. Request headers from the
|
|
browser SDK only link an event to a browser session. They never set identity
|
|
or grant access. Do not use this path to send fields that are not in the
|
|
generated contract.
|
|
|
|
On each start, a Cloud server with direct delivery also sends one
|
|
`cloud.workspace_started` event and a workspace `$groupidentify`, straight
|
|
through the PostHog client. Neither is in the generated contract, and neither
|
|
goes through `TelemetryClient` or the collector. The event carries
|
|
`install_hash`, the sha256 of the install id, which is the same value the
|
|
collector stores as `install_id`. It lets an offline job join a workspace's
|
|
pre-switch history. No other event carries `install_hash`.
|
|
|
|
### Other Data Paths
|
|
|
|
This document covers Paperclip Telemetry only. The generated Telemetry
|
|
contract covers neither the Observability path nor the run-log path. Two other
|
|
data paths document their own contract in their own file:
|
|
|
|
- [Observability](../../../../doc/observability.md) — the operator-enabled
|
|
OpenTelemetry trace path and Sentry error monitoring.
|
|
- [Run-Log Events](../../../../doc/run-log-events.md) — events written to the
|
|
local `heartbeat_run_events` table.
|
|
|
|
## Dimension Values
|
|
|
|
Telemetry dimension values must be primitives. Use only the value types allowed
|
|
by `TelemetryDimensionValue`:
|
|
|
|
- `string`
|
|
- `number`
|
|
- `boolean`
|
|
|
|
Do not emit `null`, `undefined`, arrays, or objects as dimension values. Optional
|
|
dimensions should be omitted when absent.
|
|
|
|
When a dimension is enum-like, use the shared constant from `constants.ts` when
|
|
one exists. If no shared constant exists, use the generated telemetry type as the
|
|
domain. In all cases, the generated telemetry type remains the source of truth
|
|
for the emitted value.
|
|
|
|
## Required, Optional, And Sentinel Values
|
|
|
|
Required and optional dimensions are defined by `EventDimensionsMap`.
|
|
|
|
Required dimensions must be present for every event of that name. Optional
|
|
dimensions should be emitted only when the value is known and useful.
|
|
|
|
Sentinel values are only for required fields that have no observed raw value at
|
|
the emitting layer. Do not use a sentinel to hide a concrete value that is new,
|
|
custom, or not yet represented by a shared constant. Emit the concrete raw value
|
|
and let the receiving layer canonicalize it.
|
|
|
|
## Adding Or Changing Telemetry
|
|
|
|
Client code is responsible for emitting approved telemetry events at the right
|
|
place in the product. Stable event names, dimensions, and enum domains must come
|
|
from the generated telemetry contract before normal emitters use them.
|
|
|
|
For product work that needs to propose a new first-party event before schema
|
|
registration, use the proposal marker workflow in `doc/TELEMETRY_WORKFLOW.md`.
|
|
Those proposed calls stay on `client.track()`, carry an `@ts-expect-error`
|
|
marker on the event-name argument, and are swallowed at runtime until the
|
|
generated schema registers the event name.
|
|
|
|
For stable event work:
|
|
|
|
1. Start from `generated/paperclip-telemetry.ts`. The generated types are what
|
|
reviewers use to verify event names, dimensions, optionality, value types,
|
|
enum descriptions, and schema version.
|
|
2. Choose stable event and dimension names. Do not include user content, local
|
|
machine details, secrets, credentials, private paths, or values that are not
|
|
part of the public event contract.
|
|
3. Use only `string`, `number`, or `boolean` dimension values.
|
|
4. Reuse a shared constant from `constants.ts` for enum-like dimensions when one
|
|
exists. If the generated telemetry domain has values beyond a shared constant,
|
|
keep the emitter aligned with the generated telemetry type.
|
|
5. Keep emitters raw. Do not normalize, alias-map, or lowercase enum-like values
|
|
in the client unless the generated contract explicitly calls for that emitted
|
|
value.
|
|
6. Add or update a typed helper in `events.ts` when the event is first-party and
|
|
should have a stable helper API.
|
|
7. Update tests for helper behavior, including raw pass-through for enum-like
|
|
values when that is the intended boundary.
|
|
8. Keep the telemetry transport contract assertions in `client.test.ts`, which
|
|
owns the emitted-envelope, retry, and payload-size boundaries.
|
|
9. Update this README only when the contributor workflow, source-of-truth
|
|
pointers, or durable invariants change. Do not add an event catalog here.
|
|
|
|
Before opening a pull request, verify that the emitted code, typed helpers, and
|
|
generated telemetry contract agree. If they disagree, fix the contract or code
|
|
rather than documenting around the mismatch in this README.
|
|
|
|
For new first-party events that are not in the generated contract yet, follow
|
|
the public proposal and promotion workflow in
|
|
[`doc/TELEMETRY_WORKFLOW.md`](../../../../doc/TELEMETRY_WORKFLOW.md).
|
|
|
|
## Retention
|
|
|
|
Retention windows are documented in `retention.ts`. Each event is assigned a
|
|
retention class; the class determines the window in days. This is a
|
|
housekeeping and query-cost concern managed by data-infra, not a schema
|
|
concern — updating a retention window does not require a schema version bump.
|
|
|
|
Current classes:
|
|
|
|
| Class | Window | Description |
|
|
| ------------------------ | ------- | ------------------------------------------------------------ |
|
|
| `operational_enum_count` | 90 days | Enum/boolean/count/bucket events. No token material, no PII. |
|
|
|
|
When a new event carries only enums, booleans, counts, or coarse buckets and
|
|
no token material or PII, assign it to `operational_enum_count` in
|
|
`EVENT_RETENTION_CLASS`. If no existing class fits, define a new class in
|
|
`RETENTION_DAYS` and document it here.
|
|
|
|
## GitHub-synced skills
|
|
|
|
The legacy import endpoint retains `skill.imported` with its existing `source_type`.
|
|
For source-managed GitHub skills, `skill_ref` is omitted, including public sources:
|
|
the saved repository may be private and its key contains user-authored names.
|
|
Source discovery, selection, and refresh add no first-party telemetry events.
|
|
Repository URLs, paths, commits, connection IDs, names, and file contents stay out
|
|
of these telemetry dimensions. Review this suppression in privacy review alongside
|
|
changes to the legacy import caller; the event schema and envelope are unchanged.
|