Moesif.Middleware 0.1.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package Moesif.Middleware --version 0.1.6
NuGet\Install-Package Moesif.Middleware -Version 0.1.6
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="Moesif.Middleware" Version="0.1.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Moesif.Middleware --version 0.1.6
#r "nuget: Moesif.Middleware, 0.1.6"
#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 Moesif.Middleware as a Cake Addin
#addin nuget:?package=Moesif.Middleware&version=0.1.6

// Install Moesif.Middleware as a Cake Tool
#tool nuget:?package=Moesif.Middleware&version=0.1.6

Moesif Middleware for DotNet

Built For Latest Version Software License Source Code

Middleware to capture incoming API calls from .NET apps and send to the Moesif API Analytics platform.

Source Code on GitHub

How to install

Install the Nuget Package:

    Install-Package Moesif.Middleware

How to use

In Startup.cs file in your project directory, please add app.UseMiddleware<MoesifMiddleware>(moesifOptions); to the pipeline.

Because of middleware execution order, it is best to add middleware below SessionMiddleware and AuthenticationMiddleware, because they add useful session data that enables deeper error analysis. On the other hand, if you have other middleware that modified response before going out, you may choose to place Moesif middleware above the middleware modifying response. This allows Moesif to see the modifications to the response data and see closer to what is going over the wire.

Add the middleware to your application:

app.UseMiddleware<MoesifMiddleware>(moesifOptions);

Also, add moesifOptions to your settings file,

moesifOptions = {
    'ApplicationId': 'Your Application ID Found in Settings on Moesif',
    ...
    # other options see below.
}

You can find your Application Id from Moesif DashboardTop Right MenuApp Setup

Configuration options

ApplicationId

(required), string, is obtained via your Moesif Account, this is required.

Skip

(optional) (HttpRequest, HttpResponse) ⇒ boolean, a function that takes a request and a response, and returns true if you want to skip this particular event.

IdentifyUser

(optional) (HttpRequest, HttpResponse) ⇒ string, a function that takes a request and a response, and returns a string that is the user id used by your system. While Moesif identify users automatically, if your set up is very different from the standard implementations, it would be helpful to provide this function.

GetSessionToken

(optional) (HttpRequest, HttpResponse) ⇒ string, a function that takes a request and a response, and returns a string that is the session token for this event. Again, Moesif tries to get the session token automatically, but if you setup is very different from standard, this function will be very help for tying events together, and help you replay the events.

GetMetadata

(optional) (HttpRequest, HttpResponse) ⇒ dictionary, getMetadata is a function that returns an object that allows you to add custom metadata that will be associated with the event. The metadata must be a dictionary that can be converted to JSON. For example, you may want to save a VM instance_id, a trace_id, or a tenant_id with the request.

MaskEventModel

(optional) (EventModel) ⇒ EventModel, a function that takes an EventModel and returns an EventModel with desired data removed. Use this if you prefer to write your own mask function. The return value must be a valid EventModel required by Moesif data ingestion API. For details regarding EventModel please see the Moesif CSharp API Documentation.

ApiVersion

(optional), string, api version associated with this particular event.

LocalDebug

boolean, set to True to print internal log messages for debugging SDK integration issues.

Example:

public static Func<HttpRequest, HttpResponse, string> IdentifyUser = (HttpRequest req, HttpResponse res) =>  {
    return "my_user_id";  
} ;

public static Func<HttpRequest, HttpResponse, string> GetSessionToken = (HttpRequest req, HttpResponse res) => {
    return "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f";
};

public static Func<HttpRequest, HttpResponse, Dictionary<string, string>> GetMetadata = (HttpRequest req, HttpResponse res) => {
    Dictionary<string, string> metadata = new Dictionary<string, string>
    {
        { "email", "abc@email.com" },
        { "name", "abcdef" },
        { "image", "123" }
    };
    return metadata;
};

public static Func<HttpRequest, HttpResponse, bool> Skip = (HttpRequest req, HttpResponse res) => {
    string uri = new Uri(req.GetDisplayUrl()).ToString();
    if (uri.Contains("test"))
    {
        return true;
    }
    return false;
};

public static Func<EventModel, EventModel> MaskEventModel = (EventModel event_model) => {
    event_model.UserId = "masked_user_id";
    return event_model;
};

static public Dictionary<string, object> moesifOptions = new Dictionary<string, object>
{
    {"ApplicationId", "Your Application ID Found in Settings on Moesif"},
    {"LocalDebug", true},
    {"ApiVersion", "1.0.0"},
    {"IdentifyUser", IdentifyUser},
    {"GetSessionToken", GetSessionToken},
    {"GetMetadata", GetMetadata},
    {"Skip", Skip},
    {"MaskEventModel", MaskEventModel}
};

Example

An example Moesif integration based on quick start tutorial: Moesif .NET Example

Other integrations

To view more more documentation on integration options, please visit the Integration Options Documentation.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
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.4.3 1,293 11/8/2023
1.4.2 87 11/7/2023
1.4.1 96 11/3/2023
1.4.0 123 10/31/2023
1.3.25 3,393 8/8/2023
1.3.24 182 7/24/2023
1.3.23 158 6/13/2023
1.3.22 136 6/10/2023
1.3.21 162 6/10/2023
1.3.20 3,595 10/6/2022
1.3.19 381 10/5/2022
1.3.18 389 10/5/2022
1.3.17 453 9/13/2022
1.3.16 415 9/7/2022
1.3.15 422 9/1/2022
1.3.14 396 8/30/2022
1.3.13 2,826 4/15/2021
1.3.12 402 4/1/2021
1.3.11 380 3/26/2021
1.3.10 499 3/18/2021
1.3.8 443 3/12/2021
1.3.7 414 2/9/2021
1.3.5 408 2/4/2021
1.3.4 379 2/2/2021
1.3.3 391 1/15/2021
1.3.2 460 1/9/2021
1.3.1 590 6/15/2020
1.3.0 469 6/15/2020
1.2.1 461 6/11/2020
1.1.6 526 6/9/2020
1.1.5 462 6/8/2020
1.1.4 501 6/8/2020
1.1.3 634 1/7/2020
1.1.2 562 12/19/2019
1.1.1 562 12/14/2019
1.1.0 540 11/15/2019
1.0.3 560 10/22/2019
1.0.2 563 8/27/2019
1.0.1 674 8/23/2019
0.2.2 573 6/26/2019
0.2.1 584 6/18/2019
0.2.0 589 5/30/2019
0.1.7 579 3/23/2019
0.1.6 631 3/1/2019
0.1.5 607 2/25/2019
0.1.4 586 2/25/2019
0.1.3 645 2/11/2019
0.1.1 725 11/19/2018
0.1.0 758 11/17/2018