Skip to content

Commit

Permalink
Merge pull request #17518 from wordpress-mobile/issue/17503-reader-fi…
Browse files Browse the repository at this point in the history
…lter-manage-tracking

Adds tracking to the Reader Filter Sheet and Manage view
  • Loading branch information
Emily Laguna authored Nov 23, 2021
2 parents 3ca0321 + e543b16 commit 41f358a
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 4 deletions.
5 changes: 4 additions & 1 deletion WordPress/Classes/Services/ReaderTopicService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions WordPress/Classes/Services/ReaderTopicService.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 22 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class FilterSheetViewController: UIViewController {
}

extension FilterSheetViewController: DrawerPresentable {
func handleDismiss() {
WPAnalytics.track(.readerFilterSheetDismissed)
}

var scrollableView: UIScrollView? {
return (view as? FilterSheetView)?.tableView
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class ReaderManageScenePresenter: ScenePresenter {
let navigationController = makeNavigationController()
presentedViewController = navigationController
viewController.present(navigationController, animated: true, completion: nil)

WPAnalytics.track(.readerManageViewDisplayed)
}
}

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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))
}

Expand Down

0 comments on commit 41f358a

Please sign in to comment.