feat: Task b577yQCU — videoAnalytics document type for YouTube stats#669
feat: Task b577yQCU — videoAnalytics document type for YouTube stats#669codercatdev merged 3 commits intodevfrom
Conversation
New Sanity document type that stores YouTube analytics separately from content documents (post/podcast/automatedVideo). This avoids triggering content webhooks when stats are updated. Fields: contentRef, contentType (denormalized), youtubeId, youtubeShortId, viewCount, likeCount, commentCount, favoriteCount, lastFetchedAt. Stats fields are readOnly in Studio. Includes TypeScript interface at lib/types/video-analytics.ts.
Co-authored-by: content <content@miriad.systems>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
@pm Review — feat/video-analytics-schemaVerdict: REQUEST_CHANGES — Two ✅ What's Good
|
| # | Severity | Field | Fix |
|---|---|---|---|
| 1 | Important | contentType |
Add readOnly: true |
| 2 | Important | youtubeId |
Add readOnly: true |
| 3 | Minor | stat count fields | Add required() validation or make TS interface optional |
| 4 | Minor | 1:1 uniqueness | Document in schema comment or CF Worker task |
Two-line fix for the blockers — add readOnly: true to contentType and youtubeId in videoAnalytics.ts. Happy to approve immediately after those land.
contentType and youtubeId are set by the CF Worker cron and must not be editable in Studio — contentType is denormalized from contentRef._type, youtubeId is the primary key linking to YouTube API. Co-authored-by: content <content@miriad.systems>
Task b577yQCU: YouTube Stats Document Type
Adds a
videoAnalyticsSanity document type that stores YouTube statistics separately from content documents. This eliminates webhook noise when stats are updated and drops the Supabase dependency for stats storage.New Files
sanity/schemas/documents/videoAnalytics.ts(115 lines) — Document schemalib/types/video-analytics.ts(19 lines) — TypeScript interfaceUpdated Files
sanity.config.ts— RegistervideoAnalyticsin schema typesSchema Fields
contentRefcontentTypeyoutubeIdyoutubeShortIdviewCountlikeCountcommentCountfavoriteCountlastFetchedAtDesign Decisions
videoAnalyticsdoc per content doc, linked viacontentRefcontentType— Per @seniordeveloper's suggestion, enables*[_type == "videoAnalytics" && contentType == "podcast"]without dereferencing (faster filtered leaderboards)readOnly— Only the CF Worker cron should update these, not manual Studio editsyoutubeShortIdoptional — OnlyautomatedVideodocs have both horizontal + short versionsWebhook Filter Note
videoAnalyticsto prevent stats updates from triggering the content pipeline. Recommended filter:Or more explicitly, the existing webhook filter
_type == "automatedVideo"already excludesvideoAnalyticssince they're different document types. No webhook changes needed — just documenting for clarity.NOT in scope (handled by other tasks)
lib/youtube-stats.tsrewrite → Backlog taskM6yODRZI(CF Worker cron)vmJFtHej(page migration)statisticsfrom content partial → Task 1F (cleanup after migration proven)GROQ Query Pattern (for reference)