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:

Code
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 Dashboard

This 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.

C#
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.

C#
using System.Net.Http.Headers;

public sealed class GitHubStreamListener
{
    private readonly HttpClient _httpClient;

    public GitHubStreamListener(HttpClient httpClient)
    {
        _httpClient = httpClient;
    }

    public async Task ListenAsync(
        string eventsUrl,
        Func<string, string, Task> onEvent,
        CancellationToken cancellationToken)
    {
        using var request = new HttpRequestMessage(
            HttpMethod.Get,
            eventsUrl);

        request.Headers.Accept.Add(
            new MediaTypeWithQualityHeaderValue(
                "text/event-stream"));

        using var response = await _httpClient.SendAsync(
            request,
            HttpCompletionOption.ResponseHeadersRead,
            cancellationToken);

        response.EnsureSuccessStatusCode();

        await using var stream =
            await response.Content.ReadAsStreamAsync(
                cancellationToken);

        using var reader = new StreamReader(stream);

        string? eventId = null;
        string? eventType = null;
        var dataLines = new List<string>();

        while (!reader.EndOfStream &&
               !cancellationToken.IsCancellationRequested)
        {
            var line = await reader.ReadLineAsync(
                cancellationToken);

            if (line is null)
                break;

            if (line.StartsWith(':'))
                continue;

            if (line.Length == 0)
            {
                if (dataLines.Count > 0)
                {
                    var data = string.Join("\n", dataLines);

                    await onEvent(
                        eventId ?? string.Empty,
                        data);
                }

                eventId = null;
                eventType = null;
                dataLines.Clear();

                continue;
            }

            if (line.StartsWith("id:"))
            {
                eventId = line[3..].Trim();
            }
            else if (line.StartsWith("event:"))
            {
                eventType = line[6..].Trim();
            }
            else if (line.StartsWith("data:"))
            {
                dataLines.Add(line[5..].TrimStart());
            }
        }
    }
}

The listener reads the stream without waiting for the complete HTTP response. This is important because an SSE connection can remain open for a long time.

It also ignores comment lines, which GitHub uses for heartbeats. These lines do not represent application events.

The example collects the event ID, event type, and data separately. In a complete implementation, pass all three values to the event processor and handle the special github.stream.end event before processing normal pull request events.

The stream listener should also be wrapped in a reconnection loop. When the connection closes unexpectedly, the application should reconnect with an appropriate delay and jitter.

Processing Events for the Dashboard

An incoming event tells the application that something changed. It does not always contain enough information to update the dashboard directly.

For example, a review event does not necessarily include whether the review approved the pull request or requested changes. Similarly, a pull request state-change event does not tell the application whether the pull request was merged or simply closed.

GitHub provides an api_url in the event data. The application should use this URL to retrieve the latest resource state through the REST API.

The check-suite event is an exception because its conclusion is available directly in the event data. The application can immediately identify results such as success, failure, cancelled, or timed_out.

A simple processing method can begin by parsing the CloudEvent:

C#
using System.Text.Json;

public sealed class GitHubEventProcessor
{
    public async Task ProcessAsync(
        string eventId,
        string eventData)
    {
        using var document =
            JsonDocument.Parse(eventData);

        var root = document.RootElement;

        var eventType = root.TryGetProperty(
            "type",
            out var typeElement)
            ? typeElement.GetString()
            : null;

        var apiUrl = root.TryGetProperty(
            "api_url",
            out var apiElement)
            ? apiElement.GetString()
            : null;

        if (string.IsNullOrWhiteSpace(eventType))
            return;

        Console.WriteLine(
            $"Received event: {eventType}");

        if (!string.IsNullOrWhiteSpace(apiUrl))
        {
            Console.WriteLine(
                $"Resource URL: {apiUrl}");

            // Fetch the latest resource state
            // using an authenticated GitHub API client.
        }
    }
}

This example demonstrates the processing structure. The actual dashboard should validate the CloudEvent fields and use an authenticated API client to retrieve the resource.

After fetching the latest state, save the updated pull request information and publish a notification to connected dashboard clients.

Displaying Information in the Developer Dashboard

The dashboard should focus on information that helps developers make decisions rather than displaying every raw event.

A useful pull request dashboard can include:

Dashboard fieldInformation displayed
RepositoryRepository name
Pull requestNumber and title
AuthorDeveloper who created the pull request
Review statusApproved, changes requested, or pending
Build statusSuccess, failure, or running
Merge statusOpen, merged, or closed
Last activityMost recent detected update

For example, when a check-suite event reports a failure, the dashboard can update the build status and highlight the affected pull request.

When a review event arrives, the backend can fetch the review details and update the review status.

When the pull request is merged, the dashboard can move it from the active review list into the completed section.

SignalR is a suitable option for sending these updates from an ASP.NET Core backend to browser clients. The dashboard does not need to open separate GitHub event streams for every user viewing the page. Instead, the backend maintains the subscriptions and distributes processed updates to authorized users.

Handling Duplicates, Disconnections, and Subscription Expiration

A production dashboard must account for problems that are normal in long-lived event connections.

First, events may arrive more than once. Store processed event identifiers or another suitable deduplication key in the database. For review and check-suite events, the resource URL can also help identify the underlying resource.

Second, events can arrive out of order. Do not update a pull request's final state simply by applying events in the order received. Fetch its current state from GitHub when an event requires additional information.

Third, events are not replayed. If the application disconnects, changes that occur during that period may be missed. After establishing a subscription and opening the stream, fetch the current pull request state to reconcile the dashboard.

Fourth, subscriptions expire after 24 hours. The subscription manager should track expiration and create replacement subscriptions when monitoring needs to continue.

Finally, handle the github.stream.end event. When its outcome indicates reconnect, reopen the stream with backoff and refresh an installation token if necessary. When the outcome indicates subscription_ended, create a new subscription only if the application still needs to monitor that pull request.

Best Practices for Production Applications

Keep GitHub integration code separate from dashboard business logic. The event listener should collect events, while a dedicated processor validates them, retrieves current resource state, and updates application data.

Store subscription metadata and processed event identifiers in a database. This allows the application to recover after a service restart without losing track of monitored pull requests.

Use cancellation tokens and connection timeouts appropriately. A long-lived SSE connection should not be treated like an ordinary short HTTP request.

Monitor subscription counts because GitHub limits active subscriptions to 100 per user, app, or installation token. Subscribe only to the pull requests that the dashboard actually needs to monitor.

Also, remember that Event Streams is currently in public preview. Its API, event types, and limits may change. Keep the integration isolated behind a service interface so that changes in the GitHub API do not require rewriting the dashboard.

Summary

GitHub Event Streams provides a useful way to build responsive developer dashboards without continuously polling pull request endpoints. By creating subscriptions and receiving updates through SSE, an ASP.NET Core application can monitor review activity, check-suite results, pull request state changes, and new commits.

A reliable implementation needs more than an event listener. It should include subscription management, duplicate detection, resource-state reconciliation, reconnection handling, and subscription renewal.

By combining GitHub Event Streams with a backend processing service, a database, and SignalR, development teams can build a centralized dashboard that keeps important pull request information available in one place.