Skip to content

Track post creation origin with created_via#203

Merged
paulocastellano merged 12 commits into
mainfrom
feature/post-created-via
Jul 24, 2026
Merged

Track post creation origin with created_via#203
paulocastellano merged 12 commits into
mainfrom
feature/post-created-via

Conversation

@paulocastellano

Copy link
Copy Markdown
Contributor

Summary

  • Add nullable posts.created_via with CreatedVia enum (web, mcp, api, automation)
  • Thread the value through CreatePost and every creation entry point (web/templates/AI, API, MCP, automations)
  • Cover persistence in action + channel feature tests; legacy posts remain null

Test plan

  • Run php artisan migrate
  • Create a post from the web UI → created_via = web
  • Create via API POST /postscreated_via = api
  • Create via MCP CreatePostToolcreated_via = mcp
  • Run an automation generate node → created_via = automation
  • Confirm existing posts stay null

Made with Cursor

paulocastellano and others added 12 commits July 24, 2026 11:19
Persist whether a post was created through web, MCP, API, or automation so we can attribute entry points without guessing from request context.

Co-authored-by: Cursor <cursoragent@cursor.com>
Reject CreatePost calls without CreatedVia, set Web on DuplicatePost, and assert wiring for templates, AI, automation, and API spoof attempts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Default to web when the value is missing, null, or invalid so post creation never fails over provenance.

Co-authored-by: Cursor <cursoragent@cursor.com>
Provenance is optional analytics — only persist a CreatedVia value when callers set a valid one.

Co-authored-by: Cursor <cursoragent@cursor.com>
Callers already pass a CreatedVia enum or omit it; drop the defensive resolver.

Co-authored-by: Cursor <cursoragent@cursor.com>
Dispatch TrackPost from PostCreated so we can chart which entry points create the most posts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Duplicates now sync usage and track post.created like CreatePost; TrackPost only eager-loads what capture needs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Centralize provenance/broadcast/PostHog triggers so CreatePost and DuplicatePost no longer fire the event by hand.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore the saved() automation afterCommit hook and let the event wait for commit on its own.

Co-authored-by: Cursor <cursoragent@cursor.com>
PostCreated already waits for commit via ShouldDispatchAfterCommit.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep after-commit local to created(), matching the saved() job hook, instead of marking the event itself.

Co-authored-by: Cursor <cursoragent@cursor.com>
@paulocastellano
paulocastellano merged commit 596ad49 into main Jul 24, 2026
5 checks passed
@paulocastellano
paulocastellano deleted the feature/post-created-via branch July 24, 2026 15:29
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