Skip to content

feat(workflows): register the workflows product intent on creation - #115350

Closed
Silthus wants to merge 2 commits into
PostHog:masterfrom
Silthus:workflows-tracking/creation-intent
Closed

Silthus wants to merge 2 commits into
PostHog:masterfrom
Silthus:workflows-tracking/creation-intent

Conversation

@Silthus

@Silthus Silthus commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The workflows product intent counts clicks on "New workflow", not saved workflows.

  • A click that never leads to a saved workflow still counts.
  • A workflow created from a template, a copy, PostHog AI, MCP or the API never counts.

Impact

Pays into Grow Workflows through the "Created" step of the Workflows activation funnel (measured here). Expected move: small, toward accuracy. Abandoned clicks stop counting, and creates from templates, AI, MCP and the API start counting.

Merge Danger

Note

🔵 Merge risk: low · two-way door (merge-risk rubric)

  • The workflow create endpoint now writes a product intent row and sends one analytics event per create. The first step of any funnel built on this intent reads lower than its history, because abandoned clicks stop counting.
  • A registration failure is caught and sent to error tracking, so it cannot fail a create. Reverting restores the click intent.

Changes

Kind Files Lines
Production 2 +25 −8
Tests 1 +48 −0
  • Every workflow saved through the create endpoint now registers the workflows intent (workflow_created), whatever channel created it.
    • HogFlowViewSet.perform_create calls ProductIntent.register right after the save, before activity logging.
    • The intent carries the request's analytics properties, so web, MCP and API creates stay distinguishable.
  • Desktop loops register no intent. A loop is a workflow with origin_product: "loops", owned by another product. Counting it would star Workflows and Broadcasts in the sidebar of someone who never opened either.
  • Staff impersonating a customer register no intent, the same rule replay vision uses.
  • A failed registration goes to error tracking and never fails the creation.
  • The "New workflow" button drops its client-side addProductIntent call, in both the Lemon and the Quill variant. It still sets the type filter and opens the template chooser. Nothing looks different.

Related: #115349 emits the team analytics event workflows workflow created from the model for a different consumer, product analytics. #119330 adds AI consent to the product intent event inside ProductIntent.register. None of the three share files, so they merge in any order.

Recreates the intent part of Silthus/posthog#357, originally #111267 (closed).

How did you test this code?

Test rationale: extends the create endpoint tests next to the existing activity-log test. The test seam is the public POST /api/projects/:id/hog_flows endpoint.

  • One case catches a create that registers no intent, or the wrong context.
  • Two cases catch an intent from a loop or from an impersonated session. The loop case failed before the fix.
  • One case catches a registration error that turns a saved workflow into a 500, or that never reaches error tracking. It fails when capture_exception is removed.

Ran locally on the current head, rebased onto current master:

  • All of test_hog_flow.py: 526 passed.

  • Frontend tsgo (no errors), oxlint and oxfmt on the touched file, ruff check, ruff format --check and ty check on the touched Python files.

  • Live run against a local Django server and a migrated scratch database, through the API with a personal API key:

    Team Request workflows intent contexts
    Has an intent from the register call the click endpoint makes plain create 2 → 3
    Fresh create with x-posthog-client: mcp none → 1
    Fresh create with origin_product: "loops" none → none

    Every create returned 201 and logged no error.

Gaps:

  • Repo-wide mypy did not run.
  • Production shape (how many teams already hold a workflows intent, and how many creates are loops) is not measured yet. Read access starts 2026-11-02.
  • Two creation paths outside the create endpoint landed on master after this PR opened: transactional email workflows and accepted data suggestion drafts. They register no intent. This PR keeps its scope to the create endpoint.
  • Django CI on Depot refuses PRs opened from a fork, so the local runs above stand in for it.

Release status

  • No feature flag controls this change

Docs update

None. No existing doc covers Workflows product intents.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: T3 Code with Claude Code, Claude Opus 5.5 (claude-opus-5-5). An earlier Codex worker (GPT-6.1 Sol) moved the intent server-side before its session dropped.

Question Answer Who Where
Do Desktop loop creates count as Workflows intent? No, loops register no intent; counting them was the alternative 🤖 Agent pending approval
Register the intent on the creation paths added since this PR opened? No, keep the create endpoint only; transactional email and suggestion-draft creates stay out of scope 🤖 Agent pending approval

Involvement: no grilling rounds, no prototypes. Reviews: a pre-rebase read-only Claude review and Codex review, then a QA swarm round on the rebased head (GPT-6.1 Sol on correctness, risk, design and the author's perspective; Claude Opus 5.5 fresh eyes). Live-run proof captured.

  • Rebased onto master on 2026-10-20. master had moved the button's click handler into onNewWorkflow for the Quill title actions, so the intent call came out of that handler instead.
  • Skills: tdd, writing-tests, improving-drf-endpoints, writing-pr-descriptions, writing-voice.
  • Earlier review findings, all fixed: impersonated sessions, missing request metadata, failures missing from error tracking, success-only tests, and registration after the unwrapped activity-log steps.
  • QA swarm round 1: four GPT-6.1 Sol lanes found nothing. Claude fresh eyes raised four findings. Fixed: loops counted as Workflows intent, a failure test that could not fail, and description accuracy. Rejected: silent activation when a raw API create is the team's first active workflow, which the ProductIntent model documents as a known caveat and master already reaches.
  • Duplicate search: no open or merged upstream PR moves this intent.
  • Public artifact: nothing from the session beyond this repository went into the diff or this description.

@trunk-io

trunk-io Bot commented Oct 12, 2026

Copy link
Copy Markdown

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

Silthus and others added 2 commits October 20, 2026 10:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Desktop loops are workflows with origin_product "loops". Counting them would
star Workflows and Broadcasts for people who never opened either, and inflate
the Workflows created step with another product's traffic.

The error-tracking test now asserts the captured error instead of a row that
a mocked register can never write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Silthus
Silthus force-pushed the workflows-tracking/creation-intent branch from 87c1e09 to d02dc41 Compare October 20, 2026 11:18
@Silthus Silthus closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant