Skip to content

Commit

Permalink
Add pixels.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsymons committed Dec 21, 2023
1 parent 635cce0 commit d4f20f9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ final class DefaultDataBrokerProtectionRemoteMessaging: DataBrokerProtectionRemo
try self.messageStorage.store(messages: messages)
self.updateLastRefreshDate() // Update last refresh date on success, otherwise let the app try again next time
} catch {
// Pixel.fire(.debug(event: .networkProtectionRemoteMessageStorageFailed, error: error))
Pixel.fire(.debug(event: .dataBrokerProtectionRemoteMessageStorageFailed, error: error))
}
case .failure(let error):
// Ignore 403 errors, those happen when a file can't be found on S3
Expand All @@ -100,7 +100,7 @@ final class DefaultDataBrokerProtectionRemoteMessaging: DataBrokerProtectionRemo
return
}

// Pixel.fire(.debug(event: .networkProtectionRemoteMessageFetchingFailed, error: error))
Pixel.fire(.debug(event: .dataBrokerProtectionRemoteMessageFetchingFailed, error: error))
}
}
}
Expand Down Expand Up @@ -178,4 +178,3 @@ final class DefaultDataBrokerProtectionRemoteMessaging: DataBrokerProtectionRemo
}

#endif

18 changes: 10 additions & 8 deletions DuckDuckGo/HomePage/Model/HomePageContinueSetUpModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ extension HomePage.Models {
}
#endif

// swiftlint:disable:next cyclomatic_complexity
@MainActor func performAction(for featureType: FeatureType) {
switch featureType {
case .defaultBrowser:
Expand Down Expand Up @@ -242,7 +243,8 @@ extension HomePage.Models {
#endif
case .dataBrokerProtectionRemoteMessage(let message):
#if DBP
break // TODO
dataBrokerProtectionRemoteMessaging.dismiss(message: message)
Pixel.fire(.dataBrokerProtectionRemoteMessageDismissed(messageID: message.id))
#endif
case .dataBrokerProtectionWaitlistInvited:
shouldShowDBPWaitlistInvitedCardUI = false
Expand All @@ -260,11 +262,11 @@ extension HomePage.Models {

for message in dataBrokerProtectionRemoteMessaging.presentableRemoteMessages() {
features.append(.dataBrokerProtectionRemoteMessage(message))
// DailyPixel.fire(
// pixel: .networkProtectionRemoteMessageDisplayed(messageID: message.id),
// frequency: .dailyOnly,
// includeAppVersionParameter: true
// )
DailyPixel.fire(
pixel: .dataBrokerProtectionRemoteMessageDisplayed(messageID: message.id),
frequency: .dailyOnly,
includeAppVersionParameter: true
)
}
#endif

Expand Down Expand Up @@ -463,7 +465,7 @@ extension HomePage.Models {
@MainActor private func handle(remoteMessage: DataBrokerProtectionRemoteMessage) {
#if DBP
guard let actionType = remoteMessage.action.actionType else {
// Pixel.fire(.networkProtectionRemoteMessageDismissed(messageID: remoteMessage.id))
Pixel.fire(.dataBrokerProtectionRemoteMessageDismissed(messageID: remoteMessage.id))
dataBrokerProtectionRemoteMessaging.dismiss(message: remoteMessage)
refreshFeaturesMatrix()
return
Expand All @@ -477,7 +479,7 @@ extension HomePage.Models {
if let surveyURL = remoteMessage.presentableSurveyURL() {
let tab = Tab(content: .url(surveyURL, source: .ui), shouldLoadInBackground: true)
tabCollectionViewModel.append(tab: tab)
// Pixel.fire(.networkProtectionRemoteMessageOpened(messageID: remoteMessage.id))
Pixel.fire(.dataBrokerProtectionRemoteMessageOpened(messageID: remoteMessage.id))

// Dismiss the message after the user opens the URL, even if they just close the tab immediately afterwards.
dataBrokerProtectionRemoteMessaging.dismiss(message: remoteMessage)
Expand Down
15 changes: 15 additions & 0 deletions DuckDuckGo/Statistics/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ extension Pixel {
case dataBrokerProtectionWaitlistCardUITapped
case dataBrokerProtectionWaitlistTermsAndConditionsDisplayed
case dataBrokerProtectionWaitlistTermsAndConditionsAccepted
case dataBrokerProtectionRemoteMessageDisplayed(messageID: String)
case dataBrokerProtectionRemoteMessageDismissed(messageID: String)
case dataBrokerProtectionRemoteMessageOpened(messageID: String)

// 28-day Home Button
case homeButtonHidden
Expand Down Expand Up @@ -346,6 +349,9 @@ extension Pixel {
case networkProtectionRemoteMessageFetchingFailed
case networkProtectionRemoteMessageStorageFailed

case dataBrokerProtectionRemoteMessageFetchingFailed
case dataBrokerProtectionRemoteMessageStorageFailed

case loginItemUpdateError
}

Expand Down Expand Up @@ -539,6 +545,12 @@ extension Pixel.Event {
return "m_mac_dbp_imp_terms"
case .dataBrokerProtectionWaitlistTermsAndConditionsAccepted:
return "m_mac_dbp_ev_terms_accepted"
case .dataBrokerProtectionRemoteMessageDisplayed(let messageID):
return "m_mac_dbp_remote_message_displayed_\(messageID)"
case .dataBrokerProtectionRemoteMessageDismissed(let messageID):
return "m_mac_dbp_remote_message_dismissed_\(messageID)"
case .dataBrokerProtectionRemoteMessageOpened(let messageID):
return "m_mac_dbp_remote_message_opened_\(messageID)"

// 28-day Home Button
case .homeButtonHidden:
Expand Down Expand Up @@ -791,6 +803,9 @@ extension Pixel.Event.Debug {
case .networkProtectionRemoteMessageFetchingFailed: return "netp_remote_message_fetching_failed"
case .networkProtectionRemoteMessageStorageFailed: return "netp_remote_message_storage_failed"

case .dataBrokerProtectionRemoteMessageFetchingFailed: return "dbp_remote_message_fetching_failed"
case .dataBrokerProtectionRemoteMessageStorageFailed: return "dbp_remote_message_storage_failed"

case .loginItemUpdateError: return "login-item_update-error"
}
}
Expand Down
5 changes: 4 additions & 1 deletion DuckDuckGo/Statistics/PixelParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ extension Pixel.Event {
.dataBrokerProtectionWaitlistTermsAndConditionsAccepted,
.homeButtonLeft,
.homeButtonRight,
.homeButtonHidden:
.homeButtonHidden,
.dataBrokerProtectionRemoteMessageOpened,
.dataBrokerProtectionRemoteMessageDisplayed,
.dataBrokerProtectionRemoteMessageDismissed:
return nil
}
}
Expand Down

0 comments on commit d4f20f9

Please sign in to comment.