Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Log decryption error details as context in AnalyticsEvent #6047

Merged
merged 1 commit into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Riot/Modules/Analytics/Analytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,10 @@ extension Analytics {
/// Track an E2EE error that occurred
/// - Parameters:
/// - reason: The error that occurred.
/// - count: The number of times that error occurred.
func trackE2EEError(_ reason: DecryptionFailureReason, count: Int) {
for _ in 0..<count {
let event = AnalyticsEvent.Error(context: nil, domain: .E2EE, name: reason.errorName)
capture(event: event)
}
/// - context: Additional context of the error that occured
func trackE2EEError(_ reason: DecryptionFailureReason, context: String) {
let event = AnalyticsEvent.Error(context: context, domain: .E2EE, name: reason.errorName)
capture(event: event)
}

/// Track when a user becomes unauthenticated without pressing the `sign out` button.
Expand Down
5 changes: 4 additions & 1 deletion Riot/Modules/Analytics/DecryptionFailure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ import AnalyticsEvents
let ts: TimeInterval = Date().timeIntervalSince1970
/// Decryption failure reason.
let reason: DecryptionFailureReason
/// Additional context of failure
let context: String

init(failedEventId: String, reason: DecryptionFailureReason) {
init(failedEventId: String, reason: DecryptionFailureReason, context: String) {
self.failedEventId = failedEventId
self.reason = reason
self.context = context
}
}
10 changes: 4 additions & 6 deletions Riot/Modules/Analytics/DecryptionFailureTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ - (void)reportUnableToDecryptErrorForEvent:(MXEvent *)event withRoomState:(MXRoo
break;
}

NSString *context = [NSString stringWithFormat:@"code: %ld, description: %@", event.decryptionError.code, event.decryptionError.localizedDescription];
reportedFailures[event.eventId] = [[DecryptionFailure alloc] initWithFailedEventId:failedEventId
reason:reason];
reason:reason
context:context];
}

- (void)dispatch
Expand Down Expand Up @@ -158,14 +160,10 @@ - (void)checkFailures
for (DecryptionFailure *failure in failuresToTrack)
{
failuresCounts[@(failure.reason)] = @(failuresCounts[@(failure.reason)].unsignedIntegerValue + 1);
[self.delegate trackE2EEError:failure.reason context:failure.context];
}

MXLogDebug(@"[DecryptionFailureTracker] trackFailures: %@", failuresCounts);

for (NSNumber *reason in failuresCounts)
{
[self.delegate trackE2EEError:reason.integerValue count:failuresCounts[reason].integerValue];
}
}
}

Expand Down
1 change: 1 addition & 0 deletions changelog.d/6046_uisi_context
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Analytics: Log decryption error details as context in AnalyticsEvent