Skip to content

Count daily.dev visits per blog article and collect YouTube videos on the Analytics Content view - #9685

Open
3mdistal wants to merge 2 commits into
mainfrom
alice/content-view-youtube-dailydev
Open

3mdistal wants to merge 2 commits into
mainfrom
alice/content-view-youtube-dailydev

Conversation

@3mdistal

@3mdistal 3mdistal commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Analytics Content view shows each Builder blog article's pageviews, search traffic and signups, collected once a day. Two places Builder's content reaches developers aren't in it. daily.dev, a developer news feed, links to blog articles, but the view can't say how many readers it sends each one. And Builder's and Codevolution's YouTube videos aren't in Analytics at all, so the view can't say which videos are gaining views. This is the second phase of the Content view plan: daily.dev from GA4, and YouTube through a YouTube Data API key.

Approach

  • daily.dev visits per article. daily.dev adds via=dailydev to the links it sends out. A new daily_dev collection step asks the collection's own GA4 property for sessions by day and landing page (with its query string), on the blog's host and path, that either carry that tag or come from a daily.dev source, and matches each landing page to its article the way pageviews already do. It needs no new connection, so it's on by default. Like pageviews, it writes every article's count for every day it reads, 0 included, so when GA4 lowers or drops a count on a later read, the stored one is replaced. The Articles table shows a blank before the step has ever collected.
  • YouTube videos. A new youtube step reads public counts with a YouTube Data API key saved under a new Data Sources entry, YouTube. For each channel in the collection's youtube.channels (a channel ID or an @handle, up to 20; a channel named twice is read once), it looks up the channel's uploads playlist, pages through it 50 videos at a time, and reads each video's views, likes, comments and length, 50 at a time. Each video is stored as a youtube item with its channel's ID, and its counts as "views to date" values dated the day they were read. A count the channel hides gets no row instead of a 0. A whole read costs about one quota unit per 25 videos: about 83 of the key's free 10,000 a day for Builder's and Codevolution's 1,967 videos. The step is off until an admin names channels and turns it on.
  • Dashboard. A YouTube tab with views each channel gained per day and a Videos table, ranked by views gained in the time range. A day's gain is the difference between that day's read and the next one; a video published after its channel's first read counts from 0, with each channel's first read found by channel ID, not name. The Videos table shows each count from the video's newest read only, so a count the channel has since hidden shows blank. Articles gains a daily.dev visits column, and Sources and Missing data list both new sources. Missing data names YouTube only once it has run, so a workspace that never turns it on sees no warning.

What changed

  • server/lib/content-metrics/steps/daily-dev.ts (new): the GA4 report and article matching. Like pageviews, it refetches the last three days each run and backfills 90 days on its first run or when the GA4 property changes.
  • server/lib/youtube.ts (new): the YouTube Data API client. It names a missing key as not set up (424), and a refused key, spent quota, unknown channel or a channel with more than 10,000 uploads as failures, so the step never stores a partial list.
  • server/lib/content-metrics/steps/youtube.ts (new), collect.ts, config.ts: the step, registration, and the dailyDev and youtube settings. Saved settings from before read as daily.dev on and YouTube off.
  • actions/configure-content-collection.ts: dailyDev, youtube and youtubeChannels; omitted settings keep their saved values.
  • server/lib/credential-keys.ts, app/lib/data-sources.ts, server/routes/api/test-connection.post.ts: the YOUTUBE_API_KEY credential, its Data Sources entry with setup steps, and a connection test that makes one cheap API call.
  • seeds/dashboards/content-view.json: the YouTube tab, the daily.dev column, and the Sources and Missing data rows.
  • The Analytics dashboard-management skill documents both steps, their metrics and the YouTube exception in Missing data.
  • changelog/: a What's new entry for both.

The reasons behind these choices are here rather than in code comments, which this repo doesn't take.

Safety and operations

  • No migration. Both steps write the existing items, snapshots and runs tables, under a new item source and new metric names.
  • daily.dev turns on with the next daily run for every collection with a GA4 property: one more GA4 Data API report a run, 90 days the first time and three after. Like pageviews, it stores one row per article per day it reads.
  • YouTube stays off until an admin saves a key and sets channels. The key reads public data only. It is stored like the other Data Sources keys, sent as YouTube's key parameter, and never written into an error message or a run's detail.
  • Storage. Up to three rows per video per day: about 5,900 a day for the two channels.
  • Rollback. Revert. Stored rows stay, unread.

Verification

  • On the first head, CI passed all 52 checks. After the review fixes, on a boat.dev machine with the branch applied to main: oxfmt --check and oxlint on the changed files, the Analytics typecheck, eight Analytics spec files (174 tests), and pnpm guards. All passed. CI runs again on this head.
  • New specs cover the YouTube client (uploads paged 50 at a time, counts read in batches, a hidden like count left out, lookup by channel ID, a channel named twice read once, an unknown channel, the upload cap, a missing key, a refused key, spent quota, and ISO 8601 lengths); the daily.dev step (sessions matched to articles by tag or source, a 0 for every article on every day read, a reread that replaces a dropped count with 0, and waiting for a GA4 property without querying anyone else's); the YouTube step (items and counts under the stored owner, one read a day, and "not set up" without channels or a key); saved settings from before this change; and the dashboard SQL, run on the first-party engine: daily.dev blank before its first collection, views each channel gained per day with a new video counted from 0 and a later channel with the same name kept separate, the Videos table with a count hidden on the newest read shown blank, and YouTube named in Missing data once it has run and failed.
  • Not looked at in a browser: the YouTube tab and the daily.dev column. The specs run each panel's SQL, but not the rendered dashboard.

Not yet verified: either step against real data, which runs only after merge. On beta, the plan is to save the key for the Builder.io workspace, set the two channels, run both steps, and compare a few articles' daily.dev visits and a few videos' views with GA4 and YouTube.

Checked by hand with the new key on Nov 23: both channels resolve (@Builderio, 151 videos; Codevolution, 1,816), a full read of both costs about 83 units, a made-up handle returns no channel, and a bad key comes back as API_KEY_INVALID, which the client reports as a refused key.

Review focus

  1. The daily.dev filter: the via=dailydev tag on the landing page, or a session source matching daily.dev. Does it miss daily.dev traffic or catch traffic that isn't?
  2. Views gained per day: a day's gain is credited to the day before the read, and a video counts from 0 only when it was published after its channel's first read (by channel ID), so adding a channel later doesn't count its whole history as one day's views.
  3. daily.dev on by default versus off until an admin turns it on, like YouTube.

Known limits

  • The per-day chart pivots by channel name, so a channel draws 0, not a gap, on days before its first read and on a day a read failed, and two channels with the same name draw as one line.
  • A missed read folds two days' views into the next day's gain.

Follow-ups

  • Operational, after merge: save the key and channels on beta, run both steps, and spot-check the numbers as above.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The PR changes collection and reporting within the Analytics Content workflow.

The localization requirement must still be satisfied before merging.

Summary

Adds daily.dev visits per article and optional daily YouTube counts to the Content view.

  • Articles show how many daily.dev sessions reached them.
  • Configured YouTube channels add their videos and public counts to Analytics.
  • The YouTube tab ranks videos by views gained and charts channel growth.

Reviews (2) · Last reviewed commit: "Clear dropped daily.dev counts, read a r..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Visual recap — generation failed

Recap authentication failed — PLAN_RECAP_TOKEN was rejected; it may be expired, revoked, or minted for another Plans app. Personal token: run npx @agent-native/core@latest connect <app-url> --client codex, then npx @agent-native/recap-cli@latest recap setup. Org service token: an owner/admin can mint a 10-year replacement with npx -y @agent-native/core@latest connect <app-url> --service-token <name> --ttl-days 3650. Update this repo's secret.

builder-io-integration[bot]

This comment was marked as outdated.

@builder-io-integration builder-io-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builder reviewed your changes and found 3 potential issues 🟡

Review Details

Incremental Code Review Summary

This update adds channel-ID deduplication for YouTube collection, adjusts daily.dev snapshots to write explicit zeros, improves YouTube dashboard grouping/baselines, expands coverage, and adds a changelog entry. The previously reported duplicate-channel write failure is fixed and its review thread has been resolved. Risk remains High because the PR adds API-key-backed external collection and data persistence.

New findings

  • 🟡 The daily.dev GA4 source regex matches the substring in unrelated custom sessionSource values, which can overcount attributed visits.
  • 🟡 YouTube results have no channel-list fingerprint, so a fetch finishing after settings change may save data for channels no longer configured.
  • 🟡 The chart groups by channel title rather than stable channel ID, merging distinct channels that share a title.
  • A non-JSON 403 can be mislabeled as an invalid API key; this low-severity error-reporting issue is also included for filtering.

The existing persisted-data and dashboard patterns remain sound overall. 🧪 Browser testing: Skipped — the browser-test-planner agent is unavailable.

const MAX_REPORT_ROWS = 100_000;

const TAGGED_LANDING = "[?&]via=dailydev(&|#|$)";
const DAILY_DEV_SOURCE = "daily[.-]?dev";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Daily.dev source filter matches unrelated source names

sessionSource is a free-form GA4 value, but this partial regex accepts dailydev or daily-dev anywhere in it. Unrelated values such as notdailydev can therefore be attributed as daily.dev traffic; anchor the match and require source/domain boundaries or match the intended source values explicitly.

Additional Info
Reported by one independent review agent; confirmed in the GA4 dimensionFilter added at line 18.

Fix in Builder

Comment on lines 285 to +287
case "builder_blog":
case "signups":
case "youtube":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Channel changes are not guarded against stale YouTube runs

The YouTube step has no configuration fingerprint, and its result omits one, so completeContentRun cannot reject a fetch that finishes after the saved channel list changes. That run can persist removed channels and mark the step succeeded, delaying collection of the new list until a later scheduled run; fingerprint the configured channels and return it in the outcome.

Additional Info
Reported by one independent review agent; verified against completeContentRun's existing fingerprint check.

Fix in Builder

"source": "first-party",
"width": 6,
"tab": "YouTube",
"sql": "WITH reads AS (SELECT s.item_id, s.metric, s.metric_date, s.value, MAX(s.value) OVER (PARTITION BY s.item_id, s.metric ORDER BY s.metric_date ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS previous, MIN(s.metric_date) OVER (PARTITION BY COALESCE(i.metadata::jsonb ->> 'channelId', ''), s.metric) AS channel_first_read, substr(i.published_at, 1, 10) AS published, COALESCE(i.author, 'No channel') AS channel FROM analytics_content_metric_snapshots s JOIN analytics_content_items i ON i.id = s.item_id WHERE i.source = 'youtube' AND s.metric IN ('youtube_views')), gains AS (SELECT channel, to_char(metric_date::date - 1, 'YYYY-MM-DD') AS date, value - COALESCE(previous, CASE WHEN metric_date > channel_first_read AND published >= channel_first_read THEN 0 END) AS views FROM reads) SELECT date, channel, SUM(views) AS views FROM gains WHERE views IS NOT NULL AND (date < to_char(CURRENT_DATE, 'YYYY-MM-DD') AND ('{{timeRange}}' IN ('', 'all') OR ('{{timeRange}}' = '7d' AND date >= to_char(CURRENT_DATE - INTERVAL '7 days', 'YYYY-MM-DD')) OR ('{{timeRange}}' = '28d' AND date >= to_char(CURRENT_DATE - INTERVAL '28 days', 'YYYY-MM-DD')) OR ('{{timeRange}}' = '90d' AND date >= to_char(CURRENT_DATE - INTERVAL '90 days', 'YYYY-MM-DD')) OR ('{{timeRange}}' = 'custom' AND date >= '{{timeRangeStart}}' AND date <= '{{timeRangeEnd}}'))) GROUP BY date, channel ORDER BY date, channel",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 YouTube daily gains merge channels that share a title

The query labels and groups the series by i.author (the channel title) while its baseline is partitioned by metadata.channelId. Distinct channels can share a title, causing their gains to be combined into one series; aggregate by stable channel ID and use the title only for display.

Additional Info
Reported by two independent review agents (severity differed low/medium); verified in the chart SQL at added line 616.

Fix in Builder

This branch has not been deployed

No deployments
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