13 — Observability and Growth
Tiered PostHog+Sentry+GA4 stacks wired from day one; feature flags, PLG patterns, incident auto-remediation.
Instrumentation tiers
Per _kernel/standards.md#integrations:
- Tier 1 (solo) — PostHog + Workers Tracing OTLP (2 vendors max, cookie-free, free tier covers <10k MAU)
- Tier 2 (enterprise) — + Sentry
@sentry/cloudflare v9 + GA4/GTM + Axiom
- Tier 3 (LLM-heavy >10k calls/mo) — + AI Gateway
PostHog (Tier 1 cornerstone)
- Snippet on every HTML page w/
persistence:'memory' (cookie-free); capture_pageview + capture_pageleave + autocapture:true
- Unified platform: product analytics + feature flags + session replay + error tracking
- CSP:
script-src + connect-src for posthog domain
- Per-feature event naming:
<feature>:<action> (signup:complete, editor:save, share:copy)
Sentry (Tier 2)
@sentry/cloudflare v11 (stream trace lifecycle default since 11.0) + withSentry wrapper; project via mcp__sentry__create_project (org:megabyte-labs)
SENTRY_DSN via wrangler secret put
- Pattern:
withSentry(env => ({ dsn, tracesSampleRate: 1.0, sendDefaultPii: false }), worker)
- Breadcrumbs before risky ops; capture exception w/ context tags (
worker | route | userId)
- Release tracking via
SENTRY_RELEASE env; Workers Tracing handles I/O spans
Workers Tracing (Tier 1 + 2) / GA4 + GTM (Tier 2) / AI Gateway (Tier 3)
- Workers Tracing:
[observability] enabled = true in wrangler.jsonc — zero-config OTel I/O tracing; export to Axiom, Honeycomb, Grafana, Datadog via @opentelemetry/exporter-trace-otlp-http
- GA4 + GTM: container snippet (head script + noscript iframe); CSP:
googletagmanager.com + google-analytics.com + analytics.google.com + region1.google-analytics.com; server-side tagging for EU; custom dimensions over custom events
- AI Gateway:
env.AI.run() auto-routes; direct Anthropic: https://gateway.ai.cloudflare.com/v1/{account}/{gateway}/anthropic/v1/messages; caching + rate-limit + fallback + per-call logging
Stripe + Link (accept-money default, ALL flows — per rules/payments.md)
- Accept default w/ Link ON everywhere (Payment Element / Checkout / Payment Links); Instant Bank Payments on high-ticket + donation flows
- Webhook-first w/ idempotent processing (D1 dedupe table
payment_events(event_id, source, processed_at) UNIQUE)
Stripe-Signature HMAC + 5-min replay window
- Mint products + prices via MCP (idempotent via
lookup_key); subscription state machine in D1
STRIPE_WEBHOOK_SECRET via POST /v1/webhook_endpoints
Square (on-request rail ONLY — per rules/payments.md)
- Only when the prompt names Square: Web Payments SDK card form + Apple Pay + Google Pay + Cash App Pay
Square-Signature HMAC-SHA256 w/ 6-hr replay window; idempotency_key UUID per request (24-hr dedupe)
- No 501(c)(3) discount exists (verified 2026-10) — custom rates only ≥$250K/yr
Listmonk (newsletter — self-hosted on Coolify)
- Amazon SES SMTP relay (
LISTMONK_FROM_EMAIL); listmonkSendTx(env, { templateAlias, ... }) via KV-cached alias→id map
- Templates in
emails/*.html synced via scripts/listmonk-sync.mjs
- Auth:
Authorization: token <user>:<key> (Listmonk 3.x API-user pattern)
PLG 7-Layer Framework
- Discovery — SEO + AI search + word-of-mouth + paid
- Sign-up — passwordless preferred (Clerk M2M JWT)
- Activation — first-value-in-X-min metric (aha moment per
rules/feature-flags.md instrumentation)
- Engagement — DAU/MAU ratio, session depth
- Retention — D1/D7/D30 cohort
- Revenue — upgrade trigger, expansion
- Referral — viral coefficient, two-sided rewards
Programmatic SEO (5 page types)
/integrations/{tool} · /compare/{a}-vs-{b} · /for/{audience} · /templates/{type} · /{city}-{service}
- Each: unique H1 + meta desc + 800+ unique words + 1 unique image + 3+ internal links + 1+ outbound citation. Cap 200 pages per axis.
- Per
rules/copy-writing.md § pSEO + rules/thin-source-amplification.md.
GEO / AI search
- Quotable answer blocks 40-60 words (LLM citation magnet); FAQPage schema highest AI-citation rate (ChatGPT / Perplexity / Google AI Overviews)
- JSON-LD facts MUST also appear as visible HTML body text; lead paragraphs answer query in <40 words
- EEAT: author bio +
Person schema + sameAs + dated revision + ownership statement
llms.txt at site root (DX-only, <0.3% adoption — not build gate)
Local-business conversions + CRO
Track per local-conversions.md: phone_click (tel:) · direction_click (Google Maps) · form_submit · booking_click (Calendly/Cal.com) · chat_click · review_click (Google Business/Yelp). Each fires PostHog + Sentry breadcrumb + (Tier 2) GA4 conversion event.
CRO: sticky CTA bar on mobile · scroll-progress bar (subtle) · exit-intent modal (cart/pricing only, not blogs) · social proof near every CTA · urgency without dark patterns ("3 spots left this week" if true) · trust strip above fold · single primary CTA per surface.
Incident auto-remediation
Sentry → Inngest pipeline: (1) Sentry webhook on event.alert.triggered → (2) Inngest dispatches incident-responder agent → (3) agent reads event, traces to source file, proposes fix, opens PR via gh MCP → (4) PR auto-merges if all CI gates pass per rules/ai-seniority.md.
See submodules: posthog, ga4-gtm, sentry, stripe-billing, square-payments, listmonk, plg-framework, programmatic-seo, incident-remediation, geo-ai-search, local-conversions.
1---2name: observability-and-growth-23description: "Full instrumentation from day one. PostHog consolidates product analytics + feature flags + error tracking (one platform, one bill). GA4 via GTM (14-step automation, custom dimensions over events, server-side tagging). Sentry (deep error tracking + performance). Stripe (webhook-first with idempotent processing). Listmonk on Coolify (newsletters via Amazon SES SMTP relay). PLG 7-layer framework. Programmatic SEO (5 page types). Incident auto-remediation via Sentry→Inngest pipeline. AI search (GEO) awareness. Local business conversions (phone_click, direction_click, form_submit, booking_click) with CRO patterns for both SaaS and local."4metadata:5 source: https://skillmd.com/skills/heymegabyte/observability-and-growth-26 version: "2.1.0"7 updated: "2026-05-03"8 effort: "high"9 model: "sonnet"10license: "Rutgers"11compatibility:12 claude-code: ">=2.0.0"13 agentskills: ">=1.0.0"14submodules:15 - analytics-configuration.md16 - conversion-optimization.md17 - email-marketing-and-listmonk.md18 - feature-flags-and-experiments.md19 - sentry-alert-rules.md20 - square-payments.md21 - stripe-billing.md22 - user-feedback-collection.md23 - workers-tracing-otlp.md24priority: 225pack: "backend"26stage: stable27triggers:28 - "posthog"29 - "sentry"30 - "analytics"31 - "stripe"32 - "growth"33paths:34 - "concern:observability"35---3637# 13 — Observability and Growth3839Tiered PostHog+Sentry+GA4 stacks wired from day one; feature flags, PLG patterns, incident auto-remediation.4041## Instrumentation tiers4243Per `_kernel/standards.md#integrations`:4445- **Tier 1 (solo)** — PostHog + Workers Tracing OTLP (2 vendors max, cookie-free, free tier covers <10k MAU)46- **Tier 2 (enterprise)** — + Sentry `@sentry/cloudflare` v9 + GA4/GTM + Axiom47- **Tier 3 (LLM-heavy >10k calls/mo)** — + AI Gateway4849## PostHog (Tier 1 cornerstone)5051- Snippet on every HTML page w/ `persistence:'memory'` (cookie-free); `capture_pageview` + `capture_pageleave` + `autocapture:true`52- Unified platform: product analytics + feature flags + session replay + error tracking53- CSP: `script-src` + `connect-src` for posthog domain54- Per-feature event naming: `<feature>:<action>` (`signup:complete`, `editor:save`, `share:copy`)5556## Sentry (Tier 2)5758- `@sentry/cloudflare` v11 (stream trace lifecycle default since 11.0) + `withSentry` wrapper; project via `mcp__sentry__create_project` (org:`megabyte-labs`)59- `SENTRY_DSN` via `wrangler secret put`60- Pattern: `withSentry(env => ({ dsn, tracesSampleRate: 1.0, sendDefaultPii: false }), worker)`61- Breadcrumbs before risky ops; capture exception w/ context tags (`worker` | `route` | `userId`)62- Release tracking via `SENTRY_RELEASE` env; Workers Tracing handles I/O spans6364## Workers Tracing (Tier 1 + 2) / GA4 + GTM (Tier 2) / AI Gateway (Tier 3)6566- Workers Tracing: `[observability] enabled = true` in `wrangler.jsonc` — zero-config OTel I/O tracing; export to Axiom, Honeycomb, Grafana, Datadog via `@opentelemetry/exporter-trace-otlp-http`67- GA4 + GTM: container snippet (head script + noscript iframe); CSP: `googletagmanager.com` + `google-analytics.com` + `analytics.google.com` + `region1.google-analytics.com`; server-side tagging for EU; custom dimensions over custom events68- AI Gateway: `env.AI.run()` auto-routes; direct Anthropic: `https://gateway.ai.cloudflare.com/v1/{account}/{gateway}/anthropic/v1/messages`; caching + rate-limit + fallback + per-call logging6970## Stripe + Link (accept-money default, ALL flows — per `rules/payments.md`)7172- Accept default w/ Link ON everywhere (Payment Element / Checkout / Payment Links); Instant Bank Payments on high-ticket + donation flows73- Webhook-first w/ idempotent processing (D1 dedupe table `payment_events(event_id, source, processed_at)` UNIQUE)74- `Stripe-Signature` HMAC + 5-min replay window75- Mint products + prices via MCP (idempotent via `lookup_key`); subscription state machine in D176- `STRIPE_WEBHOOK_SECRET` via `POST /v1/webhook_endpoints`7778## Square (on-request rail ONLY — per `rules/payments.md`)7980- Only when the prompt names Square: Web Payments SDK card form + Apple Pay + Google Pay + Cash App Pay81- `Square-Signature` HMAC-SHA256 w/ 6-hr replay window; `idempotency_key` UUID per request (24-hr dedupe)82- No 501(c)(3) discount exists (verified 2026-10) — custom rates only ≥$250K/yr8384## Listmonk (newsletter — self-hosted on Coolify)8586- Amazon SES SMTP relay (`LISTMONK_FROM_EMAIL`); `listmonkSendTx(env, { templateAlias, ... })` via KV-cached alias→id map87- Templates in `emails/*.html` synced via `scripts/listmonk-sync.mjs`88- Auth: `Authorization: token <user>:<key>` (Listmonk 3.x API-user pattern)8990## PLG 7-Layer Framework91921. **Discovery** — SEO + AI search + word-of-mouth + paid932. **Sign-up** — passwordless preferred (Clerk M2M JWT)943. **Activation** — first-value-in-X-min metric (aha moment per `rules/feature-flags.md` instrumentation)954. **Engagement** — DAU/MAU ratio, session depth965. **Retention** — D1/D7/D30 cohort976. **Revenue** — upgrade trigger, expansion987. **Referral** — viral coefficient, two-sided rewards99100## Programmatic SEO (5 page types)101102- `/integrations/{tool}` · `/compare/{a}-vs-{b}` · `/for/{audience}` · `/templates/{type}` · `/{city}-{service}`103- Each: unique H1 + meta desc + 800+ unique words + 1 unique image + 3+ internal links + 1+ outbound citation. Cap 200 pages per axis.104- Per `rules/copy-writing.md` § pSEO + `rules/thin-source-amplification.md`.105106## GEO / AI search107108- Quotable answer blocks 40-60 words (LLM citation magnet); FAQPage schema highest AI-citation rate (ChatGPT / Perplexity / Google AI Overviews)109- JSON-LD facts MUST also appear as visible HTML body text; lead paragraphs answer query in <40 words110- EEAT: author bio + `Person` schema + `sameAs` + dated revision + ownership statement111- `llms.txt` at site root (DX-only, <0.3% adoption — not build gate)112113## Local-business conversions + CRO114115Track per `local-conversions.md`: `phone_click` (`tel:`) · `direction_click` (Google Maps) · `form_submit` · `booking_click` (Calendly/Cal.com) · `chat_click` · `review_click` (Google Business/Yelp). Each fires PostHog + Sentry breadcrumb + (Tier 2) GA4 conversion event.116117CRO: sticky CTA bar on mobile · scroll-progress bar (subtle) · exit-intent modal (cart/pricing only, not blogs) · social proof near every CTA · urgency without dark patterns ("3 spots left this week" if true) · trust strip above fold · single primary CTA per surface.118119## Incident auto-remediation120121Sentry → Inngest pipeline: (1) Sentry webhook on `event.alert.triggered` → (2) Inngest dispatches `incident-responder` agent → (3) agent reads event, traces to source file, proposes fix, opens PR via gh MCP → (4) PR auto-merges if all CI gates pass per `rules/ai-seniority.md`.122123## See submodules: posthog, ga4-gtm, sentry, stripe-billing, square-payments, listmonk, plg-framework, programmatic-seo, incident-remediation, geo-ai-search, local-conversions.