Moesif.Middleware
0.2.2
See the version list below for details.
dotnet add package Moesif.Middleware --version 0.2.2
NuGet\Install-Package Moesif.Middleware -Version 0.2.2
<PackageReference Include="Moesif.Middleware" Version="0.2.2" />
paket add Moesif.Middleware --version 0.2.2
#r "nuget: Moesif.Middleware, 0.2.2"
// Install Moesif.Middleware as a Cake Addin #addin nuget:?package=Moesif.Middleware&version=0.2.2 // Install Moesif.Middleware as a Cake Tool #tool nuget:?package=Moesif.Middleware&version=0.2.2
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 is an object of type Dictionary<string, object> which holds configuration options for your application.
Dictionary<string, object> moesifOptions = new Dictionary<string, object>
{
{"ApplicationId", "Your Application ID Found in Settings on Moesif"},
{"LogBody", true},
...
# For 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.
IdentifyCompany
(optional) (HttpRequest, HttpResponse) ⇒ string, a function that takes a request and a response, and returns a string that is the company id for this event.
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.
LogBody
boolean, default true. Set to false to not log the request and response body to Moesif.
Capture_Outgoing_Requests
(optional), Set to capture all outgoing API calls from your app to third parties like Stripe or to your own dependencies while using System.Net.Http package. The options below is applied to outgoing API calls. When the request is outgoing, for options functions that take request and response as input arguments, the request and response objects passed in are HttpRequestMessage request and HttpResponseMessage response objects.
How to configure your application to start capturing outgoing API calls.
using System.Net.Http;
using Moesif.Middleware.Helpers;
// moesifOptions is an object of type Dictionary<string, object> which holds configuration options for your application.
MoesifCaptureOutgoingRequestHandler handler = new MoesifCaptureOutgoingRequestHandler(new HttpClientHandler(), moesifOptions);
HttpClient client = new HttpClient(handler);
GetMetadataOutgoing
(optional) (HttpRequestMessage, HttpResponseMessage) ⇒ 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.
GetSessionTokenOutgoing
(optional) (HttpRequestMessage, HttpResponseMessage) ⇒ string, a function that takes a HttpRequestMessage and a HttpResponseMessage, 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.
IdentifyUserOutgoing
(optional) (HttpRequestMessage, HttpResponseMessage) ⇒ string, a function that takes a HttpRequestMessage and a HttpResponseMessage, 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.
IdentifyCompanyOutgoing
(optional) (HttpRequestMessage, HttpResponseMessage) ⇒ string, a function that takes a HttpRequestMessage and a HttpResponseMessage, and returns a string that is the company id for this event.
SkipOutgoing
(optional) (HttpRequestMessage, HttpResponseMessage) ⇒ boolean, a function that takes a HttpRequestMessage and a HttpResponseMessage, and returns true if you want to skip this particular event.
MaskEventModelOutgoing
(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.
LogBodyOutgoing
boolean, default true. Set to false to not log the request and response body to Moesif.
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.4)
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 |