Commit Graph

7 Commits

Author SHA1 Message Date
Sam Julien d72c03e7b9 docs: track Rich Threads conversion actions 2026-07-22 15:46:32 -07:00
Jordan Ritter dcd3c16fd3 feat(showcase): route shell-docs analytics + middleware through runtime config
Migrate the remaining shell-docs consumers of NEXT_PUBLIC_* env vars
off of process.env reads and onto the runtime-config readers:

  - lib/providers/posthog-provider.tsx (client): the PostHog key is
    pulled inside PostHogProvider so the value reflects the current
    deploy's NEXT_PUBLIC_POSTHOG_KEY; empty string disables analytics
    via the existing truthiness gates around init/capture
  - lib/providers/scarf-pixel.tsx (client): pixel id read at render
    time; empty string returns null (existing no-op behavior preserved)
  - lib/hooks/use-google-analytics.tsx (client): GA tracking id read
    at hook invocation; empty string short-circuits via the existing
    `if (!GA_ID) return` guard
  - middleware.ts (Edge): POSTHOG_HOST is now resolved per-request via
    getRuntimeConfigEdge() (the Edge wrapper skips unstable_noStore()
    since next/cache is unavailable there and middleware always runs
    per-request anyway). Server-side POSTHOG_KEY is unchanged — it's
    not a NEXT_PUBLIC_* var.
2026-05-29 11:45:07 -07:00
Sam Julien 601b726631 refactor(shell-docs): remove obsolete PostHog console suppressor
The suppressor was carried over from the original telemetry-stack port
of upstream's posthog-provider.tsx. Its job was masking
ERR_BLOCKED_BY_CONTENT_BLOCKER noise from PostHog requests being
blocked by ad blockers targeting *.i.posthog.com directly.

This PR ships the /ingest reverse proxy (mirroring upstream #4554), so
PostHog calls now flow through the docs host and the underlying
hostname is invisible to ad blockers. With nothing to suppress, the
mask only hid real errors that mention "posthog". Three concrete
problems on top of the dead-code framing:

- Substring match on "posthog" swallows unrelated messages.
- isInitializedRef.current only guards the same component instance,
  so HMR or StrictMode remounts re-capture the already-patched
  console.error and layer wrappers on each remount.
- originalLog is captured but console.log is never patched.

Resolves PDX-112.
2026-05-06 15:33:15 -07:00
Sam Julien 68c997b066 refactor(shell-docs): align analytics surface with upstream LCP trim
Mirrors upstream #4646 in two changes from the same PR:

- Drop the duplicate useRB2B hook in favor of the canonical
  <Script id="reb2b-script"> in app/layout.tsx (gated on REB2B_KEY).
  Env var renames from NEXT_PUBLIC_RB2B_ID (the hook's name) to
  NEXT_PUBLIC_REB2B_KEY (upstream's canonical name) — deployment
  ops will need updating.
- Set capture_dead_clicks: false on PostHog init so the
  dead-clicks-autocapture.js bundle isn't pulled in on the critical
  path.
2026-05-06 15:32:33 -07:00
Sam Julien e1b3e363fa feat(shell-docs): track CLI command copies via global writeText hook
Mirrors upstream #4643 + #4646 follow-ups. New trackCommandCopy helper
infers install_type from the leading token (covers npx/pnpm/pip/uv/
docker/curl/brew/helm/kubectl/make/bash/sh, falls back to "code"), and
the CopyTracker provider monkey-patches navigator.clipboard.writeText
once at app boot so every programmatic copy fires cli_command_copied
without per-component instrumentation. Preserves upstream's chained-
wrapper pattern so it coexists with Reo's writeText patch.

Final event shape is { install_type, location? } — the command body
and product props from the original draft were dropped upstream
(commit 0b7b3c77c) before merge.
2026-05-06 15:32:33 -07:00
Sam Julien 4bbe4dccdf feat(shell-docs): reverse-proxy PostHog through /ingest
Routes PostHog analytics through /ingest/* (rewrites to eu.i.posthog.com)
so requests bypass ad blockers and tracking-protection that target the
*.i.posthog.com hostname directly. Hardcodes POSTHOG_HOST = "/ingest"
in the provider, points ui_host at https://eu.posthog.com so PostHog UI
links still resolve, and excludes /ingest from the middleware matcher
so the proxy itself doesn't fire phantom pageviews. Mirrors the same
fix in docs/.
2026-05-06 15:32:33 -07:00
Sam Julien b355a9aec0 feat(shell-docs): port docs telemetry stack
Brings PostHog, GA4, HubSpot, Reo.dev, Scarf, and RB2B into shell-docs
with parity to docs/. Adds the client-side PostHog provider with
session-stitched bootstrap and pageview capture, the AnalyticsClient
wrapper that mounts RB2B + GA4 hooks behind a single client boundary,
the Scarf pixel for OSS attribution, and the HubSpot and Reo.dev
scripts.

Renames POSTHOG_PROJECT_KEY to POSTHOG_KEY across shell and shell-docs
middlewares so the env names match the upstream pattern, and env-drives
POSTHOG_HOST with eu.i.posthog.com as the fallback.
2026-05-06 15:32:31 -07:00