mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Send UTD occurences to Posthog (#2575)
Co-authored-by: Stefan Ceriu <stefan.ceriu@gmail.com>
This commit is contained in:
parent
c68ec2c382
commit
7611123ae1
@ -7080,7 +7080,7 @@
|
||||
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = 1.1.49;
|
||||
version = 1.1.50;
|
||||
};
|
||||
};
|
||||
821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = {
|
||||
@ -7128,7 +7128,7 @@
|
||||
repositoryURL = "https://github.com/matrix-org/matrix-analytics-events";
|
||||
requirement = {
|
||||
kind = upToNextMinorVersion;
|
||||
minimumVersion = 0.13.0;
|
||||
minimumVersion = 0.14.0;
|
||||
};
|
||||
};
|
||||
C13F55E4518415CB4C278E73 /* XCRemoteSwiftPackageReference "DTCoreText" */ = {
|
||||
|
@ -121,8 +121,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/matrix-org/matrix-analytics-events",
|
||||
"state" : {
|
||||
"revision" : "ccc4af6aa00987abe7135fa0b7cea97c8cfb3d26",
|
||||
"version" : "0.13.0"
|
||||
"revision" : "f756bf0756b7349a1d3ccee0d038790d1ab2ec56",
|
||||
"version" : "0.14.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -130,8 +130,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
|
||||
"state" : {
|
||||
"revision" : "0361eac2610f0007f2a6880a88c750a1bbb405b9",
|
||||
"version" : "1.1.49"
|
||||
"revision" : "e6b350d257aeb7395e003c3d0c26ae65c2e2e349",
|
||||
"version" : "1.1.50"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -139,6 +139,24 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
userSession.clientProxy.actionsPublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { action in
|
||||
guard case let .receivedDecryptionError(info) = action else {
|
||||
return
|
||||
}
|
||||
|
||||
let timeToDecryptMs: Int
|
||||
if let unsignedTimeToDecryptMs = info.timeToDecryptMs {
|
||||
timeToDecryptMs = Int(unsignedTimeToDecryptMs)
|
||||
} else {
|
||||
timeToDecryptMs = -1
|
||||
}
|
||||
|
||||
analytics.trackError(context: nil, domain: .E2EE, name: .OlmKeysNotSentError, timeToDecryptMillis: timeToDecryptMs)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
@ -130,7 +130,18 @@ extension AnalyticsService {
|
||||
func trackInteraction(index: Int? = nil, name: AnalyticsEvent.Interaction.Name) {
|
||||
capture(event: AnalyticsEvent.Interaction(index: index, interactionType: .Touch, name: name))
|
||||
}
|
||||
|
||||
|
||||
/// Track the presentation of a screen
|
||||
/// - Parameter context: To provide additional context or description for the error
|
||||
/// - Parameter domain: The domain to which the error belongs to.
|
||||
/// - Parameter name: The name of the error
|
||||
/// - Parameter timeToDecryptMillis: The time it took to decrypt the event in milliseconds, needs to be used only to track UTD errors, otherwise if the error is nort related to UTD it should be nil.
|
||||
/// Can be found in `UnableToDecryptInfo`. In case the `UnableToDecryptInfo` contains the value as nil, pass it as `-1`
|
||||
func trackError(context: String?, domain: AnalyticsEvent.Error.Domain, name: AnalyticsEvent.Error.Name, timeToDecryptMillis: Int? = nil) {
|
||||
// CryptoModule is deprecated
|
||||
capture(event: AnalyticsEvent.Error(context: context, cryptoModule: nil, cryptoSDK: .Rust, domain: domain, name: name, timeToDecryptMillis: timeToDecryptMillis))
|
||||
}
|
||||
|
||||
/// Track the creation of a room
|
||||
/// - Parameter isDM: true if the created room is a direct message, false otherwise
|
||||
func trackCreatedRoom(isDM: Bool) {
|
||||
|
@ -589,6 +589,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
let syncService = try await client
|
||||
.syncService()
|
||||
.withCrossProcessLock(appIdentifier: "MainApp")
|
||||
.withUtdHook(delegate: ClientDecryptionErrorDelegate(actionsSubject: actionsSubject))
|
||||
.finish()
|
||||
let roomListService = syncService.roomListService()
|
||||
|
||||
@ -803,6 +804,18 @@ private class ClientDelegateWrapper: ClientDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private class ClientDecryptionErrorDelegate: UnableToDecryptDelegate {
|
||||
private let actionsSubject: PassthroughSubject<ClientProxyAction, Never>
|
||||
|
||||
init(actionsSubject: PassthroughSubject<ClientProxyAction, Never>) {
|
||||
self.actionsSubject = actionsSubject
|
||||
}
|
||||
|
||||
func onUtd(info: UnableToDecryptInfo) {
|
||||
actionsSubject.send(.receivedDecryptionError(info))
|
||||
}
|
||||
}
|
||||
|
||||
private class IgnoredUsersListenerProxy: IgnoredUsersListener {
|
||||
private let onUpdateClosure: ([String]) -> Void
|
||||
|
||||
|
@ -21,6 +21,7 @@ import MatrixRustSDK
|
||||
enum ClientProxyAction {
|
||||
case receivedSyncUpdate
|
||||
case receivedAuthError(isSoftLogout: Bool)
|
||||
case receivedDecryptionError(UnableToDecryptInfo)
|
||||
|
||||
var isSyncUpdate: Bool {
|
||||
if case .receivedSyncUpdate = self {
|
||||
|
@ -223,9 +223,9 @@ class LoggingTests: XCTestCase {
|
||||
formatted: FormattedBody(format: .html, body: "<b>\(emoteString)</b>"))
|
||||
|
||||
let pointer = Unmanaged.passRetained(NSURL(fileURLWithPath: "/tmp/file")).toOpaque()
|
||||
let rustImageMessage = ImageMessageContent(body: "ImageString", source: MediaSource(unsafeFromRawPointer: pointer), info: nil)
|
||||
let rustVideoMessage = VideoMessageContent(body: "VideoString", source: MediaSource(unsafeFromRawPointer: pointer), info: nil)
|
||||
let rustFileMessage = FileMessageContent(body: "FileString", filename: "FileName", source: MediaSource(unsafeFromRawPointer: pointer), info: nil)
|
||||
let rustImageMessage = ImageMessageContent(body: "ImageString", formatted: nil, filename: nil, source: MediaSource(unsafeFromRawPointer: pointer), info: nil)
|
||||
let rustVideoMessage = VideoMessageContent(body: "VideoString", formatted: nil, filename: nil, source: MediaSource(unsafeFromRawPointer: pointer), info: nil)
|
||||
let rustFileMessage = FileMessageContent(body: "FileString", formatted: nil, filename: "FileName", source: MediaSource(unsafeFromRawPointer: pointer), info: nil)
|
||||
|
||||
// When logging that value
|
||||
MXLog.info(rustTextMessage)
|
||||
|
@ -48,7 +48,7 @@ packages:
|
||||
# Element/Matrix dependencies
|
||||
MatrixRustSDK:
|
||||
url: https://github.com/matrix-org/matrix-rust-components-swift
|
||||
exactVersion: 1.1.49
|
||||
exactVersion: 1.1.50
|
||||
# path: ../matrix-rust-sdk
|
||||
Compound:
|
||||
url: https://github.com/element-hq/compound-ios
|
||||
@ -56,7 +56,7 @@ packages:
|
||||
# path: ../compound-ios
|
||||
AnalyticsEvents:
|
||||
url: https://github.com/matrix-org/matrix-analytics-events
|
||||
minorVersion: 0.13.0
|
||||
minorVersion: 0.14.0
|
||||
# path: ../matrix-analytics-events
|
||||
Emojibase:
|
||||
url: https://github.com/matrix-org/emojibase-bindings
|
||||
|
Loading…
x
Reference in New Issue
Block a user