Skip to content

Commit

Permalink
track campaign details events
Browse files Browse the repository at this point in the history
  • Loading branch information
Momo Ozawa committed Jul 11, 2023
1 parent cb9664f commit 301c0a1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
9 changes: 9 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ import Foundation
case blazeFlowCompleted
case blazeFlowError
case blazeCampaignListOpened
case blazeCampaignDetailsOpened
case blazeCampaignDetailsError
case blazeCampaignDetailsDismissed

// Moved to Jetpack static screen
case removeStaticPosterDisplayed
Expand Down Expand Up @@ -1295,6 +1298,12 @@ import Foundation
return "blaze_flow_error"
case .blazeCampaignListOpened:
return "blaze_campaign_list_opened"
case .blazeCampaignDetailsOpened:
return "blaze_campaign_details_opened"
case .blazeCampaignDetailsError:
return "blaze_campaign_details_error"
case .blazeCampaignDetailsDismissed:
return "blaze_campaign_details_dismissed"

// Moved to Jetpack static screen
case .removeStaticPosterDisplayed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ import Foundation
WPAnalytics.track(.blazeCampaignListOpened, properties: analyticsProperties(for: source))
}

// MARK: - Campaign details

static func trackCampaignDetailsOpened(for source: BlazeSource) {
WPAnalytics.track(.blazeCampaignDetailsOpened, properties: analyticsProperties(for: source))
}

static func trackCampaignDetailsError(for source: BlazeSource) {
WPAnalytics.track(.blazeCampaignDetailsError, properties: analyticsProperties(for: source))
}

static func trackCampaignDetailsDismissed(for source: BlazeSource) {
WPAnalytics.track(.blazeCampaignDetailsDismissed, properties: analyticsProperties(for: source))
}

// MARK: - Helpers

private static func analyticsProperties(for source: BlazeSource) -> [String: String] {
return [WPAppAnalyticsKeySource: source.description]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ class BlazeCampaignDetailsWebViewModel: BlazeWebViewModel {
func startBlazeFlow() {
guard let initialURL,
let cookieJar = view?.cookieJar else {
// TODO: Track Analytics Error Event
BlazeEventsTracker.trackCampaignDetailsError(for: source)
view?.dismissView()
return
}
authenticatedRequest(for: initialURL, with: cookieJar) { [weak self] (request) in
guard let weakSelf = self else {
guard let self else {
return
}
weakSelf.view?.load(request: request)
// TODO: Track Analytics Event
self.view?.load(request: request)
BlazeEventsTracker.trackCampaignDetailsOpened(for: self.source)
}
}

func dismissTapped() {
view?.dismissView()
// TODO: Track Analytics Event
BlazeEventsTracker.trackCampaignDetailsDismissed(for: source)
}

func shouldNavigate(to request: URLRequest, with type: WKNavigationType) -> WKNavigationActionPolicy {
Expand Down

0 comments on commit 301c0a1

Please sign in to comment.