mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Add location related analytics (#1241)
* Refactor trackComposer method * Track location screen * Refactor isPinDropSharing -> isSharingUserLocation * Add trackComposer event * Fix UTs * Cleanup * Add AnalyticsLocationType
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2023 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import AnalyticsEvents
|
||||
|
||||
enum AnalyticsLocationType {
|
||||
case myLocation
|
||||
case pin
|
||||
}
|
||||
|
||||
extension AnalyticsEvent.Composer.LocationType {
|
||||
init(_ analyticsLocationType: AnalyticsLocationType) {
|
||||
switch analyticsLocationType {
|
||||
case .myLocation:
|
||||
self = .MyLocation
|
||||
case .pin:
|
||||
self = .PinDrop
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,8 @@ enum AnalyticsScreen: Int {
|
||||
case spaceBottomSheet
|
||||
case invites
|
||||
case createSpace
|
||||
case locationSend
|
||||
case locationView
|
||||
|
||||
/// The screen name reported to the AnalyticsEvent.
|
||||
var screenName: AnalyticsEvent.MobileScreen.ScreenName {
|
||||
@@ -145,6 +147,10 @@ enum AnalyticsScreen: Int {
|
||||
return .Invites
|
||||
case .createSpace:
|
||||
return .CreateSpace
|
||||
case .locationSend:
|
||||
return .LocationSend
|
||||
case .locationView:
|
||||
return .LocationView
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,9 +141,19 @@ extension AnalyticsService {
|
||||
/// - inThread: whether the composer is used in a Thread
|
||||
/// - isEditing: whether the composer is used to edit a message
|
||||
/// - isReply: whether the composer is used to reply a message
|
||||
/// - locationType: the type of the shared location
|
||||
/// - startsThread: whether the composer is used to start a new thread
|
||||
func trackComposer(inThread: Bool, isEditing: Bool, isReply: Bool, startsThread: Bool?) {
|
||||
capture(event: AnalyticsEvent.Composer(inThread: inThread, isEditing: isEditing, isReply: isReply, startsThread: startsThread))
|
||||
func trackComposer(inThread: Bool,
|
||||
isEditing: Bool,
|
||||
isReply: Bool,
|
||||
locationType: AnalyticsLocationType? = nil,
|
||||
startsThread: Bool?) {
|
||||
capture(event: AnalyticsEvent.Composer(inThread: inThread,
|
||||
isEditing: isEditing,
|
||||
isLocation: locationType != nil,
|
||||
isReply: isReply,
|
||||
locationType: locationType.map { .init($0) },
|
||||
startsThread: startsThread))
|
||||
}
|
||||
|
||||
/// Track the presentation of a room
|
||||
|
||||
Reference in New Issue
Block a user