Repository navigation
test(node): read capture events from either wire format - #5414
Conversation
Add shared helpers that find analytics capture requests on the legacy /batch/ endpoint or the capture v1 analytics endpoint, and return their events in the legacy shape. A v1 event's options, session and window ids and SDK info header map back to the properties they replace, so one assertion holds for both formats. Port the tests that read events off the wire to these helpers, and answer capture requests with a body that both senders accept. The same tests pass on the legacy default and with POSTHOG_CAPTURE_MODE=v1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The collector accepted only the legacy /batch/ request. It now also accepts the capture v1 analytics and AI endpoints with a bearer token, and returns their events in the legacy shape, so the replay tests hold for both wire formats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The example tests read events only from /batch/ calls and checked the api_key in the body. Read them from the legacy or the capture v1 analytics endpoint, and accept the project key from the body or the bearer token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
📝 No Changeset FoundThis PR doesn't include a changeset. A changeset is required to release a new version. How to add a changesetRun this command and follow the prompts: pnpm changesetRemember: Never use |
Coherence4 spec problems · 0 failing chokepoints · 2 spec gaps · 0 guard failures 44 components, 7 bullets (5 invariants, 2 requirements), 4 problems Spec problems (spec --check)
Chokepoints: none declared. Spec gaps: 2 entrances with outside or unknown trust and no traced control, and 10 more held by the adoption baseline
Close one with |
Node SDK compliance v2Commit: fac9423 Capture v0 — acceptance✅ 28 passed / ❌ 3 non-passing / Drill-down: run artifacts → ❌ server_snapshot_payload_false — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ server_snapshot_payload_zero — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ server_snapshot_payload_null — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: Harness exit: 1; report validation exit: 1. Capture v1 — acceptance✅ 28 passed / ❌ 3 non-passing / Drill-down: run artifacts → ❌ server_snapshot_payload_false — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ server_snapshot_payload_zero — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ server_snapshot_payload_null — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: Harness exit: 1; report validation exit: 1. Capture v0 — migration✅ 55 passed / ❌ 1 non-passing / Drill-down: run artifacts → ❌ migration/yaml-parity-v1/remote-flags-v1.feature::Omitted GeoIP settings default to enabled in flag requests — failed_assertionFlags field differs Code: Failed step: migration/yaml-parity-v1/remote-flags-v1.feature:134 the first flags request field "geoip_disable" should equal JSON false Operation: Field: Expected: false Actual value: true Harness exit: 1; report validation exit: 1. Capture v1 — migration✅ 120 passed / ❌ 1 non-passing / Drill-down: run artifacts → ❌ migration/yaml-parity-v1/remote-flags-v1.feature::Omitted GeoIP settings default to enabled in flag requests — failed_assertionFlags field differs Code: Failed step: migration/yaml-parity-v1/remote-flags-v1.feature:134 the first flags request field "geoip_disable" should equal JSON false Operation: Field: Expected: false Actual value: true Harness exit: 1; report validation exit: 1. |
dustinbyrne
left a comment
There was a problem hiding this comment.
Looks good for the capture-v1 stack. The normalization stays in tests/private tooling and preserves the existing assertions. One optional recorded-call type consistency fix is noted inline. The outstanding Next.js installation failure is unrelated to this diff.
AI-assisted review.
…e requires Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
posthog-node's tests read sent events from the legacy
/batch/request body. Moving the SDK to capture v1 would rewrite hundreds of assertions in the same PR as the behavior change, which hides the real changes. This is the first PR stacked on the posthog-node 6 branch (#5407).Changes
packages/node/src/__tests__/utils/index.ts(sentEvents,lastSentBatch,captureRequests,sentEventsOf,anyCaptureUrl) read sent events from either wire format. They return v1 events in the legacy shape:options,session_id,window_idand the library from thePostHog-Sdk-Infoheader go back intoproperties.@posthog/aicassette collector accepts both legacy and v1 requests.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Authored with Claude Code (Claude Opus 5.5), directed by @eli-r-ph.
check-types, format, oxlint, the@posthog/aicassette harness and the convex tests pass.🤖 Generated with Claude Code