Skip to content
18 changes: 18 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ import Foundation
case jetpackSiteCreationOverlayDisplayed
case jetpackSiteCreationOverlayButtonTapped
case jetpackSiteCreationOverlayDismissed
case jetpackBrandingMenuCardDisplayed
case jetpackBrandingMenuCardTapped
case jetpackBrandingMenuCardLinkTapped
case jetpackBrandingMenuCardHidden
case jetpackBrandingMenuCardRemindLater
case jetpackBrandingMenuCardContextualMenuAccessed

/// A String that represents the event
var value: String {
Expand Down Expand Up @@ -1123,6 +1129,18 @@ import Foundation
return "remove_site_creation_overlay_button_tapped"
case .jetpackSiteCreationOverlayDismissed:
return "remove_site_creation_overlay_dismissed"
case .jetpackBrandingMenuCardDisplayed:
return "remove_feature_card_displayed"
case .jetpackBrandingMenuCardTapped:
return "remove_feature_card_tapped"
case .jetpackBrandingMenuCardLinkTapped:
return "remove_feature_card_link_tapped"
case .jetpackBrandingMenuCardHidden:
return "remove_feature_card_hide_tapped"
case .jetpackBrandingMenuCardRemindLater:
return "remove_feature_card_remind_later_tapped"
case .jetpackBrandingMenuCardContextualMenuAccessed:
return "remove_feature_card_menu_accessed"

} // END OF SWITCH
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ extension BlogDetailsViewController {
@objc func jetpackCardSectionViewModel() -> BlogDetailsSection {
let row = BlogDetailsRow()
row.callback = {
let presenter = JetpackBrandingMenuCardPresenter()
JetpackFeaturesRemovalCoordinator.presentOverlayIfNeeded(from: .card, in: self)
presenter.trackCardTapped()
}

let section = BlogDetailsSection(title: nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class JetpackBrandingMenuCardCell: UITableViewCell {
frameView.configureButtonContainerStackView()
frameView.hideHeader()

frameView.onEllipsisButtonTap = {
// TODO: Track menu shown
frameView.onEllipsisButtonTap = { [weak self] in
self?.presenter.trackContexualMenuAccessed()
}
frameView.ellipsisButton.showsMenuAsPrimaryAction = true
frameView.ellipsisButton.menu = contextMenu
Expand Down Expand Up @@ -134,7 +134,8 @@ class JetpackBrandingMenuCardCell: UITableViewCell {
private func commonInit() {
setupViews()
setupContent()
// TODO: Track card shown

presenter.trackCardShown()
}

// MARK: Helpers
Expand Down Expand Up @@ -164,7 +165,7 @@ class JetpackBrandingMenuCardCell: UITableViewCell {
let webViewController = WebViewControllerFactory.controller(url: url, source: Constants.analyticsSource)
let navController = UINavigationController(rootViewController: webViewController)
viewController?.present(navController, animated: true)
// TODO: Track button tapped
presenter.trackLinkTapped()
}
}

Expand All @@ -191,13 +192,11 @@ private extension JetpackBrandingMenuCardCell {
private func remindMeLaterTapped() {
presenter.remindLaterTapped()
viewController?.reloadTableView()
// TODO: Track button tapped
}

private func hideThisTapped() {
presenter.hideThisTapped()
viewController?.reloadTableView()
// TODO: Track button tapped
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class JetpackBrandingMenuCardPresenter {

private let remoteConfigStore: RemoteConfigStore
private let persistenceStore: UserPersistentRepository
private let featureFlagStore: RemoteFeatureFlagStore
private let currentDateProvider: CurrentDateProvider
private let phase: JetpackFeaturesRemovalCoordinator.GeneralPhase
Copy link
Contributor

Choose a reason for hiding this comment

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

The unit tests for this class are failing because the phase doesn't get updated when you do remoteFeatureFlagsStore.removalPhaseX = true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that I think about this, other than the tests, if the phase changes, we'll have to refresh the presenter to carry the correct value. So given that, I think it's best to revert this change altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 9dc4c28
Let me know what you think!

Copy link
Contributor

Choose a reason for hiding this comment

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

So given that, I think it's best to revert this change altogether.

Agreed!


// MARK: Initializers

Expand All @@ -21,15 +21,14 @@ class JetpackBrandingMenuCardPresenter {
persistenceStore: UserPersistentRepository = UserDefaults.standard,
currentDateProvider: CurrentDateProvider = DefaultCurrentDateProvider()) {
self.remoteConfigStore = remoteConfigStore
self.featureFlagStore = featureFlagStore
self.persistenceStore = persistenceStore
self.currentDateProvider = currentDateProvider
self.phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: featureFlagStore)
}

// MARK: Public Functions

func cardConfig() -> Config? {
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: featureFlagStore)
switch phase {
case .three:
let description = Strings.phaseThreeDescription
Expand All @@ -55,10 +54,45 @@ class JetpackBrandingMenuCardPresenter {
let duration = Constants.remindLaterDurationInDays * Constants.secondsInDay
let newDate = now.addingTimeInterval(TimeInterval(duration))
showCardOnDate = newDate
trackRemindMeLaterTapped()
}

func hideThisTapped() {
shouldHideCard = true
trackHideThisTapped()
}
}

// MARK: Analytics

extension JetpackBrandingMenuCardPresenter {

func trackCardShown() {
WPAnalytics.track(.jetpackBrandingMenuCardDisplayed, properties: analyticsProperties)
}

func trackLinkTapped() {
WPAnalytics.track(.jetpackBrandingMenuCardLinkTapped, properties: analyticsProperties)
}

func trackCardTapped() {
WPAnalytics.track(.jetpackBrandingMenuCardTapped, properties: analyticsProperties)
}

func trackContexualMenuAccessed() {
WPAnalytics.track(.jetpackBrandingMenuCardContextualMenuAccessed, properties: analyticsProperties)
}

func trackHideThisTapped() {
WPAnalytics.track(.jetpackBrandingMenuCardHidden, properties: analyticsProperties)
}

func trackRemindMeLaterTapped() {
WPAnalytics.track(.jetpackBrandingMenuCardRemindLater, properties: analyticsProperties)
}

private var analyticsProperties: [String: String] {
[Constants.phaseAnalyticsKey: phase.rawValue]
}
}

Expand Down Expand Up @@ -90,6 +124,7 @@ private extension JetpackBrandingMenuCardPresenter {
static let remindLaterDurationInDays = 7
static let shouldHideCardKey = "JetpackBrandingShouldHideCardKey"
static let showCardOnDateKey = "JetpackBrandingShowCardOnDateKey"
static let phaseAnalyticsKey = "phase"
}

enum Strings {
Expand Down