Skip to content

Commit

Permalink
Merge branch 'main' into T282189
Browse files Browse the repository at this point in the history
  • Loading branch information
staykids authored May 11, 2021
2 parents 3aeff89 + dc13ad3 commit 0200871
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Wikipedia.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@
678D79FD235E59B2006161FF /* DiffListUneditedViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678D79FB235E59B2006161FF /* DiffListUneditedViewModel.swift */; };
678D79FE235E59B2006161FF /* DiffListUneditedViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678D79FB235E59B2006161FF /* DiffListUneditedViewModel.swift */; };
678D79FF235E59B2006161FF /* DiffListUneditedViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678D79FB235E59B2006161FF /* DiffListUneditedViewModel.swift */; };
678E7E8126432F060005439C /* NavigationEventsFunnel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678E7E8026432F060005439C /* NavigationEventsFunnel.swift */; };
678E7E8226432F060005439C /* NavigationEventsFunnel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678E7E8026432F060005439C /* NavigationEventsFunnel.swift */; };
678E7E8326432F060005439C /* NavigationEventsFunnel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678E7E8026432F060005439C /* NavigationEventsFunnel.swift */; };
678E7E8426432F060005439C /* NavigationEventsFunnel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678E7E8026432F060005439C /* NavigationEventsFunnel.swift */; };
678F512A23A7EE5100CE5357 /* ArticleCacheDBWriter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678F511823A4B92000CE5357 /* ArticleCacheDBWriter.swift */; };
678F512B23A7EE6600CE5357 /* ArticleFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 676A8A8223A4013D0084B967 /* ArticleFetcher.swift */; };
67901E232550E45D0018B218 /* ArticleAsLivingDocFunnel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FF8E2C2550BB6F0048E741 /* ArticleAsLivingDocFunnel.swift */; };
Expand Down Expand Up @@ -3692,6 +3696,7 @@
678D79EF235E5979006161FF /* DiffListChangeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiffListChangeViewModel.swift; sourceTree = "<group>"; };
678D79F5235E599B006161FF /* DiffListContextViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiffListContextViewModel.swift; sourceTree = "<group>"; };
678D79FB235E59B2006161FF /* DiffListUneditedViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiffListUneditedViewModel.swift; sourceTree = "<group>"; };
678E7E8026432F060005439C /* NavigationEventsFunnel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationEventsFunnel.swift; sourceTree = "<group>"; };
678F511823A4B92000CE5357 /* ArticleCacheDBWriter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ArticleCacheDBWriter.swift; path = ../Wikipedia/Code/ArticleCacheDBWriter.swift; sourceTree = "<group>"; };
6798035B24F94CE300D765AA /* SignificantEventsFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignificantEventsFetcher.swift; sourceTree = "<group>"; };
6798036024F94CEE00D765AA /* ArticleAsLivingDocController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleAsLivingDocController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6179,6 +6184,7 @@
B0E8059C1C0CE2F50065EBC0 /* WMFShareFunnel.m */,
7AF1B19520A1E14F000C8DFE /* ReadingListsFunnel.swift */,
67E466F9241BED770014149B /* EditHistoryCompareFunnel.swift */,
678E7E8026432F060005439C /* NavigationEventsFunnel.swift */,
7A25B1CB20A483F1008C6F29 /* LoginFunnel.swift */,
7A00E0BF20A9E54400F033C8 /* SettingsFunnel.swift */,
7A07A46D20AA482C00F7B2BB /* SessionsFunnel.swift */,
Expand Down Expand Up @@ -10579,6 +10585,7 @@
7A715667226974D10066FEC4 /* InsertMediaImageSizeSettingsViewController.swift in Sources */,
B02B82751C696ECA00B19309 /* WMFSettingsTableViewCell.m in Sources */,
B00DDEDB1DB4B76B00615FA2 /* UIView+WMFSubviews.swift in Sources */,
678E7E8126432F060005439C /* NavigationEventsFunnel.swift in Sources */,
830ECACF1FBDD8C00080B1EF /* ReadingListsViewController.swift in Sources */,
D82117FC1EE58C080076C040 /* MapAnnotation.swift in Sources */,
7AF0265622985CB9000E0A06 /* BeKindInputAccessoryView.swift in Sources */,
Expand Down Expand Up @@ -11432,6 +11439,7 @@
7A71566A226974D10066FEC4 /* InsertMediaImageSizeSettingsViewController.swift in Sources */,
D8A42A821E815A9C00D8E281 /* WMFPageHistoryRevision.m in Sources */,
D8A42A891E815A9C00D8E281 /* WMFEmptyView.m in Sources */,
678E7E8426432F060005439C /* NavigationEventsFunnel.swift in Sources */,
830ECAD21FBDD8C00080B1EF /* ReadingListsViewController.swift in Sources */,
D8A42A8C1E815A9C00D8E281 /* WMFSettingsTableViewCell.m in Sources */,
D8A42A8D1E815A9C00D8E281 /* UIView+WMFSubviews.swift in Sources */,
Expand Down Expand Up @@ -11894,6 +11902,7 @@
6782DBB02343B812003FA21B /* DiffHeaderCompareView.swift in Sources */,
83DAA9B123FEB611002D5716 /* ReferenceBackLinksViewController.swift in Sources */,
7A9524D822669A8B00C55CDC /* InsertMediaSettingsButtonView.swift in Sources */,
678E7E8326432F060005439C /* NavigationEventsFunnel.swift in Sources */,
FF2B2112254B7D6A0009E61A /* ActivityIndicatorCollectionViewFooter.swift in Sources */,
8351CE7920D4424100E32FC1 /* CollectionViewHeader.swift in Sources */,
7A20AE092057F39C005FB5DF /* UIView+Identifier.swift in Sources */,
Expand Down Expand Up @@ -12381,6 +12390,7 @@
6782DBB12343B812003FA21B /* DiffHeaderCompareView.swift in Sources */,
83DAA9B223FEB611002D5716 /* ReferenceBackLinksViewController.swift in Sources */,
7A9524D922669A8B00C55CDC /* InsertMediaSettingsButtonView.swift in Sources */,
678E7E8226432F060005439C /* NavigationEventsFunnel.swift in Sources */,
FF2B2111254B7D6A0009E61A /* ActivityIndicatorCollectionViewFooter.swift in Sources */,
83023C2120E6584F00EC7592 /* SearchTransition.swift in Sources */,
D8EC3DF61E9BDA35006712EB /* NSDate+WMFPOTDTitle.m in Sources */,
Expand Down
153 changes: 153 additions & 0 deletions Wikipedia/Code/NavigationEventsFunnel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@

import Foundation

@objc(WMFNavigationEventsFunnel)
final class NavigationEventsFunnel: EventLoggingFunnel, EventLoggingStandardEventProviding {
enum Action: String, Codable {
case explore
case places
case saved
case savedAll = "saved_all"
case savedLists = "saved_lists"
case history
case search
case settingsOpenNav = "setting_open_nav"
case settingsOpenExplore = "setting_open_explore"
case settingsAccount = "setting_account"
case settingsClose = "setting_close"
case settingsFundraise = "setting_fundraise"
case settingsLanguages = "setting_languages"
case settingsSearch = "setting_search"
case settingsExploreFeed = "setting_explorefeed"
case settingsNotifications = "setting_notifications"
case settingsReadPrefs = "setting_read_prefs"
case settingsStorageSync = "setting_storagesync"
case settingsReadDanger = "setting_read_danger"
case settingsClearData = "setting_cleardata"
case settingsPrivacy = "setting_privacy"
case settingsTOS = "setting_tos"
case settingsUsageReports = "setting_usage_reports"
case settingsRate = "setting_rate"
case settingsHelp = "setting_help"
case settingsAbout = "setting_about"
}

@objc static let shared = NavigationEventsFunnel()

private override init() {
super.init(schema: "MobileWikiAppiOSNavigationEvents", version: 21426269)
}

private func event(action: Action) -> Dictionary<String, Any> {
let event: [String: Any] = ["action": action.rawValue, "primary_language": primaryLanguage(), "is_anon": isAnon]
return event
}

override func preprocessData(_ eventData: [AnyHashable: Any]) -> [AnyHashable: Any] {
return wholeEvent(with: eventData)
}

@objc func logTappedExplore() {
log(event(action: .explore))
}

@objc func logTappedPlaces() {
log(event(action: .places))
}

@objc func logTappedSaved() {
log(event(action: .saved))
}

@objc func logTappedHistory() {
log(event(action: .history))
}

@objc func logTappedSearch() {
log(event(action: .search))
}

@objc func logTappedSettingsFromTabBar() {
log(event(action: .settingsOpenNav))
}

@objc func logTappedSettingsFromExplore() {
log(event(action: .settingsOpenExplore))
}

func logTappedSavedAllArticles() {
log(event(action: .savedAll))
}

func logTappedSavedReadingLists() {
log(event(action: .savedLists))
}

@objc func logTappedSettingsCloseButton() {
log(event(action: .settingsClose))
}

@objc func logTappedSettingsLoginLogout() {
log(event(action: .settingsAccount))
}

@objc func logTappedSettingsSupportWikipedia() {
log(event(action: .settingsFundraise))
}

@objc func logTappedSettingsLanguages() {
log(event(action: .settingsLanguages))
}

@objc func logTappedSettingsSearch() {
log(event(action: .settingsSearch))
}

@objc func logTappedSettingsExploreFeed() {
log(event(action: .settingsExploreFeed))
}

@objc func logTappedSettingsNotifications() {
log(event(action: .settingsNotifications))
}

@objc func logTappedSettingsReadingPreferences() {
log(event(action: .settingsReadPrefs))
}

@objc func logTappedSettingsArticleStorageAndSyncing() {
log(event(action: .settingsStorageSync))
}

@objc func logTappedSettingsReadingListDangerZone() {
log(event(action: .settingsReadDanger))
}

@objc func logTappedSettingsClearCachedData() {
log(event(action: .settingsClearData))
}

@objc func logTappedSettingsPrivacyPolicy() {
log(event(action: .settingsPrivacy))
}

@objc func logTappedSettingsTermsOfUse() {
log(event(action: .settingsTOS))
}

@objc func logTappedSettingsSendUsageReports() {
log(event(action: .settingsUsageReports))
}

@objc func logTappedSettingsRateTheApp() {
log(event(action: .settingsRate))
}

@objc func logTappedSettingsHelp() {
log(event(action: .settingsHelp))
}

@objc func logTappedSettingsAbout() {
log(event(action: .settingsAbout))
}
}
10 changes: 10 additions & 0 deletions Wikipedia/Code/SavedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class SavedViewController: ViewController {
toggleButtons.first { $0.tag != sender.tag }?.isSelected = false
sender.isSelected = true
currentView = View(rawValue: sender.tag) ?? .savedArticles
logTappedView(currentView)
}

func toggleCurrentView(_ newViewRawValue: Int) {
Expand Down Expand Up @@ -162,6 +163,15 @@ class SavedViewController: ViewController {
vc.removeFromParent()
}

private func logTappedView(_ view: View) {
switch view {
case .savedArticles:
NavigationEventsFunnel.shared.logTappedSavedAllArticles()
case .readingLists:
NavigationEventsFunnel.shared.logTappedSavedReadingLists()
}
}

// MARK: - View lifecycle

override func viewDidLoad() {
Expand Down
38 changes: 38 additions & 0 deletions Wikipedia/Code/WMFAppViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,10 @@ - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewCon
[self wmf_hideKeyboard];
}

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
[self logTappedTabBarItem:item inTabBar:tabBar];
}

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
if (viewController == tabBarController.selectedViewController) {
switch (tabBarController.selectedIndex) {
Expand Down Expand Up @@ -1587,6 +1591,7 @@ - (void)updateActiveTitleAccessibilityButton:(UIViewController *)viewController
}
}
}

#pragma mark - UINavigationControllerDelegate

- (void)navigationController:(UINavigationController *)navigationController
Expand Down Expand Up @@ -1895,6 +1900,7 @@ - (void)showSearchInCurrentNavigationController {
}

- (void)showSettings {
[self logTappedSettingsFromExplore];
[self showSettingsAnimated:YES];
}

Expand Down Expand Up @@ -2092,4 +2098,36 @@ - (void)showLoggedOutPanelIfNeeded {
});
}

#pragma mark - Navigation logging

- (void)logTappedTabBarItem:(UITabBarItem *)item inTabBar:(UITabBar *)tabBar {
if (tabBar.items.count != self.viewControllers.count || self.tabBar != tabBar) {
NSAssert(false, @"Unexpected tab bar setup for logging tap events.");
return;
}

NSInteger index = [self.tabBar.items indexOfObject:item];
if (index != NSNotFound) {
UIViewController *selectedViewController = self.viewControllers[index];

if ([selectedViewController isKindOfClass:[ExploreViewController class]] && [NSUserDefaults standardUserDefaults].defaultTabType == WMFAppDefaultTabTypeExplore) {
[[WMFNavigationEventsFunnel shared] logTappedExplore];
} else if ([selectedViewController isKindOfClass:[WMFSettingsViewController class]] && [NSUserDefaults standardUserDefaults].defaultTabType == WMFAppDefaultTabTypeSettings) {
[[WMFNavigationEventsFunnel shared] logTappedSettingsFromTabBar];
} else if ([selectedViewController isKindOfClass:[WMFPlacesViewController class]]) {
[[WMFNavigationEventsFunnel shared] logTappedPlaces];
} else if ([selectedViewController isKindOfClass:[WMFSavedViewController class]]) {
[[WMFNavigationEventsFunnel shared] logTappedSaved];
} else if ([selectedViewController isKindOfClass:[WMFHistoryViewController class]]) {
[[WMFNavigationEventsFunnel shared] logTappedHistory];
} else if ([selectedViewController isKindOfClass:[SearchViewController class]]) {
[[WMFNavigationEventsFunnel shared] logTappedSearch];
}
}
}

- (void)logTappedSettingsFromExplore {
[[WMFNavigationEventsFunnel shared] logTappedSettingsFromExplore];
}

@end
63 changes: 63 additions & 0 deletions Wikipedia/Code/WMFSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ - (void)setShowCloseButton:(BOOL)showCloseButton {
}

- (void)closeButtonPressed {
[[WMFNavigationEventsFunnel shared] logTappedSettingsCloseButton];
[self dismissViewControllerAnimated:YES completion:nil];
}

Expand Down Expand Up @@ -164,6 +165,7 @@ - (BOOL)accessibilityPerformEscape {
- (void)disclosureSwitchChanged:(UISwitch *)disclosureSwitch {
WMFSettingsMenuItemType type = (WMFSettingsMenuItemType)disclosureSwitch.tag;
[self updateStateForMenuItemType:type isSwitchOnValue:disclosureSwitch.isOn];
[self logNavigationEventsForMenuType:type];
[self loadSections];
}

Expand Down Expand Up @@ -193,6 +195,62 @@ - (void)updateStateForMenuItemType:(WMFSettingsMenuItemType)type isSwitchOnValue
}
}

-(void)logNavigationEventsForMenuType:(WMFSettingsMenuItemType)type {

switch (type) {
case WMFSettingsMenuItemType_LoginAccount:
[[WMFNavigationEventsFunnel shared] logTappedSettingsLoginLogout];
break;
case WMFSettingsMenuItemType_SearchLanguage:
[[WMFNavigationEventsFunnel shared] logTappedSettingsLanguages];
break;
case WMFSettingsMenuItemType_Search:
[[WMFNavigationEventsFunnel shared] logTappedSettingsSearch];
break;
case WMFSettingsMenuItemType_ExploreFeed:
[[WMFNavigationEventsFunnel shared] logTappedSettingsExploreFeed];
break;
case WMFSettingsMenuItemType_Notifications:
[[WMFNavigationEventsFunnel shared] logTappedSettingsNotifications];
break;
case WMFSettingsMenuItemType_Appearance:
[[WMFNavigationEventsFunnel shared] logTappedSettingsReadingPreferences];
break;
case WMFSettingsMenuItemType_StorageAndSyncing:
[[WMFNavigationEventsFunnel shared] logTappedSettingsArticleStorageAndSyncing];
break;
case WMFSettingsMenuItemType_StorageAndSyncingDebug:
[[WMFNavigationEventsFunnel shared] logTappedSettingsReadingListDangerZone];
break;
case WMFSettingsMenuItemType_Support:
[[WMFNavigationEventsFunnel shared] logTappedSettingsSupportWikipedia];
break;
case WMFSettingsMenuItemType_PrivacyPolicy:
[[WMFNavigationEventsFunnel shared] logTappedSettingsPrivacyPolicy];
break;
case WMFSettingsMenuItemType_Terms:
[[WMFNavigationEventsFunnel shared] logTappedSettingsTermsOfUse];
break;
case WMFSettingsMenuItemType_RateApp:
[[WMFNavigationEventsFunnel shared] logTappedSettingsRateTheApp];
break;
case WMFSettingsMenuItemType_SendFeedback:
[[WMFNavigationEventsFunnel shared] logTappedSettingsHelp];
break;
case WMFSettingsMenuItemType_About:
[[WMFNavigationEventsFunnel shared] logTappedSettingsAbout];
break;
case WMFSettingsMenuItemType_ClearCache:
[[WMFNavigationEventsFunnel shared] logTappedSettingsClearCachedData];
break;
case WMFSettingsMenuItemType_SendUsageReports:
[[WMFNavigationEventsFunnel shared] logTappedSettingsSendUsageReports];
break;
default:
break;
}
}

#pragma mark - Cell tap handling

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Expand Down Expand Up @@ -255,6 +313,11 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
default:
break;
}

if (cell.tag != WMFSettingsMenuItemType_SendUsageReports) { //logged elsewhere via disclosureSwitchChanged:
[self logNavigationEventsForMenuType:cell.tag];
}

[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}

Expand Down

0 comments on commit 0200871

Please sign in to comment.