feat(data-warehouse): attribute posthog code-created sources as created_via=self_driving - #70661
Conversation
…ed_via=self_driving
|
Note 🤖 stamphog reviewed Gates denied: this PR includes a migration file and was classified above the auto-approval tier; it also touches a data model field (created_via) across team boundaries with no reviews or independent assurance yet.
Gate mechanics and policy version
|
Migration SQL ChangesHey 👋, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:
|
🔍 Migration Risk AnalysisWe've analyzed your migrations for potential risks. Summary: 0 Safe | 1 Needs Review | 0 Blocked
|
🦔 Hogbox preview · ✅ ready▶ Open the preview
commit |
🤖 CI report✅ Bundle size — no changeUncompressed size of every built Total: 64.43 MiB · no change No file changed by more than 1000 B. Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report ✅ Eager graph — within budgetHow 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
🟢 Largest files eagerly shipped from
|
| Size | File |
|---|---|
| 126.8 KiB | ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js |
| 24.6 KiB | ../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js |
| 6.3 KiB | ../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js |
| 4.5 KiB | ../node_modules/.pnpm/@jspm+core@2.1.0/node_modules/@jspm/core/nodelibs/browser/process.js |
| 3.9 KiB | ../node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js |
| 1.4 KiB | ../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js |
| 1.3 KiB | src/RootErrorBoundary.tsx |
| 912 B | ../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js |
| 789 B | src/scenes/ChunkLoadErrorBoundary.tsx |
| 668 B | src/index.tsx |
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
| Size | File |
|---|---|
| 278.6 KiB | ../node_modules/.pnpm/posthog-js@1.399.5/node_modules/posthog-js/dist/rrweb.js |
| 267.7 KiB | ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js |
| 234.9 KiB | src/taxonomy/core-filter-definitions-by-group.json |
| 222.1 KiB | ../node_modules/.pnpm/posthog-js@1.399.5/node_modules/posthog-js/dist/module.js |
| 164.0 KiB | src/queries/validators.js |
| 154.3 KiB | ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js |
| 126.8 KiB | ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js |
| 105.9 KiB | src/lib/api.ts |
| 93.3 KiB | ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js |
| 90.6 KiB | ../node_modules/.pnpm/@tiptap+core@3.20.6_@tiptap+pm@3.20.6/node_modules/@tiptap/core/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 — no change
Total size of the built frontend/dist folder (all assets), compared against the base branch.
Total: 1284.43 MiB · no change
Generated-By: PostHog Code Task-Id: b229f6d2-9134-4a6c-a9fc-09ddc24e6e71
Generated-By: PostHog Code Task-Id: b229f6d2-9134-4a6c-a9fc-09ddc24e6e71
CI status — one failing check is a master-wide infra flake, not this PRThe only red check is This shard is failing for an infrastructure reason, not a test in this diff:
The change here is a small, self-contained addition ( This needs a fleet-side fix (shard rebalancing or a larger runner for 🦉 via talyn.dev |
Generated-By: PostHog Code Task-Id: b229f6d2-9134-4a6c-a9fc-09ddc24e6e71
Problem
#70242 made wizard-created warehouse sources distinguishable via
created_via=wizard. PostHog Code is the next surface getting source onboarding in its UI (the self-driving area of the app), and those sources would currently land as plainmcp- indistinguishable from any other MCP client.Changes
Extends the same server-side derivation to PostHog Code:
SELF_DRIVING = "self_driving"value onExternalDataSource.CreatedVia(+ choices-only migration, no DDL).created_via=mcpis upgraded towizardfor wizard transports and toself_drivingwhenget_event_sourceresolvesEventSource.POSTHOG_CODE(the existingposthog/code/*.hog.devUA detection, which also matches the; for posthog/codesuffix the MCP server appends when proxying).self_drivingis not accepted from callers (not in the create serializer's choices - a 400), and explicitweb/apivalues are never rewritten. The MCP tool still injectsmcpitself; agents can't set the field.Note
Generated OpenAPI types are not in this PR - local codegen isn't available in this environment, so the
check-openapi-typesCI job will regenerate and auto-commit them to this branch (same-repo PR path).How did you test this code?
test_create_external_data_source_transport_user_agent_upgrades_mcp_created_via) rather than adding a new one: new cases coverposthog/codeUA, the MCP-server-proxied; for posthog/codeUA shape, a plain MCP UA stayingmcp, and explicitweb/apistaying untouched under a PostHog Code UA. The regression this catches: PostHog Code-driven creates silently reverting tomcp, or the proxied UA shape not matching.self_drivingto the reject-invalid-created_via cases - a caller must not be able to self-label as PostHog Code-created.created_viaAPI tests locally (Python 3.13 venv): all pass.Automatic notifications
Docs update
No user-facing docs affected - the field's API help text is the documentation surface and is updated in this PR.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code implemented this by mirroring the merged wizard attribution PR (#70242). Checked prod first: no
posthog_code-sourced warehouse creations exist yet, so this is preparatory for the app's onboarding flow and there is no backfill concern. Decisions: kept the upgrade rule scoped to machine-injectedmcpvalues only (consistent with the wizard's anti-spoof rationale) rather than also upgrading defaultedapivalues, so a future direct-REST path in PostHog Code would need to opt in explicitly; converted the single wizard conditional into a transport map rather than chained ifs. Skills invoked: /django-migrations (choices-only AlterField, no DDL), /writing-tests (extended existing parameterized tests instead of new functions). The migration was hand-written mirroring the wizard's 0065 because the local default venv can't run master'smanage.py; it is byte-equivalent to whatmakemigrationsproduces for a choices change.