Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

Add event dispatch middleware logging to Blazor Server

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Add event dispatch logging to Blazor Server for parity with WebAssembly

Description

Blazor Server was missing event dispatch logging that WebAssembly already had via addDispatchEventMiddleware. This adds visibility into user interactions alongside existing render batch logging.

Changes:

  • Import addDispatchEventMiddleware from WebRendererInteropMethods in Boot.Server.Common.ts
  • Register middleware in startServerCore to log event handler ID at Debug level
addDispatchEventMiddleware((_browserRendererId, eventHandlerId, continuation) => {
  logger.log(LogLevel.Debug, `Dispatching event with handler id ${eventHandlerId}.`);
  continuation();
});

Fixes #45674

Original prompt

This section details on the original issue you should resolve

<issue_title>[Blazor] Blazor Server/Webassembly should call setEventDispatcherMiddleware to wrap event dispatching and capture logs</issue_title>
<issue_description>Our logging on the client should not just include when the render batches happen, but also when the user interacts with the page. We should capture the event, the type, and the handler ID on the server.

The snippet below shows what we do on webassembly, we should do the same in all our platforms to include logging.

setDispatchEventMiddleware((browserRendererId, eventHandlerId, continuation) => {
</issue_description>

Comments on the Issue (you are @copilot in this section)

@ Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.</comment_new>
<comment_new>@
Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.</comment_new>
<comment_new>@
Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 3, 2025 15:10
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Copilot AI changed the title [WIP] Add event logging middleware to Blazor applications Add event dispatch middleware logging to Blazor Server Dec 3, 2025
Copilot AI requested a review from javiercn December 3, 2025 15:17
Copilot finished work on behalf of javiercn December 3, 2025 15:17
@javiercn javiercn added the area-blazor Includes: Blazor, Razor Components label Dec 3, 2025
@javiercn javiercn marked this pull request as ready for review December 3, 2025 15:48
@javiercn javiercn requested a review from a team as a code owner December 3, 2025 15:48
Copilot AI review requested due to automatic review settings December 3, 2025 15:48
Copilot finished reviewing on behalf of javiercn December 3, 2025 15:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds event dispatch logging to Blazor Server to improve visibility into user interactions. The implementation imports and registers the addDispatchEventMiddleware function to log event handler IDs at Debug level, providing debugging parity with the middleware infrastructure already used in WebAssembly (though WebAssembly uses it for heap locking rather than logging).

Key Changes

  • Imports addDispatchEventMiddleware from WebRendererInteropMethods
  • Registers middleware in startServerCore to log event handler IDs at Debug level
  • Adds observability into user interactions alongside existing render batch logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components Attention: Shared Code Modified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Blazor] Blazor Server/Webassembly should call setEventDispatcherMiddleware to wrap event dispatching and capture logs

2 participants