mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-16 22:48:34 +02:00
Merge branch 'feature/5327_releaseprep' into 'develop'
Feature/5327 releaseprep See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!255
This commit is contained in:
@@ -199,7 +199,7 @@ NSString *const kDecryptionFailureTrackerAnalyticsCategory = @"e2e.failure";
|
||||
for (DecryptionFailure *failure in failuresToTrack)
|
||||
{
|
||||
if (failure.reason == DecryptionFailureReasonUnspecified) {
|
||||
[BWIAnalytics.sharedTracker trackE2EEErrorWithDimension:failure.errorCode deviceCount:[BWIAnalyticsHelper dimensionForDeviceCount: failure.deviceCount] unspecifiedErrorMessage:failure.unspecifiedErrorMessage];
|
||||
[BWIAnalytics.sharedTracker trackE2EEErrorWithDimension:failure.errorCode deviceCount:[[BWIAnalyticsHelper shared] dimensionForDeviceCount: failure.deviceCount] unspecifiedErrorMessage:failure.unspecifiedErrorMessage];
|
||||
} else {
|
||||
failuresCounts[@(failure.reason)] = @(failuresCounts[@(failure.reason)].unsignedIntegerValue + 1);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class RoomInviteViewController: ContactsTableViewController {
|
||||
|
||||
private func setupShareInviteLinkHeader() {
|
||||
guard roomAlias != nil,
|
||||
RiotSettings.shared.allowInviteExernalUsers,
|
||||
BWIBuildSettings.shared.allowInviteExernalUsers,
|
||||
joinRule != .invite,
|
||||
joinRule != .restricted else {
|
||||
contactsTableView.tableHeaderView = nil
|
||||
|
||||
@@ -8217,7 +8217,7 @@ static CGSize kThreadListBarButtonItemImageSize;
|
||||
if( [profile isLogable] ) {
|
||||
[self.roomDataSource.room members:^(MXRoomMembers *roomMembers) {
|
||||
NSUInteger noOfUsers = roomMembers.joinedMembers.count;
|
||||
[BWIAnalyticsHelper getRoomDeviceCountWithRoom:self.roomDataSource.room completion:^(NSInteger deviceCount) {
|
||||
[[BWIAnalyticsHelper shared] getRoomDeviceCountWithRoom:self.roomDataSource.room completion:^(NSInteger deviceCount) {
|
||||
[profile log2AnalyticsWithUsers:noOfUsers devices:deviceCount];
|
||||
}];
|
||||
} failure:^(NSError *error) {
|
||||
@@ -8228,8 +8228,8 @@ static CGSize kThreadListBarButtonItemImageSize;
|
||||
|
||||
// Bwi #4795: voice message
|
||||
- (void) trackVoiceMessage:(NSInteger)duration {
|
||||
[BWIAnalyticsHelper getRoomDeviceCountWithRoom:self.roomDataSource.room completion:^(NSInteger deviceCount) {
|
||||
NSString *deviceCountString = [BWIAnalyticsHelper dimensionForDeviceCount: deviceCount];
|
||||
[[BWIAnalyticsHelper shared] getRoomDeviceCountWithRoom:self.roomDataSource.room completion:^(NSInteger deviceCount) {
|
||||
NSString *deviceCountString = [[BWIAnalyticsHelper shared] dimensionForDeviceCount: deviceCount];
|
||||
NSNumber *durationInSeconds = [NSNumber numberWithInteger:(duration / 1000)];
|
||||
[BWIAnalytics.sharedTracker trackEventWithDimensionWithCategory:@"Feature" action:@"SendVoiceMessage" dimension:deviceCountString value:durationInSeconds name:@"send_voice_message_default"];
|
||||
}];
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RiotSettings.shared.allowInviteExernalUsers)
|
||||
if (!BWIBuildSettings.shared.allowInviteExernalUsers)
|
||||
{
|
||||
self.contactsTableView.tableHeaderView = nil;
|
||||
return;
|
||||
|
||||
@@ -343,7 +343,7 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm";
|
||||
if (mxSession.state == MXSessionStateRunning) {
|
||||
// Track e2e failures
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[BWIAnalyticsHelper getRoomDeviceCountWithRoom:[self->mxSession roomWithRoomId:roomState.roomId] completion:^(NSInteger deviceCount) {
|
||||
[[BWIAnalyticsHelper shared] getRoomDeviceCountWithRoom:[self->mxSession roomWithRoomId:roomState.roomId] completion:^(NSInteger deviceCount) {
|
||||
[[DecryptionFailureTracker sharedInstance] reportUnableToDecryptErrorForEvent:event withRoomState:roomState myUser:self->mxSession.myUser.userId roomDeviceCount:deviceCount];
|
||||
}];
|
||||
});
|
||||
|
||||
@@ -52,6 +52,7 @@ targets:
|
||||
- path: ../bwi/NotificationTimes/Date+fromHourMinute.swift
|
||||
- path: ../bwi/MatomoAnalytics/BWIAnalytics.swift
|
||||
- path: ../bwi/MatomoAnalytics/BWIAnalyticsHelper.swift
|
||||
- path: ../bwi/MatomoAnalytics/LazyRoomDevices.swift
|
||||
- path: ../bwi/MatomoAnalytics/BWIAnalyticsAccountDataService.swift
|
||||
- path: ../bwi/MatomoAnalytics/AnalyticsConfiguration.swift
|
||||
- path: ../bwi/MatomoAnalytics/DecryptedEvent.swift
|
||||
|
||||
@@ -75,9 +75,9 @@ class ForwardingShareItemSender: NSObject, ShareItemSenderProtocol {
|
||||
}
|
||||
|
||||
func trackForwardMessage(room: MXRoom) {
|
||||
BWIAnalyticsHelper.getRoomDeviceCount(room: room) { deviceCount in
|
||||
let deviceCountString = BWIAnalyticsHelper.dimensionForDeviceCount(deviceCount)
|
||||
let messageType = BWIAnalyticsHelper.getForwardingType(event: self.event)
|
||||
BWIAnalyticsHelper.shared.getRoomDeviceCount(room: room) { deviceCount in
|
||||
let deviceCountString = BWIAnalyticsHelper.shared.dimensionForDeviceCount(deviceCount)
|
||||
let messageType = BWIAnalyticsHelper.shared.getForwardingType(event: self.event)
|
||||
BWIAnalytics.sharedTracker.trackEventWithDimension(category: "Feature", action: "ForwardMessage", dimension: deviceCountString, value: nil, name: messageType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
|
||||
// MARK: Bwi tracking
|
||||
private func log2Analytics(details: EditFormPollDetails, room: MXRoom) {
|
||||
BWIAnalyticsHelper.getRoomDeviceCount(room: room) { deviceCount in
|
||||
BWIAnalyticsHelper.shared.getRoomDeviceCount(room: room) { deviceCount in
|
||||
var eventName: String
|
||||
switch details.type {
|
||||
case .undisclosed:
|
||||
@@ -176,7 +176,7 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
}
|
||||
|
||||
BWIAnalytics.sharedTracker.trackEventWithDimension(category: "Feature", action: "SendPoll", dimension: BWIAnalyticsHelper.dimensionForDeviceCount(deviceCount), value: NSNumber(value: details.answerOptions.count), name: eventName)
|
||||
BWIAnalytics.sharedTracker.trackEventWithDimension(category: "Feature", action: "SendPoll", dimension: BWIAnalyticsHelper.shared.dimensionForDeviceCount(deviceCount), value: NSNumber(value: details.answerOptions.count), name: eventName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,24 +17,38 @@
|
||||
|
||||
import Foundation
|
||||
import MatrixSDK
|
||||
|
||||
@objc class BWIAnalyticsHelper: NSObject {
|
||||
@objc static let shared = BWIAnalyticsHelper()
|
||||
|
||||
@objc static func getRoomDeviceCount(room: MXRoom, completion: @escaping(Int) -> ()) {
|
||||
room.members { roomMembers in
|
||||
var noOfDevices = 0
|
||||
for member in roomMembers?.joinedMembers ?? [MXRoomMember]() {
|
||||
noOfDevices += room.mxSession.crypto.devices(forUser: member.userId).count
|
||||
private let serialQueue = DispatchQueue(label: "de.bwi.analyticshelper.serialQueue")
|
||||
|
||||
@objc func getRoomDeviceCount(room: MXRoom, completion: @escaping(Int) -> ()) {
|
||||
// only ask for devices per room if a refresh is needed -> room.mxSession.crypto.devices is costly in large rooms. And even with that performance win don't do it on Mainthread
|
||||
serialQueue.async {
|
||||
if LazyRoomDevices.shared.areDevicesCurrent(room: room) {
|
||||
completion(LazyRoomDevices.shared.deviceCount(room: room))
|
||||
return
|
||||
}
|
||||
|
||||
room.members { roomMembers in
|
||||
var noOfDevices = 0
|
||||
for member in roomMembers?.joinedMembers ?? [MXRoomMember]() {
|
||||
noOfDevices += room.mxSession.crypto.devices(forUser: member.userId).count
|
||||
}
|
||||
LazyRoomDevices.shared.setDeviceCount(room: room, deviceCount: noOfDevices)
|
||||
completion(noOfDevices)
|
||||
|
||||
} lazyLoadedMembers: { _ in
|
||||
completion(0)
|
||||
} failure: { error in
|
||||
MXLog.error("[RoomAnalyticsHelper] Failed loading room", context: error)
|
||||
completion(0)
|
||||
}
|
||||
completion(noOfDevices)
|
||||
} lazyLoadedMembers: { _ in
|
||||
completion(0)
|
||||
} failure: { error in
|
||||
MXLog.error("[RoomAnalyticsHelper] Failed loading room", context: error)
|
||||
completion(0)
|
||||
}
|
||||
}
|
||||
|
||||
@objc static func getForwardingType(event: MXEvent) -> String? {
|
||||
@objc func getForwardingType(event: MXEvent) -> String? {
|
||||
guard let messageType: MXMessageType = event.messageType else {
|
||||
return nil
|
||||
}
|
||||
@@ -66,7 +80,7 @@ import MatrixSDK
|
||||
|
||||
// MARK: custom dimensions
|
||||
|
||||
@objc static func dimensionForDeviceCount(_ deviceCount: Int) -> String {
|
||||
@objc func dimensionForDeviceCount(_ deviceCount: Int) -> String {
|
||||
if deviceCount <= 0 {
|
||||
return "Undefiniert"
|
||||
}
|
||||
|
||||
50
bwi/MatomoAnalytics/LazyRoomDevices.swift
Normal file
50
bwi/MatomoAnalytics/LazyRoomDevices.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
/*
|
||||
* 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
|
||||
|
||||
struct LazyDevice {
|
||||
let timeStamp: Date
|
||||
let deviceCount: Int
|
||||
}
|
||||
class LazyRoomDevices : NSObject {
|
||||
static let shared = LazyRoomDevices()
|
||||
|
||||
// reload devices older than 10 minutes
|
||||
let threshold = 10.0 * 60.0
|
||||
|
||||
var devices: Dictionary<String, LazyDevice> = Dictionary()
|
||||
|
||||
func deviceCount( room: MXRoom ) -> Int {
|
||||
guard let lazyDevice = devices[room.roomId] else {
|
||||
return 0
|
||||
}
|
||||
return lazyDevice.deviceCount
|
||||
}
|
||||
|
||||
func areDevicesCurrent( room: MXRoom) -> Bool {
|
||||
guard let lazyDevice = devices[room.roomId] else {
|
||||
return false
|
||||
}
|
||||
return Date().timeIntervalSince(lazyDevice.timeStamp) < threshold
|
||||
|
||||
}
|
||||
|
||||
func setDeviceCount( room: MXRoom, deviceCount: Int) {
|
||||
devices[room.roomId] = LazyDevice(timeStamp: Date(), deviceCount: deviceCount)
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ import Foundation
|
||||
|
||||
func log2Analytics(users: Int, devices: Int) {
|
||||
if isLogable() {
|
||||
BWIAnalytics.sharedTracker.trackSlowMessage(dimension: BWIAnalyticsHelper.dimensionForDeviceCount(devices), value: Int(timeInterval*1000))
|
||||
BWIAnalytics.sharedTracker.trackSlowMessage(dimension: BWIAnalyticsHelper.shared.dimensionForDeviceCount(devices), value: Int(timeInterval*1000))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user