Skip to content

Track Stage listenership and report stats when a Stage ends - #529

Merged
vcarl merged 1 commit into
mainfrom
stage-listener-stats
Dec 2, 2026
Merged

vcarl merged 1 commit into
mainfrom
stage-listener-stats

Conversation

@vcarl

@vcarl vcarl commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

What

When a Stage goes live (stageInstanceCreate, covered by the existing Guilds intent), track everyone in the Stage channel. When it ends (stageInstanceDelete), post two messages to vcLog:

  1. Overview: listener count, peak concurrency and when it happened, average and median listen time, and how many stayed to the end. It also has an area chart of concurrent listeners over time, sparklines of joins and leaves over time, and a histogram of listen time.
  2. Top 20 listeners: one timeline row per person showing when they were present and for how long.

Both messages stay under Discord's 2,000-character limit at 400 listeners with a peak of 283 concurrent; there is a test for this.

Sample output

From the 400-listener test (topic "Big one"; the test uses placeholder names):

[STAGE] **Stage ended: Big one** <t:0:t>–<t:7200:t> (120 min)
400 listeners · peak 283 at +53m · avg 51m · median 44m · 134 stayed to the end
```
Listening
 283 ┤             ▁▃▅▇█▇▄▃
     ┤          ▂▅▇█████████▆▄▂▁
     ┤       ▂▅█████████████████▇▆▄▃▂▁
     ┤    ▂▅████████████████████████████▇▇▇▇▇▇
     ┤  ▃▆████████████████████████████████████
   0 ┤▄▇██████████████████████████████████████
      0m                                     120m

joins  █████████████████▅                       23 max
leaves ▁▁▁▂▁▃▄▂▄▂▆▄▅▆▄▇▅▇▇▅█▅▇▆▅▆▃▅▄▃▃▂▂▁▁▁     16 max

Time listened
0–5m    ██████ 23
5–15m   ███████████ 46
15–30m  ████████████████ 69
30–60m  █████████████████████████████ 128
60m+    ██████████████████████████████ 134
```
[STAGE] **Top 20 listeners** (of 400)
```
listener_wit ████████████████████████████████████████ 120m
listener_wit ████████████████████████████████████████ 119m
listener_wit ·███████████████████████████████████████ 117m
listener_wit ··██████████████████████████████████████ 112m
…
             0m                                     120m
```

A smaller run with real rejoins (alice leaves at 20m and comes back at 30m):

alice        ████████████████████··········██████████ 30m
bob          ··········██████████████████████████████ 30m
carol        ···············██████████··············· 10m
             0m                                     40m

Also fixed

voiceStateUpdate fires on mute, deafen and stream changes, which reset each member's join time. It now only acts on channel moves, and a move logs the time spent in the old channel.

Limits

  • Tracking is in memory, so a bot restart during a Stage drops that Stage's report.
  • Speakers and listeners are counted together.

Testing

npm test passes, with new unit tests in src/features/stage-stats.test.ts. Not yet tried against a live Stage.

🤖 Generated with Claude Code

On stageInstanceCreate, track joins/leaves in the Stage channel. On
stageInstanceDelete, post an overview (concurrency area chart, join/leave
sparklines, listen-time histogram) and a top-20 listener timeline to vcLog.

Also fix voiceStateUpdate resetting join time on mute/deafen, and log
time spent in the old channel when a member moves channels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vcarl
vcarl merged commit 877c44e into main Dec 2, 2026
2 checks passed
@vcarl
vcarl deleted the stage-listener-stats branch December 2, 2026 22:27
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