Repository navigation
Batch telemetry through a getbb.app Worker and count threads and messages - #8402
Merged
Merged
Conversation
…ages The bb server no longer sends one PostHog event per message and per thread. Threads and messages are counted per day, provider and initiator and sent as usage_counts events; other events are queued. Batches go about once a minute and at shutdown to BB_TELEMETRY_URL (getbb.app/api/telemetry/v1/batch) in bb's own format, kept in telemetry-outbox.json until accepted. The new apps/telemetry Worker validates batches, adds coarse location from Cloudflare without forwarding the IP, and forwards them to PostHog without person profiles. The PostHog key moves out of the app, so the backend can change without a release. A new install id file (telemetry-id-v2) stops old person profiles from upgrading events to identified billing. new_thread_submit is only sent for failed submits.
This comment has been minimized.
This comment has been minimized.
scowalt
pushed a commit
to scowalt/bb
that referenced
this pull request
Dec 1, 2026
…ages (get-bb#8402) Cuts bb's PostHog volume and puts a Worker of ours between bb and PostHog, so the analytics backend can change without an app release. ## Why About 3.7M events a week, most of them `user_message_sent` (2.4M) and `thread_created` (746k), many from automations, plugins and duplicate first messages. Releases before 0.50.1 also created person profiles, so later events were billed as identified. Projected bill for this period: about $1,425. ## What changes **bb server** (`apps/server/src/services/system/telemetry.ts`, `telemetry-outbox.ts`) - Threads and messages are counted per day, provider and initiator, and sent as one `usage_counts` event each (`period: "day"`, `period_start`, `threads_created`, `messages_sent`). Automated threads and messages are still counted. - Other events are queued and sent in batches about once a minute and at shutdown to `BB_TELEMETRY_URL` (default `https://getbb.app/api/telemetry/v1/batch`), in bb's own format. - Unsent telemetry lives in `telemetry-outbox.json` (not `bb.db`). A batch is resent with the same event ids until the Worker accepts it; opting out sends what was recorded, then deletes the file. - New install id file `telemetry-id-v2`, so old person profiles stop upgrading events to identified billing. - `BB_TELEMETRY_URL` replaces `BB_POSTHOG_API_KEY`; the PostHog key is no longer in the app. **Worker** (`apps/telemetry`, route `getbb.app/api/telemetry/*`) - Validates batches (snake_case names only, so no `$` properties from clients; flat values; size and age limits), rate-limits per install. - Adds country, region and city from Cloudflare as PostHog's `$geoip_*` properties and does not forward the IP (`/batch/?ip=0`, `$geoip_disable`), with `$process_person_profile: false`. - Backend is a config var (`posthog` or `discard`); staging discards. - `deploy-telemetry.yml` tests and deploys it on push to `main`. **App**: `new_thread_submit` is only sent for failed submits. Docs and the privacy page are updated. ## Rollout 1. Merge: deploys the Worker (no released version calls it yet). 2. Send a test batch; check location, no IP, and that a resent uuid is deduplicated. 3. Release. Old versions keep sending the old events until they update; daily totals during the transition are old events + `usage_counts` sums. ## Tests Server tests (97 files, 1,195 tests), Worker tests, server-archive, config and composer tests pass; typecheck clean. 5 `bb-app` launcher tests in `test/index.test.ts` time out locally on `main` too.
Merged
SawyerHood
added a commit
that referenced
this pull request
Dec 2, 2026
## Human comments ## What was wrong `main` has 331 commits since `desktop-v0.50.1` with no release notes, and `bb-app` and `@bb/desktop` are still at 0.50.1. ## What changed - `packages/bb-app/package.json`, `apps/desktop/package.json`: 0.50.1 → 0.51.0 (`node scripts/bump-version.mjs --minor`). The release adds 14 database migrations (0159–0172), raises `HOST_DAEMON_PROTOCOL_VERSION` from 268 to 286, moves `@get-bb/plugin-sdk` from 0.6.157 to 0.6.216, replaces the Cursor agent with Grok Build, and turns six early-adopter experiments on for everyone (#8068). - `CHANGELOG.md`: the 0.51.0 section, covering `desktop-v0.50.1` through #8507 (`4d7a9af609`). Same sections as 0.50.0: Reliability, Performance, Usability, Experiments, Now on for everyone, Agents, Bug fixes, Plugins, Security, Thanks (21 outside contributors). The telemetry rework (#8402) is left out on purpose. - `changelog-metadata.ts`: the 0.51.0 `RELEASE_META` entry (December 2, 2026, "Warm worktrees, multi-folder projects, and new agents"). ## How you verified - `node .github/workflows/check-version-lockstep.mjs`: `bb-app=0.51.0 @bb/desktop=0.51.0`. - `pnpm exec turbo run typecheck test --filter=@bb/app --filter=@bb/config --filter=@bb/server --filter=bb-app`: 17/17 tasks (`@bb/app` 709 files, 7574 passed, 20 skipped). - `pnpm exec turbo run smoke:tarball --filter=bb-app --force`: passed in 51 s. - oxfmt on `CHANGELOG.md` and `changelog-metadata.ts`, and `git diff --check`: clean. > AGENT GENERATED
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.
Cuts bb's PostHog volume and puts a Worker of ours between bb and PostHog, so the analytics backend can change without an app release.
Why
About 3.7M events a week, most of them
user_message_sent(2.4M) andthread_created(746k), many from automations, plugins and duplicate first messages. Releases before 0.50.1 also created person profiles, so later events were billed as identified. Projected bill for this period: about $1,425.What changes
bb server (
apps/server/src/services/system/telemetry.ts,telemetry-outbox.ts)usage_countsevent each (period: "day",period_start,threads_created,messages_sent). Automated threads and messages are still counted.BB_TELEMETRY_URL(defaulthttps://getbb.app/api/telemetry/v1/batch), in bb's own format.telemetry-outbox.json(notbb.db). A batch is resent with the same event ids until the Worker accepts it; opting out sends what was recorded, then deletes the file.telemetry-id-v2, so old person profiles stop upgrading events to identified billing.BB_TELEMETRY_URLreplacesBB_POSTHOG_API_KEY; the PostHog key is no longer in the app.Worker (
apps/telemetry, routegetbb.app/api/telemetry/*)$properties from clients; flat values; size and age limits), rate-limits per install.$geoip_*properties and does not forward the IP (/batch/?ip=0,$geoip_disable), with$process_person_profile: false.posthogordiscard); staging discards.deploy-telemetry.ymltests and deploys it on push tomain.App:
new_thread_submitis only sent for failed submits.Docs and the privacy page are updated.
Rollout
usage_countssums.Tests
Server tests (97 files, 1,195 tests), Worker tests, server-archive, config and composer tests pass; typecheck clean. 5
bb-applauncher tests intest/index.test.tstime out locally onmaintoo.