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 5 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 userProfileShown
case userProfileSiteShown

/// 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 .userProfileShown:
return "user_profile_shown"
case .userProfileSiteShown:
return "user_profile_site_shown"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to call these liker_profile_* rather than user_profile_*? I'm thinking that someone looking at tracks might at a glance assume that user_profile referred to the logged in user's own profile.

Copy link
Contributor Author

@ScoutHarris ScoutHarris Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, per the User Profile designs (pbArwn-K3-p2), this sheet could be displayed from somewhere other than the liker. So I made it specific to the sheet, not the presenter. That's why I added a source to user_profile_shown. I could add a source to user_profile_site_shown if we like.

Or, I could change them to user_profile_sheet_* if that's better. Which it may be...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I made it specific to the sheet, not the presenter

Oh I see. Makes sense.

I could change them to user_profile_sheet_*

I think I'm a fan :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do. Thanks!

}
}

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(.userProfileShown, 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(.userProfileSiteShown)

// 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