← Back to Pull requests

feat(tools): relay opt-in extension usage events and feedback to PostHog #616

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 18, 2026 02:18 UTC
Author

What does this PR change?

The site middleware on blender.scenario.com now relays the extension's opt-in usage events and
user-written feedback to PostHog, so the extension needs no vendor SDK and never holds the project
token (#128). POST /telemetry/v1/events forwards only allowlisted events to PostHog's /batch/
endpoint, with MCP events under PostHog's MCP analytics names. POST /telemetry/v1/feedback sends
a rating, message and optional email as a response to an API survey and answers within four
seconds. Both accept only small JSON from a ScenarioBlender/ User-Agent, rate-limit per IPv4
address or IPv6 /64 in memory, and never reach GitHub Pages. Download counting is unchanged.

Events are anonymous: distinct_id is the extension's random install ID, not linked to the
Scenario account (a decision taken while the maintainer was away, to confirm), with no person
profile and no GeoIP. PostHog's endpoints, survey fields and MCP property names were checked
against posthog-js, posthog-python, the PostHog server and posthog.com docs.

After merge:

1. In the PostHog project that receives extension_downloaded, enable Surveys if needed, then
create and launch an API survey with a rating question (scale 5), an open question "What should
we improve?" and an open question "Email, if you would like a reply (optional)", in that order.
2. Set POSTHOG_FEEDBACK_SURVEY_ID to that survey's ID on the Vercel project and redeploy.
3. Add a Vercel Firewall rate-limit rule on /telemetry/, for example 120 requests a minute per IP
address.

Known gap: the extension side and docs/PRIVACY.md follow in a separate PR. Refs #128

Validation

  • Relevant locked pytest checks and make lint pass; commands and results are listed below.

  • Native changes were tested with make test-blender against the exact packaged ZIP in an isolated profile; Blender/OS versions and results are listed.

  • Packaging changes pass make build; the ZIP and dependency licenses were inspected.

  • UI changes include before/after screenshots and native input, focus and viewport evidence, with Blender/OS versions.

  • Live/paid smoke status is stated. Any paid check had prior authorization for its project, exact quote and budget; private approval details remain private.
  • Commands and results:

  • pnpm exec tsc, the three site type-checks from site.yml: passed

  • node --test tests/site/middleware.test.ts tests/site/handbook-search.test.ts (Node 24): 73 passed

  • pnpm exec vitest run: 7 passed

  • make check-rules: passed

  • uv run --locked --no-env-file python -m pytest tests/unit/test_house_rules.py tests/unit/test_workflows.py tests/unit/test_knowledge.py: 184 passed

  • tools/check_knowledge.py --base origin/main: 0 errors

  • No live site, PostHog or Vercel call; PostHog is a local stand-in
  • Public content

  • No private account, customer, workspace, project or internal infrastructure records are exposed.

  • No credentials, signed URL query strings or private job/asset IDs are included.

  • No personal paths, agent session IDs, private research exports or spend anecdotes are included.
  • Coding rules

  • New first-party source files have the SPDX copyright and GPL-3.0-or-later headers; existing notices are preserved.

  • Scenario service changes use the shared official SDK adapter or identify the documented issue-linked exception. Dependency changes include the exact bundle and applicable native validation.

  • scenario/core remains free of bpy; Blender operations stay on the main thread, and UI drawing does not mutate properties.

  • No em dashes or unrelated manual version/changelog edits are introduced; documentation and commands match the resulting behavior.
  • Authorship and licensing

  • Human review of the complete diff is recorded before merge.

  • Original work is identified; adopted third-party code/assets retain their compatible licenses and attribution.

  • Original contributions are licensed inbound=outbound under GPL-3.0-or-later, the repository license.
  • Written with Claude Code; the commits carry its co-author trailer.

    🤖 Generated with Claude Code

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    New public ingestion surface with strict validation and rate limits, but it forwards user feedback and usage to PostHog and needs correct POSTHOG_FEEDBACK_SURVEY_ID and firewall rules in production.

    > Overview

    The Vercel site middleware now *handles /telemetry/ locally* (matcher extended alongside /repo/) so opt-in extension traffic never hits GitHub Pages. The extension can POST without holding the PostHog token.

    > POST /telemetry/v1/events validates small JSON from a ScenarioBlender/ User-Agent, drops or refuses anything outside the allowlist, and forwards accepted batches to PostHog /batch/ (MCP events renamed to $mcp_initialize / $mcp_tool_call). POST /telemetry/v1/feedback maps rating, message, and email onto a configured API survey (POSTHOG_FEEDBACK_SURVEY_ID) as a survey sent capture, with survey metadata cached from PostHog.

    > Both paths enforce 64 KiB bodies, in-memory per-IP rate limits (60 event batches / 5 feedback per minute), anonymity flags, and structured JSON errors; feedback must answer within four seconds. *Download counting on /repo/ is unchanged.

    > docs/MAINTAINERS.md documents deployment (survey setup, firewall). middleware.test.ts and middleware.fuzz.ts** add broad coverage for validation, relay behavior, and fuzzing.

    > <sup>Reviewed by Cursor Bugbot for commit c6c9b4ea7e2e35db466f1e3dcf69a808f84e8d07. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: claude[bot] Review duration: 5m
    All Vouch review confidence checks passed
    Residual risk 0.41 = Change Risk (0.52) × (1 − Review Confidence (0.22)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 33% · Reviewer familiarity: 35%
    21%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #616"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 21.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 21.8% · Lower = rushed or shallow review
    21.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 40.7% · Moderate risk
    40.7%