Skip to content

ClearInsights/ClearInsights.ASPNetCore

Repository files navigation


Logo

ClearInsights.ASPNetCore

An example of how to use the ClearInsights SDK within your ASPNetCore applications.

Explore the docs »

Report Bug · Request Feature



Getting Started

Prerequisites

Install the ClearInsights SDK

  • Package Manager
    Install-Package ClearInsights -Version 1.0.42
  • .Net CLI
    dotnet add package ClearInsights --version 1.0.42

Installation

Create a free ClearInsights account to start using the SDK

  1. Get a free account at https://clearinsights.io and retrieve your API Key under the Administration ->APIKey menu.

  2. Create at least 1 product and 1 environment and retrieve the Client Secret for the product/environment.

  3. Clone the repo

    git clone https://github.com/ClearInsights/ClearInsights.Console.git
  4. Enter your API Key and Client Secret in Program.cs

     builder.Logging.AddClearInsightsLogger(configuration =>
     {
         configuration.ApiKey = "{ApiKey}";
         configuration.Secret = "{Environment Client Secret}";
         configuration.ApplicationName = "{Application Name}";
     })
  5. Use and extend global exception handling

     //Add to use ClearInsights global error handling.
     //This will automatically catch any unhandled exceptions
     app.UseClearInsightsExceptionHandling(options =>
     {
         //Add to extend the error handler and add additional logic.
         //Add logic like custom HTTP response, etc...
         options.OnError += (sender, arg) =>
         {
             var response = "Oops something went wrong";
             arg.HttpContext.Response.ContentType = "text/html";
             arg.HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound;
             arg.HttpContext.Response.WriteAsync(response);
         };
     });

(back to top)

Usage

Use this app as an example of how to use the ClearInsights SDK within your ASPNetCore applications.

For more examples, please refer to the Documentation

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published