mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
MESSENGER-4821 add dimension for decryption error tracking
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user