Skip to content

Commit

Permalink
Merge pull request #53 from Moesif/add-maskevent-example
Browse files Browse the repository at this point in the history
Add: MaskEventModel examples
  • Loading branch information
dgilling authored May 10, 2022
2 parents 53dcd42 + a9f6ee0 commit 189b93d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 Moesif, Inc
Copyright (c) 2022 Moesif, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Moesif.Middleware/Moesif.Middleware.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<description>.NET Middleware to log API Calls to Moesif API Analytics and Monitoring</description>
<summary />
<releaseNotes />
<copyright>Copyright 2021</copyright>
<copyright>Copyright 2022</copyright>
<language>en-US</language>
<tags>azure web app moesif API analytics insights debug debugging log logging apm performance monitor monitoring restful rest graphql ethereum web3 json-rpc soap net java node python php go golang ruby microsoft</tags>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion Moesif.Middleware/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Moesif, Inc")]
[assembly: AssemblyProduct("Moesif.Middleware")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
Expand Down
31 changes: 19 additions & 12 deletions Moesif.NetCore.Test/MoesifNetCoreTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Microsoft.Extensions.Logging;
using System.IO;
using System.Net;
using Moesif.Api.Models;
using Moesif.Api.Models;

namespace Moesif.NetCore.Test
{
Expand Down Expand Up @@ -75,9 +75,16 @@ public class MoesifNetCoreTest{
return false;
};

public static Func<EventModel, EventModel> MaskEventModelOutgoing = (EventModel event_model) => {
event_model.UserId = "masked_user_id";
return event_model;
public static Func<EventModel, EventModel> MaskEventModel = (EventModel moesifEvent) =>
{
Dictionary<String, String> eventRequestHeaders = moesifEvent.Request.Headers;
bool keyExists = eventRequestHeaders.ContainsKey("Authorization");
if (keyExists)
{
eventRequestHeaders.Remove("Authorization");
};

return moesifEvent;
};

public MoesifNetCoreTest() {
Expand Down Expand Up @@ -155,10 +162,10 @@ public void It_Should_Update_User() {
}
};

Dictionary<string, string> campaign = new Dictionary<string, string>
{
{"utm_source", "Newsletter" },
{"utm_medium", "Email" }
Dictionary<string, string> campaign = new Dictionary<string, string>
{
{"utm_source", "Newsletter" },
{"utm_medium", "Email" }
};

Dictionary<string, object> user = new Dictionary<string, object>
Expand Down Expand Up @@ -225,10 +232,10 @@ public void It_Should_Update_Company()
}
};

Dictionary<string, string> campaign = new Dictionary<string, string>
{
{"utm_source", "Adwords" },
{"utm_medium", "Twitter" }
Dictionary<string, string> campaign = new Dictionary<string, string>
{
{"utm_source", "Adwords" },
{"utm_medium", "Twitter" }
};

Dictionary<string, object> company = new Dictionary<string, object>
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ to add custom metadata that will be associated with the event. The metadata must
#### __`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](https://www.moesif.com/docs/api?csharp#).

```csharp
public static Func<EventModel, EventModel> MaskEventModel = (EventModel moesifEvent) =>
{
Dictionary<String, String> eventRequestHeaders = moesifEvent.Request.Headers;
bool keyExists = eventRequestHeaders.ContainsKey("Authorization");
if (keyExists)
{
eventRequestHeaders.Remove("Authorization");
};

return moesifEvent;
};
```

#### __`ApiVersion`__
(optional), _string_, API version associated with this particular event.

Expand Down Expand Up @@ -289,6 +303,20 @@ to add custom metadata that will be associated with the event. The metadata must
#### __`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](https://www.moesif.com/docs/api?csharp#).

```csharp
public static Func<EventModel, EventModel> MaskEventModel = (EventModel moesifEvent) =>
{
Dictionary<String, String> eventRequestHeaders = moesifEvent.Request.Headers;
bool keyExists = eventRequestHeaders.ContainsKey("Authorization");
if (keyExists)
{
eventRequestHeaders.Remove("Authorization");
};

return moesifEvent;
};
```

#### __`ApiVersion`__
(optional), _string_, api version associated with this particular event.

Expand Down

0 comments on commit 189b93d

Please sign in to comment.