From 6004bb7de8d741dd714ea90c06222addc1cb7843 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 30 May 2024 12:36:41 +0300 Subject: [PATCH] Track when the user starts a room call and when they enable formatting options on the message composer --- ElementX.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- .../UserSessionFlowCoordinator.swift | 2 ++ .../ComposerToolbarViewModel.swift | 11 ++++++++++- .../ComposerToolbar/View/ComposerToolbar.swift | 15 ++++++++++----- .../View/RoomAttachmentPicker.swift | 3 ++- .../RoomScreen/RoomScreenCoordinator.swift | 3 ++- .../Screens/RoomScreen/RoomScreenViewModel.swift | 2 +- project.yml | 2 +- 9 files changed, 31 insertions(+), 13 deletions(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 71685c43b..712875dea 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -7383,7 +7383,7 @@ repositoryURL = "https://github.com/matrix-org/matrix-analytics-events"; requirement = { kind = upToNextMinorVersion; - minimumVersion = 0.21.0; + minimumVersion = 0.23.1; }; }; C13F55E4518415CB4C278E73 /* XCRemoteSwiftPackageReference "DTCoreText" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2a8664961..7c5e31efc 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -121,8 +121,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/matrix-org/matrix-analytics-events", "state" : { - "revision" : "f10d044b9eaf35871bbb61cdfdb8f93a04e429e0", - "version" : "0.21.0" + "revision" : "de0cac487e5e7f607ee17045882204c91585461f", + "version" : "0.23.1" } }, { diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index 99ab53f15..848e9c87d 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -559,6 +559,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { .store(in: &cancellables) navigationSplitCoordinator.setSheetCoordinator(callScreenCoordinator, animated: true) + + analytics.track(screen: .RoomCall) } private func presentCallScreen(roomID: String) async { diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift index 1f84a314d..be3c57ff4 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift @@ -27,6 +27,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool private let wysiwygViewModel: WysiwygComposerViewModel private let completionSuggestionService: CompletionSuggestionServiceProtocol private let appSettings: AppSettings + private let analyticsService: AnalyticsService private let mentionBuilder: MentionBuilderProtocol private let attributedStringBuilder: AttributedStringBuilderProtocol @@ -47,10 +48,16 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool private var currentLinkData: WysiwygLinkData? - init(wysiwygViewModel: WysiwygComposerViewModel, completionSuggestionService: CompletionSuggestionServiceProtocol, mediaProvider: MediaProviderProtocol, appSettings: AppSettings, mentionDisplayHelper: MentionDisplayHelper) { + init(wysiwygViewModel: WysiwygComposerViewModel, + completionSuggestionService: CompletionSuggestionServiceProtocol, + mediaProvider: MediaProviderProtocol, + appSettings: AppSettings, + mentionDisplayHelper: MentionDisplayHelper, + analyticsService: AnalyticsService) { self.wysiwygViewModel = wysiwygViewModel self.completionSuggestionService = completionSuggestionService self.appSettings = appSettings + self.analyticsService = analyticsService mentionBuilder = MentionBuilder() attributedStringBuilder = AttributedStringBuilder(cacheKey: "Composer", mentionBuilder: mentionBuilder) @@ -157,6 +164,8 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool case .enableTextFormatting: state.bindings.composerFormattingEnabled = true state.bindings.composerFocused = true + + analyticsService.trackInteraction(name: .MobileRoomComposerFormattingEnabled) case .composerAction(let action): if action == .link { createLinkAlert() diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift index a8e1104d6..abcbf2b83 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift @@ -292,7 +292,8 @@ struct ComposerToolbar_Previews: PreviewProvider, TestablePreview { completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init(suggestions: suggestions)), mediaProvider: MockMediaProvider(), appSettings: ServiceLocator.shared.settings, - mentionDisplayHelper: ComposerMentionDisplayHelper.mock) + mentionDisplayHelper: ComposerMentionDisplayHelper.mock, + analyticsService: ServiceLocator.shared.analytics) static let suggestions: [SuggestionItem] = [.user(item: MentionSuggestionItem(id: "@user_mention_1:matrix.org", displayName: "User 1", avatarURL: nil, range: .init())), .user(item: MentionSuggestionItem(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: URL.documentsDirectory, range: .init()))] @@ -328,7 +329,8 @@ extension ComposerToolbar { completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), mediaProvider: MockMediaProvider(), appSettings: ServiceLocator.shared.settings, - mentionDisplayHelper: ComposerMentionDisplayHelper.mock) + mentionDisplayHelper: ComposerMentionDisplayHelper.mock, + analyticsService: ServiceLocator.shared.analytics) model.state.composerEmpty = focused return model } @@ -344,7 +346,8 @@ extension ComposerToolbar { completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), mediaProvider: MockMediaProvider(), appSettings: ServiceLocator.shared.settings, - mentionDisplayHelper: ComposerMentionDisplayHelper.mock) + mentionDisplayHelper: ComposerMentionDisplayHelper.mock, + analyticsService: ServiceLocator.shared.analytics) model.state.composerEmpty = focused return model } @@ -360,7 +363,8 @@ extension ComposerToolbar { completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), mediaProvider: MockMediaProvider(), appSettings: ServiceLocator.shared.settings, - mentionDisplayHelper: ComposerMentionDisplayHelper.mock) + mentionDisplayHelper: ComposerMentionDisplayHelper.mock, + analyticsService: ServiceLocator.shared.analytics) model.state.composerMode = .recordVoiceMessage(state: AudioRecorderState()) return model } @@ -377,7 +381,8 @@ extension ComposerToolbar { completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), mediaProvider: MockMediaProvider(), appSettings: ServiceLocator.shared.settings, - mentionDisplayHelper: ComposerMentionDisplayHelper.mock) + mentionDisplayHelper: ComposerMentionDisplayHelper.mock, + analyticsService: ServiceLocator.shared.analytics) model.state.composerMode = .previewVoiceMessage(state: AudioPlayerState(id: .recorderPreview, duration: 10.0), waveform: .data(waveformData), isUploading: uploading) return model } diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift index 900af16a6..d7ab68d03 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift @@ -100,7 +100,8 @@ struct RoomAttachmentPicker_Previews: PreviewProvider, TestablePreview { completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), mediaProvider: MockMediaProvider(), appSettings: ServiceLocator.shared.settings, - mentionDisplayHelper: ComposerMentionDisplayHelper.mock) + mentionDisplayHelper: ComposerMentionDisplayHelper.mock, + analyticsService: ServiceLocator.shared.analytics) static var previews: some View { RoomAttachmentPicker(context: viewModel.context) diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift index 0ee9183f0..1a4cd3dee 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift @@ -79,7 +79,8 @@ final class RoomScreenCoordinator: CoordinatorProtocol { completionSuggestionService: parameters.completionSuggestionService, mediaProvider: parameters.mediaProvider, appSettings: parameters.appSettings, - mentionDisplayHelper: ComposerMentionDisplayHelper(roomContext: viewModel.context)) + mentionDisplayHelper: ComposerMentionDisplayHelper(roomContext: viewModel.context), + analyticsService: ServiceLocator.shared.analytics) } // MARK: - Public diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift index dbd31fb40..a1e23e15a 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift @@ -180,7 +180,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol displayReadReceipts(for: itemID) case .displayCall: actionsSubject.send(.displayCallScreen) - + analyticsService.trackInteraction(name: .MobileRoomCallButton) case .handlePasteOrDrop(let provider): roomScreenInteractionHandler.handlePasteOrDrop(provider) case .handlePollAction(let pollAction): diff --git a/project.yml b/project.yml index 8e1d5b42d..1db0296f3 100644 --- a/project.yml +++ b/project.yml @@ -57,7 +57,7 @@ packages: # path: ../compound-ios AnalyticsEvents: url: https://github.com/matrix-org/matrix-analytics-events - minorVersion: 0.21.0 + minorVersion: 0.23.1 # path: ../matrix-analytics-events Emojibase: url: https://github.com/matrix-org/emojibase-bindings