Add trigger to join and view room metrics events #5769

- Added trigger for JoinedRoom event
- Tracking ViewRoom event for rooms and events
This commit is contained in:
Gil Eluard
2022-03-15 10:31:24 +01:00
parent 59a6f2d356
commit 0df41c3b90
34 changed files with 355 additions and 5 deletions
@@ -213,9 +213,11 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
case .homeSpace:
MXLog.verbose("Switch to home space")
self.navigateToSpace(with: nil)
Analytics.shared.activeSpace = nil
case .space(let spaceId):
MXLog.verbose("Switch to space with id: \(spaceId)")
self.navigateToSpace(with: spaceId)
Analytics.shared.activeSpace = userSessionsService.mainUserSession?.matrixSession.spaceService.getSpace(withId: spaceId)
}
}
@@ -1104,6 +1104,19 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
shouldNavigateToRoomWithId:(NSString *)roomId
threadId:(NSString *)threadId
{
if (roomId)
{
MXRoom *room = [self.mxSessions.firstObject roomWithRoomId:roomId];
if (room.summary.membership != MXMembershipJoin)
{
Analytics.shared.joinedRoomTrigger = AnalyticsJoinedRoomTriggerNotification;
}
else
{
Analytics.shared.viewRoomTrigger = AnalyticsViewRoomTriggerNotification;
}
}
_lastNavigatedRoomIdFromPush = roomId;
[self navigateToRoomById:roomId threadId:threadId];
}
@@ -2941,6 +2954,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
{
MXRoom *room = [mxSession roomWithRoomId:roomId];
if (room && room.summary.membership == MXMembershipJoin)
{
[Analytics.shared trackViewRoom:room];
}
// Indicates that spaces are not supported
if (room.summary.roomType == MXRoomTypeSpace)
{
@@ -3172,6 +3190,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
[mxSession createRoomWithParameters:roomCreationParameters success:^(MXRoom *room) {
// Open created room
Analytics.shared.viewRoomTrigger = AnalyticsViewRoomTriggerCreated;
[self showRoom:room.roomId andEventId:nil withMatrixSession:mxSession];
if (completion)
@@ -3206,6 +3225,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
if (directRoom)
{
// open it
Analytics.shared.viewRoomTrigger = AnalyticsViewRoomTriggerCreated;
[self showRoom:directRoom.roomId andEventId:nil withMatrixSession:mxSession];
if (completion)