-
Notifications
You must be signed in to change notification settings - Fork 59
[iOS] Implement pixels for fire mode #4437
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
Changes from 2 commits
d685b83
45b5379
2b4b932
7505b46
a80a853
15d193b
bd55d8c
b4f9326
e6be53e
29f04fb
88c9602
b6f0d50
2ff6b0a
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 |
|---|---|---|
|
|
@@ -397,9 +397,10 @@ class FireExecutor: FireExecuting { | |
| switch scope { | ||
| case .tab: | ||
| return TimedPixel(.singleTabDataCleared) | ||
| case .fireMode, .normalMode: | ||
| // TODO: - return new pixel | ||
| return nil | ||
| case .fireMode: | ||
| return TimedPixel(.fireModeDataCleared) | ||
| case .normalMode: | ||
| return TimedPixel(.normalModeDataCleared) | ||
|
Contributor
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. Just a note here that we’ll need to make adjustments to our dashboards as this will stop sending the forgetAllDataCleared pixel for users who have the fire mode enabled.
Contributor
Author
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. Synced on this, and we agreed to leave it as is. Added a comment, though, to clarify the intention of the normalMode scope. |
||
| case .all: | ||
| return TimedPixel(.forgetAllDataCleared) | ||
| } | ||
|
|
@@ -413,7 +414,8 @@ class FireExecutor: FireExecuting { | |
| let tabType = viewModel.tab.isAITab ? "ai" : "web" | ||
| return [ | ||
| PixelParameters.tabType: tabType, | ||
| PixelParameters.domainsCount: "\(domains?.count ?? 0)" | ||
| PixelParameters.domainsCount: "\(domains?.count ?? 0)", | ||
| PixelParameters.browsingMode: viewModel.tab.pixelParamValue | ||
| ] | ||
| case .fireMode: | ||
| tabsModel = self.tabManager.tabsModel(for: .fire) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1548,6 +1548,7 @@ | |
| let bucket = HomePageDisplayDailyPixelBucket(favoritesCount: favoritesCount) | ||
| DailyPixel.fire(pixel: .newTabPageDisplayedDaily, withAdditionalParameters: [ | ||
| "FavoriteCount": bucket.value, | ||
| PixelParameters.browsingMode: tabManager.currentBrowsingMode.pixelParamValue | ||
| ]) | ||
| } | ||
|
|
||
|
|
@@ -1577,8 +1578,9 @@ | |
| ) | ||
| } | ||
|
|
||
| Pixel.fire(pixel: .forgetAllPressedBrowsing) | ||
| DailyPixel.fire(pixel: .forgetAllPressedBrowsingDaily) | ||
| let browsingModeParam = [PixelParameters.browsingMode: tabManager.currentBrowsingMode.pixelParamValue] | ||
| Pixel.fire(pixel: .forgetAllPressedBrowsing, withAdditionalParameters: browsingModeParam) | ||
| DailyPixel.fire(pixel: .forgetAllPressedBrowsingDaily, withAdditionalParameters: browsingModeParam) | ||
|
|
||
| performActionIfAITab { DailyPixel.fireDailyAndCount(pixel: .aiChatFireButtonTapped) } | ||
|
|
||
|
|
@@ -3029,8 +3031,8 @@ | |
| action() | ||
| } | ||
|
|
||
| func navigateToFireMode() { | ||
| tabManager.setBrowsingMode(.fire) | ||
| func navigateToFireMode(source: FireModeSwitchSource = .internal) { | ||
| tabManager.setBrowsingMode(.fire, source: source) | ||
| showTabSwitcher() | ||
| } | ||
| } | ||
|
|
@@ -3401,14 +3403,15 @@ | |
|
|
||
| tab.didLaunchBrowsingMenu() | ||
|
|
||
| let modeParam = [PixelParameters.browsingMode: tabManager.currentBrowsingMode.pixelParamValue] | ||
| switch context { | ||
| case .newTabPage: | ||
| Pixel.fire(pixel: .browsingMenuOpenedNewTabPage) | ||
| case .aiChatTab: | ||
| Pixel.fire(pixel: .browsingMenuOpened) | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| Pixel.fire(pixel: .browsingMenuOpened, withAdditionalParameters: modeParam) | ||
| DailyPixel.fireDailyAndCount(pixel: .aiChatSettingsMenuOpened) | ||
| case .website: | ||
| Pixel.fire(pixel: .browsingMenuOpened) | ||
| Pixel.fire(pixel: .browsingMenuOpened, withAdditionalParameters: modeParam) | ||
|
|
||
| if tab.isError { | ||
| Pixel.fire(pixel: .browsingMenuOpenedError) | ||
|
|
@@ -3565,16 +3568,17 @@ | |
| aiChat: .keyboardGoWhileOnAIChat) | ||
| } | ||
|
|
||
| func fireControllerAwarePixel(ntp: Pixel.Event, serp: Pixel.Event, website: Pixel.Event, aiChat: Pixel.Event) { | ||
| func fireControllerAwarePixel(ntp: Pixel.Event, serp: Pixel.Event, website: Pixel.Event, aiChat: Pixel.Event, | ||
| additionalParameters: [String: String] = [:]) { | ||
| if newTabPageViewController != nil { | ||
| Pixel.fire(pixel: ntp) | ||
| Pixel.fire(pixel: ntp, withAdditionalParameters: additionalParameters) | ||
| } else if let currentTab { | ||
| if currentTab.isAITab == true { | ||
| Pixel.fire(pixel: aiChat) | ||
| Pixel.fire(pixel: aiChat, withAdditionalParameters: additionalParameters) | ||
| } else if currentTab.url?.isDuckDuckGoSearch == true { | ||
| Pixel.fire(pixel: serp) | ||
| Pixel.fire(pixel: serp, withAdditionalParameters: additionalParameters) | ||
| } else { | ||
| Pixel.fire(pixel: website) | ||
| Pixel.fire(pixel: website, withAdditionalParameters: additionalParameters) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -3599,7 +3603,7 @@ | |
| if featureFlagger.internalUserDecider.isInternalUser || isDebugBuild { | ||
| segueToDebugSettings() | ||
| } else { | ||
| segueToSettings() | ||
|
Check failure on line 3606 in iOS/DuckDuckGo/MainViewController.swift
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -3649,21 +3653,21 @@ | |
| } | ||
|
|
||
| private func newTabShortcutAction() { | ||
| Pixel.fire(pixel: .tabSwitchLongPressNewTab) | ||
| Pixel.fire(pixel: .tabSwitchLongPressNewTab, withAdditionalParameters: [ | ||
| PixelParameters.browsingMode: tabManager.currentBrowsingMode.pixelParamValue | ||
| ]) | ||
| performCancel() | ||
| newTab() | ||
| } | ||
|
|
||
| private func newFireTabLongPressMenuAction() { | ||
| // TODO: - Add pixel | ||
| tabManager.setBrowsingMode(.fire) | ||
| tabManager.setBrowsingMode(.fire, source: .longPressTabsIcon) | ||
| performCancel() | ||
| newTab() | ||
| } | ||
|
|
||
| private func newNormalTabLongPressMenuAction() { | ||
| // TODO: - Add pixel | ||
| tabManager.setBrowsingMode(.normal) | ||
| tabManager.setBrowsingMode(.normal, source: .longPressTabsIcon) | ||
| performCancel() | ||
| newTab() | ||
| } | ||
|
|
@@ -3687,10 +3691,12 @@ | |
| } | ||
|
|
||
| if tapped { | ||
| let modeParam = [PixelParameters.browsingMode: tabManager.currentBrowsingMode.pixelParamValue] | ||
| fireControllerAwarePixel(ntp: .addressBarClickOnNTP, | ||
| serp: .addressBarClickOnSERP, | ||
| website: .addressBarClickOnWebsite, | ||
| aiChat: .addressBarClickOnAIChat) | ||
| aiChat: .addressBarClickOnAIChat, | ||
| additionalParameters: modeParam) | ||
| } | ||
|
|
||
| guard newTabPageViewController == nil else { return } | ||
|
|
@@ -3938,10 +3944,12 @@ | |
|
|
||
| // MARK: - Experimental Address Bar (pixels only) | ||
| func onExperimentalAddressBarTapped() { | ||
| let modeParam = [PixelParameters.browsingMode: tabManager.currentBrowsingMode.pixelParamValue] | ||
| fireControllerAwarePixel(ntp: .addressBarClickOnNTP, | ||
| serp: .addressBarClickOnSERP, | ||
| website: .addressBarClickOnWebsite, | ||
| aiChat: .addressBarClickOnAIChat) | ||
| aiChat: .addressBarClickOnAIChat, | ||
| additionalParameters: modeParam) | ||
| } | ||
|
|
||
| func onExperimentalAddressBarClearPressed() { | ||
|
|
@@ -3969,7 +3977,9 @@ | |
|
|
||
| /// Delegate method called when the omnibar branding area is tapped while in AI Chat mode. | ||
| func onAIChatBrandingPressed() { | ||
| Pixel.fire(pixel: .addressBarClickOnAIChat) | ||
| Pixel.fire(pixel: .addressBarClickOnAIChat, withAdditionalParameters: [ | ||
| PixelParameters.browsingMode: tabManager.currentBrowsingMode.pixelParamValue | ||
| ]) | ||
| viewCoordinator.omniBar.beginEditing(animated: true, forTextEntryMode: .aiChat) | ||
| } | ||
|
|
||
|
|
@@ -4049,7 +4059,7 @@ | |
| } | ||
|
|
||
| func onFireModeRequested() { | ||
| navigateToFireMode() | ||
| navigateToFireMode(source: .ntpPromotion) | ||
| } | ||
|
|
||
| func isCurrentTabFireTab() -> Bool { | ||
|
|
@@ -4171,7 +4181,7 @@ | |
| } | ||
|
|
||
| func newTabPageDidRequestFireMode(_ controller: NewTabPageViewController) { | ||
| navigateToFireMode() | ||
| navigateToFireMode(source: .ntpPromotion) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -4186,7 +4196,7 @@ | |
| } | ||
|
|
||
| func tabDidRequestFireMode(tab: TabViewController) { | ||
| navigateToFireMode() | ||
| navigateToFireMode(source: .menuPromotion) | ||
| } | ||
|
|
||
| var isAIChatEnabled: Bool { | ||
|
|
@@ -4272,7 +4282,7 @@ | |
| func tab(_ tab: TabViewController, | ||
| didRequestNewFireTabForUrl url: URL, | ||
| inheritingAttribution attribution: AdClickAttributionLogic.State?) { | ||
| tabManager.setBrowsingMode(.fire) | ||
| tabManager.setBrowsingMode(.fire, source: .longPressLink) | ||
| loadUrlInNewTab(url, inheritedAttribution: attribution) | ||
| } | ||
|
|
||
|
|
@@ -4714,8 +4724,11 @@ | |
| } | ||
|
|
||
| func showTabSwitcher(_ button: TabSwitcherButton) { | ||
| Pixel.fire(pixel: .tabBarTabSwitcherOpened) | ||
| DailyPixel.fireDaily(.tabSwitcherOpenedDaily, withAdditionalParameters: TabSwitcherOpenDailyPixel().parameters(with: tabManager.allTabsModel.tabs)) | ||
| Pixel.fire(pixel: .tabBarTabSwitcherOpened, | ||
| withAdditionalParameters: [PixelParameters.browsingMode: tabManager.currentBrowsingMode.pixelParamValue]) | ||
| var openedDailyParams = TabSwitcherOpenDailyPixel().parameters(with: tabManager.allTabsModel.tabs) | ||
| openedDailyParams[PixelParameters.browsingMode] = tabManager.currentBrowsingMode.pixelParamValue | ||
| DailyPixel.fireDaily(.tabSwitcherOpenedDaily, withAdditionalParameters: openedDailyParams) | ||
|
|
||
| performActionIfAITab { DailyPixel.fireDailyAndCount(pixel: .aiChatTabSwitcherOpened) } | ||
|
|
||
|
|
@@ -4949,6 +4962,7 @@ | |
| extension MainViewController: TabManagerFireModeDelegate { | ||
|
|
||
| func tabManagerDidCloseLastFireTab() { | ||
| DailyPixel.fireDailyAndCount(pixel: .fireModeLastTabClosedBurn) | ||
| Task { | ||
| let request = FireRequest(options: [.data, .aiChats], | ||
| trigger: .fireModeAutoClear, | ||
|
|
@@ -4983,20 +4997,23 @@ | |
|
|
||
| private func firePixels(for request: FireRequest) { | ||
| let tabType = tabManager.viewModelForCurrentTab()?.tab.isAITab == true ? "ai" : "web" | ||
| let browsingMode = tabManager.currentBrowsingMode.pixelParamValue | ||
| let params: [String: String] = [ | ||
| PixelParameters.source: request.source.rawValue, | ||
| PixelParameters.tabType: tabType | ||
| PixelParameters.tabType: tabType, | ||
| PixelParameters.browsingMode: browsingMode | ||
| ] | ||
|
|
||
| switch request.scope { | ||
| case .all: | ||
| Pixel.fire(pixel: .forgetAllExecuted, withAdditionalParameters: params) | ||
| DailyPixel.fire(pixel: .forgetAllExecutedDaily, withAdditionalParameters: params) | ||
| case .tab: | ||
| DailyPixel.fireDailyAndCount(pixel: .singleTabBurnExecuted, withAdditionalParameters: params) | ||
| case .fireMode, .normalMode: | ||
| // TODO: - Add fire mode burn pixel | ||
| break | ||
| case .fireMode: | ||
| DailyPixel.fireDailyAndCount(pixel: .fireModeBurnExecuted, withAdditionalParameters: params) | ||
| case .normalMode: | ||
| DailyPixel.fireDailyAndCount(pixel: .normalModeBurnExecuted, withAdditionalParameters: params) | ||
|
Contributor
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. Browsing mode may be stale for scoped burnsMedium Severity In Please tell me if this was useful or not with a 👍 or 👎. Reviewed by Cursor Bugbot for commit 2ff6b0a. Configure here. |
||
| } | ||
| } | ||
|
|
||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.