mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 07:28:28 +02:00
MESSENGER-4535 matomo e2ee error tracking
This commit is contained in:
@@ -43,10 +43,13 @@ import AnalyticsEvents
|
||||
let reason: DecryptionFailureReason
|
||||
/// Additional context of failure
|
||||
let context: String
|
||||
// bwi: tracking information
|
||||
let errorCode: NSInteger
|
||||
|
||||
init(failedEventId: String, reason: DecryptionFailureReason, context: String) {
|
||||
init(failedEventId: String, reason: DecryptionFailureReason, context: String, errorCode: NSInteger) {
|
||||
self.failedEventId = failedEventId
|
||||
self.reason = reason
|
||||
self.context = context
|
||||
self.errorCode = errorCode
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,8 @@ NSString *const kDecryptionFailureTrackerAnalyticsCategory = @"e2e.failure";
|
||||
NSString *context = [NSString stringWithFormat:@"code: %ld, description: %@", event.decryptionError.code, event.decryptionError.localizedDescription];
|
||||
reportedFailures[event.eventId] = [[DecryptionFailure alloc] initWithFailedEventId:failedEventId
|
||||
reason:reason
|
||||
context:context];
|
||||
context:context
|
||||
errorCode:event.decryptionError.code];
|
||||
}
|
||||
|
||||
- (void)dispatch
|
||||
@@ -157,16 +158,18 @@ 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 context:failure.context];
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
// FRANK181
|
||||
//[self.delegate trackE2EEError:reason.integerValue count:failuresCounts[reason].integerValue];
|
||||
[BWIAnalytics.sharedTracker trackE2EEErrors:reason.integerValue count:failuresCounts[reason].integerValue];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8140,7 +8140,6 @@ static CGSize kThreadListBarButtonItemImageSize;
|
||||
|
||||
}];
|
||||
}
|
||||
[BWIAnalytics.sharedTracker trackEvent:@"Session" action:@"No DIMENSION"];
|
||||
}
|
||||
|
||||
#pragma mark - BWI Emoji History
|
||||
|
||||
@@ -50,6 +50,8 @@ targets:
|
||||
- path: ../bwi/NotificationTimes/NotificationTimesRoomSettings.swift
|
||||
- path: ../bwi/NotificationTimes/NotificationTimesWeekday.swift
|
||||
- path: ../bwi/NotificationTimes/Date+fromHourMinute.swift
|
||||
- path: ../bwi/MatomoAnalytics/BWIAnalytics.swift
|
||||
- path: ../bwi/MatomoAnalytics/BWIAnalyticsAccountDataService.swift
|
||||
- path: ../Riot/Managers/Settings/RiotSettings.swift
|
||||
- path: ../Config/BuildSettings.swift
|
||||
- path: ../Config/BWIBuildSettings.swift
|
||||
@@ -65,6 +67,8 @@ targets:
|
||||
- path: ../Riot/Managers/Locale/LocaleProvider.swift
|
||||
- path: ../Riot/Managers/Locale/LocaleProviderType.swift
|
||||
- path: ../Riot/Managers/EncryptionKeyManager/EncryptionKeyManager.swift
|
||||
- path: ../Riot/Managers/Serialization/SerializationService.swift
|
||||
- path: ../Riot/Managers/Serialization/SerializationServiceType.swift
|
||||
- path: ../Riot/Categories/Bundle.swift
|
||||
- path: ../Riot/Categories/MXEvent.swift
|
||||
- path: ../Riot/Generated/Strings.swift
|
||||
|
||||
@@ -53,7 +53,7 @@ import MatomoTracker
|
||||
} else {
|
||||
appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as! String
|
||||
}
|
||||
appVersion = AppDelegate.theDelegate().appVersion
|
||||
appVersion = AppInfo.current.appVersion?.bundleShortVersion ?? ""
|
||||
|
||||
if BWIBuildSettings.shared.bwiMatomoEnabled {
|
||||
// bwi: Analytics use custom config
|
||||
@@ -158,9 +158,9 @@ import MatomoTracker
|
||||
func trackSlowMessage( dimension: String, value: Int) {
|
||||
if fastRunning {
|
||||
// bwi: Analytics use custom config
|
||||
matomo?.setDimension(dimension, forIndex: 1)
|
||||
matomo?.setDimension(dimension, forIndex: 2)
|
||||
matomo?.track(eventWithCategory: "Performance", action: "SendMessage", name: nil, number: NSNumber(value: value), url:nil)
|
||||
matomo?.remove(dimensionAtIndex: 1)
|
||||
matomo?.remove(dimensionAtIndex: 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,5 +224,22 @@ extension BWIAnalytics : MXAnalyticsDelegate {
|
||||
func trackNonFatalIssue(_ issue: String, details: [String : Any]?) {
|
||||
// dont track NV specific logs
|
||||
}
|
||||
|
||||
func trackE2EEError(_ reason: DecryptionFailureReason, context: String) {
|
||||
if let errorCode = AnalyticsE2EEErrorCode(rawValue: reason.rawValue) {
|
||||
self.trackBwiValue(NSNumber(value: 1), "Encryption", "SendMessage", errorCode.description)
|
||||
} else {
|
||||
self.trackBwiValue(NSNumber(value: 1), "Encryption", "SendMessage", "Unknown_Error")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func trackE2EEErrors(_ reason: DecryptionFailureReason, count: Int) {
|
||||
if let errorCode = AnalyticsE2EEErrorCode(rawValue: reason.rawValue) {
|
||||
self.trackBwiValue(NSNumber(value: count), "Encryption", "SendMessage", errorCode.description)
|
||||
} else {
|
||||
self.trackBwiValue(NSNumber(value: count), "Encryption", "SendMessage", "Unknown_Error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
99
bwi/MatomoAnalytics/E2EEError.swift
Normal file
99
bwi/MatomoAnalytics/E2EEError.swift
Normal file
@@ -0,0 +1,99 @@
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2022 BWI GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
/*
|
||||
typedef enum : NSUInteger
|
||||
{
|
||||
encryptionNotEnabledCode = 0,
|
||||
unableToEncryptCode,
|
||||
unableToDecryptCode,
|
||||
olmCode,
|
||||
unknownInboundSessionIdCode,
|
||||
inboundSessionMismatchRoomIdCode,
|
||||
missingFieldsCode,
|
||||
missingCiphertextCode,
|
||||
notIncludedInRecipientsCode,
|
||||
badRecipientCode,
|
||||
badRecipientKeyCode,
|
||||
forwardedMessageCode,
|
||||
badRoomCode,
|
||||
badEncryptedMessageCode,
|
||||
duplicateMessageIndexCode,
|
||||
missingPropertyCode,
|
||||
} Code;
|
||||
*/
|
||||
|
||||
enum AnalyticsE2EEErrorCode: Int {
|
||||
case encryptionNotEnabledCode = 0
|
||||
case unableToEncryptCode = 1
|
||||
case unableToDecryptCode = 2
|
||||
case olmCode = 3
|
||||
case unknownInboundSessionIdCode = 4
|
||||
case inboundSessionMismatchRoomIdCode = 5
|
||||
case missingFieldsCode = 6
|
||||
case missingCiphertextCode = 7
|
||||
case notIncludedInRecipientsCode = 8
|
||||
case badRecipientCode = 9
|
||||
case badRecipientKeyCode = 10
|
||||
case forwardedMessageCode = 11
|
||||
case badRoomCode = 12
|
||||
case badEncryptedMessageCode = 13
|
||||
case duplicateMessageIndexCode = 14
|
||||
case missingPropertyCode = 15
|
||||
// Add more error codes as needed
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .encryptionNotEnabledCode:
|
||||
return "Encryption_Not_Enabled"
|
||||
case .unableToEncryptCode:
|
||||
return "Unable_To_Encrypt"
|
||||
case .unableToDecryptCode:
|
||||
return "Unable_To_Decrypt"
|
||||
case .olmCode:
|
||||
return "Olm_Unknown_Message_Index"
|
||||
case .unknownInboundSessionIdCode:
|
||||
return "Unknown_Inbound_SessionId"
|
||||
case .inboundSessionMismatchRoomIdCode:
|
||||
return "Inbound_Session_Mismatch_RoomId"
|
||||
case .missingFieldsCode:
|
||||
return "Missing_Fields"
|
||||
case .missingCiphertextCode:
|
||||
return "Missing_Ciphertext"
|
||||
case .notIncludedInRecipientsCode:
|
||||
return "Not_Included_In_Recipients"
|
||||
case .badRecipientCode:
|
||||
return "Bad_Recipient"
|
||||
case .badRecipientKeyCode:
|
||||
return "Bad_Recipient_Key"
|
||||
case .forwardedMessageCode:
|
||||
return "Forwarded_Message"
|
||||
case .badRoomCode:
|
||||
return "Bad_Room"
|
||||
case .badEncryptedMessageCode:
|
||||
return "Bad_Encrypted_Message"
|
||||
case .duplicateMessageIndexCode:
|
||||
return "Duplicate_Message_Index"
|
||||
case .missingPropertyCode:
|
||||
return "Missing_Property"
|
||||
}
|
||||
}
|
||||
|
||||
// You can also define additional methods or properties as needed
|
||||
}
|
||||
Reference in New Issue
Block a user