diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index 300b2b63a1..7c1cc45b99 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -535,7 +535,8 @@ extension Pixel { case debugCannotClearObservationsDatabase case debugWebsiteDataStoresNotClearedMultiple case debugWebsiteDataStoresNotClearedOne - + case debugWebsiteDataStoresCleared + case debugBookmarksMigratedMoreThanOnce // Return user measurement @@ -1243,7 +1244,8 @@ extension Pixel.Event { case .debugCannotClearObservationsDatabase: return "m_d_cannot_clear_observations_database" case .debugWebsiteDataStoresNotClearedMultiple: return "m_d_wkwebsitedatastoresnotcleared_multiple" case .debugWebsiteDataStoresNotClearedOne: return "m_d_wkwebsitedatastoresnotcleared_one" - + case .debugWebsiteDataStoresCleared: return "m_d_wkwebsitedatastorescleared" + // MARK: Ad Attribution case .adAttributionGlobalAttributedRulesDoNotExist: return "m_attribution_global_attributed_rules_do_not_exist" diff --git a/Core/WebCacheManager.swift b/Core/WebCacheManager.swift index 682afae536..91a10c0781 100644 --- a/Core/WebCacheManager.swift +++ b/Core/WebCacheManager.swift @@ -96,12 +96,18 @@ public class WebCacheManager { extension WebCacheManager { @available(iOS 17, *) - private func checkForLeftBehindDataStores() async { + private func checkForLeftBehindDataStores(leftOversCount: Int) async { + let params = [ + "left_overs_count": "\(leftOversCount)" + ] + let ids = await WKWebsiteDataStore.allDataStoreIdentifiers if ids.count > 1 { - Pixel.fire(pixel: .debugWebsiteDataStoresNotClearedMultiple) + Pixel.fire(pixel: .debugWebsiteDataStoresNotClearedMultiple, withAdditionalParameters: params) } else if ids.count > 0 { - Pixel.fire(pixel: .debugWebsiteDataStoresNotClearedOne) + Pixel.fire(pixel: .debugWebsiteDataStoresNotClearedOne, withAdditionalParameters: params) + } else if leftOversCount > 0 { + Pixel.fire(pixel: .debugWebsiteDataStoresCleared, withAdditionalParameters: params) } } @@ -113,10 +119,11 @@ extension WebCacheManager { dataStore = nil let uuids = await WKWebsiteDataStore.allDataStoreIdentifiers + let count = max(0, uuids.count - 1) // -1 because there should be a current store for uuid in uuids { try? await WKWebsiteDataStore.remove(forIdentifier: uuid) } - await checkForLeftBehindDataStores() + await checkForLeftBehindDataStores(leftOversCount: count) storeIdManager.allocateNewContainerId() return cookies