Skip to content

[CI] (3f39e0e) stripe/stripe-saas-demo - #4186

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-3f39e0e-stripe-stripe-saas-demo
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-3f39e0e-stripe-stripe-saas-demo

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 3f39e0e
App: stripe/stripe-saas-demo
App directory: apps/stripe/stripe-saas-demo
Workbench branch: wizard-ci-3f39e0e-stripe-stripe-saas-demo
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-09-23T22:28:06.629Z
Duration: 132.4s

YARA Scanner

✓ 40 tool calls scanned, 0 violations detected

No violations: ✓ 40 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown
Author

Now I have all the context needed. Let me produce the evaluation report.


PR Evaluation Report

Summary

This PR adds PostHog revenue analytics integration to a Stripe SaaS demo app by propagating the PostHog distinct_id through the frontend API layer into Stripe metadata on checkout sessions, customers, and subscriptions. The base app already has PostHog SDK installed and initialized with capture/identify/error tracking — this PR only adds the Stripe↔PostHog identity linking.

Files changed Lines added Lines removed
6 +43 -9

Confidence score: 4/5 👍

  • client_reference_id regression in checkout.ts: The original code always set client_reference_id: userId. The new code only sets client_reference_id (now to posthogDistinctId) when posthogDistinctId is truthy. If it's absent, client_reference_id is dropped entirely — losing the userId linkage. [MEDIUM]
  • No reverse proxy configured: The frontend posthog-js SDK sends events directly to us.i.posthog.com, making them susceptible to ad blockers. No reverse proxy or rewrite is configured. [MEDIUM]

File changes

Filename Score Description
backend/routes/checkout.ts 3/5 Adds posthogDistinctId to Stripe session metadata and client_reference_id, but drops the original userId fallback
backend/routes/customers.ts 5/5 Adds posthog_person_distinct_id to Stripe customer metadata conditionally
backend/routes/subscriptions.ts 5/5 Adds posthog_person_distinct_id to Stripe subscription metadata conditionally
frontend/src/api.ts 5/5 Extends API functions with optional posthogDistinctId parameter
frontend/src/pages/Home.tsx 5/5 Passes distinctId to createCheckoutSession
frontend/src/pages/Subscribe.tsx 5/5 Passes posthog.get_distinct_id() to createSubscription

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes All changes are syntactically correct TypeScript
Preserves existing env vars & configs No client_reference_id: userId is dropped when posthogDistinctId is absent in checkout.ts
No syntax or type errors Yes Valid TypeScript throughout
Correct imports/exports Yes No new imports needed; existing imports unchanged
Minimal, focused changes Yes All 6 files relate to propagating the PostHog distinct ID to Stripe
Pre-existing issues See below Backend posthog.ts file exists locally but is not committed; frontend init missing defaults config

Issues

  • client_reference_id fallback removed: In checkout.ts, the original client_reference_id: userId was unconditionally set. The PR wraps it in a conditional that only sets it when posthogDistinctId is truthy. While posthog.get_distinct_id() always returns a value in practice (PostHog auto-generates anonymous IDs), the fallback to userId is lost. Fix: always set client_reference_id: posthogDistinctId || userId, and add the metadata separately. [MEDIUM]

Other completed criteria

  • Environment variables already documented in .env.example (pre-existing)
  • Build configuration is valid — no changes to package.json or tsconfig
  • Changes are minimal and focused on revenue analytics metadata propagation

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js@^1.205.2 (frontend) and posthog-node@^5.29.0 (backend) — pre-existing
PostHog client initialized Yes Frontend: posthog.init() in posthog.ts called from main.tsx. Backend: imported from ../posthog — pre-existing
capture() Yes Multiple capture calls: checkout_initiated, user_signed_up, payment_failed, subscription_started, etc. — pre-existing
identify() Yes posthog.identify(email, { email, name }) on sign-up; email as distinct_id is acceptable per docs as a fallback — pre-existing
Error tracking Yes posthog.captureException() used in Subscribe.tsx on payment failure — pre-existing
Reverse proxy No No reverse proxy configured; events sent directly to us.i.posthog.com

Issues

  • No reverse proxy: For a client-only app using posthog-js, a reverse proxy is recommended to prevent ad blockers from intercepting event capture. No Next.js rewrites, Vercel rewrites, or other proxy configuration is present. [MEDIUM]

Other completed criteria

  • API key loaded from VITE_POSTHOG_API_KEY / POSTHOG_API_KEY environment variables
  • Host correctly configured via VITE_POSTHOG_HOST / POSTHOG_HOST env vars
  • Stripe metadata correctly uses posthog_person_distinct_id key across checkout sessions, customers, and subscriptions
  • subscription_data.metadata set on checkout sessions to propagate distinct ID to created subscriptions

PostHog insights and events ✅

Filename PostHog events Description
Home.tsx checkout_initiated, user_signed_up, checkout_cancelled Tracks signup flow, checkout initiation with method/priceId, and cancellation
Subscribe.tsx payment_failed, subscription_started, captureException Tracks payment errors with error details, successful subscriptions, and exception capture
checkout.ts checkout_session_failed Server-side error tracking for failed checkout creation
customers.ts user_created, identify Server-side user creation and identification
webhooks.ts (unchanged) Stripe webhook events Handles checkout.session.completed, subscription.created, invoice.paid

Issues

No issues specific to event quality in this PR's changes.

Other completed criteria

  • Events represent real user actions in a subscription purchase funnel
  • Events enable product insights (signup → checkout → payment → subscription funnel)
  • Events include relevant properties (priceId, method, error codes, stripe IDs)
  • No PII introduced in capture properties by this PR
  • 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