Skip to content

Commit

Permalink
Enable Sync Rate pixel
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaresiak committed Dec 19, 2023
1 parent fb3b898 commit 33b186b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
6 changes: 5 additions & 1 deletion Core/DailyPixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ public final class DailyPixel {
/// Does not append any suffix unlike the alternative function below
public static func fire(pixel: Pixel.Event,
withAdditionalParameters params: [String: String] = [:],
includedParameters: [Pixel.QueryParameters] = [.atb, .appVersion],
onComplete: @escaping (Swift.Error?) -> Void = { _ in }) {

if !pixel.hasBeenFiredToday(dailyPixelStorage: storage) {
Pixel.fire(pixel: pixel, withAdditionalParameters: params, onComplete: onComplete)
Pixel.fire(pixel: pixel,
withAdditionalParameters: params,
includedParameters: includedParameters,
onComplete: onComplete)
updatePixelLastFireDate(pixel: pixel)
} else {
onComplete(Error.alreadyFired)
Expand Down
4 changes: 2 additions & 2 deletions Core/SyncMetricsEventsHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class SyncMetricsEventsHandler: EventMapping<MetricsEvent> {
super.init { event, _, _, _ in
switch event {
case .overrideEmailProtectionSettings:
Pixel.fire(pixel: .syncDuckAddressOverride)
Pixel.fire(pixel: .syncDuckAddressOverride, includedParameters: [.appVersion])
case .localTimestampResolutionTriggered(let feature):
Pixel.fire(pixel: .syncLocalTimestampResolutionTriggered(feature))
Pixel.fire(pixel: .syncLocalTimestampResolutionTriggered(feature), includedParameters: [.appVersion])
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9220,8 +9220,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 95.0.0;
branch = "bartek/sync-rate-pixel";
kind = branch;
};
};
C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "ae9e9180f74d92c83fc3cc1d2fc23f4855fb361c",
"version" : "95.0.0"
"branch" : "bartek/sync-rate-pixel",
"revision" : "eaae16e1982421c35225f0e6baf3c206e2d9a877"
}
},
{
Expand Down
10 changes: 7 additions & 3 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

isSyncInProgressCancellable = syncService.isSyncInProgressPublisher
.filter { $0 }
.prefix(1)
.sink { _ in
DailyPixel.fire(pixel: .syncDaily)
.sink { [weak syncService] _ in
DailyPixel.fire(pixel: .syncDaily, includedParameters: [.appVersion])
syncService?.syncDailyInfo.sendStatusIfNeeded(handler: { params in
Pixel.fire(pixel: .syncSuccessRateDaily,
withAdditionalParameters: params,
includedParameters: [.appVersion])
})
}

#if APP_TRACKING_PROTECTION
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extension SyncSettingsViewController: SyncManagementViewModelDelegate {
self.dismissPresentedViewController()
self.showPreparingSync()
try await syncService.createAccount(deviceName: deviceName, deviceType: deviceType)
Pixel.fire(pixel: .syncSignupDirect)
Pixel.fire(pixel: .syncSignupDirect, includedParameters: [.appVersion])
self.rootView.model.syncEnabled(recoveryCode: recoveryCode)
self.refreshDevices()
navigationController?.topViewController?.dismiss(animated: true, completion: showRecoveryPDF)
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/SyncSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ extension SyncSettingsViewController: ScanOrPasteCodeViewModelDelegate {
func loginAndShowDeviceConnected(recoveryKey: SyncCode.RecoveryKey) async throws {
let registeredDevices = try await syncService.login(recoveryKey, deviceName: deviceName, deviceType: deviceType)
mapDevices(registeredDevices)
Pixel.fire(pixel: .syncLogin)
Pixel.fire(pixel: .syncLogin, includedParameters: [.appVersion])
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.dismissVCAndShowRecoveryPDF()
}
Expand Down Expand Up @@ -281,7 +281,7 @@ extension SyncSettingsViewController: ScanOrPasteCodeViewModelDelegate {
showPreparingSync()
if syncService.account == nil {
try await syncService.createAccount(deviceName: deviceName, deviceType: deviceType)
Pixel.fire(pixel: .syncSignupConnect)
Pixel.fire(pixel: .syncSignupConnect, includedParameters: [.appVersion])
self.dismissVCAndShowRecoveryPDF()
shouldShowSyncEnabled = false
rootView.model.syncEnabled(recoveryCode: recoveryCode)
Expand Down

0 comments on commit 33b186b

Please sign in to comment.