Skip to content

Commit

Permalink
adding allowlist pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Osbourne committed Oct 18, 2023
1 parent 761c8f2 commit 2afd823
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"branch" : "shane/form-updates",
"revision" : "1e17576d5612a64ee9eea8243ab62b766a4418c2"
"revision" : "96072e2e2a5ccee1e602482a5407cae17cbf861d"
}
},
{
Expand Down Expand Up @@ -78,7 +78,7 @@
"location" : "https://github.com/duckduckgo/privacy-dashboard",
"state" : {
"branch" : "shane/form-updates",
"revision" : "aa3706033d41a650917ea118987ef7125d6cf52a"
"revision" : "7dc7e171e5bc2d3c540a6e8cb38c337f1e7a6869"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,18 @@ final class PrivacyDashboardViewController: NSViewController {

extension PrivacyDashboardViewController: PrivacyDashboardControllerDelegate {

func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didChangeProtectionSwitch isEnabled: Bool) {
func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didChangeProtectionSwitch protectionState: ProtectionState) {
guard let domain = privacyDashboardController.privacyInfo?.url.host else {
return
}

let configuration = ContentBlocking.shared.privacyConfigurationManager.privacyConfig
if isEnabled && configuration.isUserUnprotected(domain: domain) {
if protectionState.isProtected && configuration.isUserUnprotected(domain: domain) {
configuration.userEnabledProtection(forDomain: domain)
Pixel.fire(.dashboardProtectionAllowlistRemove(triggerOrigin: protectionState.eventOrigin.screen.rawValue))
} else {
configuration.userDisabledProtection(forDomain: domain)
Pixel.fire(.dashboardProtectionAllowlistAdd(triggerOrigin: protectionState.eventOrigin.screen.rawValue))
}

let completionToken = ContentBlocking.shared.contentBlockingManager.scheduleCompilation()
Expand Down
11 changes: 11 additions & 0 deletions DuckDuckGo/Statistics/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ extension Pixel {
case duckPlayerSettingNever
case duckPlayerSettingBackToDefault

// Dashboard
case dashboardProtectionAllowlistAdd(triggerOrigin: String?)
case dashboardProtectionAllowlistRemove(triggerOrigin: String?)

// Network Protection Waitlist
case networkProtectionWaitlistUserActive
case networkProtectionWaitlistEntryPointMenuItemDisplayed
Expand Down Expand Up @@ -457,6 +461,13 @@ extension Pixel.Event {
return "m_mac_duck-player_setting_never"
case .duckPlayerSettingBackToDefault:
return "m_mac_duck-player_setting_back-to-default"
case .duckPlayerSettingBackToDefault:
return "m_mac_duck-player_setting_back-to-default"

case .dashboardProtectionAllowlistAdd(let triggerOrigin):
return "m_mac_mp_wla"
case .dashboardProtectionAllowlistRemove(let triggerOrigin):
return "m_mac_mp_wlr"

case .launchInitial:
return "m.mac.first-launch"
Expand Down
8 changes: 8 additions & 0 deletions DuckDuckGo/Statistics/PixelParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ extension Pixel.Event {
case .dailyPixel(let pixel, isFirst: _):
return pixel.parameters

case .dashboardProtectionAllowlistAdd(let triggerOrigin):
guard let trigger = triggerOrigin else { return nil }
return [PixelKit.Parameters.dashboardTriggerOrigin: trigger]

case .dashboardProtectionAllowlistRemove(let triggerOrigin):
guard let trigger = triggerOrigin else { return nil }
return [PixelKit.Parameters.dashboardTriggerOrigin: trigger]

// Don't use default to force new items to be thought about
case .crash,
.brokenSiteReport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public extension PixelKit {

// Pixel experiments
public static let experimentCohort = "cohort"

// Dashboard
public static let dashboardTriggerOrigin = "trigger_origin"
}

enum Values {
Expand Down

0 comments on commit 2afd823

Please sign in to comment.