Moesif.Middleware 0.1.4

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

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

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
3.0.11 39 11/15/2024
3.0.10 50 11/13/2024
3.0.9 52 11/12/2024
1.5.2 38 11/15/2024
1.5.1 85 11/8/2024
1.5.0 69 11/8/2024
1.4.9 252 8/30/2024
1.4.8 841 6/6/2024
1.4.7 250 6/4/2024
1.4.6 106 5/29/2024
1.4.5 139 5/23/2024
1.4.4 107 5/21/2024
1.4.3 2,552 11/8/2023
1.4.2 112 11/7/2023
1.4.1 119 11/3/2023
1.4.0 155 10/31/2023
1.3.25 12,622 8/8/2023
1.3.24 220 7/24/2023
1.3.23 180 6/13/2023
1.3.22 163 6/10/2023
1.3.21 183 6/10/2023
1.3.20 3,735 10/6/2022
1.3.19 403 10/5/2022
1.3.18 409 10/5/2022
1.3.17 486 9/13/2022
1.3.16 452 9/7/2022
1.3.15 448 9/1/2022
1.3.14 418 8/30/2022
1.3.13 2,940 4/15/2021
1.3.12 426 4/1/2021
1.3.11 405 3/26/2021
1.3.10 528 3/18/2021
1.3.8 476 3/12/2021
1.3.7 442 2/9/2021
1.3.5 448 2/4/2021
1.3.4 416 2/2/2021
1.3.3 421 1/15/2021
1.3.2 484 1/9/2021
1.3.1 624 6/15/2020
1.3.0 499 6/15/2020
1.2.1 485 6/11/2020
1.1.6 557 6/9/2020
1.1.5 491 6/8/2020
1.1.4 525 6/8/2020
1.1.3 806 1/7/2020
1.1.2 594 12/19/2019
1.1.1 588 12/14/2019
1.1.0 566 11/15/2019
1.0.3 585 10/22/2019
1.0.2 593 8/27/2019
1.0.1 705 8/23/2019
0.2.2 603 6/26/2019
0.2.1 605 6/18/2019
0.2.0 618 5/30/2019
0.1.7 601 3/23/2019
0.1.6 659 3/1/2019
0.1.5 636 2/25/2019
0.1.4 616 2/25/2019
0.1.3 667 2/11/2019
0.1.1 752 11/19/2018
0.1.0 786 11/17/2018