Moesif.Middleware
0.1.3
See the version list below for details.
dotnet add package Moesif.Middleware --version 0.1.3
NuGet\Install-Package Moesif.Middleware -Version 0.1.3
<PackageReference Include="Moesif.Middleware" Version="0.1.3" />
paket add Moesif.Middleware --version 0.1.3
#r "nuget: Moesif.Middleware, 0.1.3"
// Install Moesif.Middleware as a Cake Addin #addin nuget:?package=Moesif.Middleware&version=0.1.3 // Install Moesif.Middleware as a Cake Tool #tool nuget:?package=Moesif.Middleware&version=0.1.3
Moesif Middleware for DotNet
Middleware to capture incoming API calls from .NET apps and send to the Moesif API Analytics platform.
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 Dashboard → Top Right Menu → App 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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- Microsoft.AspNetCore.Http (>= 2.1.1)
- Microsoft.AspNetCore.Http.Extensions (>= 2.1.1)
- Moesif.Api (>= 1.1.2)
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.1.1 | 52 | 11/22/2024 |
3.1.0 | 53 | 11/21/2024 |
3.0.11 | 81 | 11/15/2024 |
3.0.10 | 82 | 11/13/2024 |
3.0.9 | 90 | 11/12/2024 |
1.5.2 | 73 | 11/15/2024 |
1.5.1 | 90 | 11/8/2024 |
1.5.0 | 74 | 11/8/2024 |
1.4.9 | 255 | 8/30/2024 |
1.4.8 | 873 | 6/6/2024 |
1.4.7 | 267 | 6/4/2024 |
1.4.6 | 107 | 5/29/2024 |
1.4.5 | 140 | 5/23/2024 |
1.4.4 | 108 | 5/21/2024 |
1.4.3 | 2,554 | 11/8/2023 |
1.4.2 | 113 | 11/7/2023 |
1.4.1 | 122 | 11/3/2023 |
1.4.0 | 156 | 10/31/2023 |
1.3.25 | 12,904 | 8/8/2023 |
1.3.24 | 221 | 7/24/2023 |
1.3.23 | 181 | 6/13/2023 |
1.3.22 | 164 | 6/10/2023 |
1.3.21 | 184 | 6/10/2023 |
1.3.20 | 3,736 | 10/6/2022 |
1.3.19 | 404 | 10/5/2022 |
1.3.18 | 412 | 10/5/2022 |
1.3.17 | 487 | 9/13/2022 |
1.3.16 | 453 | 9/7/2022 |
1.3.15 | 449 | 9/1/2022 |
1.3.14 | 419 | 8/30/2022 |
1.3.13 | 2,945 | 4/15/2021 |
1.3.12 | 427 | 4/1/2021 |
1.3.11 | 406 | 3/26/2021 |
1.3.10 | 529 | 3/18/2021 |
1.3.8 | 477 | 3/12/2021 |
1.3.7 | 443 | 2/9/2021 |
1.3.5 | 449 | 2/4/2021 |
1.3.4 | 417 | 2/2/2021 |
1.3.3 | 422 | 1/15/2021 |
1.3.2 | 485 | 1/9/2021 |
1.3.1 | 625 | 6/15/2020 |
1.3.0 | 500 | 6/15/2020 |
1.2.1 | 486 | 6/11/2020 |
1.1.6 | 558 | 6/9/2020 |
1.1.5 | 492 | 6/8/2020 |
1.1.4 | 526 | 6/8/2020 |
1.1.3 | 807 | 1/7/2020 |
1.1.2 | 595 | 12/19/2019 |
1.1.1 | 589 | 12/14/2019 |
1.1.0 | 567 | 11/15/2019 |
1.0.3 | 586 | 10/22/2019 |
1.0.2 | 594 | 8/27/2019 |
1.0.1 | 706 | 8/23/2019 |
0.2.2 | 604 | 6/26/2019 |
0.2.1 | 606 | 6/18/2019 |
0.2.0 | 619 | 5/30/2019 |
0.1.7 | 602 | 3/23/2019 |
0.1.6 | 660 | 3/1/2019 |
0.1.5 | 637 | 2/25/2019 |
0.1.4 | 617 | 2/25/2019 |
0.1.3 | 668 | 2/11/2019 |
0.1.1 | 753 | 11/19/2018 |
0.1.0 | 787 | 11/17/2018 |