Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry support for Blazor WebAssembly #2021

Open
PeterDraex opened this issue Oct 27, 2022 · 10 comments
Open

Sentry support for Blazor WebAssembly #2021

PeterDraex opened this issue Oct 27, 2022 · 10 comments
Labels
Blazor Feature New feature or request

Comments

@PeterDraex
Copy link

Problem Statement

This is a feature request for support for Blazor WebAssembly. According to #317, there seems to be at least some level of integration supported, but I couldn't find any installation tutorial. I would love to see support including features like User Feedback Prompt or Tunneling.

Solution Brainstorm

No response

@PeterDraex PeterDraex added Feature New feature or request Platform: .NET labels Oct 27, 2022
@bruno-garcia
Copy link
Member

We have a sample in the repo: https://github.com/getsentry/sentry-dotnet/tree/23be90cd6b57446f7bbfeecc7c5f30eb692999fc/samples/Sentry.Samples.AspNetCore.Blazor.Wasm

But indeed no docs at the time. That said, support is there, it's just .NET running on Wasm (MonoAOT afaik).

User Feedback would require you to call the C# API. If you're using the JS widget, you'd need to do JS interop to pass around the event id. But it should work too.

@bruno-garcia bruno-garcia added Question Further information is requested Blazor and removed Feature New feature or request Status: Untriaged labels Nov 15, 2022
@mattjohnsonpint mattjohnsonpint added Feature New feature or request and removed Question Further information is requested labels Apr 6, 2023
@krossley
Copy link

krossley commented Apr 25, 2023

Can we get some support docs for Blazer Server Side?

@mattjohnsonpint
Copy link
Contributor

@krossley - I opened a new issue specifically for Blazor Server here: #2329

We don't have any specific guidance at the moment. As always, we're open to PRs. Thanks.

@bruno-garcia
Copy link
Member

bruno-garcia commented Aug 25, 2023

I played a bit during hackweek. Some learnings/ideas:

Stuff I explored in the draft PR above

  • JavaScript SDK bundled in Sentry.AspNetCore.Blazor
    • Docs would recommend adding the script tag directly, before loading the blazor.wasm.js file. This way Sentry can capture errors loading the .NET runtime. Performance and even Profiling will include time spent on that. And Replay will start recording as early as possible. I explored starting the JS SDK from C#, using the properties in C# to pass values to JS and it was all doable. But we'd be missing out too much.
  • Session Replay works pretty well
  • Browser performance monitoring. Didn't get C# span data into the JS layer though.
  • Download JavaScript SDK during .NET package build
    • Didn't set upload sourcemap tasks though
  • Init the .NET SDK with UseSentry on the WebAssemblyHostBuilder. (JS SDK needs to be added by itself)
  • Support for dependency injection in Blazor wasm
  • Auto registering Sentry.Extensions.Logging to capture errors/breadcrumbs
    • Some exceptions logged via ILogger have the whole stack trace in the message. so TODO is to parse those out of the messages.
  • Scope changes in C# propagate to JavaScript
  • Set User-Agent to get browser/OS info in Sentry:
  • Navigation breadcrumbs (from page A to B)
  • Since we include a Crash method in the SDK, the package includes a component with sample errors. Things to consider are: JS calling into C# and vice-versa. Which SDK captures the data? How scope data flows (my experiment has C#->JS since main lang is C# on Blazor).

WebAssembly error monitoring

Blazor Server

Lots to explore here. Since we have decent support with the Sentry.AspNetCore package already, I didn't invest too much time. But some areas:

Performance monitoring

  • Performance coming from the JS SDK seems quite rich already. But having insights of what's happning in blazor and on the code the user writes is missing. We could use the JS Interop to call into JS SDK to start/end span for example for blazor component lifecycle stuff (at least the built-in one). Or have a span observers similar to what we have on Scope to pass data from C# to JS.
  • We could monkeypatch some framework functions to get auto span for wasm bridge (as proposed by @AbhiPrasad)

Profiling

  • We might be able to leverage Sentry.Profiling. At least from .NET 8 if I read some threads online, EventPipe should get some data. Not sure about prod builds
  • Browser profiling is likely a good candidate. We can use the JS interop to add some blocks from C# (console.time and console.timeEnd (see this))

@bruno-garcia
Copy link
Member

@bruno-garcia
Copy link
Member

bruno-garcia commented Sep 14, 2023

.NET 8 introduces WasmStripILAfterAOT

@jamescrosswell
Copy link
Collaborator

jamescrosswell commented Sep 17, 2023

https://twitter.com/davidfowl/status/1701667585522290730

image

Weird that they separate out .NET and C#... I wonder what the results would look like if those two were grouped together (who is using C# but not .NET??? How could less people be using .NET and C#?).

@bruno-garcia
Copy link
Member

@klemmchr
Copy link

klemmchr commented Apr 6, 2024

Is there any timeline on a proper Blazor SDK? The current situation is not really satisfying since Sentry in Blazor WASM using the existing SDKs misses out on all the cool features like replays and profiling.

@bitsandfoxes
Copy link
Contributor

As a very soft ETA, we would like to be able to support this sometime within the next quarter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blazor Feature New feature or request
Projects
Status: No status
Status: No status
Archived in project
Development

No branches or pull requests

7 participants