From 04bf08453ac8ed485f33fafb3ed01f5845d667bf Mon Sep 17 00:00:00 2001 From: George Menhorn Date: Wed, 8 Nov 2023 15:44:25 -0500 Subject: [PATCH] metrics: retry submission on connection failure Previously, only a subset protocol errors would be considered for retry when submitting metrics (summed or unique) to events.backtrace.io. This excluded, notably, a failure to connect to the server at all. If the device was offline at startup, for instance, then the "Application Launches" event would never get sent. This commit changes the handling so that any network error will also go through the retry logic for submitting an event. --- Runtime/Model/Metrics/MetricsSubmissionQueue.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Runtime/Model/Metrics/MetricsSubmissionQueue.cs b/Runtime/Model/Metrics/MetricsSubmissionQueue.cs index 4ef360e5..4557a994 100644 --- a/Runtime/Model/Metrics/MetricsSubmissionQueue.cs +++ b/Runtime/Model/Metrics/MetricsSubmissionQueue.cs @@ -116,8 +116,11 @@ internal void SendPayload(ICollection events, uint attempts = 0) { OnRequestCompleted(); } - else if (statusCode > 501 && statusCode != 505) + else if (httpError == true || (statusCode > 501 && statusCode != 505)) { + // Failed to communicate with server or received a 5xx response code. Retry + // again at a later time, up to the configured number of maximum attempts. + // _numberOfDroppedRequests++; if (attempts + 1 == BacktraceMetrics.MaxNumberOfAttempts) {