Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,29 @@ final class DashboardBlazeCardCell: DashboardCollectionViewCell {
switch viewModel.state {
case .promo:
let cardView = DashboardBlazePromoCardView(.make(with: blog, viewController: viewController))
self.setCardView(cardView, subtype: .promo)
self.setCardView(cardView, subtype: .promo, blog: blog)
case .campaign(let campaign):
let cardView = DashboardBlazeCampaignsCardView()
cardView.configure(blog: blog, viewController: viewController, campaign: campaign)
self.setCardView(cardView, subtype: .campaigns)
self.setCardView(cardView, subtype: .campaigns, blog: blog)
}
}

private func setCardView(_ cardView: UIView, subtype: DashboardBlazeCardSubtype) {
private func setCardView(_ cardView: UIView, subtype: DashboardBlazeCardSubtype, blog: Blog) {
contentView.subviews.forEach { $0.removeFromSuperview() }

cardView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(cardView)
contentView.pinSubviewToAllEdges(cardView, priority: UILayoutPriority(999))

BlogDashboardAnalytics.shared.track(.dashboardCardShown, properties: [
"type": DashboardCard.blaze.rawValue,
"sub_type": subtype.rawValue
])
BlogDashboardAnalytics.shared.track(
.dashboardCardShown,
properties: [
"type": DashboardCard.blaze.rawValue,
"sub_type": subtype.rawValue
],
blog: blog
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ class DashboardPostsListCardCell: UICollectionViewCell, Reusable {
contentView.addSubview(frameView)
contentView.pinSubviewToAllEdges(frameView, priority: UILayoutPriority(999))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This wasn't called anywhere

func trackPostsDisplayed() {
BlogDashboardAnalytics.shared.track(.dashboardCardShown, properties: ["type": "post", "sub_type": status.rawValue])
}
}

// MARK: BlogDashboardCardConfigurable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ private extension PostsCardViewModel {
func trackCardDisplayedIfNeeded() {
switch currentState {
case .posts:
BlogDashboardAnalytics.shared.track(.dashboardCardShown, properties: ["type": "post", "sub_type": status.rawValue])
BlogDashboardAnalytics.shared.track(.dashboardCardShown, properties: ["type": "post", "sub_type": status.rawValue], blog: blog)
case .error:
BlogDashboardAnalytics.shared.track(.dashboardCardShown, properties: ["type": "post", "sub_type": "error"])
BlogDashboardAnalytics.shared.track(.dashboardCardShown, properties: ["type": "post", "sub_type": "error"], blog: blog)
case .loading:
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ class BlogDashboardAnalytics {
/// This will track the given event and properties given they haven't been
/// triggered before.
///
/// The My Site dashboard always shows exactly one site, so every card-shown
/// event carries that site. `blog` is required so the site identifier is
/// always attached and no future card can regress by omitting it.
///
/// - Parameters:
/// - event: a `String` that represents the event name
/// - properties: a `Hash` that represents the properties
/// - blog: a `Blog` asssociated with the event
func track(_ event: WPAnalyticsEvent, properties: [AnyHashable: String] = [:], blog: Blog? = nil) {
/// - blog: the `Blog` whose dashboard is being shown
func track(_ event: WPAnalyticsEvent, properties: [AnyHashable: String] = [:], blog: Blog) {
if !fired.contains(where: { $0 == (event, properties) }) {
fired.append((event, properties))

if let blog {
WPAnalytics.track(event, properties: properties, blog: blog)
} else {
WPAnalytics.track(event, properties: properties)
}
WPAnalytics.track(event, properties: properties, blog: blog)
}
}

Expand Down