Skip to content

Commit

Permalink
fix(analytics): add content entity to upsell call
Browse files Browse the repository at this point in the history
  • Loading branch information
cyndichin committed May 1, 2023
1 parent 1b09202 commit f7bf943
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions PocketKit/Sources/Analytics/AppEvents/Tags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,17 @@ public extension Events.Tags {
}

/// "Go Premium" button viewed
static func premiumUpsellViewed() -> Event {
static func premiumUpsellViewed(itemURL: URL) -> Event {
return Impression(
component: .button,
requirement: .viewable,
uiEntity: UiEntity(
.button,
identifier: "global-nav.addTags.upsell"
)
),
extraEntities: [
ContentEntity(url: itemURL)
]
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Localization
struct PremiumUpsellView: View {
@ObservedObject
var viewModel: PremiumUpsellViewModel
let itemURL: URL

@State var dismissReason: DismissReason = .swipe
var body: some View {
Expand All @@ -31,7 +32,7 @@ struct PremiumUpsellView: View {
PremiumUpgradeView(dismissReason: self.$dismissReason, viewModel: viewModel.makePremiumUpgradeViewModel())
}
.task {
viewModel.trackPremiumUpsellViewed()
viewModel.trackPremiumUpsellViewed(with: itemURL)
}
.accessibilityIdentifier("get-pocket-premium-button")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SharedPocketKit
import Sync
import Combine
import Analytics
import Foundation

class PremiumUpsellViewModel: ObservableObject {
private let premiumUpgradeViewModelFactory: PremiumUpgradeViewModelFactory
Expand Down Expand Up @@ -58,7 +59,7 @@ extension PremiumUpsellViewModel {
}
}

func trackPremiumUpsellViewed() {
tracker.track(event: Events.Tags.premiumUpsellViewed())
func trackPremiumUpsellViewed(with itemURL: URL) {
tracker.track(event: Events.Tags.premiumUpsellViewed(itemURL: itemURL))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PocketAddTagsViewModel: AddTagsViewModel {
PremiumUpgradeViewModel(store: store, tracker: tracker, source: .tags, networkPathMonitor: networkPathMonitor)
})

self.premiumUpsellView = PremiumUpsellView(viewModel: premiumUpsellViewModel)
self.premiumUpsellView = PremiumUpsellView(viewModel: premiumUpsellViewModel, itemURL: item.url)

tags = itemTagNames
allOtherTags()
Expand Down

0 comments on commit f7bf943

Please sign in to comment.