Introduction
Development teams often work with several pull requests at the same time. A developer may be waiting for a code review, a team lead may be checking build results, and a release engineer may need to know whether a pull request has been merged or closed. When this information is spread across different GitHub pages, keeping track of the team's progress becomes difficult.
A developer dashboard can bring this information into one place. Instead of repeatedly checking pull requests manually, the dashboard can receive events from GitHub and update its view when something changes.
GitHub Event Streams provides a way to build this type of application. It allows an integration to subscribe to changes on an individual pull request and receive notifications through Server-Sent Events (SSE). The application can then fetch the latest pull request information and update its dashboard.
GitHub Event Streams is currently a public preview, and access is being provided through a waitlist. It currently supports pull request events on GitHub.com. The feature is not a replacement for repository-wide webhooks or a general-purpose event feed.
In this article, we will explore how to build a developer dashboard using GitHub Event Streams, process incoming events in a .NET application, and display useful information for a development team.
Understanding GitHub Event Streams
GitHub Event Streams allows applications and agents to subscribe to changes on a particular resource instead of repeatedly polling an API.
For example, suppose a team is working on five pull requests. The dashboard can create a subscription for each pull request and listen for selected events.
GitHub currently supports these pull request event types:
- Pull request head changed: Triggered when the pull request's head commit changes.
- Pull request review submitted: Triggered when someone submits a review.
- Pull request state changed: Triggered when a pull request is merged, closed, reopened, or moved between draft and ready-for-review states.
- Check suite status changed: Triggered when a check suite completes.
- Merge conflict detected: Triggered when GitHub identifies a merge conflict.
Events are delivered over an SSE connection. Unlike webhooks, this approach does not require the application to expose a publicly accessible endpoint to receive event notifications.
There are some important limitations. A subscription covers one pull request, expires after 24 hours, and supports a maximum of 100 active subscriptions per user, app, or installation token. Events are not replayed after a disconnection, and they can arrive more than once or out of order.
Because of these limitations, a production dashboard should treat events as notifications that something changed, not as a complete and permanently ordered record of every activity.
Designing the Dashboard Architecture
A practical developer dashboard can be divided into four main components.
GitHub subscription manager
The subscription manager creates subscriptions for the pull requests that the team wants to monitor. It stores the subscription ID, pull request URL, event types, expiration time, and stream URL.
It should also renew subscriptions before they expire and remove subscriptions that are no longer required.
Event stream listener
The listener maintains an SSE connection for each active subscription. It reads incoming events and passes them to the application's processing service.
Since connections can close unexpectedly, the listener must support reconnection, token renewal, and appropriate retry delays.
Event processing service
The processing service validates incoming events, prevents duplicate processing, and fetches the latest pull request or check information when required.
It should not assume that the order in which events arrive represents the actual order of changes on GitHub.
Dashboard interface
The dashboard displays the latest information using cards, tables, or activity timelines. A real-time communication mechanism such as SignalR can push updates from the backend to connected browser clients.
The overall flow looks like this:
GitHub Pull Requests
|
v
Subscription Manager
|
v
GitHub Event Streams
|
v
SSE Event Listener
|
v
Event Processing Service
|
+------> GitHub REST API
|
v
Database
|
v
SignalR
|
v
Developer DashboardThis design separates event collection from dashboard presentation. It also makes it easier to add features such as notifications, activity history, and team-level reporting.
Creating a GitHub Event Subscription
Before creating subscriptions, make sure the GitHub account has access to Event Streams. The feature requires an eligible user token or GitHub App installation token with permission to read the pull request.
For a dashboard that monitors pull request reviews and build results, create a subscription with the required event types.
The following example uses the GitHub REST API through HttpClient in a .NET application.
using System.Net.Http.Headers;
using System.Net.Http.Json;
public sealed class GitHubEventClient
{
private readonly HttpClient _httpClient;
public GitHubEventClient(
HttpClient httpClient,
IConfiguration configuration)
{
_httpClient = httpClient;
var token = configuration["GitHub:Token"]
?? throw new InvalidOperationException(
"GitHub token is missing.");
_httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token);
_httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue(
"application/vnd.github+json"));
}
public async Task<string> CreateSubscriptionAsync(
string owner,
string repository,
int pullRequestNumber,
CancellationToken cancellationToken)
{
var request = new
{
resource_url =
$"https://github.com/{owner}/{repository}/pull/{pullRequestNumber}",
event_types = new[]
{
"com.github.pull_request.review.submitted.v1",
"com.github.pull_request.check_suite.status.changed.v1",
"com.github.pull_request.state.changed.v1",
"com.github.pull_request.head.changed.v1"
}
};
using var response = await _httpClient.PostAsJsonAsync(
"https://api.github.com/event-subscriptions",
request,
cancellationToken);
response.EnsureSuccessStatusCode();
var subscription = await response.Content
.ReadFromJsonAsync<SubscriptionResponse>(
cancellationToken: cancellationToken);
return subscription?.EventsUrl
?? throw new InvalidOperationException(
"GitHub did not return an events URL.");
}
}
public sealed class SubscriptionResponse
{
public string Id { get; set; } = string.Empty;
public string EventsUrl { get; set; } = string.Empty;
public DateTimeOffset ExpiresAt { get; set; }
}The example creates a subscription for one pull request and requests review, check-suite, state, and head-change events.
The returned events URL is used to open the SSE connection. In a production application, store the complete subscription response rather than keeping only the stream URL.
Also, configure the GitHub token through a secure secret store. Do not commit access tokens to source control or expose them to browser clients.
Reading Events From the SSE Connection
Once the subscription has been created, the application can open the stream and wait for incoming events.
SSE messages use a text-based format. An event can contain an ID, an event type, and a data field containing a single-line JSON CloudEvent.
The following example demonstrates how a .NET application can read the stream.
Join the conversation! Your thoughts help the community grow.