Skip to content

[CI] (c3e1fec) javascript-node/fastify-blog - #3666

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-c3e1fec-javascript-node-fastify-blog
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-c3e1fec-javascript-node-fastify-blog

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: c3e1fec
App: javascript-node/fastify-blog
App directory: apps/javascript-node/fastify-blog
Workbench branch: wizard-ci-c3e1fec-javascript-node-fastify-blog
Wizard branch: brandon/gateway-responses-shape
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-08-28T22:14:51.091Z
Duration: 348.5s

YARA Scanner

✓ 118 tool calls scanned, 0 violations detected

No violations: ✓ 118 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates PostHog into a server-only Fastify blog API using the posthog-node SDK. It adds a dedicated posthog.js initialization module, captures events for CRUD operations on posts and comments, sets up error tracking via captureException in a global error handler, and gracefully shuts down PostHog on process signals. Environment variables are documented in .env.example.

Files changed Lines added Lines removed
4 +102 -1

Confidence score: 4/5 👍

  • All capture() calls are missing the required distinctId field — posthog-node's capture() requires distinctId as a mandatory property. Every capture call in this PR omits it, meaning events will either throw or be unattributable. [CRITICAL]
  • captureException called with undefined as distinctId — The error handler passes undefined for the distinct ID, so exceptions won't be linked to any user. [CRITICAL]

File changes

Filename Score Description
posthog.js 4/5 New module that initializes PostHog from env vars with null-safe pattern; good defensive coding
index.js 2/5 Adds capture calls for all CRUD actions and error handler, but every capture is missing distinctId
package.json 4/5 Adds posthog-node and dotenv dependencies correctly
.env.example 5/5 Documents required environment variables

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes Valid JS, dependencies are correct, app should start
Preserves existing env vars & configs Yes Existing fastify dependency and app logic preserved
No syntax or type errors No capture() calls omit the required distinctId field — this will cause runtime errors or silently produce invalid events
Correct imports/exports Yes posthog-node import is correct, posthog.js exports correctly
Minimal, focused changes Yes All changes are focused on PostHog integration
Pre-existing issues None Base app is clean

Issues

  • Missing distinctId in all capture() calls: The posthog-node SDK's capture() method requires a distinctId property. All four capture calls (post_created, post_updated, post_deleted, comment_created) omit it entirely. Each call should extract a user identifier from the request context (e.g., request.headers['x-user-id'], auth session, or a fallback like 'anonymous-server'). [CRITICAL]
  • captureException with undefined distinctId: The error handler calls posthog.captureException(error, undefined, {...}), passing undefined as the distinct ID. This means captured exceptions won't be associated with any user. [CRITICAL]

Other completed criteria

  • Environment variables documented in .env.example
  • Build configuration is valid (package.json has correct dependencies and scripts)
  • Graceful shutdown handler calls posthog.shutdown() to flush events

PostHog implementation ❌

Criteria Result Description
PostHog SDKs installed Yes posthog-node@^5.51.4 added to package.json dependencies
PostHog client initialized Yes new PostHog(projectToken, { host, enableExceptionAutocapture: true, flushAt: 1, flushInterval: 0 }) — correct server-side pattern with immediate flush
capture() No Four capture calls exist but all are missing the required distinctId field
identify() N/A Server-only app
Error tracking Yes Global Fastify error handler uses captureException() and enableExceptionAutocapture: true is set
Reverse proxy N/A Server-only app

Issues

  • Missing distinctId on every capture() call: posthog-node requires distinctId as a mandatory field in the capture call object ({ distinctId, event, properties }). None of the four capture calls include it. Without a distinct ID, events cannot be attributed to users and will fail the SDK's validation. Fix: extract a user identifier from the request (e.g., from an auth header, session, or request body author field) and pass it as distinctId. [CRITICAL]
  • captureException missing user context: The captureException call passes undefined for the distinct ID. While exception autocapture is enabled, manually captured exceptions should include a distinctId for user attribution. [MEDIUM]

Other completed criteria

  • API key loaded from POSTHOG_PROJECT_TOKEN environment variable
  • Host loaded from POSTHOG_HOST environment variable
  • posthog.shutdown() called on SIGINT/SIGTERM for clean event flushing
  • Null-safe initialization pattern (exports null if config is missing)

PostHog insights and events ⚠️

Filename PostHog events Description
index.js post_created Captures when a new blog post is created, with post_id and published properties
index.js post_updated Captures post updates with flags for which fields changed
index.js post_deleted Captures post deletion with post_id
index.js comment_created Captures new comments with comment_id and post_id
index.js captureException Captures unhandled route errors with endpoint, method, and status code

Issues

  • Events lack user attribution: Without distinctId, none of these events can be used for per-user funnels, retention, or user-level analysis. The author field is available in request bodies for post/comment creation and could serve as a basis for distinct IDs. [CRITICAL]

Other completed criteria

  • Events represent real user actions (CRUD operations on a blog)
  • Events enable product insights (could build funnels like post_created → comment_created)
  • Events include relevant contextual properties (post_id, published status, field-level change tracking)
  • No PII in event properties
  • Event names are descriptive and use consistent snake_case convention

Reviewed by wizard workbench PR evaluator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants