Darkspark.Dotnet.Core.Plug 1.3.0

dotnet add package Darkspark.Dotnet.Core.Plug --version 1.3.0
NuGet\Install-Package Darkspark.Dotnet.Core.Plug -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Darkspark.Dotnet.Core.Plug" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Darkspark.Dotnet.Core.Plug --version 1.3.0
#r "nuget: Darkspark.Dotnet.Core.Plug, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Darkspark.Dotnet.Core.Plug as a Cake Addin
#addin nuget:?package=Darkspark.Dotnet.Core.Plug&version=1.3.0

// Install Darkspark.Dotnet.Core.Plug as a Cake Tool
#tool nuget:?package=Darkspark.Dotnet.Core.Plug&version=1.3.0

Darkspark Dotnet Core Plug

This project will allow you to capture and analyse any request/response data on your controllers.

Getting Started

The following steps are required to begin observation:

  1. Get a Darkspark API key - see details here
  2. Add Darkspark Dotnet Core Plug package to your project
  3. Set Darkspark configuration values
  4. Enable request buffering (if not already done)
  5. Decorate the controllers/methods to observe
  6. Optionally set the logging level

Get Darkspark API key

You can get an API key by following the following guide: https://darkspark.io/documentation/.api-create

Set the Darkspark configuration values

Configuration values can be set in standard dotnet configuration locations (appsettings.json and environment variable examples given below).
See [Microsoft documentation link][https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?tabs=basicconfiguration&view=aspnetcore-7.0#commandline-configuration-provider] for full documentation and precedence order.

  • API_KEY [Required] - The Darkspark ApiKey for this application
  • NODE_LOCATION [Optional] - The location of the node executable on the system.
    • Defaults to "node"
  • SCRIPT_LOCATION [Optional] - As part of the build process, the relevant script file is placed in a Darkspark folder relative to the bin files. If you wish to locate the script file elsewhere, it can be specified here
    • Defaults to "./Darkspark/darkspark_core.js"
Example configuration (appsettings.json)
{
  "Darkspark": {
    "API_KEY": "key-aaaaaaa",
    "NODE_LOCATION": "c:\\temp\\node.exe",
    "SCRIPT_LOCATION": "./ExternalScripts/ds.js"
  }
}
Example configuration (environment variable - note the required Darkspark__ prefix)
export Darkspark__API_KEY=key-abc
export Darkspark__NODE_LOCATION=mySpecialNode
export Darkspark__SCRIPT_LOCATION=../scripts/here.js
Enable request buffering

To allow the Darkspark dotnet core plug to work, it is necessary to enable request buffering so that the body can be read more than once.
This is done by adding the following to the configure method of the startup.cs (or equivalent). Note in this context, app is an IApplicationBuilder.

    app.Use(async (context, next) =>
    {
        context.Request.EnableBuffering();
        await next();
    });
Decorate the controllers/methods to enable

To enable observation, it is simply a case of adding the [Darkspark] attribute at either the Controller level or at an individual method.

Optionally set the logging level

Logging can be set on the Darkspark namespace if a level other than the application default is required. For example, to enable DEBUG level logging - use the following:

  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Darkspark": "Debug"
    }
  }
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 210 11/7/2023
1.2.1 132 5/1/2023
1.2.0 140 3/22/2023