Skip to content

feat(mcp): implement @posthog/mcp SDK on top of @posthog/core (2/2)#3653

Open
lucasheriques wants to merge 22 commits into
posthog-code/mcp-scaffoldfrom
posthog-code/mcp-implementation
Open

feat(mcp): implement @posthog/mcp SDK on top of @posthog/core (2/2)#3653
lucasheriques wants to merge 22 commits into
posthog-code/mcp-scaffoldfrom
posthog-code/mcp-implementation

Conversation

@lucasheriques
Copy link
Copy Markdown
Contributor

@lucasheriques lucasheriques commented May 21, 2026

Second (and main) half of the @posthog/mcp port. Stacks on top of #3652 (scaffold). Brings in the real public API, all SDK modules under src/extensions/, the consolidated test suite, and the architecture doc.

The diff is large because porting the SDK is large, but the actual review surface is concentrated in ~10 files (listed below). The rest is a verbatim port of behavior we already shipped in the standalone repo, plus tests.

⚠️ Before merging this PR

@posthog/mcp is already published on npm from a different repo (PostHog/mcp-analytics, the previous standalone). The release workflow in this monorepo publishes via OIDC trusted publishing (no NPM_TOKEN), which means npm pins the publisher to a specific GitHub Actions workflow path on a specific repo.

The npm trusted publisher for @posthog/mcp needs to be updated (or a second one added) before the release approval Slack ping fires for this PR. On npmjs.com:

  • Package: @posthog/mcp → Settings → Trusted Publisher
  • Add (or change to): repo PostHog/posthog-js, workflow file .github/workflows/release.yml, environment NPM Release

Once that's done, merging this PR triggers the release workflow, the maintainer approves the Slack notification, and @posthog/mcp 0.1.0 publishes from the monorepo. If you approve without updating the trusted publisher, the publish step will fail with a provenance/publisher mismatch and we'll need to retry after the npm settings change.

Recommended order of operations:

  1. Merge feat(mcp): scaffold @posthog/mcp package (1/2) #3652 (scaffold) — silent, no release workflow triggered (changeset lives on this PR now).
  2. Update the npm trusted publisher on @posthog/mcp.
  3. Merge this PR → approve the Slack release prompt → publish.

📊 Composition

Kind Files LOC Share
Source code (src/extensions/*.ts, src/index.ts, src/types.ts, src/storage-memory.ts) 25 4,723 41%
Tests (src/__tests__/) 24 6,304 55%
Architecture doc + README 2 424 4%
Configs (package.json, tsconfig*, rslib, jest, babel, .prettierrc, .gitignore) 8 135 <1%

Test-to-code ratio: 1.33x. Most of the test volume is integration tests against a real in-memory MCP transport (in test-utils/client-server-factory.ts), which is harder to compress than unit tests but catches real regressions in the tracing wrapper.

📝 Where to look

Why it matters File
Public API contract packages/mcp/src/index.ts
Public types packages/mcp/src/types.ts
New codePostHogMCP extends PostHogCoreStateless packages/mcp/src/extensions/client.ts
New code — per-server publish helper packages/mcp/src/extensions/publish.ts
New code — STDIO-safe logger packages/mcp/src/extensions/logger.ts
New code — in-process storage (matches posthog-node) packages/mcp/src/storage-memory.ts
$-prefixed wire contract packages/mcp/src/extensions/constants.ts
Event fan-out logic ($mcp_* + $exception + $ai_span) packages/mcp/src/extensions/posthog-events.ts
Full design narrative + HogQL queries + migration notes from 0.0.x packages/mcp/docs/ARCHITECTURE.md

Skim only — verbatim ports from the standalone repo, behavior unchanged: tracing.ts, tracing-v2.ts, tools.ts, compatibility.ts, mcp-sdk-compat.ts, context-parameters.ts, conversation-id.ts, intent.ts, internal.ts, session.ts, ids.ts, redaction.ts, sanitization.ts, truncation.ts, mcp-payloads.ts, exceptions.ts, event-types.ts, tracing-helpers.ts.

🤖 PostHog Code review prompt

Copy-paste this into PostHog Code (or any code-aware AI) to get a focused second pass:

You are reviewing PR #3653 in PostHog/posthog-js — the initial release of `@posthog/mcp`, a new SDK that ports the previous standalone @posthog/mcp repo into this monorepo on top of @posthog/core. Target version is 0.1.0.

Focus your review on these dimensions, in order:

1. **API surface fitness for initial release.** Look at `packages/mcp/src/index.ts` and `packages/mcp/src/types.ts`. Is `MCPAnalyticsOptions` minimal and coherent? Are option names consistent with posthog-node's conventions (`client`, `clientOptions`, `host`, `logger`)? Anything that should be marked experimental, deprecated, or removed before 0.1.0 ships?

2. **`PostHogMCP` correctness.** `packages/mcp/src/extensions/client.ts` extends `PostHogCoreStateless`. Verify: are all four abstract methods implemented correctly (`fetch`, `getLibraryId`, `getLibraryVersion`, `getCustomUserAgent`, `getPersistedProperty`, `setPersistedProperty`)? Does it match the shape of `PostHogBackendClient` in `packages/node/src/client.ts`? Is the in-memory storage abstraction (`packages/mcp/src/storage-memory.ts`) identical in pattern to `packages/node/src/storage-memory.ts`?

3. **Monorepo convention alignment.** Compare `packages/mcp/` against `packages/node/`: package.json shape, tsconfig setup, rslib config, jest+babel config, .prettierrc, .gitignore, prebuild script, eslint override in root `.eslintrc.cjs`, publish matrix entry in `.github/workflows/release.yml`. Flag any divergence.

4. **`$`-prefix discipline.** Every PostHog-owned event name should start with `$`. Grep for `'mcp_` (without leading `$`) in `packages/mcp/src/extensions/constants.ts` and `packages/mcp/src/extensions/posthog-events.ts` to confirm no wire-level event name is missing the prefix. Note: the internal `MCPAnalyticsEventType` enum uses protocol-shaped strings (`mcp:tools/call`, `posthog:identify`) — that's intentional, those never reach the wire.

5. **Event pipeline integrity.** Trace one tool call from `tracing-v2.ts` → `publish.ts` → `client.ts` `ingest()` → fan-out in `posthog-events.ts` → `captureStateless()`. Are redact / sanitize / truncate run in the right order? Are errors at any stage logged and dropped (not re-thrown into tool code)? Does the SDK ever crash the host app?

6. **Removed features stay removed.** Confirm no leftover references to: `posthog-node` (runtime dep), `eventTags` callback, `posthogClient` option, `posthogOptions` option, `~/posthog-mcp-analytics.log`, `node:crypto`, `createRequire(import.meta.url)`, `POSTHOG_MCP_ANALYTICS_HOST` env var, the vendored `thirdparty/ksuid/` directory, the old `validation.ts` and `event-queue.ts` and `logging.ts` files.

7. **Test coverage is behavior, not implementation.** Skim the 24 test files in `packages/mcp/src/__tests__/`. Are tests asserting on observable behavior (events captured, errors propagated, identity stored) or on internal mocks? Anything still over-tested? Anything important that's *under*-tested for an initial release — e.g. edge runtimes, concurrent server instances, the proxy listener for late-registered tools? Flag any test file that still feels like dead weight.

8. **Memory and resource correctness.** The SDK uses a module-level `WeakMap<MCPServerLike, MCPAnalyticsData>` in `internal.ts`, an LRU `IdentityCache` (max 1000) for identity dedup, and a `Proxy` on `_registeredTools` for late-registered tools (`tracing-v2.ts`). Are any of these a leak risk under churn (many short-lived servers, many sessions, many tools added/removed)?

9. **Edge runtime safety.** The SDK is meant to work in environments without `node:fs`, `node:crypto`, full `process`, or `createRequire`. Check `exceptions.ts` (lazy fs require), `ids.ts` (FNV-1a fallback), and `logger.ts` (no-op default) for graceful degradation. `edge-runtime-compatibility.test.ts` is the canary.

10. **Architecture doc accuracy.** `packages/mcp/docs/ARCHITECTURE.md` is the canonical spec — events, properties, pipeline, intent resolution, migration notes. Spot-check it against the actual code: are the event names, property keys, default values, and file paths still correct after the consolidation commits?

Output your findings grouped by dimension, with file:line citations and a P1/P2/P3 severity. Prioritize anything that would either ship a bug or lock us into a bad API contract before 0.1.0 publishes to npm.

Stack

Test plan

  • pnpm --filter=@posthog/mcp build — clean (ESM + CJS + .d.ts, ~155 kB CJS).
  • pnpm --filter=@posthog/mcp test:unit346 passing, 1 skipped, 0 failing across 24 jest test files.
  • pnpm --filter=@posthog/mcp lint — clean.
  • pnpm lint (all 26 monorepo packages) — clean.
  • CI passes on this PR.
  • npm trusted publisher for @posthog/mcp updated to point at PostHog/posthog-js (see "Before merging" above).
  • Optional: archive or freeze the old PostHog/mcp-analytics repo to prevent accidental dual publishes.

Created with PostHog Code

@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
posthog-example-next-app-router Ready Ready Preview May 27, 2026 5:41pm
posthog-js Ready Ready Preview May 27, 2026 5:41pm
posthog-nextjs-config Ready Ready Preview May 27, 2026 5:41pm

Request Review

Copy link
Copy Markdown
Contributor Author

lucasheriques commented May 21, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@lucasheriques lucasheriques changed the title feat(mcp): implement @posthog/mcp SDK on top of @posthog/core feat(mcp): implement @posthog/mcp SDK on top of @posthog/core (2/2) May 21, 2026
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented May 21, 2026

Graphite Automations

"sdk release label" took an action on this PR • (05/21/26)

1 label was added to this PR based on Adam Bowker's automation.

"Add graphite merge queue [copy]" took an action on this PR • (05/21/26)

2 labels were added to this PR based on Lucas Faria's automation.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 21, 2026

Prompt To Fix All With AI
Fix the following 4 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 4
packages/mcp/src/extensions/publish.ts:20-22
**`publishCustomEvent` silently no-ops when `enableTracing: false`**

The `enableTracing` option is documented as a "master switch for auto-captured events," implying `publishCustomEvent` (a deliberate, user-initiated call) should still fire. But because `publishEvent` gates on `!data.options.enableTracing` before the client check, any call to `publishCustomEvent` is silently swallowed when the user has opted out of automatic tracing. The test suite has no coverage for this case. A user who disables auto-capture but explicitly calls `publishCustomEvent` will get no event, no error, and no warning.

### Issue 2 of 4
packages/mcp/src/extensions/tracing.ts:38-40
**Three helpers duplicated across `tracing.ts` and `tracing-v2.ts`**

`isToolResultError`, `applyResolvedMetadata`, and `getContextArgument` are all defined identically in both `tracing.ts` and `tracing-v2.ts`. This violates OnceAndOnlyOnce and means any future fix or behaviour change must be applied in two places. These should be extracted to a shared utility module and imported by both files.

### Issue 3 of 4
packages/mcp/src/extensions/tracing.ts:173-264
**Initialize-handler logic duplicated inside `setupToolCallTracing`**

`setupInitializeTracing` (lines 173–212) was extracted so that `tracing-v2.ts` can call it directly, but the identical inline copy inside `setupToolCallTracing` (lines 222–254) was never removed. Any behaviour change to the initialize handler must now be applied in both places. The inline block inside `setupToolCallTracing` should be replaced with a call to `setupInitializeTracing`.

### Issue 4 of 4
packages/mcp/src/index.ts:51
This looks like a debug log left over from development. It will appear in production logs of any STDIO-based MCP server where the user has provided a logger.

```suggestion
      log('track() - Server already being tracked, skipping initialization')
```

Reviews (1): Last reviewed commit: "feat(mcp): implement @posthog/mcp SDK on..." | Re-trigger Greptile

Comment thread packages/mcp/src/extensions/publish.ts Outdated
Comment thread packages/mcp/src/extensions/tracing.ts Outdated
Comment thread packages/mcp/src/extensions/tracing.ts Outdated
Comment thread packages/mcp/src/index.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Size Change: +273 kB (+1.66%)

Total Size: 16.7 MB

Filename Size Change
packages/browser/dist/all-external-dependencies.js 261 kB +1.6 kB (+0.62%)
packages/browser/dist/array.full.js 429 kB +1.6 kB (+0.37%)
packages/browser/dist/array.full.no-********.js 503 kB +1.6 kB (+0.32%)
packages/browser/dist/lazy-********.js 151 kB +57 B (+0.04%)
packages/browser/dist/logs.js 40.6 kB +1.63 kB (+4.19%)
packages/browser/dist/module.full.js 432 kB +1.6 kB (+0.37%)
packages/browser/dist/module.full.no-********.js 506 kB +1.6 kB (+0.32%)
packages/browser/dist/posthog-********.js 151 kB +56 B (+0.04%)
packages/browser/dist/recorder-v2.js 98.7 kB +56 B (+0.06%)
packages/browser/dist/recorder.js 98.7 kB +56 B (+0.06%)
packages/browser/dist/rrweb.js 279 kB +73 B (+0.03%)
packages/convex/dist/component/version.js 68 B +1 B (+1.49%)
packages/core/dist/posthog-core-stateless.js 33.8 kB +272 B (+0.81%)
packages/core/dist/posthog-core-stateless.mjs 31.1 kB +117 B (+0.38%)
packages/mcp/dist/index.js 9.54 kB +8.24 kB (+638%) 🆘
packages/mcp/dist/index.mjs 6.61 kB +6.55 kB (+10734.43%) 🆘
packages/node/dist/client.js 45.5 kB +184 B (+0.41%)
packages/node/dist/client.mjs 43.2 kB +184 B (+0.43%)
packages/react-native/dist/error-tracking/index.js 7.36 kB +112 B (+1.55%)
packages/react-native/dist/version.js 130 B -1 B (-0.76%)
packages/rrweb/all/dist/rrweb-all.cjs 611 kB +354 B (+0.06%)
packages/rrweb/all/dist/rrweb-all.js 611 kB +354 B (+0.06%)
packages/rrweb/all/dist/rrweb-all.umd.cjs 614 kB +354 B (+0.06%)
packages/rrweb/all/dist/rrweb-all.umd.min.cjs 290 kB +107 B (+0.04%)
packages/rrweb/record/dist/rrweb-record.cjs 173 kB +354 B (+0.2%)
packages/rrweb/record/dist/rrweb-record.js 173 kB +354 B (+0.2%)
packages/rrweb/record/dist/rrweb-record.umd.cjs 174 kB +354 B (+0.2%)
packages/rrweb/record/dist/rrweb-record.umd.min.cjs 83.3 kB +107 B (+0.13%)
packages/rrweb/rrweb-snapshot/dist/record.cjs 32.2 kB +380 B (+1.19%)
packages/rrweb/rrweb-snapshot/dist/record.js 31.2 kB +350 B (+1.14%)
packages/rrweb/rrweb-snapshot/dist/record.umd.cjs 53.5 kB +378 B (+0.71%)
packages/rrweb/rrweb-snapshot/dist/record.umd.min.cjs 25.6 kB +107 B (+0.42%)
packages/rrweb/rrweb-snapshot/dist/rrweb-********.cjs 2.27 kB +74 B (+3.37%)
packages/rrweb/rrweb-snapshot/dist/rrweb-********.js 1.42 kB +60 B (+4.42%)
packages/rrweb/rrweb-snapshot/dist/rrweb-********.umd.cjs 217 kB +516 B (+0.24%)
packages/rrweb/rrweb-snapshot/dist/rrweb-********.umd.min.cjs 91.5 kB +169 B (+0.19%)
packages/rrweb/rrweb/dist/rrweb.cjs 594 kB +354 B (+0.06%)
packages/rrweb/rrweb/dist/rrweb.js 594 kB +354 B (+0.06%)
packages/rrweb/rrweb/dist/rrweb.umd.cjs 595 kB +354 B (+0.06%)
packages/rrweb/rrweb/dist/rrweb.umd.min.cjs 280 kB +107 B (+0.04%)
packages/mcp/dist/extensions/capture.js 3.77 kB +3.77 kB (new file) 🆕
packages/mcp/dist/extensions/capture.mjs 2.3 kB +2.3 kB (new file) 🆕
packages/mcp/dist/extensions/client.js 4.79 kB +4.79 kB (new file) 🆕
packages/mcp/dist/extensions/client.mjs 2.88 kB +2.88 kB (new file) 🆕
packages/mcp/dist/extensions/compatibility.js 5.63 kB +5.63 kB (new file) 🆕
packages/mcp/dist/extensions/compatibility.mjs 3.79 kB +3.79 kB (new file) 🆕
packages/mcp/dist/extensions/constants.js 4.59 kB +4.59 kB (new file) 🆕
packages/mcp/dist/extensions/constants.mjs 2.48 kB +2.48 kB (new file) 🆕
packages/mcp/dist/extensions/context-parameters.js 3.9 kB +3.9 kB (new file) 🆕
packages/mcp/dist/extensions/context-parameters.mjs 2.11 kB +2.11 kB (new file) 🆕
packages/mcp/dist/extensions/conversation-id.js 7.01 kB +7.01 kB (new file) 🆕
packages/mcp/dist/extensions/conversation-id.mjs 4.1 kB +4.1 kB (new file) 🆕
packages/mcp/dist/extensions/event-types.js 1.63 kB +1.63 kB (new file) 🆕
packages/mcp/dist/extensions/event-types.mjs 407 B +407 B (new file) 🆕
packages/mcp/dist/extensions/exceptions.js 15 kB +15 kB (new file) 🆕
packages/mcp/dist/extensions/exceptions.mjs 12.6 kB +12.6 kB (new file) 🆕
packages/mcp/dist/extensions/ids.js 2.01 kB +2.01 kB (new file) 🆕
packages/mcp/dist/extensions/ids.mjs 637 B +637 B (new file) 🆕
packages/mcp/dist/extensions/intent.js 3.31 kB +3.31 kB (new file) 🆕
packages/mcp/dist/extensions/intent.mjs 1.68 kB +1.68 kB (new file) 🆕
packages/mcp/dist/extensions/internal.js 6.57 kB +6.57 kB (new file) 🆕
packages/mcp/dist/extensions/internal.mjs 4.42 kB +4.42 kB (new file) 🆕
packages/mcp/dist/extensions/logger.js 1.44 kB +1.44 kB (new file) 🆕
packages/mcp/dist/extensions/logger.mjs 204 B +204 B (new file) 🆕
packages/mcp/dist/extensions/mcp-********.js 3.93 kB +3.93 kB (new file) 🆕
packages/mcp/dist/extensions/mcp-********.mjs 2.56 kB +2.56 kB (new file) 🆕
packages/mcp/dist/extensions/mcp-sdk-compat.js 4.08 kB +4.08 kB (new file) 🆕
packages/mcp/dist/extensions/mcp-sdk-compat.mjs 2.22 kB +2.22 kB (new file) 🆕
packages/mcp/dist/extensions/posthog-events.js 12.4 kB +12.4 kB (new file) 🆕
packages/mcp/dist/extensions/posthog-events.mjs 8.55 kB +8.55 kB (new file) 🆕
packages/mcp/dist/extensions/redaction.js 2.53 kB +2.53 kB (new file) 🆕
packages/mcp/dist/extensions/redaction.mjs 1.35 kB +1.35 kB (new file) 🆕
packages/mcp/dist/extensions/sanitization.js 3.9 kB +3.9 kB (new file) 🆕
packages/mcp/dist/extensions/sanitization.mjs 2.37 kB +2.37 kB (new file) 🆕
packages/mcp/dist/extensions/session.js 4.71 kB +4.71 kB (new file) 🆕
packages/mcp/dist/extensions/session.mjs 2.6 kB +2.6 kB (new file) 🆕
packages/mcp/dist/extensions/tools.js 7.97 kB +7.97 kB (new file) 🆕
packages/mcp/dist/extensions/tools.mjs 5.46 kB +5.46 kB (new file) 🆕
packages/mcp/dist/extensions/tracing-helpers.js 2.41 kB +2.41 kB (new file) 🆕
packages/mcp/dist/extensions/tracing-helpers.mjs 772 B +772 B (new file) 🆕
packages/mcp/dist/extensions/tracing-v2.js 16.7 kB +16.7 kB (new file) 🆕
packages/mcp/dist/extensions/tracing-v2.mjs 13.6 kB +13.6 kB (new file) 🆕
packages/mcp/dist/extensions/tracing.js 14.1 kB +14.1 kB (new file) 🆕
packages/mcp/dist/extensions/tracing.mjs 10 kB +10 kB (new file) 🆕
packages/mcp/dist/extensions/truncation.js 10.8 kB +10.8 kB (new file) 🆕
packages/mcp/dist/extensions/truncation.mjs 9.07 kB +9.07 kB (new file) 🆕
packages/mcp/dist/storage-memory.js 1.52 kB +1.52 kB (new file) 🆕
packages/mcp/dist/storage-memory.mjs 297 B +297 B (new file) 🆕
packages/mcp/dist/types.js 603 B +603 B (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
packages/ai/dist/anthropic/index.cjs 26 kB 0 B
packages/ai/dist/anthropic/index.mjs 25.6 kB 0 B
packages/ai/dist/gemini/index.cjs 34.4 kB 0 B
packages/ai/dist/gemini/index.mjs 34.2 kB 0 B
packages/ai/dist/index.cjs 171 kB 0 B
packages/ai/dist/index.mjs 170 kB 0 B
packages/ai/dist/langchain/index.cjs 47.9 kB 0 B
packages/ai/dist/langchain/index.mjs 47.3 kB 0 B
packages/ai/dist/openai-agents/index.cjs 25.5 kB 0 B
packages/ai/dist/openai-agents/index.mjs 25.4 kB 0 B
packages/ai/dist/openai/index.cjs 50.7 kB 0 B
packages/ai/dist/openai/index.mjs 50.3 kB 0 B
packages/ai/dist/otel/index.cjs 4.97 kB 0 B
packages/ai/dist/otel/index.mjs 4.86 kB 0 B
packages/ai/dist/vercel/index.cjs 44.5 kB 0 B
packages/ai/dist/vercel/index.mjs 44.5 kB 0 B
packages/browser/dist/array.full.es5.js 348 kB 0 B
packages/browser/dist/array.js 192 kB 0 B
packages/browser/dist/array.no-********.js 209 kB 0 B
packages/browser/dist/conversations.js 67.3 kB 0 B
packages/browser/dist/crisp-chat-integration.js 1.97 kB 0 B
packages/browser/dist/customizations.full.js 18 kB 0 B
packages/browser/dist/dead-clicks-autocapture.js 14.3 kB 0 B
packages/browser/dist/default-extensions.js 190 kB 0 B
packages/browser/dist/element-inference.js 5.69 kB 0 B
packages/browser/dist/exception-autocapture.js 11.8 kB 0 B
packages/browser/dist/extension-bundles.js 106 kB 0 B
packages/browser/dist/external-scripts-loader.js 3.13 kB 0 B
packages/browser/dist/intercom-integration.js 2.03 kB 0 B
packages/browser/dist/main.js 196 kB 0 B
packages/browser/dist/module.js 196 kB 0 B
packages/browser/dist/module.no-********.js 213 kB 0 B
packages/browser/dist/module.slim.js 102 kB 0 B
packages/browser/dist/module.slim.no-********.js 107 kB 0 B
packages/browser/dist/product-tours-preview.js 76.4 kB 0 B
packages/browser/dist/product-tours.js 115 kB 0 B
packages/browser/dist/rrweb-plugin-console-record.js 6.67 kB 0 B
packages/browser/dist/rrweb-types.js 2.28 kB 0 B
packages/browser/dist/surveys-preview.js 76.3 kB 0 B
packages/browser/dist/surveys.js 94.7 kB 0 B
packages/browser/dist/tracing-headers.js 1.84 kB 0 B
packages/browser/dist/web-vitals-with-attribution.js 11.8 kB 0 B
packages/browser/dist/web-vitals.js 6.39 kB 0 B
packages/browser/react/dist/esm/index.js 21.2 kB 0 B
packages/browser/react/dist/esm/slim/index.js 17.6 kB 0 B
packages/browser/react/dist/esm/surveys/index.js 4.68 kB 0 B
packages/browser/react/dist/umd/index.js 24.4 kB 0 B
packages/browser/react/dist/umd/slim/index.js 20.4 kB 0 B
packages/browser/react/dist/umd/surveys/index.js 5.45 kB 0 B
packages/convex/dist/client/feature-flags/crypto.js 461 B 0 B
packages/convex/dist/client/feature-flags/evaluator.js 16.5 kB 0 B
packages/convex/dist/client/feature-flags/index.js 196 B 0 B
packages/convex/dist/client/feature-flags/match-********.js 14.8 kB 0 B
packages/convex/dist/client/feature-flags/types.js 44 B 0 B
packages/convex/dist/client/index.js 14.7 kB 0 B
packages/convex/dist/component/_generated/api.js 712 B 0 B
packages/convex/dist/component/_generated/component.js 212 B 0 B
packages/convex/dist/component/_generated/dataModel.js 230 B 0 B
packages/convex/dist/component/_generated/server.js 3.71 kB 0 B
packages/convex/dist/component/convex.config.js 133 B 0 B
packages/convex/dist/component/lib.js 19.9 kB 0 B
packages/convex/dist/component/schema.js 694 B 0 B
packages/core/dist/cookie.js 5.34 kB 0 B
packages/core/dist/cookie.mjs 3.12 kB 0 B
packages/core/dist/error-tracking/chunk-ids.js 2.54 kB 0 B
packages/core/dist/error-tracking/chunk-ids.mjs 1.31 kB 0 B
packages/core/dist/error-tracking/coercers/dom-exception-coercer.js 2.3 kB 0 B
packages/core/dist/error-tracking/coercers/dom-exception-coercer.mjs 993 B 0 B
packages/core/dist/error-tracking/coercers/error-coercer.js 2.02 kB 0 B
packages/core/dist/error-tracking/coercers/error-coercer.mjs 794 B 0 B
packages/core/dist/error-tracking/coercers/error-event-coercer.js 1.76 kB 0 B
packages/core/dist/error-tracking/coercers/error-event-coercer.mjs 513 B 0 B
packages/core/dist/error-tracking/coercers/event-coercer.js 1.82 kB 0 B
packages/core/dist/error-tracking/coercers/event-coercer.mjs 548 B 0 B
packages/core/dist/error-tracking/coercers/index.js 6.79 kB 0 B
packages/core/dist/error-tracking/coercers/index.mjs 326 B 0 B
packages/core/dist/error-tracking/coercers/object-coercer.js 3.46 kB 0 B
packages/core/dist/error-tracking/coercers/object-coercer.mjs 2.07 kB 0 B
packages/core/dist/error-tracking/coercers/primitive-coercer.js 1.67 kB 0 B
packages/core/dist/error-tracking/coercers/primitive-coercer.mjs 419 B 0 B
packages/core/dist/error-tracking/coercers/promise-rejection-event.js 2.59 kB 0 B
packages/core/dist/error-tracking/coercers/promise-rejection-event.mjs 1.25 kB 0 B
packages/core/dist/error-tracking/coercers/string-coercer.js 2.01 kB 0 B
packages/core/dist/error-tracking/coercers/string-coercer.mjs 820 B 0 B
packages/core/dist/error-tracking/coercers/utils.js 2.06 kB 0 B
packages/core/dist/error-tracking/coercers/utils.mjs 716 B 0 B
packages/core/dist/error-tracking/error-properties-builder.js 5.56 kB 0 B
packages/core/dist/error-tracking/error-properties-builder.mjs 4.23 kB 0 B
packages/core/dist/error-tracking/exception-steps.js 6.87 kB 0 B
packages/core/dist/error-tracking/exception-steps.mjs 4.71 kB 0 B
packages/core/dist/error-tracking/index.js 4.74 kB 0 B
packages/core/dist/error-tracking/index.mjs 191 B 0 B
packages/core/dist/error-tracking/parsers/base.js 1.83 kB 0 B
packages/core/dist/error-tracking/parsers/base.mjs 464 B 0 B
packages/core/dist/error-tracking/parsers/chrome.js 2.73 kB 0 B
packages/core/dist/error-tracking/parsers/chrome.mjs 1.32 kB 0 B
packages/core/dist/error-tracking/parsers/gecko.js 2.47 kB 0 B
packages/core/dist/error-tracking/parsers/gecko.mjs 1.13 kB 0 B
packages/core/dist/error-tracking/parsers/index.js 4.75 kB 0 B
packages/core/dist/error-tracking/parsers/index.mjs 2.1 kB 0 B
packages/core/dist/error-tracking/parsers/node.js 3.94 kB 0 B
packages/core/dist/error-tracking/parsers/node.mjs 2.68 kB 0 B
packages/core/dist/error-tracking/parsers/opera.js 2.26 kB 0 B
packages/core/dist/error-tracking/parsers/opera.mjs 746 B 0 B
packages/core/dist/error-tracking/parsers/safari.js 1.88 kB 0 B
packages/core/dist/error-tracking/parsers/safari.mjs 574 B 0 B
packages/core/dist/error-tracking/parsers/winjs.js 1.72 kB 0 B
packages/core/dist/error-tracking/parsers/winjs.mjs 426 B 0 B
packages/core/dist/error-tracking/types.js 1.33 kB 0 B
packages/core/dist/error-tracking/types.mjs 131 B 0 B
packages/core/dist/error-tracking/utils.js 1.8 kB 0 B
packages/core/dist/error-tracking/utils.mjs 604 B 0 B
packages/core/dist/eventemitter.js 1.78 kB 0 B
packages/core/dist/eventemitter.mjs 571 B 0 B
packages/core/dist/featureFlagUtils.js 6.8 kB 0 B
packages/core/dist/featureFlagUtils.mjs 4.32 kB 0 B
packages/core/dist/gzip.js 5.72 kB 0 B
packages/core/dist/gzip.mjs 3.84 kB 0 B
packages/core/dist/index.js 13.6 kB 0 B
packages/core/dist/index.mjs 1.31 kB 0 B
packages/core/dist/logs/index.js 9.47 kB 0 B
packages/core/dist/logs/index.mjs 7.87 kB 0 B
packages/core/dist/logs/logs-utils.js 5.96 kB 0 B
packages/core/dist/logs/logs-utils.mjs 3.99 kB 0 B
packages/core/dist/logs/types.js 603 B 0 B
packages/core/dist/logs/types.mjs 0 B 0 B 🆕
packages/core/dist/posthog-core.js 42 kB 0 B
packages/core/dist/posthog-core.mjs 37 kB 0 B
packages/core/dist/surveys/events.js 4.21 kB 0 B
packages/core/dist/surveys/events.mjs 1.99 kB 0 B
packages/core/dist/surveys/index.js 4.57 kB 0 B
packages/core/dist/surveys/index.mjs 894 B 0 B
packages/core/dist/surveys/translations.js 9.4 kB 0 B
packages/core/dist/surveys/translations.mjs 7.03 kB 0 B
packages/core/dist/surveys/validation.js 3.06 kB 0 B
packages/core/dist/surveys/validation.mjs 1.51 kB 0 B
packages/core/dist/testing/index.js 2.93 kB 0 B
packages/core/dist/testing/index.mjs 79 B 0 B
packages/core/dist/testing/PostHogCoreTestClient.js 3.15 kB 0 B
packages/core/dist/testing/PostHogCoreTestClient.mjs 1.74 kB 0 B
packages/core/dist/testing/test-utils.js 2.83 kB 0 B
packages/core/dist/testing/test-utils.mjs 1.15 kB 0 B
packages/core/dist/tracing-headers.js 3.38 kB 0 B
packages/core/dist/tracing-headers.mjs 2.08 kB 0 B
packages/core/dist/types.js 9.62 kB 0 B
packages/core/dist/types.mjs 7.07 kB 0 B
packages/core/dist/utils/bot-detection.js 3.28 kB 0 B
packages/core/dist/utils/bot-detection.mjs 1.95 kB 0 B
packages/core/dist/utils/bucketed-rate-limiter.js 3 kB 0 B
packages/core/dist/utils/bucketed-rate-limiter.mjs 1.62 kB 0 B
packages/core/dist/utils/index.js 11.9 kB 0 B
packages/core/dist/utils/index.mjs 1.98 kB 0 B
packages/core/dist/utils/logger.js 2.58 kB 0 B
packages/core/dist/utils/logger.mjs 1.29 kB 0 B
packages/core/dist/utils/number-utils.js 3.32 kB 0 B
packages/core/dist/utils/number-utils.mjs 1.68 kB 0 B
packages/core/dist/utils/promise-queue.js 2 kB 0 B
packages/core/dist/utils/promise-queue.mjs 768 B 0 B
packages/core/dist/utils/string-utils.js 2.73 kB 0 B
packages/core/dist/utils/string-utils.mjs 1.09 kB 0 B
packages/core/dist/utils/type-utils.js 7.04 kB 0 B
packages/core/dist/utils/type-utils.mjs 3.11 kB 0 B
packages/core/dist/utils/user-agent-utils.js 15.5 kB 0 B
packages/core/dist/utils/user-agent-utils.mjs 12.4 kB 0 B
packages/core/dist/vendor/uuidv7.js 8.29 kB 0 B
packages/core/dist/vendor/uuidv7.mjs 6.72 kB 0 B
packages/mcp/dist/version.js 1.21 kB 0 B
packages/mcp/dist/version.mjs 45 B 0 B
packages/next/dist/app/PostHogProvider.js 3.33 kB 0 B
packages/next/dist/client/ClientPostHogProvider.js 1.76 kB 0 B
packages/next/dist/client/hooks.js 172 B 0 B
packages/next/dist/client/PostHogPageView.js 1.76 kB 0 B
packages/next/dist/index.client.js 401 B 0 B
packages/next/dist/index.edge.js 447 B 0 B
packages/next/dist/index.js 444 B 0 B
packages/next/dist/index.react-server.js 420 B 0 B
packages/next/dist/middleware/postHogMiddleware.js 3.7 kB 0 B
packages/next/dist/pages.client.js 502 B 0 B
packages/next/dist/pages.edge.js 570 B 0 B
packages/next/dist/pages.js 414 B 0 B
packages/next/dist/pages/getServerSidePostHog.js 1.99 kB 0 B
packages/next/dist/pages/PostHogPageView.js 1.32 kB 0 B
packages/next/dist/pages/PostHogProvider.js 1.61 kB 0 B
packages/next/dist/server/getPostHog.js 2.79 kB 0 B
packages/next/dist/server/nodeClientCache.js 1.31 kB 0 B
packages/next/dist/shared/browser.js 195 B 0 B
packages/next/dist/shared/config.js 2.08 kB 0 B
packages/next/dist/shared/constants.js 201 B 0 B
packages/next/dist/shared/cookie.js 540 B 0 B
packages/next/dist/shared/identity.js 264 B 0 B
packages/next/dist/shared/tracing-headers.js 2.18 kB 0 B
packages/nextjs-config/dist/config.js 5.82 kB 0 B
packages/nextjs-config/dist/config.mjs 4.34 kB 0 B
packages/nextjs-config/dist/index.js 2.24 kB 0 B
packages/nextjs-config/dist/index.mjs 30 B 0 B
packages/nextjs-config/dist/utils.js 2.94 kB 0 B
packages/nextjs-config/dist/utils.mjs 826 B 0 B
packages/node/dist/entrypoints/index.edge.js 4.25 kB 0 B
packages/node/dist/entrypoints/index.edge.mjs 723 B 0 B
packages/node/dist/entrypoints/index.node.js 6.04 kB 0 B
packages/node/dist/entrypoints/index.node.mjs 1.22 kB 0 B
packages/node/dist/entrypoints/nestjs.js 2.31 kB 0 B
packages/node/dist/entrypoints/nestjs.mjs 42 B 0 B
packages/node/dist/experimental.js 870 B 0 B
packages/node/dist/experimental.mjs 267 B 0 B
packages/node/dist/exports.js 6.75 kB 0 B
packages/node/dist/exports.mjs 582 B 0 B
packages/node/dist/extensions/context/context.js 2.13 kB 0 B
packages/node/dist/extensions/context/context.mjs 863 B 0 B
packages/node/dist/extensions/context/types.js 603 B 0 B
packages/node/dist/extensions/context/types.mjs 0 B 0 B 🆕
packages/node/dist/extensions/error-tracking/autocapture.js 2.66 kB 0 B
packages/node/dist/extensions/error-tracking/autocapture.mjs 1.24 kB 0 B
packages/node/dist/extensions/error-tracking/index.js 4.14 kB 0 B
packages/node/dist/extensions/error-tracking/index.mjs 2.87 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/context-lines.node.js 8.81 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs 7.15 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/module.node.js 2.78 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/module.node.mjs 1.45 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/relative-path.node.js 1.97 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs 624 B 0 B
packages/node/dist/extensions/express.js 4.56 kB 0 B
packages/node/dist/extensions/express.mjs 2.45 kB 0 B
packages/node/dist/extensions/feature-flags/cache.js 603 B 0 B
packages/node/dist/extensions/feature-flags/cache.mjs 0 B 0 B 🆕
packages/node/dist/extensions/feature-flags/crypto.js 1.57 kB 0 B
packages/node/dist/extensions/feature-flags/crypto.mjs 395 B 0 B
packages/node/dist/extensions/feature-flags/feature-flags.js 40.6 kB 0 B
packages/node/dist/extensions/feature-flags/feature-flags.mjs 38.5 kB 0 B
packages/node/dist/extensions/nestjs.js 5 kB 0 B
packages/node/dist/extensions/nestjs.mjs 2.9 kB 0 B
packages/node/dist/extensions/sentry-integration.js 4.66 kB 0 B
packages/node/dist/extensions/sentry-integration.mjs 3.17 kB 0 B
packages/node/dist/extensions/tracing-headers.js 3.31 kB 0 B
packages/node/dist/extensions/tracing-headers.mjs 1.53 kB 0 B
packages/node/dist/feature-flag-evaluations.js 5.97 kB 0 B
packages/node/dist/feature-flag-evaluations.mjs 4.63 kB 0 B
packages/node/dist/storage-memory.js 1.52 kB 0 B
packages/node/dist/storage-memory.mjs 297 B 0 B
packages/node/dist/types.js 1.43 kB 0 B
packages/node/dist/types.mjs 224 B 0 B
packages/node/dist/version.js 1.21 kB 0 B
packages/node/dist/version.mjs 46 B 0 B
packages/nuxt/dist/module.mjs 5.29 kB 0 B
packages/nuxt/dist/runtime/composables/useFeatureFlagEnabled.js 566 B 0 B
packages/nuxt/dist/runtime/composables/useFeatureFlagPayload.js 690 B 0 B
packages/nuxt/dist/runtime/composables/useFeatureFlagVariantKey.js 591 B 0 B
packages/nuxt/dist/runtime/composables/usePostHog.js 128 B 0 B
packages/nuxt/dist/runtime/nitro-plugin.js 1.08 kB 0 B
packages/nuxt/dist/runtime/vue-plugin.js 1.14 kB 0 B
packages/plugin-utils/dist/cli.js 3.14 kB 0 B
packages/plugin-utils/dist/cli.mjs 1.64 kB 0 B
packages/plugin-utils/dist/config.js 3.07 kB 0 B
packages/plugin-utils/dist/config.mjs 1.83 kB 0 B
packages/plugin-utils/dist/index.js 4.3 kB 0 B
packages/plugin-utils/dist/index.mjs 217 B 0 B
packages/plugin-utils/dist/spawn-local.js 2.17 kB 0 B
packages/plugin-utils/dist/spawn-local.mjs 918 B 0 B
packages/plugin-utils/dist/utils.js 3.27 kB 0 B
packages/plugin-utils/dist/utils.mjs 1.3 kB 0 B
packages/react-native/dist/autocapture.js 5.05 kB 0 B
packages/react-native/dist/error-tracking/utils.js 2.58 kB 0 B
packages/react-native/dist/frameworks/wix-navigation.js 1.3 kB 0 B
packages/react-native/dist/hooks/useFeatureFlag.js 1.7 kB 0 B
packages/react-native/dist/hooks/useFeatureFlagResult.js 963 B 0 B
packages/react-native/dist/hooks/useFeatureFlags.js 921 B 0 B
packages/react-native/dist/hooks/useNavigationTracker.js 2.45 kB 0 B
packages/react-native/dist/hooks/usePostHog.js 544 B 0 B
packages/react-native/dist/hooks/utils.js 988 B 0 B
packages/react-native/dist/index.js 4.33 kB 0 B
packages/react-native/dist/logs-********.js 3.32 kB 0 B
packages/react-native/dist/native-deps.js 8.77 kB 0 B
packages/react-native/dist/optional/OptionalAsyncStorage.js 299 B 0 B
packages/react-native/dist/optional/OptionalExpoApplication.js 377 B 0 B
packages/react-native/dist/optional/OptionalExpoDevice.js 347 B 0 B
packages/react-native/dist/optional/OptionalExpoFileSystem.js 386 B 0 B
packages/react-native/dist/optional/OptionalExpoFileSystemLegacy.js 423 B 0 B
packages/react-native/dist/optional/OptionalExpoLocalization.js 383 B 0 B
packages/react-native/dist/optional/OptionalReactNativeDeviceInfo.js 415 B 0 B
packages/react-native/dist/optional/OptionalReactNativeLocalize.js 303 B 0 B
packages/react-native/dist/optional/OptionalReactNativeNavigation.js 415 B 0 B
packages/react-native/dist/optional/OptionalReactNativeNavigationWix.js 443 B 0 B
packages/react-native/dist/optional/OptionalReactNativeSafeArea.js 644 B 0 B
packages/react-native/dist/optional/OptionalReactNativeSvg.js 872 B 0 B
packages/react-native/dist/optional/OptionalSessionReplay.js 455 B 0 B
packages/react-native/dist/posthog-rn.js 46 kB 0 B
packages/react-native/dist/PostHogContext.js 329 B 0 B
packages/react-native/dist/PostHogErrorBoundary.js 3.19 kB 0 B
packages/react-native/dist/PostHogMaskView.js 1.68 kB 0 B
packages/react-native/dist/PostHogProvider.js 4.55 kB 0 B
packages/react-native/dist/storage.js 5.2 kB 0 B
packages/react-native/dist/surveys/components/BottomSection.js 1.46 kB 0 B
packages/react-native/dist/surveys/components/Cancel.js 909 B 0 B
packages/react-native/dist/surveys/components/ConfirmationMessage.js 1.65 kB 0 B
packages/react-native/dist/surveys/components/QuestionHeader.js 1.37 kB 0 B
packages/react-native/dist/surveys/components/QuestionTypes.js 13.3 kB 0 B
packages/react-native/dist/surveys/components/SurveyModal.js 6.27 kB 0 B
packages/react-native/dist/surveys/components/Surveys.js 6.58 kB 0 B
packages/react-native/dist/surveys/getActiveMatchingSurveys.js 2.64 kB 0 B
packages/react-native/dist/surveys/icons.js 9.97 kB 0 B
packages/react-native/dist/surveys/index.js 600 B 0 B
packages/react-native/dist/surveys/PostHogSurveyProvider.js 6.28 kB 0 B
packages/react-native/dist/surveys/survey-translations.js 1.11 kB 0 B
packages/react-native/dist/surveys/surveys-utils.js 14.2 kB 0 B
packages/react-native/dist/surveys/useActivatedSurveys.js 3.67 kB 0 B
packages/react-native/dist/surveys/useSurveyStorage.js 2.16 kB 0 B
packages/react-native/dist/tooling/expoconfig.js 4.02 kB 0 B
packages/react-native/dist/tooling/metroconfig.js 2.32 kB 0 B
packages/react-native/dist/tooling/posthogMetroSerializer.js 4.86 kB 0 B
packages/react-native/dist/tooling/utils.js 4.05 kB 0 B
packages/react-native/dist/tooling/vendor/expo/expoconfig.js 70 B 0 B
packages/react-native/dist/tooling/vendor/metro/countLines.js 237 B 0 B
packages/react-native/dist/tooling/vendor/metro/utils.js 3.35 kB 0 B
packages/react-native/dist/types.js 70 B 0 B
packages/react-native/dist/utils.js 1.14 kB 0 B
packages/react/dist/esm/index.js 21.2 kB 0 B
packages/react/dist/esm/slim/index.js 17.6 kB 0 B
packages/react/dist/esm/surveys/index.js 4.68 kB 0 B
packages/react/dist/umd/index.js 24.4 kB 0 B
packages/react/dist/umd/slim/index.js 20.4 kB 0 B
packages/react/dist/umd/surveys/index.js 5.45 kB 0 B
packages/rollup-plugin/dist/index.js 2.44 kB 0 B
packages/rrweb/packer/dist/base-********.js 18.2 kB 0 B
packages/rrweb/packer/dist/base-********.cjs 18.3 kB 0 B
packages/rrweb/packer/dist/base-********.umd.cjs 18.7 kB 0 B
packages/rrweb/packer/dist/base-********.umd.min.cjs 9.5 kB 0 B
packages/rrweb/packer/dist/pack.cjs 347 B 0 B
packages/rrweb/packer/dist/pack.js 285 B 0 B
packages/rrweb/packer/dist/pack.umd.cjs 1.63 kB 0 B
packages/rrweb/packer/dist/pack.umd.min.cjs 1.11 kB 0 B
packages/rrweb/packer/dist/packer.cjs 257 B 0 B
packages/rrweb/packer/dist/packer.js 136 B 0 B
packages/rrweb/packer/dist/packer.umd.cjs 662 B 0 B
packages/rrweb/packer/dist/packer.umd.min.cjs 626 B 0 B
packages/rrweb/packer/dist/unpack.cjs 769 B 0 B
packages/rrweb/packer/dist/unpack.js 702 B 0 B
packages/rrweb/packer/dist/unpack.umd.cjs 1.17 kB 0 B
packages/rrweb/packer/dist/unpack.umd.min.cjs 955 B 0 B
packages/rrweb/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.cjs 37.6 kB 0 B
packages/rrweb/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.js 37.5 kB 0 B
packages/rrweb/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.umd.cjs 38 kB 0 B
packages/rrweb/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.umd.min.cjs 22.2 kB 0 B
packages/rrweb/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.cjs 34.3 kB 0 B
packages/rrweb/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.js 34.2 kB 0 B
packages/rrweb/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.umd.cjs 34.7 kB 0 B
packages/rrweb/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.umd.min.cjs 20.5 kB 0 B
packages/rrweb/plugins/rrweb-plugin-console-record/dist/rrweb-plugin-console-record.cjs 14.9 kB 0 B
packages/rrweb/plugins/rrweb-plugin-console-record/dist/rrweb-plugin-console-record.js 14.8 kB 0 B
packages/rrweb/plugins/rrweb-plugin-console-record/dist/rrweb-plugin-console-record.umd.cjs 15.4 kB 0 B
packages/rrweb/plugins/rrweb-plugin-console-record/dist/rrweb-plugin-console-record.umd.min.cjs 7.33 kB 0 B
packages/rrweb/plugins/rrweb-plugin-console-replay/dist/rrweb-plugin-console-replay.cjs 5.01 kB 0 B
packages/rrweb/plugins/rrweb-plugin-console-replay/dist/rrweb-plugin-console-replay.js 4.9 kB 0 B
packages/rrweb/plugins/rrweb-plugin-console-replay/dist/rrweb-plugin-console-replay.umd.cjs 5.44 kB 0 B
packages/rrweb/plugins/rrweb-plugin-console-replay/dist/rrweb-plugin-console-replay.umd.min.cjs 2.64 kB 0 B
packages/rrweb/plugins/rrweb-plugin-sequential-id-record/dist/rrweb-plugin-sequential-id-record.cjs 681 B 0 B
packages/rrweb/plugins/rrweb-plugin-sequential-id-record/dist/rrweb-plugin-sequential-id-record.js 548 B 0 B
packages/rrweb/plugins/rrweb-plugin-sequential-id-record/dist/rrweb-plugin-sequential-id-record.umd.cjs 1.12 kB 0 B
packages/rrweb/plugins/rrweb-plugin-sequential-id-record/dist/rrweb-plugin-sequential-id-record.umd.min.cjs 829 B 0 B
packages/rrweb/plugins/rrweb-plugin-sequential-id-replay/dist/rrweb-plugin-sequential-id-replay.cjs 933 B 0 B
packages/rrweb/plugins/rrweb-plugin-sequential-id-replay/dist/rrweb-plugin-sequential-id-replay.js 820 B 0 B
packages/rrweb/plugins/rrweb-plugin-sequential-id-replay/dist/rrweb-plugin-sequential-id-replay.umd.cjs 1.37 kB 0 B
packages/rrweb/plugins/rrweb-plugin-sequential-id-replay/dist/rrweb-plugin-sequential-id-replay.umd.min.cjs 968 B 0 B
packages/rrweb/replay/dist/rrweb-replay.cjs 440 kB 0 B
packages/rrweb/replay/dist/rrweb-replay.js 439 kB 0 B
packages/rrweb/replay/dist/rrweb-replay.umd.cjs 442 kB 0 B
packages/rrweb/replay/dist/rrweb-replay.umd.min.cjs 209 kB 0 B
packages/rrweb/rrdom-nodejs/dist/rrdom-nodejs.cjs 150 kB 0 B
packages/rrweb/rrdom-nodejs/dist/rrdom-nodejs.js 149 kB 0 B
packages/rrweb/rrdom-nodejs/dist/rrdom-nodejs.umd.cjs 152 kB 0 B
packages/rrweb/rrdom-nodejs/dist/rrdom-nodejs.umd.min.cjs 70.8 kB 0 B
packages/rrweb/rrdom/dist/rrdom.cjs 174 kB 0 B
packages/rrweb/rrdom/dist/rrdom.js 173 kB 0 B
packages/rrweb/rrdom/dist/rrdom.umd.cjs 175 kB 0 B
packages/rrweb/rrdom/dist/rrdom.umd.min.cjs 80.8 kB 0 B
packages/rrweb/rrweb-snapshot/dist/replay.cjs 137 kB 0 B
packages/rrweb/rrweb-snapshot/dist/replay.js 137 kB 0 B
packages/rrweb/rrweb-snapshot/dist/replay.umd.cjs 160 kB 0 B
packages/rrweb/rrweb-snapshot/dist/replay.umd.min.cjs 73.8 kB 0 B
packages/rrweb/rrweb-snapshot/dist/types-********.cjs 18.3 kB 0 B
packages/rrweb/rrweb-snapshot/dist/types-********.umd.cjs 18.8 kB 0 B
packages/rrweb/rrweb-snapshot/dist/types-********.umd.min.cjs 9.31 kB 0 B
packages/rrweb/rrweb-snapshot/dist/types-********.js 17.8 kB 0 B
packages/rrweb/types/dist/rrweb-types.cjs 5.64 kB 0 B
packages/rrweb/types/dist/rrweb-types.js 5.38 kB 0 B
packages/rrweb/types/dist/rrweb-types.umd.cjs 6.04 kB 0 B
packages/rrweb/types/dist/rrweb-types.umd.min.cjs 2.8 kB 0 B
packages/rrweb/utils/dist/rrweb-utils.cjs 6.41 kB 0 B
packages/rrweb/utils/dist/rrweb-utils.js 5.95 kB 0 B
packages/rrweb/utils/dist/rrweb-utils.umd.cjs 6.82 kB 0 B
packages/rrweb/utils/dist/rrweb-utils.umd.min.cjs 3.51 kB 0 B
packages/types/dist/capture-log.js 603 B 0 B
packages/types/dist/capture-log.mjs 0 B 0 B 🆕
packages/types/dist/capture.js 603 B 0 B
packages/types/dist/capture.mjs 0 B 0 B 🆕
packages/types/dist/common.js 603 B 0 B
packages/types/dist/common.mjs 0 B 0 B 🆕
packages/types/dist/feature-flags.js 603 B 0 B
packages/types/dist/feature-flags.mjs 0 B 0 B 🆕
packages/types/dist/index.js 603 B 0 B
packages/types/dist/index.mjs 0 B 0 B 🆕
packages/types/dist/posthog-config.js 603 B 0 B
packages/types/dist/posthog-config.mjs 0 B 0 B 🆕
packages/types/dist/posthog.js 603 B 0 B
packages/types/dist/posthog.mjs 0 B 0 B 🆕
packages/types/dist/request.js 603 B 0 B
packages/types/dist/request.mjs 0 B 0 B 🆕
packages/types/dist/segment.js 603 B 0 B
packages/types/dist/segment.mjs 0 B 0 B 🆕
packages/types/dist/session-recording.js 603 B 0 B
packages/types/dist/session-recording.mjs 0 B 0 B 🆕
packages/types/dist/survey.js 603 B 0 B
packages/types/dist/survey.mjs 0 B 0 B 🆕
packages/types/dist/toolbar.js 603 B 0 B
packages/types/dist/toolbar.mjs 0 B 0 B 🆕
packages/types/dist/tree-shakeable.js 603 B 0 B
packages/types/dist/tree-shakeable.mjs 0 B 0 B 🆕
packages/web/dist/index.cjs 13.8 kB 0 B
packages/web/dist/index.mjs 13.7 kB 0 B
packages/webpack-plugin/dist/config.js 1.53 kB 0 B
packages/webpack-plugin/dist/config.mjs 543 B 0 B
packages/webpack-plugin/dist/index.js 5.38 kB 0 B
packages/webpack-plugin/dist/index.mjs 2.04 kB 0 B
tooling/changelog/dist/index.js 3.31 kB 0 B
tooling/rollup-utils/dist/index.js 1.17 kB 0 B
packages/mcp/dist/types.mjs 0 B 0 B 🆕

compressed-size-action

lucasheriques added a commit that referenced this pull request May 21, 2026
Four review items from the AI reviewer on the implementation PR:

1. (P1) `publishCustomEvent` was silently swallowed when the host opted
   out of auto-capture via `enableTracing: false`. That option is the
   master switch for *auto*-captured events (tool calls, listings,
   identify) — a user-initiated `publishCustomEvent` call is explicit
   and shouldn't be gated by it. Fixed in `publish.ts` by exempting
   `MCPAnalyticsEventType.custom` from the gate. Added a regression
   test in `publishCustomEvent.test.ts`.

2. (P2) Three helpers (`isToolResultError`, `applyResolvedMetadata`,
   `getContextArgument`) were defined identically in both `tracing.ts`
   and `tracing-v2.ts`. Extracted to a new `tracing-helpers.ts` along
   with `getEventDuration`; both files now import from it.

3. (P2) `setupToolCallTracing` in `tracing.ts` contained an inline copy
   of the initialize-handler wrapping that the also-exported
   `setupInitializeTracing` function already implements. Changed
   `setupInitializeTracing` to take `MCPServerLike` directly (it only
   ever used `highLevelServer.server` anyway) and replaced the inline
   block with a call. Updated the caller in `tracing-v2.ts` to pass
   `server.server` instead of `server`.

4. (P2) Removed the `[SESSION DEBUG]` prefix from the
   "Server already being tracked" log in `index.ts` — it was leftover
   development noise, not a useful prefix for production logs.

Verification:
- `pnpm --filter=@posthog/mcp test:unit` — 346 passing (was 345; +1 for
  the new `enableTracing: false` regression test).
- `pnpm --filter=@posthog/mcp lint` — clean.
- `pnpm --filter=@posthog/mcp build` — clean.

Generated-By: PostHog Code
Task-Id: baa7e0cd-4946-4524-a05f-42c547a55f44
@lucasheriques lucasheriques force-pushed the posthog-code/mcp-implementation branch from 54edfbe to 407003e Compare May 21, 2026 20:14
@lucasheriques lucasheriques requested review from a team, marandaneto and pauldambra May 21, 2026 20:50
lucasheriques added a commit that referenced this pull request May 21, 2026
Four review items from the AI reviewer on the implementation PR:

1. (P1) `publishCustomEvent` was silently swallowed when the host opted
   out of auto-capture via `enableTracing: false`. That option is the
   master switch for *auto*-captured events (tool calls, listings,
   identify) — a user-initiated `publishCustomEvent` call is explicit
   and shouldn't be gated by it. Fixed in `publish.ts` by exempting
   `MCPAnalyticsEventType.custom` from the gate. Added a regression
   test in `publishCustomEvent.test.ts`.

2. (P2) Three helpers (`isToolResultError`, `applyResolvedMetadata`,
   `getContextArgument`) were defined identically in both `tracing.ts`
   and `tracing-v2.ts`. Extracted to a new `tracing-helpers.ts` along
   with `getEventDuration`; both files now import from it.

3. (P2) `setupToolCallTracing` in `tracing.ts` contained an inline copy
   of the initialize-handler wrapping that the also-exported
   `setupInitializeTracing` function already implements. Changed
   `setupInitializeTracing` to take `MCPServerLike` directly (it only
   ever used `highLevelServer.server` anyway) and replaced the inline
   block with a call. Updated the caller in `tracing-v2.ts` to pass
   `server.server` instead of `server`.

4. (P2) Removed the `[SESSION DEBUG]` prefix from the
   "Server already being tracked" log in `index.ts` — it was leftover
   development noise, not a useful prefix for production logs.

Verification:
- `pnpm --filter=@posthog/mcp test:unit` — 346 passing (was 345; +1 for
  the new `enableTracing: false` regression test).
- `pnpm --filter=@posthog/mcp lint` — clean.
- `pnpm --filter=@posthog/mcp build` — clean.

Generated-By: PostHog Code
Task-Id: baa7e0cd-4946-4524-a05f-42c547a55f44
@lucasheriques lucasheriques force-pushed the posthog-code/mcp-implementation branch from 407003e to fe591a3 Compare May 21, 2026 20:53
@pauldambra
Copy link
Copy Markdown
Member

i found the docs you wrote were the best way for me to wrap my head around the SDK... wanna update those now we've made changes (or point me at them :))))

pauldambra and others added 3 commits May 26, 2026 14:43
#3669)

* chore: drop IE11 from browserslist, keep ES5 bundle as polyfill canary

Remove IE 11 from packages/browser/package.json#browserslist. The
ES5 bundle (array.full.es5.js) is still built with IE11-compatible
Babel targets (hard-coded in rollup.config.mjs) and validated by
es-check in CI, so it continues to act as a canary that surfaces
when we need a new polyfill.

The previous attempt to drop IE11 broke CI because two tests
(web-vitals.test.ts and posthog-core-also.test.ts) reference
let mockX: jest.Mock from inside jest.mock(...) factories. Jest
hoists the factory above the declaration, which is a TDZ bug. With
IE 11 in browserslist, babel-jest's @babel/preset-env was transpiling
let -> var, masking the bug. Switching the two declarations to var
is the canonical jest workaround for out-of-scope mock references.

Generated-By: PostHog Code
Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96

* fix: pin babel.config.cjs targets so testcafe IE11 keeps working

packages/browser/babel.config.cjs used @babel/preset-env without
explicit targets, which falls back to package.json#browserslist. That
config is what jest and testcafe both use to transpile sources and
test code. With IE 11 removed from browserslist, testcafe's
ClientFunction bodies stopped being transpiled to ES5 and the
browserstack IE11 test hung at posthog.init (the test runner injects
its ClientFunction wrapper into the page; IE11 chokes on arrow
functions and default params).

Pinning the babel targets here decouples this transpile pipeline from
package.json#browserslist. Same reason the rollup ES5 build hard-codes
its own targets in rollup.config.mjs.

This also restores the let -> var test fix from the previous commit:
with babel now consistently transpiling let to var for jest, the TDZ
bug in those jest.mock factories is masked again. Reverting keeps the
test source untouched relative to main.

Generated-By: PostHog Code
Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96

* fix: feed IE11 to testcafe via BROWSERSLIST env, not babel.config

testcafe ignores the project's babel config (BASE_BABEL_OPTIONS
sets babelrc: false, configFile: false). It transpiles its injected
ClientFunction wrappers with @babel/preset-env and no targets, which
falls back to the browserslist module — which reads
package.json#browserslist.

So the real lever for fixing the IE11 hang is browserslist, not
babel.config.cjs. Set BROWSERSLIST inline on the testcafe workflow
step instead, which:

- keeps package.json#browserslist clean (IE11 truly removed)
- keeps babel.config.cjs untouched (jest runs in node, no need to
  transpile to es5)
- limits the IE11 target to the one place it actually matters: the
  testcafe ClientFunction transpile pipeline

Revert babel.config.cjs and restore the let -> var fix in the two
jest.mock factories — the TDZ bug there is real (jest hoists the
factory above the let declaration), independent of any babel config.

Generated-By: PostHog Code
Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96

* fix: silence no-var on the TDZ workaround in two jest.mock factories

The var declarations are necessary so the assignments inside the
hoisted jest.mock factories don't hit TDZ. Add per-line
eslint-disable instead of leaving CI red on no-var.

Generated-By: PostHog Code
Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96

* chore: explain why the two jest.mock var declarations need eslint-disable

Generated-By: PostHog Code
Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96
…3667)

* fix(replay): stop polling preload-as-style <link> elements forever

Session recorder treated <link rel="preload" as="style" href="*.css"> as if it
were a stylesheet and waited for link.sheet to populate. Per spec preload
links never instantiate a CSSStyleSheet, so the wait timed out, recursively
re-serialized the link, scheduled another wait, and leaked a 'load' listener
on every cycle - multiplying further on every real load event. Pages with
Next.js-style CSS preloads accumulated thousands of active polling chains,
saturating the main thread and freezing the tab on refocus.

- Drop preload from the predicate so only rel=stylesheet schedules a wait.
- Replace the recursive serializeNodeWithId call with the serializedNode
  already in scope.
- Track tracked links in a WeakSet so repeat calls are no-ops; gate the load
  handler on the same 'fired' guard as the timer; pass { once: true } so the
  listener self-removes if a load event ever fires.

Added jsdom unit tests in rrweb-snapshot and a real-browser Playwright spec
that loads a page with five preload-as-style links, instruments
HTMLLinkElement.prototype.addEventListener, and asserts the count stays
bounded across timer cycles plus dispatched load events. Without the fix
the spec sees ~30 leaked listeners; with the fix it sees zero.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* fix(replay): re-serialize stylesheet link on load so _cssText reaches replay

qa-swarm found a convergent HIGH-severity regression: dropping the recursive
serializeNodeWithId call inside the load callback meant late-loading
<link rel="stylesheet"> elements would deliver their original pre-load
serializedNode to onStylesheetLoad — which has no _cssText, so
StylesheetManager.attachLinkElement (gated on '_cssText' in attributes) never
emitted the cssText mutation. Every replay with a stylesheet not loaded by
first snapshot would render unstyled.

The new WeakSet idempotency guard makes restoring the recursive call safe:
re-entry into onceStylesheetLoaded sees the link in the WeakSet and returns
early, so the chain cannot re-arm.

Also from qa-swarm:
- Parameterize the three new unit tests and add a fourth case that populates
  link.sheet between first serialize and load, asserting _cssText reaches
  onStylesheetLoad (regression coverage for the bug this commit fixes).
- Tighten the Playwright assertion from toBeLessThanOrEqual(5) to toBe(0) —
  preload-as-style links bypass onceStylesheetLoaded entirely now.
- HTML comment in the leak-repro playground explaining the CSS chunks are
  intentionally non-existent.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* chore(changeset): add @posthog/rrweb-snapshot to bumped packages

The fix lives in packages/rrweb/rrweb-snapshot/src/snapshot.ts so the
rrweb-snapshot package needs the same patch bump as posthog-js. Flagged by
the changeset-hygiene action.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* fix(replay): reset stylesheet-load tracking when StylesheetManager resets

The module-level stylesheetLoadTracked WeakSet persisted for the document
lifetime, so a recorder stop/restart on the same page (SPA toggling
session recording) silently skipped re-tracking any <link rel="stylesheet">
whose load was still pending from the previous lifecycle. The pending
{ once: true } listener was closed over the stopped recorder's
onStylesheetLoad, so the second recorder never received the _cssText
mutation when the sheet finally loaded.

Pre-fix this didn't bite because there was no skip — each call attached a
fresh listener (which was the leak being fixed). The WeakSet now resets
inside StylesheetManager.reset() so the second recorder sees a clean
tracker.

Added a jsdom test that exercises the cross-lifecycle path: serialize a
pending link, call resetStylesheetLoadTracking, serialize it again,
populate sheet, dispatch load — assert the second session receives a
_cssText payload.

Note: the WeakSet still lives in rrweb-snapshot rather than in
StylesheetManager. Moving it into the recorder would couple the snapshot
package to load-tracking state it does not own; threading the WeakSet
through serializeNodeWithId options is the cleaner long-term refactor.
For now the reset hook is the minimal fix.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* test(snapshot): pin firstSessionCalls to its actual value of 1

qa-swarm v2 flagged toBeLessThanOrEqual(1) as hand-wavy. The actual value
is 1, not 0 — even after resetStylesheetLoadTracking(), the first session's
{ once: true } load listener is still attached to the link element (reset
only clears the dedup tracker, not the listeners themselves). When the
sheet finally loads, both session 1's and session 2's listeners fire.

Pinning to toBe(1) documents this trade-off explicitly. The cost is one
duplicate attachLinkElement mutation per checkout-pending link (same id,
same _cssText — applied idempotently by the replayer). Tracked separately
as a follow-up to abort previous-snapshot listeners on reset.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* chore(lint): prettier-format playwright preload-link-leak spec

CI lint failed: my multi-line function signature broke prettier's printWidth.
Auto-fixed with `prettier --write`.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* chore(changeset): add @posthog/rrweb to bumped packages

ff5f56d modified packages/rrweb/rrweb/src/record/stylesheet-manager.ts
(the @posthog/rrweb package) when wiring resetStylesheetLoadTracking()
into the StylesheetManager.reset() hook. The changeset-hygiene action
flagged this as missing.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* fix(replay): tear down pending stylesheet listeners on reset

resetStylesheetLoadTracking() previously only cleared the WeakSet of
"already-tracked" links. The actual listener + setTimeout it had
scheduled on each link stayed attached. So when StylesheetManager.reset()
ran from takeFullSnapshot (start AND every checkout), the next full
snapshot would register a SECOND listener on still-pending links and
both listeners would fire when the sheet eventually loaded — emitting a
duplicate attachLinkElement mutation per pending link per checkout.

Switch the tracker to Map<HTMLLinkElement, { timer, onLoad }>. Reset now
iterates entries, clearTimeout each timer, removeEventListener each
named onLoad handler, then clears the Map. Each watch removes its own
entry from the Map after fire() runs (try/finally so a thrown listener
still cleans up), so successful loads behave exactly as before.

Stays within the existing browser support matrix — no AbortController,
no AbortSignal, just setTimeout/addEventListener with the named handler
we now retain a reference to. Strong refs in the Map are bounded by
pending stylesheets and cleared on every full-snapshot reset.

Updates the cross-lifecycle test (firstSessionCalls is now 0, not 1,
because the previous session's listener is removed in reset).

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* refactor(replay): use AbortController for stylesheet-load watch teardown

Same semantics as 3ed123d, modern shape. Each watch owns an
AbortController; the load listener is bound with { signal }, the timer
is bridged to the signal via a one-shot abort handler. resetStylesheetLoadTracking
just calls ac.abort() on every entry instead of manually iterating
timer + listener handles.

IE11 is in the compat matrix for historical reasons but session replay
already does not work there, so the AbortController dependency is fine.

Functionally identical: same Map<HTMLLinkElement, …> shape for the
idempotency check + reset iteration, same try/finally on listener,
same re-entry safety (delete happens AFTER listener() so the recursive
serializeNodeWithId call sees has(link) === true and returns early).

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* test(snapshot): rename cross-lifecycle test to lead with the behaviour

qa-swarm convergent NIT (paul + xp): the old name described the mechanism
("re-tracks a pending stylesheet link after resetStylesheetLoadTracking")
not the behaviour the test guards. The new name leads with what the
test asserts — that the previous session's listener is torn down — so
a future reader sees the regression intent without diffing the body.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* test(replay): add cross-lifecycle Playwright spec for stylesheet load tracking

End-to-end coverage of the listener-teardown-on-reset fix in a real browser.

The spec:
- Loads a page with no stylesheet in HTML.
- Holds the CSS response via a Playwright route.
- Injects a <link rel="stylesheet"> after recording starts (mutation
  observer picks it up).
- Configures session_recording.full_snapshot_interval_millis to 1500ms so
  rrweb's takeFullSnapshot fires repeatedly, each one calling
  StylesheetManager.reset() -> resetStylesheetLoadTracking(). Each
  checkout reschedules a fresh load watch on the still-pending link.
- Releases the CSS only after several checkouts have happened.
- Asserts the captured event stream contains exactly one _cssText
  attribute mutation for the link's mirror id.

Verified the spec catches the regression: with resetStylesheetLoadTracking
neutered to skip the controller.abort() loop, the spec sees 3 _cssText
mutations (one per checkout listener that wasn't torn down). With the
abort restored, exactly 1.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620

* test(replay): constrain cross-lifecycle stylesheet spec to chromium

CI showed the spec failing on Firefox and WebKit with Received: 0 — those
browsers do not populate link.sheet.cssRules from a Playwright-route-
fulfilled CSS response within our wait window. The end-to-end load
delivery doesn't complete in time, so the mutation is never emitted.

The fix being verified is JS-internal (Map+AbortController teardown on
reset) and browser-agnostic. The jsdom unit tests cover the logic
deterministically. The Playwright spec adds Chromium end-to-end
confirmation; non-Chromium coverage would need a different fixture
strategy (e.g., serving the CSS via a real test server instead of route
interception) and isn't worth the complexity here.

Generated-By: PostHog Code
Task-Id: 18dbe2b5-9a25-4b4c-a756-db029804f620
Comment thread packages/mcp/src/index.ts

const client = resolveClient(options)
if (!client) {
log('Warning: No PostHog project token configured. Events will not be sent anywhere.')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should return server already then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it does — line 57 (before the no-client log) returns early with return validatedServer as TServer when the server is already instrumented. the log at line 62 is for the separate case of no project token configured. ill let users configure projectToken via clientOptions later if they want, so we still wrap the server. but ack the readability — happy to short-circuit the no-token case too if you think thats cleaner.

@marandaneto
Copy link
Copy Markdown
Member

marandaneto commented May 27, 2026

a few thoughts:

  • i thought we dropped clientOptions from MCPAnalyticsOptions
  • enableAITracing and enableTracing (MCPAnalyticsOptions), is confusing, both have similar name but dif description, should we rename enableAITracing to enableAIObservability instead since its the new name of the product? i'd also make clear the description for enableTracing
  • i think publishCustomEvent should be called just capture as the other SDKs? i know the event name is $mcp_custom but this is an internal detail, what really matters here is resourceName right which is similar to event name for capture
  • i think redactSensitiveInformation should be renamed to beforeSend which is exactly what this is for the other SDKs, beforeSend can also apend/remove attributes and not only redact so more powerful
  • i see a lot of dupe from the node sdk, i wonder if using the node sdk directly would be better than core since its a node server anyway

maybe @pauldambra has opinions here as well

Comment thread packages/mcp/src/extensions/client.ts Outdated
* Push an MCP event through the pipeline (redact → sanitize → truncate → fan out → enqueue).
* Errors at any stage are logged and the event is dropped, never re-thrown into tool code.
*/
async ingest(event: UnredactedEvent, enableAITracing: boolean): Promise<void> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

all SDKs call this just capture or similar, i think this SDK is calling in many places with other synonyms like publish, ingest, etc, I'd align cus its already a mix across repositories and this one has all the 3 mixed up (see eg node sdk)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done in bc745bc. renamed client.ingest() -> client.capture() and the standalone publishEvent -> captureEvent (file publish.ts -> capture.ts). the public publishCustomEvent keeps its name since it semantically means "custom event, not auto-captured", but happy to revisit if you want everything called capture*.

* @param contextStack - Optional Error object to use for stack context (for validation errors)
* @returns ErrorData object with structured error information
*/
export function captureException(error: unknown, contextStack?: Error): ErrorData {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

node and rn have something called buildEventMessage or buildFromUnknown
this whole parsing now is being duplicated the 3rd time (not sure if they match 100%), but i do see a reason here to extract something of it to the core and reuse here, probably from node i guess

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

at least the stack trace part should be the same

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

are MCP servers minified? if so, we'll need to attach debug ids in order to symbolicate those errors

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agreed, this is duplicated work. filing as a follow-up — i did not want this pr to also touch @posthog/core since it would need a coordinated migration across node, react-native and us. happy to pick it up next.

on debug ids: yes, mcp servers built with tsdown/rollup/bun do get minified. the symbolication story for an mcp server is the same as for posthog-node (uploading sourcemaps via the cli), so once core gets the shared exception parsing, this falls out of the migration too.

Comment thread packages/mcp/src/extensions/publish.ts Outdated
* here with `eventType: custom` and bypass that gate — disabling auto-capture should not
* silently swallow events the host application explicitly chose to emit.
*/
export function publishEvent(server: MCPServerLike, eventInput: UnredactedEvent): void {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'd probably call capture

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, renamed publishEvent -> captureEvent (and the file). bc745bc.

* persist anything across restarts — every server gets a fresh client — so a
* plain object is enough. Mirrors `PostHogMemoryStorage` from `posthog-node`.
*/
export class PostHogMemoryStorage {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

node also has that, move to core and reuse

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ack, follow-up. would prefer to do this in a separate pr that touches @posthog/core so the migration is reviewable on its own. for now the duplication is intentional and small — PostHogMemoryStorage is ~20 lines.

Comment thread packages/mcp/src/types.ts
[key: string]: unknown
}

export interface MCPAnalyticsOptions {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

missing enableExceptionAutocapture?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch, added in bc745bc. enableExceptionAutocapture?: boolean on MCPAnalyticsOptions, defaults to true. unit-tested both default-on and explicit-off paths.

ioannisj and others added 7 commits May 27, 2026 12:51
* chore: ignore .worktrees directory

* chore: exclude examples from Dependabot and add reviewer

* chore: address review comments

* chore: drop block 2 and use team-client-libraries as reviewer
…p to 1.6.0 (#3673)

* chore(react-native): bump posthog-react-native-session-replay peer dep to 1.6.0

Bump the optional peer dependency `posthog-react-native-session-replay` from `>= 1.5.8` to `>= 1.6.0`. The new minor adds an opt-in path that resolves `posthog-ios` through Swift Package Manager via `"posthog.useSpm": "true"` in the consumer's `ios/Podfile.properties.json` + `use_frameworks! :linkage => :dynamic`. Default consumer behavior is unchanged.

`packages/react-native` itself has no podspec or native iOS code; `posthog-ios` only reaches RN apps via the session-replay peer dependency. Consumers who don't use session-replay are unaffected.

* chore: bump changeset to minor
* fix: speed up logs serialization

* test: cover budgeted log serialization

* test: strengthen logs serialization coverage

* fix: handle logs serializer edge cases

* fix: skip logs properties with non-serializable toJSON

* fix: serialize boxed primitives in logs

* perf: reduce logs serializer allocations

* fix: type boxed strings in logs serializer

* address pr review feedback
@lucasheriques lucasheriques requested a review from a team as a code owner May 27, 2026 17:27
…ocapture

Per @marandaneto review on PR #3653:

- Rename internal `publishEvent` -> `captureEvent` and file
  `publish.ts` -> `capture.ts`. Rename `PostHogMCP#ingest` ->
  `PostHogMCP#capture`. Aligns with posthog-node's `capture` verb
  instead of mixing publish/ingest/capture across the SDK.
- Add `enableExceptionAutocapture?: boolean` to MCPAnalyticsOptions
  (default true). Set to false to skip the parallel `$exception`
  event when a tool errors. Plumbed through
  `buildPostHogCaptureEvents` and the new `PostHogMCPCaptureOptions`
  passed to `client.capture()`. Unit tests cover both the default-on
  and explicit-off paths.

Public surface unchanged: `publishCustomEvent` is still the
user-facing name for arbitrary `$mcp_custom` events.

Generated-By: PostHog Code
Task-Id: baa7e0cd-4946-4524-a05f-42c547a55f44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants