MESSENGER-4821 add dimension for decryption error tracking

This commit is contained in:
JanNiklas Grabowski
2023-10-11 15:07:07 +02:00
parent 7312ad09ad
commit 77705a42ae
5 changed files with 19 additions and 12 deletions

View File

@@ -45,11 +45,14 @@ import AnalyticsEvents
let context: String
// bwi: tracking information
let errorCode: NSInteger
init(failedEventId: String, reason: DecryptionFailureReason, context: String, errorCode: NSInteger) {
// bwi: #4821 RoomDevicesCount
let deviceCount: NSInteger
init(failedEventId: String, reason: DecryptionFailureReason, context: String, errorCode: NSInteger, deviceCount: NSInteger) {
self.failedEventId = failedEventId
self.reason = reason
self.context = context
self.errorCode = errorCode
self.deviceCount = deviceCount
}
}

View File

@@ -20,6 +20,7 @@
@class Analytics;
@import MatrixSDK;
@class BWIAnalyticsHelper;
@interface DecryptionFailureTracker : NSObject
@@ -44,8 +45,9 @@
@param event the event.
@param roomState the room state when the event was received.
@param userId my user id.
@param deviceCount room device count.
*/
- (void)reportUnableToDecryptErrorForEvent:(MXEvent*)event withRoomState:(MXRoomState*)roomState myUser:(NSString*)userId;
- (void)reportUnableToDecryptErrorForEvent:(MXEvent*)event withRoomState:(MXRoomState*)roomState myUser:(NSString*)userId roomDeviceCount:(NSInteger)deviceCount;
/**
Flush current data.

View File

@@ -77,7 +77,7 @@ NSString *const kDecryptionFailureTrackerAnalyticsCategory = @"e2e.failure";
return self;
}
- (void)reportUnableToDecryptErrorForEvent:(MXEvent *)event withRoomState:(MXRoomState *)roomState myUser:(NSString *)userId
- (void)reportUnableToDecryptErrorForEvent:(MXEvent *)event withRoomState:(MXRoomState *)roomState myUser:(NSString *)userId roomDeviceCount:(NSInteger)deviceCount
{
if (reportedFailures[event.eventId] || [trackedEvents containsObject:event.eventId])
{
@@ -117,7 +117,8 @@ NSString *const kDecryptionFailureTrackerAnalyticsCategory = @"e2e.failure";
reportedFailures[event.eventId] = [[DecryptionFailure alloc] initWithFailedEventId:failedEventId
reason:reason
context:context
errorCode:event.decryptionError.code];
errorCode:event.decryptionError.code
deviceCount:deviceCount];
}
- (void)dispatch
@@ -158,8 +159,8 @@ NSString *const kDecryptionFailureTrackerAnalyticsCategory = @"e2e.failure";
NSMutableDictionary<NSNumber*, NSNumber*> *failuresCounts = [NSMutableDictionary dictionary];
for (DecryptionFailure *failure in failuresToTrack)
{
if ( failure.reason == DecryptionFailureReasonUnspecified) {
[BWIAnalytics.sharedTracker trackE2EEError:failure.errorCode];
if (failure.reason == DecryptionFailureReasonUnspecified) {
[BWIAnalytics.sharedTracker trackE2EEErrorWithDimension:failure.errorCode deviceCount:[BWIAnalyticsHelper dimensionForDeviceCount: failure.deviceCount]];
} else {
failuresCounts[@(failure.reason)] = @(failuresCounts[@(failure.reason)].unsignedIntegerValue + 1);
}

View File

@@ -341,7 +341,9 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm";
{
// Track e2e failures
dispatch_async(dispatch_get_main_queue(), ^{
[[DecryptionFailureTracker sharedInstance] reportUnableToDecryptErrorForEvent:event withRoomState:roomState myUser:self->mxSession.myUser.userId];
[BWIAnalyticsHelper getRoomDeviceCountWithRoom:[self->mxSession roomWithRoomId:roomState.roomId] completion:^(NSInteger deviceCount) {
[[DecryptionFailureTracker sharedInstance] reportUnableToDecryptErrorForEvent:event withRoomState:roomState myUser:self->mxSession.myUser.userId roomDeviceCount:deviceCount];
}];
});
if (event.decryptionError.code == MXDecryptingErrorUnknownInboundSessionIdCode)

View File

@@ -274,13 +274,12 @@ extension BWIAnalytics : MXAnalyticsDelegate {
// dont track NV specific logs
}
func trackE2EEError(_ errorCode: Int) {
func trackE2EEErrorWithDimension(_ errorCode: Int, deviceCount: String) {
if let errorCode = AnalyticsE2EEErrorCode(rawValue: errorCode) {
self.trackBwiValue(NSNumber(value: 1), "Encryption", "ViewMessage", errorCode.description)
self.trackEventWithDimension(category: "Encryption", action: "ViewMessage", dimension: deviceCount, value: NSNumber(value: 1), name: errorCode.description)
} else {
self.trackBwiValue(NSNumber(value: 1), "Encryption", "ViewMessage", "Unknown_Error")
self.trackEventWithDimension(category: "Encryption", action: "ViewMessage", dimension: deviceCount, value: NSNumber(value: 1), name: "Unknown_Error")
}
}
func trackE2EEErrors(_ reason: DecryptionFailureReason, count: Int) {