[iOS] Guide statistics

https://jira.mail.ru/browse/MAPSME-15089
This commit is contained in:
Alexander Boriskov 2020-10-16 11:22:29 +03:00 committed by Aleksey Belousov
parent 715aa34bc5
commit cfd05d53fa
7 changed files with 100 additions and 10 deletions

View file

@ -36,6 +36,7 @@ NS_SWIFT_NAME(BookmarkGroup)
@property(nonatomic, readonly) NSArray<MWMTrack *> *tracks;
@property(nonatomic, readonly) NSArray<MWMBookmarkGroup *> *collections;
@property(nonatomic, readonly) NSArray<MWMBookmarkGroup *> *categories;
@property(nonatomic, readonly) MWMBookmarkGroupType type;
@end

View file

@ -96,4 +96,8 @@
return [self.manager categoriesForGroup:self.categoryId];
}
- (MWMBookmarkGroupType)type {
return [self.manager getCategoryGroupType:self.categoryId];
}
@end

View file

@ -51,6 +51,7 @@ NS_SWIFT_NAME(BookmarksManager)
- (NSString *)getCategoryDescription:(MWMMarkGroupID)groupId;
- (NSString *)getCategoryAuthorName:(MWMMarkGroupID)groupId;
- (NSString *)getCategoryAuthorId:(MWMMarkGroupID)groupId;
- (MWMBookmarkGroupType)getCategoryGroupType:(MWMMarkGroupID)groupId;
- (nullable NSURL *)getCategoryImageUrl:(MWMMarkGroupID)groupId;
- (BOOL)hasExtraInfo:(MWMMarkGroupID)groupId;

View file

@ -397,6 +397,21 @@ static BookmarkManager::SortingType convertSortingTypeToCore(MWMBookmarksSorting
return @(self.bm.GetCategoryData(groupId).m_authorId.c_str());
}
- (MWMBookmarkGroupType)getCategoryGroupType:(MWMMarkGroupID)groupId {
if (self.bm.IsCompilation(groupId) == false) {
return MWMBookmarkGroupTypeRoot;
}
switch (self.bm.GetCompilationType(groupId)) {
case kml::CompilationType::Category:
return MWMBookmarkGroupTypeCategory;
case kml::CompilationType::Collection:
return MWMBookmarkGroupTypeCollection;
case kml::CompilationType::Day:
return MWMBookmarkGroupTypeDay;
}
return MWMBookmarkGroupTypeRoot;
}
- (nullable NSURL *)getCategoryImageUrl:(MWMMarkGroupID)groupId {
NSString *urlString = @(self.bm.GetCategoryData(groupId).m_imageUrl.c_str());
return [NSURL URLWithString:urlString];

View file

@ -47,4 +47,11 @@ typedef NS_ENUM(NSUInteger, MWMBookmarkGroupAuthorType) {
MWMBookmarkGroupAuthorTypeTraveler
} NS_SWIFT_NAME(BookmarkGroupAuthorType);
typedef NS_ENUM(NSInteger, MWMBookmarkGroupType) {
MWMBookmarkGroupTypeRoot,
MWMBookmarkGroupTypeCategory,
MWMBookmarkGroupTypeCollection,
MWMBookmarkGroupTypeDay
} NS_SWIFT_NAME(BookmarkGroupType);
NS_ASSUME_NONNULL_END

View file

@ -248,23 +248,22 @@ extension BookmarksListPresenter: IBookmarksListPresenter {
interactor.viewBookmarkOnMap(bookmark.bookmarkId)
router.viewOnMap(bookmarkGroup)
Statistics.logEvent(kStatEventName(kStatBookmarks, kStatShowOnMap))
if bookmarkGroup.isGuide {
Statistics.logEvent(kStatGuidesBookmarkSelect,
withParameters: [kStatServerId : bookmarkGroup.serverId],
with: .realtime)
}
logSelectEvent(kStatGuidesBookmarkSelect, type: bookmarkGroup.type)
case let tracksSection as ITracksSectionViewModel:
let track = tracksSection.tracks[index] as! TrackViewModel
interactor.viewTrackOnMap(track.trackId)
router.viewOnMap(bookmarkGroup)
if bookmarkGroup.isGuide {
Statistics.logEvent(kStatGuidesTrackSelect,
withParameters: [kStatServerId : bookmarkGroup.serverId],
with: .realtime)
}
logSelectEvent(kStatGuidesTrackSelect)
case let subgroupsSection as ISubgroupsSectionViewModel:
let subgroup = subgroupsSection.subgroups[index] as! SubgroupViewModel
router.showSubgroup(subgroup.groupId)
if subgroup.type == .collection {
logSelectEvent(kStatGuidesCollectionSelect, name: subgroup.subgroupName)
} else if subgroup.type == .category {
logSelectEvent(kStatGuidesCategorySelect, name: subgroup.subgroupName)
} else {
assertionFailure()
}
default:
fatalError("Wrong section type: \(section.self)")
}
@ -275,6 +274,9 @@ extension BookmarksListPresenter: IBookmarksListPresenter {
case let subgroupsSection as ISubgroupsSectionViewModel:
let subgroup = subgroupsSection.subgroups[index] as! SubgroupViewModel
interactor.setGroup(subgroup.groupId, visible: checked)
logVisibleEvent(serverId: bookmarkGroup.serverId,
type: subgroup.type,
action: checked ? kStatShow : kStatHide)
reload()
default:
fatalError("Wrong section type: \(section.self)")
@ -298,6 +300,9 @@ extension BookmarksListPresenter: IBookmarksListPresenter {
interactor.setGroup(subgroup.groupId, visible: visible)
}
reload()
logVisibleEvent(serverId: bookmarkGroup.serverId,
type: bookmarkGroup.type,
action: visible ? kStatShowAll : kStatHideAll)
default:
fatalError("Wrong section type: \(section.self)")
}
@ -306,6 +311,36 @@ extension BookmarksListPresenter: IBookmarksListPresenter {
func showDescription() {
router.showDescription(bookmarkGroup)
}
private func logSelectEvent(_ eventName: String, type: BookmarkGroupType? = nil, name: String? = nil) {
var eventArguments: [AnyHashable: Any] = [:]
if let type = type {
eventArguments[kStatFrom] = type.getStatName()
}
if let name = name {
eventArguments[kStatName] = name
}
if !bookmarkGroup.serverId.isEmpty {
eventArguments[kStatServerId] = bookmarkGroup.serverId
}
Statistics.logEvent(eventName,
withParameters: eventArguments,
with: .realtime)
}
private func logVisibleEvent(serverId: String, type: BookmarkGroupType, action: String) {
var eventArguments: [AnyHashable: Any] = [:]
if !serverId.isEmpty {
eventArguments[kStatServerId] = bookmarkGroup.serverId
}
eventArguments[kStatType] = type.getStatName()
eventArguments[kStatAction] = action
Statistics.logEvent(kStatGuidesVisibilityChange,
withParameters: eventArguments,
with: .realtime)
}
}
extension BookmarksListPresenter: BookmarksSharingViewControllerDelegate {
@ -398,12 +433,14 @@ fileprivate struct SubgroupViewModel: ISubgroupViewModel {
let subgroupName: String
let subtitle: String
let isVisible: Bool
let type: BookmarkGroupType
init(_ bookmarkGroup: BookmarkGroup) {
groupId = bookmarkGroup.categoryId
subgroupName = bookmarkGroup.title
subtitle = bookmarkGroup.placesCountTitle()
isVisible = bookmarkGroup.isVisible
type = bookmarkGroup.type
}
}
@ -464,3 +501,20 @@ fileprivate struct BookmarksListInfo: IBookmakrsListInfoViewModel {
self.hasLogo = hasLogo
}
}
fileprivate extension BookmarkGroupType {
func getStatName() -> String {
switch self {
case .root:
return kStatMain
case .collection:
return kStatCollection
case .category:
return kStatCategory
case .day:
return kStatDay
@unknown default:
fatalError()
}
}
}

View file

@ -132,6 +132,7 @@ static NSString *const kStatCheckOut = @"check_out";
static NSString *const kStatClear = @"Clear";
static NSString *const kStatClose = @"Close";
static NSString *const kStatCollapse = @"Collapse";
static NSString *const kStatCollection = @"collection";
static NSString *const kStatCompass = @"Compass";
static NSString *const kStatConnection = @"connection";
static NSString *const kStatCopyLink = @"copy_link";
@ -140,6 +141,7 @@ static NSString *const kStatCount = @"Count";
static NSString *const kStatCountry = @"Country";
static NSString *const kStatCurrentMap = @"current_map";
static NSString *const kStatDate = @"date";
static NSString *const kStatDay = @"day";
static NSString *const kStatDeeplink = @"Deeplink";
static NSString *const kStatDeeplinkCall = @"Deeplink_call";
static NSString *const kStatDeeplinkCallMissed = @"Deeplink_call_missed";
@ -229,6 +231,9 @@ static NSString *const kStatGotIt = @"Got_it";
static NSString *const kStatGuestHouse = @"guestHouse";
static NSString *const kStatGuides = @"guides";
static NSString *const kStatGuidesBookmarkSelect = @"Bookmarks_BookmarksList_Bookmark_select";
static NSString *const kStatGuidesCategorySelect = @"Bookmarks_BookmarksList_Category_select";
static NSString *const kStatGuidesCollectionSelect = @"Bookmarks_BookmarksList_Collection_select";
static NSString *const kStatGuidesVisibilityChange = @"Bookmarks_Guide_Visibility_change";
static NSString *const kStatGuidesShown = @"Bookmarks_Downloaded_Guides_list";
static NSString *const kStatGuidesOpen = @"Bookmarks_Downloaded_Guide_open";
static NSString *const kStatGuidesClose = @"GuideCatalogue_closed";
@ -238,6 +243,7 @@ static NSString *const kStatGuidesTrackSelect = @"Bookmarks_BookmarksList_Track_
static NSString *const kStatHasAuthorization = @"has_auth";
static NSString *const kStatHelp = @"Help";
static NSString *const kStatHide = @"hide";
static NSString *const kStatHideAll = @"hide_all";
static NSString *const kStatHidden = @"Hidden";
static NSString *const kStatHistory = @"History";
static NSString *const kStatHoliday = @"Holiday";
@ -282,6 +288,7 @@ static NSString *const kStatLocation = @"Location";
static NSString *const kStatLogout = @"Logout";
static NSString *const kStatMakeInvisibleOnMap = @"make_invisible_on_map";
static NSString *const kStatMap = @"map";
static NSString *const kStatMain = @"main";
static NSString *const kStatMapGallery = @"map_gallery";
static NSString *const kStatMapSponsoredButtonShow = @"Map_SponsoredButton_show";
static NSString *const kStatMapSponsoredButtonClick = @"Map_SponsoredButton_click";
@ -511,6 +518,7 @@ static NSString *const kStatSharingOptionsClick = @"Bookmarks_SharingOptions_cli
static NSString *const kStatSharingOptionsUploadError = @"Bookmarks_SharingOptions_upload_error";
static NSString *const kStatSharingOptionsUploadSuccess = @"Bookmarks_SharingOptions_upload_success";
static NSString *const kStatShow = @"show";
static NSString *const kStatShowAll = @"show_all";
static NSString *const kStatShowBig2SmallMWM = @"Big mwms to small mwms dialog appearing counter";
static NSString *const kStatShowOnMap = @"Show on map";
static NSString *const kStatSide = @"side";