Add analytics tracking for room creation (#1100)

This commit is contained in:
Johannes Marbach 2023-06-19 14:35:58 +02:00 committed by GitHub
parent 1f65b7b9f9
commit ee643f7a69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 0 deletions

View File

@ -156,6 +156,7 @@ class CreateRoomViewModel: CreateRoomViewModelType, CreateRoomViewModelProtocol
userIDs: state.selectedUsers.map(\.userID),
avatarURL: avatarURL) {
case .success(let roomId):
ServiceLocator.shared.analytics.trackCreatedRoom(isDM: false)
actionsSubject.send(.openRoom(withIdentifier: roomId))
case .failure(let failure):
displayError(failure)

View File

@ -32,6 +32,7 @@ struct CreateRoomScreen: View {
securitySection
}
.elementFormStyle()
.track(screen: .createRoom)
.scrollDismissesKeyboard(.immediately)
.navigationTitle(L10n.screenCreateRoomTitle)
.navigationBarTitleDisplayMode(.inline)

View File

@ -133,6 +133,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
showLoadingIndicator()
switch await clientProxy.createDirectRoom(with: user.userID, expectedRoomName: user.displayName) {
case .success(let roomId):
ServiceLocator.shared.analytics.trackCreatedRoom(isDM: true)
actionsSubject.send(.openRoom(withIdentifier: roomId))
case .failure(let failure):
displayError(failure)

View File

@ -29,6 +29,7 @@ struct StartChatScreen: View {
}
}
.elementFormStyle()
.track(screen: .startChat)
.scrollDismissesKeyboard(.immediately)
.navigationTitle(L10n.actionStartChat)
.navigationBarTitleDisplayMode(.inline)

View File

@ -125,4 +125,10 @@ extension Analytics {
let event = AnalyticsEvent.MobileScreen(durationMs: milliseconds, screenName: screen.screenName)
client.screen(event)
}
/// Track the creation of a room
/// - Parameter isDM: true if the created room is a direct message, false otherwise
func trackCreatedRoom(isDM: Bool) {
capture(event: AnalyticsEvent.CreatedRoom(isDM: isDM))
}
}

View File

@ -0,0 +1 @@
Add analytics tracking for room creation