Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specific UX for Expected UTDs due to membership #2740

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7372,7 +7372,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-analytics-events";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.14.0;
minimumVersion = 0.20.0;
};
};
C13F55E4518415CB4C278E73 /* XCRemoteSwiftPackageReference "DTCoreText" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-analytics-events",
"state" : {
"revision" : "f756bf0756b7349a1d3ccee0d038790d1ab2ec56",
"version" : "0.14.0"
"revision" : "e4e49896331c9dcf7346c90529a9aad7944a3259",
"version" : "0.20.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
} else {
timeToDecryptMs = -1
}

analytics.trackError(context: nil, domain: .E2EE, name: .OlmKeysNotSentError, timeToDecryptMillis: timeToDecryptMs)

switch info.cause {
case .unknown:
analytics.trackError(context: nil, domain: .E2EE, name: .OlmKeysNotSentError, timeToDecryptMillis: timeToDecryptMs)
case .membership:
analytics.trackError(context: nil, domain: .E2EE, name: .HistoricalMessage, timeToDecryptMillis: timeToDecryptMs)
}
}
.store(in: &cancellables)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,29 @@
// limitations under the License.
//

import Compound
import SwiftUI

struct EncryptedRoomTimelineView: View {
let timelineItem: EncryptedRoomTimelineItem

var icon: KeyPath<CompoundIcons, Image> {
switch timelineItem.encryptionType {
case .megolmV1AesSha2(_, let cause):
switch cause {
case .unknown:
return \.time
case .membership:
return \.block
}
default:
return \.time
}
}

var body: some View {
TimelineStyler(timelineItem: timelineItem) {
Label(timelineItem.body, icon: \.time, iconSize: .small, relativeTo: .compound.bodyLG)
Label(timelineItem.body, icon: icon, iconSize: .small, relativeTo: .compound.bodyLG)
.labelStyle(RoomTimelineViewLabelStyle())
.font(.compound.bodyLG)
}
Expand Down Expand Up @@ -68,6 +83,10 @@ struct EncryptedRoomTimelineView_Previews: PreviewProvider, TestablePreview {
timestamp: "Later",
isOutgoing: true,
senderId: "Anne"))

EncryptedRoomTimelineView(timelineItem: expectedItemWith(timestamp: "Now",
isOutgoing: false,
senderId: "Bob"))
}
}

Expand All @@ -81,4 +100,15 @@ struct EncryptedRoomTimelineView_Previews: PreviewProvider, TestablePreview {
canBeRepliedTo: false,
sender: .init(id: senderId))
}

private static func expectedItemWith(timestamp: String, isOutgoing: Bool, senderId: String) -> EncryptedRoomTimelineItem {
EncryptedRoomTimelineItem(id: .random,
body: L10n.commonUnableToDecryptNoAccess,
encryptionType: .megolmV1AesSha2(sessionID: "foo", cause: .membership),
timestamp: timestamp,
isOutgoing: isOutgoing,
isEditable: false,
canBeRepliedTo: false,
sender: .init(id: senderId))
}
}
12 changes: 11 additions & 1 deletion ElementX/Sources/Services/Analytics/AnalyticsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,17 @@ extension AnalyticsService {
/// 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))
capture(event: AnalyticsEvent.Error(context: context,
cryptoModule: .Rust,
cryptoSDK: .Rust,
domain: domain,
eventLocalAgeMillis: nil,
isFederated: nil,
isMatrixDotOrg: nil,
name: name,
timeToDecryptMillis: timeToDecryptMillis,
userTrustsOwnIdentity: nil,
wasVisibleToUser: nil))
}

/// Track the creation of a room
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,25 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
_ encryptedMessage: EncryptedMessage,
_ isOutgoing: Bool) -> RoomTimelineItemProtocol {
var encryptionType = EncryptedRoomTimelineItem.EncryptionType.unknown
var errorLabel = L10n.commonWaitingForDecryptionKey
switch encryptedMessage {
case .megolmV1AesSha2(let sessionID, let cause):
let cause: EncryptedRoomTimelineItem.UTDCause = switch cause {
case .unknown: .unknown
case .membership: .membership
switch cause {
case .unknown:
encryptionType = .megolmV1AesSha2(sessionID: sessionID, cause: .unknown)
errorLabel = L10n.commonWaitingForDecryptionKey
case .membership:
encryptionType = .megolmV1AesSha2(sessionID: sessionID, cause: .membership)
errorLabel = L10n.commonUnableToDecryptNoAccess
}
encryptionType = .megolmV1AesSha2(sessionID: sessionID, cause: cause)
case .olmV1Curve25519AesSha2(let senderKey):
encryptionType = .olmV1Curve25519AesSha2(senderKey: senderKey)
case .unknown:
break
}

return EncryptedRoomTimelineItem(id: eventItemProxy.id,
body: L10n.commonWaitingForDecryptionKey,
body: errorLabel,
encryptionType: encryptionType,
timestamp: eventItemProxy.timestamp.formatted(date: .omitted, time: .shortened),
isOutgoing: isOutgoing,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions changelog.d/2740.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add specific UX for Expected UTDs due to membership
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ packages:
# path: ../compound-ios
AnalyticsEvents:
url: https://github.com/matrix-org/matrix-analytics-events
minorVersion: 0.14.0
minorVersion: 0.20.0
# path: ../matrix-analytics-events
Emojibase:
url: https://github.com/matrix-org/emojibase-bindings
Expand Down
Loading