Skip to content

Log plugin installs to PostHog - #1743

Merged
SawyerHood merged 2 commits into
mainfrom
bb/log-plugin-installs-to-posthog-thr_mpxpbeirqz
Aug 18, 2026
Merged

SawyerHood merged 2 commits into
mainfrom
bb/log-plugin-installs-to-posthog-thr_mpxpbeirqz

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Summary

  • Add a plugin_installed telemetry event. The event fires at registerInstalled, the one chokepoint that every user install passes through (CLI, store, and API; git, npm, path, and builtin sources). Boot-time reconcile of auto-installed bundled plugins does not use it, so it does not count.
  • Public plugins (bundled builtins and marketplace catalog entries) report plugin_id and marketplace, so PostHog can rank plugins by install count: trend on plugin_installed, breakdown by plugin_id, aggregation "unique users".
  • Direct path/git/npm installs report plugin_id: null. Their ids and sources can name private code, so they report only provenance and source_kind.
  • Pass the existing server telemetry service into the plugin service.

No wire change between the server and host daemon, so no protocol version bump.

Tests

  • pnpm exec turbo run typecheck --filter=@bb/server
  • pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-service.test.ts test/services/telemetry.test.ts (27 passed). New tests: one install emits exactly one event; reload, enable/disable, and restart emit none; the catalog payload names the plugin.

AGENT GENERATED: by Claude Opus 5

Capture an anonymous plugin_installed telemetry event at the one install
chokepoint (registerInstalled). Public plugins (bundled builtins and
marketplace catalog entries) report their id so PostHog can rank them by
install count. Direct path/git/npm installs report only provenance and
source kind, because their ids can name private code.

Co-Authored-By: Claude <[email protected]>

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

I am SlopCop. I will review this pull request under the review rule.

In plain English, this change records anonymous plugin install events. It names public plugins, but it hides names for direct installs.

I will check security, code quality, architecture, performance, tests, and the full install path.

provenance: PluginProvenance,
sourceIntent: PluginSourceIntent,
): Extract<TelemetryEvent, { name: "plugin_installed" }> {
const isPublic = provenance.kind !== "direct";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — Private catalog names can reach PostHog.

This condition treats each catalog as public. BB accepts local path: catalogs and private Git catalogs.

A private catalog can contain internal plugin and marketplace names. This event sends both names with the stable install ID.

Limit names to builtins and CURATED_MARKETPLACE_NAME. Set both names to null for all other catalogs, or add explicit telemetry-safe metadata.

Please add a local third-party catalog test for this privacy boundary.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 66e271d: names are limited to bundled builtins and bb-community entries, the telemetry dependency is required, and the README/BB_TELEMETRY notices mention plugin installs. A third-party catalog test guards the boundary.

>;
logger: ServerLogger;
/** Anonymous usage telemetry. Omitted only by isolated plugin tests. */
telemetry?: TelemetryService;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — The optional dependency hides a required default.

The comment says that only tests omit telemetry. Production already requires a telemetry service.

This optional field lets a future production call site lose events without a type error. Make the field required.

Use createNoopTelemetryService() in isolated tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 66e271d: names are limited to bundled builtins and bb-community entries, the telemetry dependency is required, and the README/BB_TELEMETRY notices mention plugin installs. A third-party catalog test guards the boundary.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain English summary

This PR records one PostHog event after a successful plugin install. It uses the common install action point and hides direct-install names.

The main problem is that it does not hide names from private plugin catalogs.

Findings

  1. High — Private plugin data can reach PostHog.

    The code treats every catalog as public. BB also accepts local and private Git catalogs.

    A private catalog can expose its marketplace name and plugin ID under the stable telemetry install ID. Limit named events to builtins and bb-community.

  2. Medium — The user telemetry notice is incomplete.

    README.md and the BB_TELEMETRY description list only app starts, thread counts, and message counts. Add plugin install data and the identifier policy.

  3. Low — The telemetry dependency is optional only for tests.

    Make it required. Give isolated tests the existing no-operation telemetry service.

Checks

  • The server type check passed.
  • The focused plugin service test passed all 21 tests.
  • All current GitHub checks passed.
  • A browser test installed the bundled Tasks plugin through the plugin catalog route. The server returned HTTP 200 and loaded Tasks.
  • A source run does not send external telemetry by policy. The tests and type checks therefore validate the event payload.
  • The performance review found no new concern. The event uses a small object and a fire-and-forget request.
  • The architecture scan found no duplicate install event. The common registration point is the correct action point.

I left a comment-only review, as required. Please fix the private catalog leak before merge.

- Name only bundled builtins and bb-community catalog entries in the
  plugin_installed event; third-party and local catalogs report no name.
- Make the plugin service telemetry dependency required; tests pass the
  no-op service.
- Document plugin installs in the README and BB_TELEMETRY notices.

Co-Authored-By: Claude <[email protected]>
@SawyerHood
SawyerHood merged commit b4eb22b into main Aug 18, 2026
17 of 18 checks passed
@SawyerHood
SawyerHood deleted the bb/log-plugin-installs-to-posthog-thr_mpxpbeirqz branch August 18, 2026 00:18
SawyerHood added a commit to get-bb/marketplace that referenced this pull request Oct 19, 2026
The daily install-count query had no timestamp bound, so ClickHouse
scanned the project's whole event history and sometimes hit PostHog's
execution limit (HTTP 504 on Oct 9, 13 and 19). Bound it to 2026-08-17,
when BB first sent plugin_installed (get-bb/bb#1743), which loses no
counts and lets partitions be pruned.

Also retry, up to three attempts with backoff, only the 504
"max execution time" answer: the query is a read, so a rerun is safe.
Every other failure still fails at once.

Co-authored-by: Sawyer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant