posthog icon indicating copy to clipboard operation
posthog copied to clipboard

feat(user-interviews): add non-personalised (shared) interview link

Open pauldambra opened this issue 4 months ago • 8 comments

Problem

User research today only supports personalised interview links — one token per invitee, minted from an email or distinct_id we already have. That rules out interviewing people we have no contact details for (e.g. visitors on comparison/alternatives blog pages), which is exactly where we want AI interviews.

We want a non-personalised (shared) link: one link for a whole topic, where every visitor is a new respondent who tells us their name, and we optionally tie them back to a PostHog person/session via query params.

Raised in a Slack thread (linked below).

Changes

  • Topic-level share token. SharingConfiguration gains a user_interview_topic FK alongside the existing interviewee_context FK. /interview/<token> now resolves to either a personalised invitee share or a shared topic share. New POST .../user_interview_topics/{id}/shared_link/ endpoint get-or-creates the (single, idempotent) shared link.
  • Anonymous respondents. On a shared link the public viewer asks for a name before starting, then start_call carries the name plus distinct_id/session_id (read from the URL query string) and a client respondent_key into the call. The webhook persists a UserInterview attributed to the topic. distinct_id/session_id are best-effort, untrusted linkage — never used for access control. New UserInterview fields: respondent_name, respondent_key, distinct_id, session_id.
  • Abuse protection, modelled on the support widget. start_call keeps the per-IP burst, adds a per-respondent burst (keyed on respondent_key, falling back to IP — like WidgetUserBurstThrottle), and relaxes the per-token cap into a sustained ceiling: a shared token is used by many people at once, so a tight per-minute burst would throttle legitimate concurrent respondents. A honeypot field on the name form drops naive bots. (Hosted Surveys turned out to do none of this — the widget was the useful reference.)
  • Accidental-refresh handling. Three fixes, applying to both link types where relevant:
    • has_replied no longer counts abandoned interviews, so a mid-call refresh no longer permanently locks a personalised interviewee out.
    • The shared viewer persists respondent_key in localStorage, so a refreshed respondent re-attaches instead of becoming a duplicate; the webhook then supersedes the abandoned partial once they finish.
    • The live call warns before unload. (Vapi browser calls can't resume across a reload — the realistic bar is "don't lose progress and don't punish the return".)

How did you test this code?

Automated tests (added, not run in this environment — no local stack):

  • test_facade.py: has_replied ignores abandoned responses — guards the refresh-lockout regression, which no existing case covered.
  • test_shared_interview_link.py: shared-link creation is topic-level + idempotent + works with zero targeted interviewees; the public viewer marks the payload shared/not-already-replied and keeps agent context/Vapi creds off the HTML; start_call carries respondent name + linkage into metadata and rejects a filled honeypot; the webhook persists respondent/linkage for a topic share and supersedes an abandoned partial on respondent return.

ruff format/ruff check pass on all touched Python. I could not run pnpm typescript:check, pytest, or hogli build:openapi here.

Needs codegen: the new shared_link endpoint/serializer means the OpenAPI + Orval + MCP artifacts need regenerating (hogli build:openapi) — not run in this environment.

Follow-up (not in this PR): the internal product-frontend "copy shared link" button. The feature is usable via the API + public page; the button is deferred because it depends on the regenerated product API types.

Docs update

No user-facing docs exist for this product yet.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Authored by the PostHog Slack app from a Slack thread. Skills invoked: /django-migrations, /improving-drf-endpoints, /writing-tests. Approach was explored with the requester first: surveyed how Hosted Surveys and the Conversations support widget protect their public endpoints, concluded the widget's two-tier throttle + honeypot (not surveys, which relies on generic ingestion limits) was the right model, and confirmed the refresh edge case before building. Chose to extend the existing SharingConfiguration (topic FK) and UserInterview (respondent fields) rather than introduce a new respondent model, keeping the shared and personalised paths on one code path.


Created with PostHog from a Slack thread

pauldambra avatar Jul 17 '26 19:07 pauldambra

Hey @pauldambra! 👋

It looks like your git author email on this PR isn't your @posthog.com address ([email protected]). Since you're on the PostHog team, it's worth pointing your local git author email at your @posthog.com address. Why it matters:

  • Consistent work identity in git history — internal tooling that attributes commits to team members keys off your @posthog.com address.
  • Keeps team contributions easy to tell apart from external community ones when scanning history.

You can fix it for this repo with:

git config user.email "[email protected]"

Or set it globally with git config --global user.email "[email protected]". No need to redo this PR — just a nudge for next time. 🙂

github-actions[bot] avatar Jul 17 '26 19:07 github-actions[bot]

🤖 CI report

⚠️ Bundle size — 🔺 +4.8 KiB (+0.0%)

Uncompressed size of every built .js bundle, compared against the base branch.

Total: 64.22 MiB · 🔺 +4.8 KiB (+0.0%)

File Size Δ vs base
exporter/src/exporter/scenes/ExporterInterviewScene.js 304.7 KiB 🔺 +1.7 KiB (+0.6%)
posthog-app/src/scenes/inbox/InboxScene.js 674.6 KiB 🔺 +1.5 KiB (+0.2%)
render-query/src/render-query/render-query.js 21.33 MiB 🔺 +1.2 KiB (+0.0%)
posthog-app/_parent/products/metrics/frontend/MetricsScene.js 41.8 KiB 🔺 +1.1 KiB (+2.8%)
posthog-app/src/scenes/experiments/Experiment.js 224.5 KiB 🟢 -1.0 KiB (-0.4%)

Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report

✅ Eager graph — within budget

How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.

Root Eager (shipped) Δ vs base Budget
entry (logged-out pages, app bootstrap)
src/index.tsx
1.23 MiB · 22 files 🟢 -67 B (-0.0%) ███░░░░░░░ 28.6% of 4.29 MiB
authenticated shell (every logged-in page)
src/scenes/AuthenticatedShell.tsx
8.16 MiB · 2,988 files 🔺 +299 B (+0.0%) █████████░ 88.2% of 9.25 MiB

🟢 node_modules/monaco-editor/ stays out of src/index.tsx 🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx 🟢 [object Object] stays out of src/index.tsx 🟢 [object Object] stays out of src/index.tsx 🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx 🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx 🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx 🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx

Largest files eagerly shipped from src/index.tsx
Size File
126.8 KiB ../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.production.min.js
24.6 KiB ../node_modules/.pnpm/[email protected]/node_modules/buffer/index.js
6.3 KiB ../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.production.min.js
4.5 KiB ../node_modules/.pnpm/@[email protected]/node_modules/@jspm/core/nodelibs/browser/process.js
3.9 KiB ../node_modules/.pnpm/[email protected]/node_modules/scheduler/cjs/scheduler.production.min.js
1.4 KiB ../node_modules/.pnpm/[email protected]/node_modules/base64-js/index.js
1.3 KiB src/RootErrorBoundary.tsx
912 B ../node_modules/.pnpm/[email protected]/node_modules/ieee754/index.js
789 B src/scenes/ChunkLoadErrorBoundary.tsx
762 B src/index.tsx
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
Size File
281.3 KiB ../node_modules/.pnpm/[email protected]/node_modules/posthog-js/dist/rrweb.js
267.7 KiB ../node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@posthog/icons/dist/posthog-icons.es.js
235.5 KiB src/taxonomy/core-filter-definitions-by-group.json
223.4 KiB ../node_modules/.pnpm/[email protected]/node_modules/posthog-js/dist/module.js
164.0 KiB src/queries/validators.js
154.3 KiB ../node_modules/.pnpm/[email protected]/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.production.min.js
105.8 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/[email protected]/node_modules/prosemirror-view/dist/index.js
93.2 KiB ../packages/quill/packages/quill/dist/index.js

Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479

✅ Dist folder size — 🔺 +209.6 KiB (+0.0%)

Total size of the built frontend/dist folder (all assets), compared against the base branch.

Total: 1341.70 MiB · 🔺 +209.6 KiB (+0.0%)

ℹ️ MCP UI apps size — 31 app(s), 16603.0 KB JS

Built size of each MCP UI app (main.js + styles.css).

App JS CSS
debug 599.5 KB 187.4 KB
action 457.8 KB 187.4 KB
action-list 564.3 KB 187.4 KB
cohort 456.8 KB 187.4 KB
cohort-list 563.3 KB 187.4 KB
email-template 456.6 KB 187.4 KB
error-details 472.4 KB 187.4 KB
error-issue 457.5 KB 187.4 KB
error-issue-list 564.2 KB 187.4 KB
experiment 561.5 KB 187.4 KB
experiment-list 565.1 KB 187.4 KB
experiment-results 563.2 KB 187.4 KB
feature-flag 567.1 KB 187.4 KB
feature-flag-list 570.9 KB 187.4 KB
feature-flag-testing 461.0 KB 187.4 KB
insight-actors 562.1 KB 187.4 KB
invite-email-preview 456.0 KB 187.4 KB
llm-costs 559.5 KB 187.4 KB
session-recording 458.6 KB 187.4 KB
session-summary 463.9 KB 187.4 KB
survey 458.4 KB 187.4 KB
survey-global-stats 562.2 KB 187.4 KB
survey-list 565.0 KB 187.4 KB
survey-stats 562.2 KB 187.4 KB
trace-span 457.2 KB 187.4 KB
trace-span-list 564.2 KB 187.4 KB
workflow 457.1 KB 187.4 KB
workflow-list 563.7 KB 187.4 KB
query-results 744.9 KB 187.4 KB
render-ui 825.5 KB 187.4 KB
visual-review-snapshots 461.6 KB 187.4 KB
✅ Playwright — all passed

All tests passed.

View test results →

ℹ️ Backend snapshots — skipped stale run for 52e82ad

Skipped the snapshot commit because the branch advanced to b0ceec6 while the workflow was testing 52e82ad.

The new commit will trigger its own snapshot update workflow. If a fresh run does not start, merge master or push an empty commit.

⚠️ Backend coverage — 97.0% of changed backend lines covered — 9 uncovered

🧪 Backend test coverage

Patch coverage — changed backend lines (products + core): ███████████████████░ 97.0% (378 / 387)

File Patch Uncovered changed lines
posthog/api/sharing.py 0.0% 1193, 1206–1209, 1211–1212
products/user_interviews/backend/presentation/views.py 95.2% 1444–1445

🤖 Agents: add a test covering the lines above, or note why under "How did you test this code?". Machine-readable gap list: the patch-coverage artifact on this run (gh run download 29661731325 -n patch-coverage), or the coverage-data block at the end of this comment.

Per-product line coverage (touched products)
Product Coverage Lines
platform_features ██░░░░░░░░░░░░░░░░░░ 12.1% 7 / 58
batch_exports ████████░░░░░░░░░░░░ 39.6% 8,414 / 21,225
demo ███████████░░░░░░░░░ 56.2% 1,497 / 2,663
warehouse_sources_queue ████████████░░░░░░░░ 59.2% 148 / 250
tasks █████████████░░░░░░░ 67.0% 25,933 / 38,686
data_tools ██████████████░░░░░░ 70.0% 63 / 90
ai_gateway ███████████████░░░░░ 75.0% 9 / 12
signals ████████████████░░░░ 79.4% 19,493 / 24,553
data_modeling ████████████████░░░░ 80.0% 4,834 / 6,045
cdp ████████████████░░░░ 80.7% 3,118 / 3,864
wizard ████████████████░░░░ 82.5% 772 / 936
notebooks █████████████████░░░ 85.1% 7,096 / 8,338
cohorts █████████████████░░░ 86.2% 4,065 / 4,717
agent_platform █████████████████░░░ 86.4% 3,807 / 4,405
actions █████████████████░░░ 86.6% 717 / 828
product_tours █████████████████░░░ 87.5% 1,266 / 1,447
exports ██████████████████░░ 88.4% 6,933 / 7,842
visual_review ██████████████████░░ 88.5% 5,565 / 6,287
business_knowledge ██████████████████░░ 88.5% 4,400 / 4,969
conversations ██████████████████░░ 89.0% 16,183 / 18,186
mcp_analytics ██████████████████░░ 89.2% 2,514 / 2,819
dashboards ██████████████████░░ 89.3% 5,841 / 6,540
engineering_analytics ██████████████████░░ 89.5% 5,507 / 6,154
alerts ██████████████████░░ 89.9% 4,045 / 4,499
early_access_features ██████████████████░░ 90.1% 1,031 / 1,144
error_tracking ██████████████████░░ 90.1% 9,885 / 10,966
streamlit_apps ██████████████████░░ 90.4% 2,501 / 2,767
slack_app ██████████████████░░ 90.6% 9,018 / 9,955
links ██████████████████░░ 90.6% 183 / 202
marketing_analytics ██████████████████░░ 90.8% 11,514 / 12,684
stamphog ██████████████████░░ 91.0% 3,993 / 4,387
product_analytics ██████████████████░░ 91.3% 5,757 / 6,304
mcp_store ██████████████████░░ 91.8% 3,685 / 4,012
data_warehouse ██████████████████░░ 92.4% 18,771 / 20,309
notifications ███████████████████░ 92.7% 1,031 / 1,112
workflows ███████████████████░ 92.8% 5,482 / 5,909
ai_observability ███████████████████░ 92.8% 14,916 / 16,077
web_analytics ███████████████████░ 92.9% 13,853 / 14,913
surveys ███████████████████░ 93.0% 5,724 / 6,157
posthog_ai ███████████████████░ 93.2% 1,325 / 1,421
approvals ███████████████████░ 93.3% 3,395 / 3,640
reminders ███████████████████░ 93.4% 468 / 501
tracing ███████████████████░ 93.4% 2,546 / 2,725
managed_migrations ███████████████████░ 93.8% 1,220 / 1,300
legal_documents ███████████████████░ 94.1% 1,568 / 1,667
endpoints ███████████████████░ 94.1% 8,606 / 9,143
revenue_analytics ███████████████████░ 94.5% 3,598 / 3,809
skills ███████████████████░ 94.5% 2,881 / 3,049
messaging ███████████████████░ 94.5% 2,530 / 2,677
review_hog ███████████████████░ 94.6% 6,806 / 7,191
logs ███████████████████░ 95.3% 9,844 / 10,325
experiments ███████████████████░ 95.7% 24,417 / 25,527
replay_vision ███████████████████░ 95.8% 13,776 / 14,383
growth ███████████████████░ 95.8% 2,837 / 2,960
annotations ███████████████████░ 96.2% 732 / 761
feature_flags ███████████████████░ 96.3% 16,233 / 16,859
warehouse_sources ███████████████████░ 96.4% 287,393 / 297,985
access_control ███████████████████░ 96.8% 849 / 877
user_interviews ███████████████████░ 96.9% 2,576 / 2,659
customer_analytics ███████████████████░ 97.2% 7,482 / 7,700
data_catalog ███████████████████░ 97.4% 2,304 / 2,365
analytics_platform ████████████████████ 98.0% 2,102 / 2,145
metrics ████████████████████ 98.2% 2,491 / 2,536
pulse ████████████████████ 98.4% 2,017 / 2,049
live_debugger ████████████████████ 99.2% 613 / 618
field_notes ████████████████████ 99.4% 158 / 159

Report-only. Patch coverage = changed backend lines covered vs origin/master. Sorted lowest first. Known gaps: lines covered only by Temporal tests show as uncovered; core line numbers may drift if master changed the same file.

⚠️ Django migration SQL — 1 new migration to review

We've detected new migrations on this PR. Review the SQL output for each migration:

products/user_interviews/backend/migrations/0009_userinterview_shared_respondent_fields.py

BEGIN;
--
-- Add field respondent_name to userinterview
--
ALTER TABLE "user_interviews_userinterview" ADD COLUMN "respondent_name" varchar(400) DEFAULT '' NOT NULL;
--
-- Add field respondent_key to userinterview
--
ALTER TABLE "user_interviews_userinterview" ADD COLUMN "respondent_key" varchar(64) DEFAULT '' NOT NULL;
--
-- Add field distinct_id to userinterview
--
ALTER TABLE "user_interviews_userinterview" ADD COLUMN "distinct_id" varchar(200) DEFAULT '' NOT NULL;
COMMIT;

Last updated: 2026-07-18 21:56 UTC (7bdc652)

✅ Django migration risk — migration analysis complete

We've analyzed your migrations for potential risks.

Summary: 1 Safe | 0 Needs Review | 0 Blocked

✅ Safe

Brief or no lock, backwards compatible

user_interviews.0009_userinterview_shared_respondent_fields
  └─ #1 ✅ AddField
     Adding NOT NULL field with constant default (safe in PG11+)
     model: userinterview, field: respondent_name
  └─ #2 ✅ AddField
     Adding NOT NULL field with constant default (safe in PG11+)
     model: userinterview, field: respondent_key
  └─ #3 ✅ AddField
     Adding NOT NULL field with constant default (safe in PG11+)
     model: userinterview, field: distinct_id

Last updated: 2026-07-18 21:57 UTC (7bdc652)

github-actions[bot] avatar Jul 17 '26 19:07 github-actions[bot]

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

posthog[bot] avatar Jul 17 '26 20:07 posthog[bot]

🦔 Hogbox preview · ✅ ready

▶ Open the preview

🔑 Login [email protected] / 12345678 (demo data)
🧩 Running this PR's backend and frontend, on the PostHog :master base
🔗 Link stable across rebuilds — a re-push swaps the box underneath, the URL stays
🔒 Access tailnet only (PostHog VPN)
🛠️ Admin inspect & debug state in hogland
💤 Idle sleeps after ~30 min idle (snapshot to S3, zero node cost) and wakes on your next visit in ~30s, behind a brief "waking up" screen

commit 7bdc652 · box box-6686c21900be · ready in 800s (push → usable) · build log · rebuilds on every push, torn down on close

github-actions[bot] avatar Jul 17 '26 20:07 github-actions[bot]

[!NOTE] 🤖 stamphog reviewed 7bdc6525a64ee9d9a897518ab7ef5c24530dcb61 — verdict: REFUSED

Gates denied on size/tier/migration deny-list, and this is genuinely risky territory (public auth-adjacent endpoint, abuse throttling, new migration) with one still-unresolved medium security finding (call throttles bypassable after one request) plus a large surface for a single automated pass to certify.

  • 👍 on the PR from hex-security-app[bot].
  • Gates failed: deny-list match on migrations, size (917L/14F substantive vs 800L ceiling), and tier (T2-never)
  • Unresolved veria-ai finding: shared-link respondents can bypass start_call throttles by reusing captured Vapi call-setup details to originate calls directly, consuming voice/LLM capacity outside rate limits
  • New Django migration plus significant changes to public-facing abuse protection and identity handling need human/domain review, not automated approval
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✗ matches: migrations
size ✗ too large for auto-review (917L, 14F substantive, 1477L/20F incl. docs/generated/snapshots — ceiling is 800L)
tier ✗ classified as T2-never: T2-never (1477L, 20F, cross-cutting, feat)
stamphog 2.0.0b3 .stamphog/policy.yml @ ebb56fb · reviewed head 7bdc652

Updated in place — this replaces 2 earlier stamphog review(s) on this PR.

stamphog[bot] avatar Jul 17 '26 20:07 stamphog[bot]

PR overview

This PR adds support for non-personalised shared interview links in the user interviews product, including backend webhook/start-call handling that lets anonymous shared-link visitors initiate an interview flow.

There is one open security concern remaining after several issues have already been addressed. The remaining issue allows a shared-link visitor to reuse call setup details from an initial response to start additional Vapi calls outside the intended throttling path, which could consume voice/LLM capacity and generate extra interview webhooks. The overall trajectory is positive, but quota enforcement still needs to move to the actual call-creation boundary before the shared link flow is fully protected.

Open issues (1)

Fixed/addressed: 4 · PR risk: 6/10

veria-ai[bot] avatar Jul 17 '26 20:07 veria-ai[bot]

I verified the new throttle is token-keyed from the route token, has a distinct burst scope, and is applied alongside the 600/hour ceiling; the namespaced/recomputed shared identifier also prevents a supplied distinct ID from becoming a targeted invite identity.

One concern remains with the chosen 120/minute rate: a distributed caller can still consume all 600 entries in five minutes, after which the sliding hourly throttle blocks legitimate respondents for roughly the remaining 55 minutes. This is a substantial improvement over an instantaneous drain, but it does not fully remove the token-wide lockout vector from the original finding. A lower per-token burst rate (or another per-token allocation that recovers quickly) is needed if the goal is to prevent a public token from being exhausted early in its hour.

parameterai[bot] avatar Jul 17 '26 22:07 parameterai[bot]

[!NOTE] 🤖 Automated summary by PostHog Code (pr-shepherd) — not written by a human

Multi-reviewer pass — outcome

Ran a four-perspective review (qa-team specialists + generalists, paul-reviewer, xp-reviewer, security-audit). No CRITICAL/HIGH security issues — the namespaced-identity IDOR defenses, migration safety, and revoke path all verified.

Addressed

  • Throttles (a7624c19): raised per-IP start_call cap 60→200/min (shared links are opened by many people behind one NAT/CGNAT egress; 200 clears the 120/min token burst so the token bucket governs a single link's concurrency), retry-friendly 429 in the public viewer, deduped the two identical metrics-emitting throttle mixins.
  • Hard-delete safety (7bdc652): the abandoned-partial collapse now re-derives abandoned from each row's own transcript before deleting, so a real response mislabelled abandoned (the label is user-mutable) can't be permanently deleted; deletions are now logged.
  • Responded-count semantics (7bdc652): the topic page no longer counts abandoned interviews as "responded", matching the has_replied change.
  • Reserved-identifier collision (7bdc652): the shared-link sentinel and shared: namespace are now rejected at every interviewee input boundary.
  • Zero-target topics (7bdc652): personalised links are only fetched once a topic has targets, so a shared-only topic no longer fires a guaranteed-400 on mount.
  • Honeypot observability (7bdc652): honeypot rejections are now logged.

Deferred follow-ups (not blocking; tracked here so they aren't lost)

  • respondent_name / distinct_id have no read path — collected + persisted on shared responses but absent from UserInterviewSerializer, so the UI shows shared:<key>. Needs a serializer field + hogli build:openapi (codegen).
  • Diagnostic log dumps raw webhook body + signature on signature-failure (webhooks.py, TODO: REMOVE) — pre-existing, kept for an active signature-mismatch investigation; remove before this serves real public traffic.
  • Missing indexes / call.id idempotency scan — once a shared link accumulates unbounded rows, has_replied and the JSONB call_metadata__id idempotency lookup want supporting indexes. Schedule before GA.
  • $session_id linkage rides an event into PostHog's internal telemetry project, not the customer's — works for dogfooding only.
  • Per-IP throttle at 200/min still binds a very large simultaneous burst behind one egress; revisit if a link goes on a high-traffic public page.

Needs a stack (can't run headless)

  • hogli build:openapi for the shared_link DELETE operation + any serializer drift.
  • Branch is 19 commits behind master (MERGEABLE, no conflict) — merge + regenerate on a devbox.

Automated by PostHog Code — not a human review

pauldambra avatar Jul 18 '26 21:07 pauldambra