diff --git a/WordPress/Classes/Services/ReaderTopicService.h b/WordPress/Classes/Services/ReaderTopicService.h index d082d88c1e34..0208529fcad6 100644 --- a/WordPress/Classes/Services/ReaderTopicService.h +++ b/WordPress/Classes/Services/ReaderTopicService.h @@ -113,7 +113,10 @@ extern NSString * const ReaderTopicFreshlyPressedPathCommponent; @param success block called on a successful fetch. @param failure block called if there is any error. `error` can be any underlying network error. */ -- (void)followTagNamed:(NSString *)tagName withSuccess:(void (^)(void))success failure:(void (^)(NSError *error))failure; +- (void)followTagNamed:(NSString *)tagName + withSuccess:(void (^)(void))success + failure:(void (^)(NSError *error))failure + source:(NSString *)source; /** Follow the tag with the specified slug diff --git a/WordPress/Classes/Services/ReaderTopicService.m b/WordPress/Classes/Services/ReaderTopicService.m index e5eaba0bdff1..e5fae98498d2 100644 --- a/WordPress/Classes/Services/ReaderTopicService.m +++ b/WordPress/Classes/Services/ReaderTopicService.m @@ -354,14 +354,17 @@ - (void)unfollowTag:(ReaderTagTopic *)topic withSuccess:(void (^)(void))success }]; } -- (void)followTagNamed:(NSString *)topicName withSuccess:(void (^)(void))success failure:(void (^)(NSError *error))failure +- (void)followTagNamed:(NSString *)topicName + withSuccess:(void (^)(void))success + failure:(void (^)(NSError *error))failure + source:(NSString *)source { topicName = [[topicName lowercaseString] trim]; ReaderTopicServiceRemote *remoteService = [[ReaderTopicServiceRemote alloc] initWithWordPressComRestApi:[self apiForRequest]]; [remoteService followTopicNamed:topicName withSuccess:^(NSNumber *topicID) { [self fetchReaderMenuWithSuccess:^{ - NSDictionary *properties = @{@"tag":topicName}; + NSDictionary *properties = @{@"tag":topicName, @"source":source}; [WPAnalytics trackReaderStat:WPAnalyticsStatReaderTagFollowed properties:properties]; [self selectTopicWithID:topicID]; if (success) { diff --git a/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift b/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift index 6986dd7dd47e..f4bfa8da5211 100644 --- a/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift +++ b/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift @@ -224,6 +224,16 @@ import Foundation case siteSwitcherSearchPerformed case siteSwitcherToggleBlogVisible + // Reader: Filter Sheet + case readerFilterSheetDisplayed + case readerFilterSheetDismissed + case readerFilterSheetItemSelected + case readerFilterSheetCleared + + // Reader: Manage + case readerManageViewDisplayed + case readerManageViewDismissed + /// A String that represents the event var value: String { switch self { @@ -613,6 +623,18 @@ import Foundation case .siteSwitcherToggleBlogVisible: return "site_switcher_toggle_blog_visible" + case .readerFilterSheetDisplayed: + return "reader_filter_sheet_displayed" + case .readerFilterSheetDismissed: + return "reader_filter_sheet_dismissed" + case .readerFilterSheetItemSelected: + return "reader_filter_sheet_item_selected" + case .readerFilterSheetCleared: + return "reader_filter_sheet_cleared" + case .readerManageViewDisplayed: + return "reader_manage_view_displayed" + case .readerManageViewDismissed: + return "reader_manage_view_dismissed" } // END OF SWITCH } diff --git a/WordPress/Classes/ViewRelated/Reader/Filter/FilterSheetViewController.swift b/WordPress/Classes/ViewRelated/Reader/Filter/FilterSheetViewController.swift index be60e427e575..4f4833dafcb9 100644 --- a/WordPress/Classes/ViewRelated/Reader/Filter/FilterSheetViewController.swift +++ b/WordPress/Classes/ViewRelated/Reader/Filter/FilterSheetViewController.swift @@ -26,6 +26,10 @@ class FilterSheetViewController: UIViewController { } extension FilterSheetViewController: DrawerPresentable { + func handleDismiss() { + WPAnalytics.track(.readerFilterSheetDismissed) + } + var scrollableView: UIScrollView? { return (view as? FilterSheetView)?.tableView } diff --git a/WordPress/Classes/ViewRelated/Reader/Manage/ReaderManageScenePresenter.swift b/WordPress/Classes/ViewRelated/Reader/Manage/ReaderManageScenePresenter.swift index 1212b9129d3d..a4661a609dba 100644 --- a/WordPress/Classes/ViewRelated/Reader/Manage/ReaderManageScenePresenter.swift +++ b/WordPress/Classes/ViewRelated/Reader/Manage/ReaderManageScenePresenter.swift @@ -52,6 +52,8 @@ class ReaderManageScenePresenter: ScenePresenter { let navigationController = makeNavigationController() presentedViewController = navigationController viewController.present(navigationController, animated: true, completion: nil) + + WPAnalytics.track(.readerManageViewDisplayed) } } @@ -64,6 +66,7 @@ private extension ReaderManageScenePresenter { let tabbedViewController = TabbedViewController(items: tabbedItems, onDismiss: { self.delegate?.didDismiss(presenter: self) NotificationCenter.default.post(name: .readerManageControllerWasDismissed, object: self) + WPAnalytics.track(.readerManageViewDismissed) }) tabbedViewController.title = NSLocalizedString("Manage", comment: "Title for the Reader Manage screen.") if let section = selectedSection, let firstSelection = sections.firstIndex(of: section) { diff --git a/WordPress/Classes/ViewRelated/Reader/Manage/ReaderTagsTableViewModel.swift b/WordPress/Classes/ViewRelated/Reader/Manage/ReaderTagsTableViewModel.swift index c196dbf8c653..5b77b721d4c0 100644 --- a/WordPress/Classes/ViewRelated/Reader/Manage/ReaderTagsTableViewModel.swift +++ b/WordPress/Classes/ViewRelated/Reader/Manage/ReaderTagsTableViewModel.swift @@ -179,7 +179,7 @@ extension ReaderTagsTableViewModel { let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) alert.addCancelActionWithTitle(NSLocalizedString("OK", comment: "Button title. An acknowledgement of the message displayed in a prompt.")) alert.presentFromRootViewController() - }) + }, source: "manage") } /// Tells the ReaderTopicService to unfollow the specified topic. diff --git a/WordPress/Classes/ViewRelated/Reader/Tab Navigation/ReaderTabViewModel.swift b/WordPress/Classes/ViewRelated/Reader/Tab Navigation/ReaderTabViewModel.swift index f7ce467c958a..3f9a826863b7 100644 --- a/WordPress/Classes/ViewRelated/Reader/Tab Navigation/ReaderTabViewModel.swift +++ b/WordPress/Classes/ViewRelated/Reader/Tab Navigation/ReaderTabViewModel.swift @@ -123,6 +123,8 @@ extension ReaderTabViewModel { let bottomSheet = BottomSheetViewController(childViewController: viewController) bottomSheet.additionalSafeAreaInsetsRegular = UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0) bottomSheet.show(from: from, sourceView: sourceView, arrowDirections: .up) + + WPAnalytics.track(.readerFilterSheetDisplayed) } func presentManage(from: UIViewController) { @@ -139,12 +141,16 @@ extension ReaderTabViewModel { } func resetFilter(selectedItem: FilterTabBarItem) { + WPAnalytics.track(.readerFilterSheetCleared) if let content = (selectedItem as? ReaderTabItem)?.content { setContent?(content) } } func setFilterContent(topic: ReaderAbstractTopic) { + let type = ((topic as? ReaderSiteTopic) != nil) ? "site" : "topic" + WPAnalytics.track(.readerFilterSheetItemSelected, properties: ["type": type]) + setContent?(ReaderContent(topic: topic)) }