Choosing a North Star metric for GitHub newcomers
Declare first: five candidate numbers and seven predictions were set before any query; four predictions missed, and a third sign-up day, declared in advance, tested the choice.
How the numbers on the summary were made, and how to reproduce them.
Method and checks
Data and the cohort
GH Archive publishes every public GitHub event as one file per hour. For each cohort the study reads 15 days: the day before the cohort day, the cohort day, days 1 to 6 and days 84 to 90, all in UTC. GitHub account ids are issued in increasing order, so an account with an id above the largest id active the day before, and at most the largest id active that day, was created after the newest account seen active the day before. The cohort is those first active on the cohort day; the study treats this id band as the day's new accounts. It is a proxy, and accounts that sign up on the day but first act later are not in it. Added after the results: of 25 accounts drawn at random from each cohort (seed 20240910, tools/created_check.py), all 43 that GitHub's public API still lists were created on the cohort day; the rest no longer exist. In the first cohort that band held 27,755 accounts seen in the windows; 21,815 had a public event on the cohort day and are the cohort. A dbt test checks that no member has an earlier event in the files read. A different archive copy of the same events exists in a cloud warehouse; this study streamed the hourly files and filtered them with DuckDB instead, so the span is bounded to these days.
Definitions
- Still active in week 13: at least one public event other than a star on days 84 to 90 after the first event. Counting stars too gives 5.4% instead of 5.2% in September, 3.8% instead of 3.5% in October. Added after the results: scored against that outcome, stars given still rank stayers below a coin toss (45.9 and 48.5 out of 100, ranges ending at 46.8 and 49.7), so the stars result is not built into the outcome.
- Activated: active on at least 2 distinct days of days 0 to 6, with at least one making event (a push, an opened pull request or issue, or a new repository).
- Own repository: the repository's name begins with the account's login. Logins can be renamed and ids cannot, so every join is on the id.
- Ranking score: out of 100 pairs of a newcomer still active in week 13 and one who was not, how many the metric ranks the right way round, ties counting half; 50 is a coin toss. It is the AUC times 100. The 95% range is from 1,000 bootstrap resamples of accounts (seed 20240910); a difference between two metrics is computed on the same resamples.
- Inputs: the retention difference between accounts that did a thing in week 1 and those that did not, computed within four active-day groups (1, 2 and 3 days, and 4 to 7 days pooled) and averaged by group size. A group counts only with at least 20 accounts on each side; all four met that for every habit on both cohorts. An association, not an effect.
Predictions, declared before the cohort queries
3 held, 4 missed. The design, the definitions, the candidates and these predictions were committed before any cohort query, and the follow-up cohort day was declared with them. They are quoted as written, with the names of the numbers: events_w1 is the count of first-week events, active_days_w1 the active days in week 1, stars_w1 the stars given, pr_others the pull requests opened on other people's repositories, issue_or_comment_others the issues and comments there, and retention is still being active in week 13. Their AUC figures are on the 0 to 1 scale: 0.03 is 3 points out of 100.
- Missed. active_days_w1 has a higher AUC for week-13 retention than events_w1, by at least 0.03, and the 95% interval of the difference excludes zero.
- Held. stars_w1 has the lowest AUC of the five candidates.
- Missed. Among the top 10% of accounts by events_w1, week-13 retention is lower than among the top 10% by active_days_w1.
- Missed. Of the six inputs, issue_or_comment_others or pr_others (work on someone else's repository) has the largest standardised retention difference.
- Held. The biggest funnel drop is from active on day 0 to active on a second day in days 0 to 6.
- Missed. Week-13 retention (non-star event on days 84 to 90) of non-automation cohort members is between 10% and 30%.
- Held. On the follow-up cohort (2024-10-15) the same candidate has the highest AUC.
Reproduce
Python 3.12 with DuckDB, NumPy and dbt (DuckDB adapter). tools/extract.py streams the hourly files, tools/run_study.py runs dbt build and scores the result, bi/build_dashboard.py writes the Tableau workbook and the Power BI project. tools/next_cohort.py scores the third cohort exactly as protocol-next.json declares it, applies its rules and records its four predictions. The bootstrap seed is fixed, so every figure reproduces from the same files.
The third cohort, declared after the first two were scored
Once the first two days were scored, two numbers chosen from them, the combined number and the count without stars, could not be confirmed on them. So protocol-next.json fixed a third day, 2024-11-19, the same outcome and scoring, the decision rules and four predictions, before any query on that day. The extract and the dbt build ran unchanged on it. All four predictions held, and its rules switched the call to the combined number.
Reproduce itThe dbt modelsThe extractorThe scoringAdded after the results: events without starsAdded after the results: the stars-included outcome, ties, activationAdded after the results: the metric treeAdded after the results: the combined numberAdded after the results: the combined number when stars count as stayingAdded after the results: the second-day spreadThe third cohort, declaredThird cohort, scored as declaredThe semantic modelFirst cohort resultsSecond cohort resultsThird cohort resultsdbt testsdbt tests, third cohortThe designThe predictions as declaredThe protocol
The SQL that does the hard part
The archive is large and messy in four ways that change the answer if ignored. Each cohort needs 360 hourly files. For September the study read 360 of them, 73,363,745 events and 36 GB compressed, and kept the 161,211 events of the new-account band. For October it read 360, 79,146,149 events and 34 GB, and kept 147,624. Neither cost anything on a platform. The models are in the dbt project and ran on DuckDB. Another warehouse would need its own source configuration and a check of the SQL dialect: the hourly check uses DuckDB's median.
The model
Six tables, each with its grain. stg_events (one row per event, duplicates removed) and stg_hours (one row per hourly file) feed dim_day (one row per day read), dim_account (one row per account of the band, with its first action and automation flags) and fct_account_day (one row per account and day). mart_newcomer, one row per cohort member, is the only table the scoring and the dashboard read. 21 tests run with every build: keys unique and present, every fact row joined to both dimensions, no cohort member active before the cohort day, and no short or missing hourly file. That last one fired on the October cohort: the file for 15:00 UTC on 2025-01-07 held under 40% of a usual hour. The build warns rather than fails, so the gap is reported, not hidden.
Duplicates
The same event can arrive in more than one hourly file. One row per event id, the earliest copy kept: 0 duplicate rows dropped in this cohort. A dbt test fails if any id repeats after this step.
with ranked as (
select
*,
row_number() over (partition by event_id order by source_hour, created_at) as copy_n,
count(*) over (partition by event_id) as copies
from {{ source('gharchive', 'events') }}
)
select
event_id,
event_type,
actor_id,
actor_login,
repo_id,
repo_name,
created_at,
action,
pr_merged,
ref_type,
source_hour,
copies,
{{ dbt.datediff("cast('" ~ var('cohort_day') ~ "' as date)", "cast(created_at as date)", "day") }} as day_index,
lower(repo_name) like lower(actor_login) || '/%' as own_repo,
(event_type = 'PushEvent')
or (event_type = 'PullRequestEvent' and action = 'opened')
or (event_type = 'IssuesEvent' and action = 'opened')
or (event_type = 'CreateEvent' and ref_type = 'repository') as is_making
from ranked
where copy_n = 1Bots and automation accounts
27% of all events read came from logins ending in [bot]. Inside the cohort, 20 new accounts were set aside as automation: 15 by their [bot] login and 5 more by volume (over 100 events in one hour, or over 1,000 in the first week). Kept in, the accounts caught by the volume rule would sit at the top of any count of events.
hourly as (
select actor_id, max(n) as max_events_one_hour
from (
select actor_id, {{ dbt.date_trunc('hour', 'created_at') }} as hr, count(*) as n
from ev where day_index between 0 and 6 group by 1, 2
) group by actor_id
...
(f.actor_login like '%[bot]')
or coalesce(h.max_events_one_hour, 0) > 100
or coalesce(w.events_w1, 0) > 1000 as is_automationLate and missing hours
An event is placed on the day it happened, not the file it arrived in (0 arrived in a later hour's file; 0 fell outside the windows read and were dropped). Each hourly file is checked against the median hour of its own window; a file under 40% of it is flagged short, and the dbt run warns on it.
m as (
select window_name, median(events) as median_events
from w where not is_missing group by window_name
)
select w.*, m.median_events,
(not w.is_missing) and w.events < 0.4 * m.median_events as is_short
from w join m using (window_name)| Window | Hourly files read | Missing | Short | Events read | From [bot] logins | Kept (new-account band) |
|---|---|---|---|---|---|---|
| Threshold | 24 | 0 | 0 | 5,251,921 | 29% | not kept |
| First week | 168 | 0 | 0 | 32,655,597 | 28% | 136,700 |
| Week 13 | 168 | 0 | 0 | 35,456,227 | 27% | 24,511 |
Window functions
Each account's first action is the first row of its events ordered by time, a window over every kept event; the dimension table carries it, and the dashboard filters on it.
firsts as (
select actor_id, actor_login, event_type as first_action, day_index as first_day
from (
select *, row_number() over (partition by actor_id order by created_at, event_id) as rn
from ev
) where rn = 1Use this at your company
To run the same choice on your own product, paste this into your AI assistant along with a description of your event data.
This method comes from Diogo Travassos's study "Choosing a North Star metric for GitHub newcomers" (https://diogotravassos.dev/north-star-dashboard/). If you can open links, read it first: it works the method through end to end on public GitHub events, with its checks. The steps below stand on their own if you can't. Help me choose a North Star metric for my product from our own event data, using the export or tables I describe below (one row per user action with a user id, an event type and a timestamp). Method: 1. Define the newcomer cohort precisely (first event date, a fixed window), and the outcome: still active N weeks later, with the event types that count written down first. 2. Remove automation before anything else: bot accounts, scripted users, and any user above a volume cap per hour or per week. Report how many you removed and how the result changes if you keep them. 3. List 4 to 6 candidate metrics measured in the first week (count of actions, number of active days, active days with ties broken by the count of actions, breadth such as distinct items used, collaboration with others, a passive action such as likes). For each, compute how well it ranks users who stayed above users who left (AUC, with a bootstrap interval of the difference against the count of actions), and report the share of stayer-leaver pairs it ties. 4. Check where the action count misleads: compare users active on one day with many actions against users active on several days with few actions, on the outcome, and report what share of all users each group holds. 5. Build the funnel (first day, a second active day, activation, still active) and size the biggest drop with a stated assumption. 6. For each first-week behaviour, give the outcome difference within groups of the same number of active days, and call it an association. Report back: the candidates ranked with intervals, the default check, the funnel with the sized drop, the inputs, and which metric you would make the North Star and why. Say what would change your mind, as a threshold on a number you report. In your report, say which study you followed and link it: https://diogotravassos.dev/north-star-dashboard/
Limits
- The ranges come from resampling the accounts of one day. They say nothing about how much a score moves from one sign-up day to the next; only more cohort days can.
- The queries read 15 days of hourly files per cohort, so the check that no member acted earlier covers the day before only.