diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index dd524dc68..9a8f3c74a 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -7775,7 +7775,7 @@ repositoryURL = "https://github.com/matrix-org/matrix-analytics-events"; requirement = { kind = upToNextMinorVersion; - minimumVersion = 0.23.1; + minimumVersion = 0.25.0; }; }; C13F55E4518415CB4C278E73 /* XCRemoteSwiftPackageReference "DTCoreText" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 13ef9fbfd..b4bb6468e 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -131,8 +131,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/matrix-org/matrix-analytics-events", "state" : { - "revision" : "de0cac487e5e7f607ee17045882204c91585461f", - "version" : "0.23.1" + "revision" : "c9b40120a5f7b8ce1bab3f09f8417fdc9407f006", + "version" : "0.25.0" } }, { diff --git a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenCoordinator.swift b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenCoordinator.swift index dc3b7820d..850f7026e 100644 --- a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenCoordinator.swift +++ b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenCoordinator.swift @@ -40,7 +40,7 @@ final class PinnedEventsTimelineScreenCoordinator: CoordinatorProtocol { init(parameters: PinnedEventsTimelineScreenCoordinatorParameters) { self.parameters = parameters - viewModel = PinnedEventsTimelineScreenViewModel() + viewModel = PinnedEventsTimelineScreenViewModel(analyticsService: ServiceLocator.shared.analytics) timelineViewModel = TimelineViewModel(roomProxy: parameters.roomProxy, timelineController: parameters.timelineController, mediaProvider: parameters.mediaProvider, diff --git a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenViewModel.swift b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenViewModel.swift index b73bf78a0..81cf8e5f9 100644 --- a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenViewModel.swift +++ b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenViewModel.swift @@ -11,12 +11,15 @@ import SwiftUI typealias PinnedEventsTimelineScreenViewModelType = StateStoreViewModel class PinnedEventsTimelineScreenViewModel: PinnedEventsTimelineScreenViewModelType, PinnedEventsTimelineScreenViewModelProtocol { + private let analyticsService: AnalyticsService + private let actionsSubject: PassthroughSubject = .init() var actionsPublisher: AnyPublisher { actionsSubject.eraseToAnyPublisher() } - init() { + init(analyticsService: AnalyticsService) { + self.analyticsService = analyticsService super.init(initialViewState: PinnedEventsTimelineScreenViewState()) } @@ -27,6 +30,7 @@ class PinnedEventsTimelineScreenViewModel: PinnedEventsTimelineScreenViewModelTy switch viewAction { case .close: + analyticsService.trackInteraction(name: .PinnedMessageBannerCloseListButton) actionsSubject.send(.dismiss) } } diff --git a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift index cf6157d44..8e7f04711 100644 --- a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift +++ b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift @@ -84,7 +84,7 @@ struct PinnedEventsTimelineScreen: View { // MARK: - Previews struct PinnedEventsTimelineScreen_Previews: PreviewProvider, TestablePreview { - static let viewModel = PinnedEventsTimelineScreenViewModel() + static let viewModel = PinnedEventsTimelineScreenViewModel(analyticsService: ServiceLocator.shared.analytics) static let emptyTimelineViewModel: TimelineViewModel = { let timelineController = MockRoomTimelineController(timelineKind: .pinned) timelineController.timelineItems = [] diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift index fec14ee67..79e83484e 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift @@ -161,6 +161,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr case .processTapCall: actionsSubject.send(.startCall) case .processTapPinnedEvents: + analyticsService.trackInteraction(name: .PinnedMessageRoomInfoButton) actionsSubject.send(.displayPinnedEventsTimeline) } } diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift index 077779de7..8c33e3e3a 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift @@ -73,11 +73,13 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol override func process(viewAction: RoomScreenViewAction) { switch viewAction { case .tappedPinnedEventsBanner: + analyticsService.trackInteraction(name: .PinnedMessageBannerClick) if let eventID = state.pinnedEventsBannerState.selectedPinnedEventID { actionsSubject.send(.focusEvent(eventID: eventID)) } state.pinnedEventsBannerState.previousPin() case .viewAllPins: + analyticsService.trackInteraction(name: .PinnedMessageBannerViewAllButton) actionsSubject.send(.displayPinnedEventsTimeline) case .displayRoomDetails: actionsSubject.send(.displayRoomDetails) diff --git a/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift b/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift index 181e55e32..b4ad60281 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift @@ -163,12 +163,17 @@ class TimelineInteractionHandler { case .endPoll(let pollStartID): endPoll(pollStartID: pollStartID) case .pin: + analyticsService.trackPinUnpinEvent(.init(from: timelineController.timelineKind == .pinned ? .MessagePinningList : .Timeline, + kind: .Pin)) guard let eventID = itemID.eventID else { return } Task { await timelineController.pin(eventID: eventID) } case .unpin: + analyticsService.trackPinUnpinEvent(.init(from: timelineController.timelineKind == .pinned ? .MessagePinningList : .Timeline, + kind: .Unpin)) guard let eventID = itemID.eventID else { return } Task { await timelineController.unpin(eventID: eventID) } case .viewInRoomTimeline: + analyticsService.trackInteraction(name: .PinnedMessageListViewTimeline) guard let eventID = itemID.eventID else { return } actionsSubject.send(.viewInRoomTimeline(eventID: eventID)) } diff --git a/ElementX/Sources/Services/Analytics/AnalyticsService.swift b/ElementX/Sources/Services/Analytics/AnalyticsService.swift index f2b625a90..3ecbed805 100644 --- a/ElementX/Sources/Services/Analytics/AnalyticsService.swift +++ b/ElementX/Sources/Services/Analytics/AnalyticsService.swift @@ -243,4 +243,8 @@ extension AnalyticsService { func updateUserProperties(_ userProperties: AnalyticsEvent.UserProperties) { client.updateUserProperties(userProperties) } + + func trackPinUnpinEvent(_ event: AnalyticsEvent.PinUnpinAction) { + capture(event: event) + } } diff --git a/project.yml b/project.yml index b3d7ec2c1..cc50bc345 100644 --- a/project.yml +++ b/project.yml @@ -68,7 +68,7 @@ packages: # path: ../compound-ios AnalyticsEvents: url: https://github.com/matrix-org/matrix-analytics-events - minorVersion: 0.23.1 + minorVersion: 0.25.0 # path: ../matrix-analytics-events Emojibase: url: https://github.com/matrix-org/emojibase-bindings