Skip to content

Latest commit

 

History

History

XO.Diagnostics.Bugsnag

XO.Diagnostics.Bugsnag

NuGet GitHub Actions Status

A simple HTTP client library for the BugSnag API. For a more complete solution, see XO.Diagnostics.Bugsnag.OpenTelemetry.

Usage

  1. Populate an instance of BugsnagClientOptions with your API key and any information about the host application or device that you want to report.

    var options = new BugsnagClientOptions
    {
        ApiKey = "abcxyz",
    };
  2. Create an instance of BugsnagClient using the options.

    var client = new BugsnagClient(options);
  3. Create instances of NotifyEventApp and NotifyEventDevice and customize them as needed.

    var app = client.CreateDefaultApp();
    var device = client.CreateDefaultDevice();
  4. Use the client to send events.

    var notifyEvent = new NotifyEvent {
        App = app,
        Device = device,
        Exceptions = {
            new NotifyEventException {
                "System.Exception",
                "Something went wrong",
                stacktrace: new() {
                     new NotifyEventStacktrace("Program.cs", 42, "Program.Main()") { InProject = true },
                },
            },
        },
    };
    
    var request = new NotifyRequest(client.Notifier) {
        Events = { notifyEvent },
    };
    
    await client.PostEventsAsync(request, cancellationToken);