-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Empty Stats: Add event tracking for Publicize / Blogging Reminders #17313
Changes from all commits
68b7110
7c3148a
80dc1e3
32434b5
941d7c5
d75d3db
1907b9c
abffcf1
c887490
b4fb243
64d12ac
c74d496
74e47ec
94d4b9e
9f6da61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,18 +211,30 @@ private extension SiteStatsInsightsTableViewController { | |
} | ||
|
||
func loadPinnedCards() { | ||
let viewsCount = insightsStore.getAllTimeStats()?.viewsCount ?? 0 | ||
switch pinnedItemStore?.itemToDisplay(for: viewsCount) { | ||
let viewsCount = insightsStore.getAllTimeStats()?.viewsCount | ||
switch pinnedItemStore?.itemToDisplay(for: viewsCount ?? 0) { | ||
case .none: | ||
insightsToShow = insightsToShow.filter { $0 != .growAudience || $0 != .customize } | ||
case .some(let item): | ||
switch item { | ||
case is GrowAudienceCell.HintType where !insightsToShow.contains(.growAudience): | ||
case let hintType as GrowAudienceCell.HintType where !insightsToShow.contains(.growAudience): | ||
insightsToShow = insightsToShow.filter { $0 != .customize } | ||
insightsToShow.insert(.growAudience, at: 0) | ||
|
||
// Work around to make sure nudge shown is tracked only once | ||
if viewsCount != nil { | ||
trackNudgeShown(for: hintType) | ||
} | ||
|
||
case InsightType.customize where !insightsToShow.contains(.customize): | ||
insightsToShow = insightsToShow.filter { $0 != .growAudience } | ||
insightsToShow.insert(.customize, at: 0) | ||
|
||
// Work around to make sure customize insights shown is tracked only once | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this to prevent the event from being fired multiple times? if that's the case, this is something we should not be worried about, given that normally we look at "unique" events. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, this is a workaround to make sure the correct event will be fired once. If you go to a site with more than 30 views (i.e. customize should be showing) and comment out the I tried doing b4fb243 in an attempt to fix this behavior, but that actually ended up breaking the presentation logic. (after dismissing a card, the next card shown would be the incorrect card, etc.) Maybe @nikola-milicevic has some insight on how to address this issue without breaking the presentation logic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ok! If that's the case then don't worry. Just wanted to make sure. |
||
if viewsCount != nil { | ||
WPAnalytics.trackEvent(.statsCustomizeInsightsShown) | ||
} | ||
|
||
default: | ||
break | ||
} | ||
|
@@ -246,6 +258,8 @@ private extension SiteStatsInsightsTableViewController { | |
} | ||
insightsToShow = insightsToShow.filter { $0 != .growAudience } | ||
pinnedItemStore?.markPinnedItemAsHidden(item) | ||
|
||
trackNudgeDismissed(for: item) | ||
} | ||
|
||
func refreshGrowAudienceCardIfNecessary() { | ||
|
@@ -466,6 +480,8 @@ extension SiteStatsInsightsTableViewController: SiteStatsInsightsDelegate { | |
present(navigationController, animated: true) | ||
|
||
applyTableUpdates() | ||
|
||
trackNudgeEvent(.statsPublicizeNudgeTapped) | ||
} | ||
|
||
func growAudienceBloggingRemindersButtonTapped() { | ||
|
@@ -481,6 +497,8 @@ extension SiteStatsInsightsTableViewController: SiteStatsInsightsDelegate { | |
delegate: self) | ||
|
||
applyTableUpdates() | ||
|
||
trackNudgeEvent(.statsBloggingRemindersNudgeTapped) | ||
} | ||
|
||
func showAddInsight() { | ||
|
@@ -549,7 +567,10 @@ extension SiteStatsInsightsTableViewController: SiteStatsInsightsDelegate { | |
extension SiteStatsInsightsTableViewController: SharingViewControllerDelegate { | ||
func didChangePublicizeServices() { | ||
viewModel?.markEmptyStatsNudgeAsCompleted() | ||
insightsToShow = insightsToShow.filter { $0 != .growAudience } | ||
refreshTableView() | ||
|
||
trackNudgeEvent(.statsPublicizeNudgeCompleted) | ||
} | ||
} | ||
|
||
|
@@ -558,7 +579,10 @@ extension SiteStatsInsightsTableViewController: SharingViewControllerDelegate { | |
extension SiteStatsInsightsTableViewController: BloggingRemindersFlowDelegate { | ||
func didSetUpBloggingReminders() { | ||
viewModel?.markEmptyStatsNudgeAsCompleted() | ||
insightsToShow = insightsToShow.filter { $0 != .growAudience } | ||
refreshTableView() | ||
|
||
trackNudgeEvent(.statsBloggingRemindersNudgeCompleted) | ||
} | ||
} | ||
|
||
|
@@ -622,3 +646,35 @@ extension SiteStatsInsightsTableViewController: NoResultsViewHost { | |
static let manageInsightsButtonTitle = NSLocalizedString("Add stats card", comment: "Button title displayed when the user has removed all Insights from display.") | ||
} | ||
} | ||
|
||
// MARK: - Tracks Support | ||
|
||
private extension SiteStatsInsightsTableViewController { | ||
|
||
func trackNudgeEvent(_ event: WPAnalyticsEvent) { | ||
if let blogId = SiteStatsInformation.sharedInstance.siteID, | ||
let blog = Blog.lookup(withID: blogId, in: mainContext) { | ||
WPAnalytics.track(event, properties: [:], blog: blog) | ||
} else { | ||
WPAnalytics.track(event) | ||
} | ||
} | ||
|
||
func trackNudgeShown(for hintType: GrowAudienceCell.HintType) { | ||
switch hintType { | ||
case .social: | ||
trackNudgeEvent(.statsPublicizeNudgeShown) | ||
case .bloggingReminders: | ||
trackNudgeEvent(.statsBloggingRemindersNudgeShown) | ||
} | ||
} | ||
|
||
func trackNudgeDismissed(for hintType: GrowAudienceCell.HintType) { | ||
switch hintType { | ||
case .social: | ||
trackNudgeEvent(.statsPublicizeNudgeDismissed) | ||
case .bloggingReminders: | ||
trackNudgeEvent(.statsBloggingRemindersNudgeDismissed) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌