From 77dcf7f339eb22e8c8cd499d1ffa3198e612e443 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Thu, 27 Jun 2024 13:07:51 -0400 Subject: [PATCH] Log SignalR pushes (#4392) We are interested in the rate at which signalR notifications are pushed to clients. This enables tracking only of that rate and the type of notification, nothing more identifiable. Data will be used to determine feasibility of transferring to web push --- src/Notifications/AzureQueueHostedService.cs | 2 +- src/Notifications/Controllers/SendController.cs | 6 ++++-- src/Notifications/HubHelpers.cs | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Notifications/AzureQueueHostedService.cs b/src/Notifications/AzureQueueHostedService.cs index 9d1fcb1932..977d9a9d1d 100644 --- a/src/Notifications/AzureQueueHostedService.cs +++ b/src/Notifications/AzureQueueHostedService.cs @@ -65,7 +65,7 @@ public class AzureQueueHostedService : IHostedService, IDisposable try { await HubHelpers.SendNotificationToHubAsync( - message.DecodeMessageText(), _hubContext, _anonymousHubContext, cancellationToken); + message.DecodeMessageText(), _hubContext, _anonymousHubContext, _logger, cancellationToken); await _queueClient.DeleteMessageAsync(message.MessageId, message.PopReceipt); } catch (Exception e) diff --git a/src/Notifications/Controllers/SendController.cs b/src/Notifications/Controllers/SendController.cs index a5780517eb..7debd51df7 100644 --- a/src/Notifications/Controllers/SendController.cs +++ b/src/Notifications/Controllers/SendController.cs @@ -11,11 +11,13 @@ public class SendController : Controller { private readonly IHubContext _hubContext; private readonly IHubContext _anonymousHubContext; + private readonly ILogger _logger; - public SendController(IHubContext hubContext, IHubContext anonymousHubContext) + public SendController(IHubContext hubContext, IHubContext anonymousHubContext, ILogger logger) { _hubContext = hubContext; _anonymousHubContext = anonymousHubContext; + _logger = logger; } [HttpPost("~/send")] @@ -27,7 +29,7 @@ public class SendController : Controller var notificationJson = await reader.ReadToEndAsync(); if (!string.IsNullOrWhiteSpace(notificationJson)) { - await HubHelpers.SendNotificationToHubAsync(notificationJson, _hubContext, _anonymousHubContext); + await HubHelpers.SendNotificationToHubAsync(notificationJson, _hubContext, _anonymousHubContext, _logger); } } } diff --git a/src/Notifications/HubHelpers.cs b/src/Notifications/HubHelpers.cs index 8463e1f34a..53edb76389 100644 --- a/src/Notifications/HubHelpers.cs +++ b/src/Notifications/HubHelpers.cs @@ -14,10 +14,12 @@ public static class HubHelpers string notificationJson, IHubContext hubContext, IHubContext anonymousHubContext, + ILogger logger, CancellationToken cancellationToken = default(CancellationToken) ) { var notification = JsonSerializer.Deserialize>(notificationJson, _deserializerOptions); + logger.LogInformation("Sending notification: {NotificationType}", notification.Type); switch (notification.Type) { case PushType.SyncCipherUpdate: