Lazers/Documentation/.NET SDK Guide
SDKs

.NET SDK Guide

.NET 8 server-side SDK for ASP.NET Core, Minimal APIs, and Worker Services. Explicit distinction from client-side Blazor/MAUI.

The Lazers .NET SDK (`Oneverse.Lazers`) targets .NET 8 LTS for backend servers, cloud microservices, and background Worker Services.

Installation ```bash dotnet add package Oneverse.Lazers ```

Integration Code Examples

ASP.NET Core Minimal API
using Oneverse.Lazers;

var builder = WebApplication.CreateBuilder(args);

// Register singleton LazersClient in DI
builder.Services.AddSingleton(sp => new LazersClient(new LazersOptions
{
    ApiKey = builder.Configuration["Lazers:ApiKey"]!,
    Endpoint = builder.Configuration["Lazers:Endpoint"] ?? "https://api.lazers.app",
    ProjectId = builder.Configuration["Lazers:ProjectId"]!,
    Environment = builder.Environment.EnvironmentName,
    ServiceName = "billing-service",
    Release = builder.Configuration["Lazers:Release"]
}));

var app = builder.Build();

app.UseExceptionHandler(exceptionHandlerApp =>
{
    exceptionHandlerApp.Run(async context =>
    {
        var lazers = context.RequestServices.GetRequiredService<LazersClient>();
        var exceptionHandlerPathFeature = context.Features.Get<IExceptionHandlerPathFeature>();
        if (exceptionHandlerPathFeature?.Error != null)
        {
            await lazers.CaptureErrorAsync(exceptionHandlerPathFeature.Error, new CaptureContext
            {
                CorrelationId = context.TraceIdentifier
            });
        }
        context.Response.StatusCode = 500;
        await context.Response.WriteAsync("Internal server error");
    });
});

app.MapGet("/health", () => "OK");

// Flush during shutdown
app.Lifetime.ApplicationStopping.Register(() =>
{
    var lazers = app.Services.GetRequiredService<LazersClient>();
    lazers.CloseAsync().GetAwaiter().GetResult();
});

app.Run();

Ready to test with your service?

Create a project, generate an API key or Client DSN, and send a signal in 2 minutes.