fix: enable Telegram alerts for client-side errors
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m24s
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m24s
Problem: Client JavaScript/Blazor WebAssembly errors were logged but NOT sent to Telegram because ClientLogsController used LogWarning instead of LogError. Solution: ClientLogsController now checks entry.Level: - level='error' → LogError → Telegram alert ✓ - level='warning'/'info' → LogWarning → Log file only Result: Browser console errors now trigger Telegram notifications: - Blazor WebAssembly init failures - JavaScript exceptions - Unhandled promise rejections - Custom client errors This closes the monitoring gap for client-side issues. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,9 @@ public class ClientLogsController(ILogger<ClientLogsController> logger) : Contro
|
|||||||
return BadRequest();
|
return BadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogWarning(
|
var logMessage = "ClientLog {Level} {Source} {Message} Url={Url} Route={Route} Screen={Screen} Feature={Feature} Action={Action} Step={Step} Entity={Entity} EntityId={EntityId} DataKey={DataKey} BuildVersion={BuildVersion} UserAgent={UserAgent} Stack={Stack}";
|
||||||
"ClientLog {Level} {Source} {Message} Url={Url} Route={Route} Screen={Screen} Feature={Feature} Action={Action} Step={Step} Entity={Entity} EntityId={EntityId} DataKey={DataKey} BuildVersion={BuildVersion} UserAgent={UserAgent} Stack={Stack}",
|
var args = new object?[]
|
||||||
|
{
|
||||||
entry.Level ?? "error",
|
entry.Level ?? "error",
|
||||||
entry.Source ?? "unknown",
|
entry.Source ?? "unknown",
|
||||||
entry.Message,
|
entry.Message,
|
||||||
@@ -34,7 +35,19 @@ public class ClientLogsController(ILogger<ClientLogsController> logger) : Contro
|
|||||||
entry.DataKey ?? string.Empty,
|
entry.DataKey ?? string.Empty,
|
||||||
entry.BuildVersion ?? string.Empty,
|
entry.BuildVersion ?? string.Empty,
|
||||||
entry.UserAgent ?? string.Empty,
|
entry.UserAgent ?? string.Empty,
|
||||||
entry.Stack ?? string.Empty);
|
entry.Stack ?? string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
// Client errors (level: error) → Telegram alert
|
||||||
|
// Client warnings (level: warning/info) → Log file only
|
||||||
|
if (entry.Level?.Equals("error", StringComparison.OrdinalIgnoreCase) ?? true)
|
||||||
|
{
|
||||||
|
logger.LogError(logMessage, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogWarning(logMessage, args);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user