Skip to content

Commit 1a2fcb8

Browse files
committed
Log decryption error details as context in AnalyticsEvent
1 parent efb1476 commit 1a2fcb8

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Riot/Modules/Analytics/Analytics.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,10 @@ extension Analytics {
261261
/// Track an E2EE error that occurred
262262
/// - Parameters:
263263
/// - reason: The error that occurred.
264-
/// - count: The number of times that error occurred.
265-
func trackE2EEError(_ reason: DecryptionFailureReason, count: Int) {
266-
for _ in 0..<count {
267-
let event = AnalyticsEvent.Error(context: nil, domain: .E2EE, name: reason.errorName)
268-
capture(event: event)
269-
}
264+
/// - context: Additional context of the error that occured
265+
func trackE2EEError(_ reason: DecryptionFailureReason, context: String) {
266+
let event = AnalyticsEvent.Error(context: context, domain: .E2EE, name: reason.errorName)
267+
capture(event: event)
270268
}
271269

272270
/// Track when a user becomes unauthenticated without pressing the `sign out` button.

Riot/Modules/Analytics/DecryptionFailure.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ import AnalyticsEvents
4545
let ts: TimeInterval = Date().timeIntervalSince1970
4646
/// Decryption failure reason.
4747
let reason: DecryptionFailureReason
48+
/// Additional context of failure
49+
let context: String
4850

49-
init(failedEventId: String, reason: DecryptionFailureReason) {
51+
init(failedEventId: String, reason: DecryptionFailureReason, context: String) {
5052
self.failedEventId = failedEventId
5153
self.reason = reason
54+
self.context = context
5255
}
5356
}

Riot/Modules/Analytics/DecryptionFailureTracker.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ - (void)reportUnableToDecryptErrorForEvent:(MXEvent *)event withRoomState:(MXRoo
115115
break;
116116
}
117117

118+
NSString *context = [NSString stringWithFormat:@"code: %ld, description: %@", event.decryptionError.code, event.decryptionError.localizedDescription];
118119
reportedFailures[event.eventId] = [[DecryptionFailure alloc] initWithFailedEventId:failedEventId
119-
reason:reason];
120+
reason:reason
121+
context:context];
120122
}
121123

122124
- (void)dispatch
@@ -158,14 +160,10 @@ - (void)checkFailures
158160
for (DecryptionFailure *failure in failuresToTrack)
159161
{
160162
failuresCounts[@(failure.reason)] = @(failuresCounts[@(failure.reason)].unsignedIntegerValue + 1);
163+
[self.delegate trackE2EEError:failure.reason context:failure.context];
161164
}
162165

163166
MXLogDebug(@"[DecryptionFailureTracker] trackFailures: %@", failuresCounts);
164-
165-
for (NSNumber *reason in failuresCounts)
166-
{
167-
[self.delegate trackE2EEError:reason.integerValue count:failuresCounts[reason].integerValue];
168-
}
169167
}
170168
}
171169

changelog.d/6046_uisi_context

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Analytics: Log decryption error details as context in AnalyticsEvent

0 commit comments

Comments
 (0)