Skip to content

fix: upgrade posthog-node to v5 to fix missing telemetry events#28

Merged
AmanVarshney01 merged 1 commit intomainfrom
aman/upgrade-posthog-node
Mar 17, 2026
Merged

fix: upgrade posthog-node to v5 to fix missing telemetry events#28
AmanVarshney01 merged 1 commit intomainfrom
aman/upgrade-posthog-node

Conversation

@AmanVarshney01
Copy link
Member

@AmanVarshney01 AmanVarshney01 commented Mar 17, 2026

Summary

  • Upgrades posthog-node from 4.18.0 to 5.28.2 to fix a bug where captureImmediate didn't properly await the HTTP request, causing telemetry events to be silently dropped before process.exit()
  • Removes deprecated captureMode and persistence constructor options that no longer exist in v5

Root cause

In posthog-node v4, captureImmediate() had a missing return in a .then() chain, so the promise resolved before the HTTP request completed. Since trpc-cli calls process.exit() after the handler finishes, the in-flight request was killed. This is fixed in v5.

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated PostHog analytics library to the latest version
    • Optimized internal telemetry data collection and configuration handling

…HTTP request

posthog-node v4's `captureImmediate` had a bug where the `.then()` chain
didn't return the promise from `captureStatelessImmediate`, causing the
HTTP request to be fire-and-forget. Combined with trpc-cli calling
`process.exit()` after the handler completes, telemetry events were
silently dropped before the request could finish.

This upgrades posthog-node from 4.18.0 to 5.28.2 where the bug is fixed,
and removes the deprecated `captureMode` and `persistence` options that
no longer exist in v5.
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Updated posthog-node dependency from version 4.18.0 to ^5.28.2 (major version). Refactored telemetry client to compute anonymousId and sanitizedProperties once rather than repeatedly, and removed explicit captureMode and persistence configuration settings.

Changes

Cohort / File(s) Summary
Dependency Update
package.json
Updated posthog-node from 4.18.0 to ^5.28.2, introducing a major version change.
Telemetry Client Refactoring
src/telemetry/client.ts
Consolidated anonymousId and sanitizedProperties computation to occur once per invocation; removed captureMode: "json" and persistence: "memory" from PostHog client configuration.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: upgrading posthog-node to v5 to address missing telemetry events. It is specific, concise, and directly related to the primary objective of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch aman/upgrade-posthog-node
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

PR preview published

  • Version: 0.3.0-pr.28.42.1
  • Tag: pr28
  • Run with Bun: bunx create-prisma@pr28
  • Run with npm: npx create-prisma@pr28
  • Run with Yarn: yarn dlx create-prisma@pr28
  • Run with pnpm: pnpm dlx create-prisma@pr28
  • Run with Deno: deno run -A npm:create-prisma@pr28
  • Workflow run: https://github.com/prisma/create-prisma/actions/runs/23208696949

@AmanVarshney01 AmanVarshney01 merged commit 550ea30 into main Mar 17, 2026
2 of 3 checks passed
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.

2 participants