Skip to content

Commit

Permalink
Add daily stats pixel (#1993)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/0/1206206145252506/f
https://app.asana.com/0/0/1204831721662171/f

Description:
Add Sync success rate pixel.
  • Loading branch information
bwaresiak authored Dec 20, 2023
1 parent be73f44 commit 00e4e18
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 70 deletions.
114 changes: 73 additions & 41 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

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"
"revision" : "308abf4ebf170dc73d9f1a8a1730ed3170bed2d5",
"version" : "96.0.1"
}
},
{
Expand Down
6 changes: 4 additions & 2 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
isSyncInProgressCancellable = syncService.isSyncInProgressPublisher
.filter { $0 }
.asVoid()
.prefix(1)
.sink {
.sink { [weak syncService] in
Pixel.fire(.syncDaily, limitTo: .dailyFirst)
syncService?.syncDailyStats.sendStatsIfNeeded(handler: { params in
Pixel.fire(.syncSuccessRateDaily, withAdditionalParameters: params)
})
}

subscribeSyncQueueToScreenLockedNotifications()
Expand Down
12 changes: 0 additions & 12 deletions DuckDuckGo/Bookmarks/Services/LocalBookmarkStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,6 @@ final class LocalBookmarkStore: BookmarkStore {
// will return the children of the root folder, as the root folder is an implementation detail of the bookmarks store.
let rootFolder = self.bookmarksRoot(in: context)
let orphanedEntities = BookmarkUtils.fetchOrphanedEntities(context)
if !orphanedEntities.isEmpty {
self.reportOrphanedBookmarksIfNeeded()
}
results = (rootFolder?.childrenArray ?? []) + orphanedEntities
case .favorites:
results = self.favoritesRoot(in: context)?.favoritesArray ?? []
Expand All @@ -300,15 +297,6 @@ final class LocalBookmarkStore: BookmarkStore {
}
}

private func reportOrphanedBookmarksIfNeeded() {
Task { @MainActor in
guard let syncService = NSApp.delegateTyped.syncService, syncService.authState == .inactive else {
return
}
Pixel.fire(.debug(event: .orphanedBookmarksPresent))
}
}

func save(bookmark: Bookmark, parent: BookmarkFolder?, index: Int?, completion: @escaping (Bool, Error?) -> Void) {
applyChangesAndSave(changes: { [weak self] context in
guard let self = self else {
Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/Statistics/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ extension Pixel {
case missingParent
case bookmarksSaveFailed
case bookmarksSaveFailedOnImport
case orphanedBookmarksPresent

case bookmarksCouldNotLoadDatabase
case bookmarksCouldNotPrepareDatabase
Expand Down Expand Up @@ -753,7 +752,6 @@ extension Pixel.Event.Debug {
case .missingParent: return "bookmark_missing_parent"
case .bookmarksSaveFailed: return "bookmarks_save_failed"
case .bookmarksSaveFailedOnImport: return "bookmarks_save_failed_on_import"
case .orphanedBookmarksPresent: return "bookmarks_orphans_present"

case .bookmarksCouldNotLoadDatabase: return "bookmarks_could_not_load_database"
case .bookmarksCouldNotPrepareDatabase: return "bookmarks_could_not_prepare_database"
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Account/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["Account"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
.package(path: "../Purchase")
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
targets: ["DataBrokerProtection"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
.package(path: "../PixelKit"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../XPCHelper")
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/LoginItems/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let package = Package(
.library(name: "NetworkProtectionUI", targets: ["NetworkProtectionUI"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
.package(path: "../XPCHelper"),
.package(path: "../SwiftUIExtensions")
],
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/PixelKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Purchase/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Subscription/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
.package(path: "../Account"),
.package(path: "../Purchase"),
.package(path: "../SwiftUIExtensions"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SwiftUIExtensions/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SyncUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
],
dependencies: [
.package(path: "../SwiftUIExtensions"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SystemExtensionManager/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/XPCHelper/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let package = Package(
.library(name: "XPCHelper", targets: ["XPCHelper"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "95.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "96.0.1"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
4 changes: 4 additions & 0 deletions UnitTests/Sync/SyncPreferencesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Combine
import Persistence
import SyncUI
import XCTest
import TestUtils
@testable import BrowserServicesKit
@testable import DDGSync
@testable import DuckDuckGo_Privacy_Browser
Expand Down Expand Up @@ -136,6 +137,7 @@ final class SyncPreferencesTests: XCTestCase {
}

class MockDDGSyncing: DDGSyncing {

let registeredDevices = [RegisteredDevice(id: "1", name: "Device 1", type: "desktop"), RegisteredDevice(id: "2", name: "Device 2", type: "mobile"), RegisteredDevice(id: "3", name: "Device 1", type: "desktop")]
var disconnectCalled = false

Expand All @@ -151,6 +153,8 @@ class MockDDGSyncing: DDGSyncing {

var scheduler: Scheduling

var syncDailyStats = SyncDailyStats(store: MockKeyValueStore())

@Published var isSyncInProgress: Bool

var isSyncInProgressPublisher: AnyPublisher<Bool, Never> {
Expand Down

0 comments on commit 00e4e18

Please sign in to comment.