Track post creation origin with created_via#203
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
posts.created_viawithCreatedViaenum (web,mcp,api,automation)CreatePostand every creation entry point (web/templates/AI, API, MCP, automations)nullTest plan
php artisan migratecreated_via = webPOST /posts→created_via = apiCreatePostTool→created_via = mcpcreated_via = automationnullMade with Cursor