mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 00:52:43 +02:00
Feature/4795 feature tracking matomo
This commit is contained in:
committed by
Frank Rotermund
parent
013047191e
commit
27723fa953
@@ -0,0 +1,94 @@
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2023 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
|
||||
import MatrixSDK
|
||||
@objc class BWIAnalyticsHelper: NSObject {
|
||||
|
||||
@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
|
||||
}
|
||||
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? {
|
||||
guard let messageType: MXMessageType = event.messageType else {
|
||||
return nil
|
||||
}
|
||||
switch messageType {
|
||||
case .text:
|
||||
return "text"
|
||||
case .image:
|
||||
return "image"
|
||||
case .video:
|
||||
return "video"
|
||||
case .audio:
|
||||
if (event.content["org.matrix.msc2516.voice"] != nil) || (event.content["org.matrix.msc3245.voice"] != nil) {
|
||||
return "voice_message"
|
||||
} else {
|
||||
return "audio"
|
||||
}
|
||||
case .emote:
|
||||
return nil
|
||||
case .notice:
|
||||
return nil
|
||||
case .location:
|
||||
return "location"
|
||||
case .file:
|
||||
return "file"
|
||||
case .custom(_):
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: custom dimensions
|
||||
|
||||
@objc static func dimensionForDeviceCount(_ deviceCount: Int) -> String {
|
||||
if deviceCount <= 0 {
|
||||
return "Undefiniert"
|
||||
}
|
||||
if deviceCount <= 10 {
|
||||
return "1 bis 10"
|
||||
}
|
||||
if deviceCount <= 100 {
|
||||
return "11 bis 100"
|
||||
}
|
||||
if deviceCount <= 200 {
|
||||
return "101 bis 200"
|
||||
}
|
||||
if deviceCount <= 500 {
|
||||
return "201 bis 500"
|
||||
}
|
||||
if deviceCount <= 1000 {
|
||||
return "501 bis 1000"
|
||||
}
|
||||
if deviceCount <= 2500 {
|
||||
return "1001 bis 2500"
|
||||
} else {
|
||||
return "mehr als 2500"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user