Skip to content

Commit

Permalink
Merge pull request #137 from LeonAquitaine/master
Browse files Browse the repository at this point in the history
Analytics
  • Loading branch information
lbotinelly authored Nov 26, 2023
2 parents 4eb1812 + ab3f830 commit e73410c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Zen.Web.App/Controllers/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Settings : ControllerBase
internal JavaScriptResult JavaScriptSettingsPayload(string variableName)
{

Base.Log.KeyValuePair("JavaScriptSettingsPayload","New Instance");
Base.Log.KeyValuePair(nameof(JavaScriptSettingsPayload),"New Instance");


var zen_ver = "";
Expand Down
17 changes: 11 additions & 6 deletions Zen.Web/Middleware/Html5Router.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Serilog.Core;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -65,10 +64,10 @@ public static void UseHtml5Routing(this IApplicationBuilder app)

var physicalPath = Path.Combine(pathParts.ToArray());

Base.Log.Add(context.Request.Path + context.Request.QueryString, Base.Module.Log.Message.EContentType.Debug);
Base.Log.Add(physicalPath, Base.Module.Log.Message.EContentType.Debug);
//Base.Log.Add(context.Request.Path + context.Request.QueryString, Base.Module.Log.Message.EContentType.Debug);
//Base.Log.Add(physicalPath, Base.Module.Log.Message.EContentType.Debug);

await LogRequest(context);
await LogAnalytics(context);

if (File.Exists(physicalPath)) { await next.Invoke(); return; }

Expand All @@ -92,7 +91,7 @@ public static void UseHtml5Routing(this IApplicationBuilder app)
});
}

private static async Task LogRequest(HttpContext context)
private static async Task LogAnalytics(HttpContext context)

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web.SelfHost)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web.SelfHost)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Facebook)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Facebook)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.GitHub)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.GitHub)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web.OpenApi)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web.OpenApi)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web.Auth)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web.Auth)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Steam)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Steam)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Discord)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Discord)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Google)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Google)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Microsoft)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Provider.Microsoft)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Module.Cloud.Google)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Module.Cloud.Google)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web.App)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Zen.Web/Middleware/Html5Router.cs

View workflow job for this annotation

GitHub Actions / Warm-Up (Web.App)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
var url = context.Request.GetDisplayUrl();

Expand All @@ -102,7 +101,13 @@ private static async Task LogRequest(HttpContext context)

try
{
new RequestLog() { Referer = context.Request.Headers["referer"].ToString(), Url = context.Request.GetDisplayUrl(), }.Save();
new Model.Analytics.Request()
{
Url = context.Request.GetDisplayUrl(),
Headers = context.Request.Headers.ToDictionary(i => i.Key.ToString(), i => i.Value.ToString()),
Path = context.Request.Path + context.Request.QueryString,
Type = Model.Analytics.Request.EType.Html5Redirect
}.Save();
}
catch (Exception) { }

Expand Down
27 changes: 27 additions & 0 deletions Zen.Web/Model/Analytics/Request.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Zen.Base.Module;
using Zen.Base.Module.Data.CommonAttributes;

namespace Zen.Web.Model.Analytics
{
internal class Request : Data<Request>, IDataId
{
public enum EType
{
Regular,
Html5Redirect
}


[Key]
public string Id { get; set; }
[Display]
public string Url { get; set; }
public Dictionary<string, string> Headers { get; set; }
public string Path { get; set; }
public EType Type { get; set; } = EType.Regular;
public DateTime Timestamp { get; set; } = DateTime.Now;
}
}
3 changes: 3 additions & 0 deletions Zen.Web/Model/RequestLog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Zen.Base.Module;
using Zen.Base.Module.Data.CommonAttributes;
Expand All @@ -16,5 +17,7 @@ public class RequestLog : Data<RequestLog>, IDataId
public string Referer { get; set; }

public DateTime Timestamp { get; set; } = DateTime.Now;
public Dictionary<string, string> Headers { get; internal set; }
public string Path { get; internal set; }
}
}

0 comments on commit e73410c

Please sign in to comment.