Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Profile: track events #16327

Merged
merged 6 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ import Foundation
case categoryFilterSelected
case categoryFilterDeselected

// User Profile Sheet
case userProfileSheetShown
case userProfileSheetSiteShown

/// A String that represents the event
var value: String {
switch self {
Expand Down Expand Up @@ -444,6 +448,12 @@ import Foundation
return "category_filter_selected"
case .categoryFilterDeselected:
return "category_filter_deselected"

// User Profile Sheet
case .userProfileSheetShown:
return "user_profile_sheet_shown"
case .userProfileSheetSiteShown:
return "user_profile_sheet_site_shown"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,8 @@ private extension NotificationDetailsViewController {

let sourceView = tableView.cellForRow(at: indexPath) ?? view
bottomSheet.show(from: self, sourceView: sourceView)

WPAnalytics.track(.userProfileSheetShown, properties: ["source": "like_notification_list"])
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ import WordPressFlux
}
}

/// Used for the `source` property in Stats.
/// Indicates where the view was shown from.
enum StatSource: String {
case reader
case user_profile
}
var statSource: StatSource = .reader

/// Facilitates sharing of a blog via `ReaderStreamViewController+Sharing.swift`.
let sharingController = PostSharingController()

Expand Down Expand Up @@ -718,14 +726,17 @@ import WordPressFlux
assertionFailure("A reader topic is required")
return nil
}

let title = topic.title
var key: String = "list"

if ReaderHelpers.isTopicTag(topic) {
key = "tag"
} else if ReaderHelpers.isTopicSite(topic) {
key = "site"
}
return [key: title]

return [key: title, "source": statSource.rawValue]
}

/// The fetch request can need a different predicate depending on how the content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ extension UserProfileSheetViewController {
private extension UserProfileSheetViewController {

func showSite() {
WPAnalytics.track(.userProfileSheetSiteShown)

// TODO: Remove. For testing only. Use siteID from user object.
var stubbySiteID: NSNumber?
// use this to test external site
// stubbySiteID = nil
stubbySiteID = nil
// use this to test internal site
stubbySiteID = NSNumber(value: 9999999999)
// stubbySiteID = NSNumber(value: 9999999999)

guard let siteID = stubbySiteID else {
showSiteWebView()
Expand All @@ -154,13 +155,14 @@ private extension UserProfileSheetViewController {

func showSiteTopicWithID(_ siteID: NSNumber) {
let controller = ReaderStreamViewController.controllerWithSiteID(siteID, isFeed: false)
controller.statSource = ReaderStreamViewController.StatSource.user_profile
let navController = UINavigationController(rootViewController: controller)
present(navController, animated: true)
}

func showSiteWebView() {
// TODO: Remove. For testing only. Use URL from user object.
let siteUrl = "http://www.peopleofwalmart.com/"
let siteUrl = "https://www.funnycatpix.com/"

guard let url = URL(string: siteUrl) else {
DDLogError("User Profile: Error creating URL from site string.")
Expand Down