From 1ead3fc60be5cd2f17f260260b6ef66ea8d88bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20=C5=9Apiewak?= Date: Thu, 12 Sep 2024 17:59:59 +0200 Subject: [PATCH] Remove checking for negative attribution case (#3355) Task/Issue URL: https://app.asana.com/0/414709148257752/1208213972615184/f Tech Design URL: CC: Description: Removes the negative attribution pixel report, since the data was already collected. --- Core/PixelEvent.swift | 2 -- .../AdAttributionPixelReporter.swift | 24 +++++++++---------- .../AdAttributionPixelReporterTests.swift | 7 ++---- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index e5cb5bcdf9..2afe5960b8 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -725,7 +725,6 @@ extension Pixel { // MARK: Apple Ad Attribution case appleAdAttribution - case appleAdAttributionNotAttributed // MARK: Secure Vault case secureVaultL1KeyMigration @@ -1446,7 +1445,6 @@ extension Pixel.Event { // MARK: - Apple Ad Attribution case .appleAdAttribution: return "m_apple-ad-attribution" - case .appleAdAttributionNotAttributed: return "m_apple-ad-attribution_not-attributed" // MARK: - User behavior case .userBehaviorReloadTwiceWithin12Seconds: return "m_reload-twice-within-12-seconds" diff --git a/DuckDuckGo/AdAttribution/AdAttributionPixelReporter.swift b/DuckDuckGo/AdAttribution/AdAttributionPixelReporter.swift index 24811b6fd0..a09eb9d693 100644 --- a/DuckDuckGo/AdAttribution/AdAttributionPixelReporter.swift +++ b/DuckDuckGo/AdAttribution/AdAttributionPixelReporter.swift @@ -22,7 +22,7 @@ import Core final actor AdAttributionPixelReporter { - static let isAdAttributionReportingEnabled = true + static let isAdAttributionReportingEnabled = false static var shared = AdAttributionPixelReporter() @@ -56,17 +56,17 @@ final actor AdAttributionPixelReporter { } if let (token, attributionData) = await self.attributionFetcher.fetch() { - let event: Pixel.Event = attributionData.attribution ? .appleAdAttribution : .appleAdAttributionNotAttributed - let parameters = attributionData.attribution ? self.pixelParametersForAttribution(attributionData, attributionToken: token) : [:] - - do { - try await pixelFiring.fire( - pixel: event, - withAdditionalParameters: parameters, - includedParameters: [.appVersion, .atb] - ) - } catch { - return false + if attributionData.attribution { + let parameters = self.pixelParametersForAttribution(attributionData, attributionToken: token) + do { + try await pixelFiring.fire( + pixel: .appleAdAttribution, + withAdditionalParameters: parameters, + includedParameters: [.appVersion, .atb] + ) + } catch { + return false + } } await fetcherStorage.markAttributionReportSuccessful() diff --git a/DuckDuckGoTests/AdAttributionPixelReporterTests.swift b/DuckDuckGoTests/AdAttributionPixelReporterTests.swift index 1c6a2a6d7c..eb21f4507b 100644 --- a/DuckDuckGoTests/AdAttributionPixelReporterTests.swift +++ b/DuckDuckGoTests/AdAttributionPixelReporterTests.swift @@ -124,16 +124,13 @@ final class AdAttributionPixelReporterTests: XCTestCase { XCTAssertNil(pixelAttributes["ad_id"]) } - func testNotAttributedPixelFiredAndMarkedReported_WhenAttributionFalse() async throws { + func testPixelNotFiredAndMarksReport_WhenAttributionFalse() async { let sut = createSUT() attributionFetcher.fetchResponse = ("example", AdServicesAttributionResponse(attribution: false)) let result = await sut.reportAttributionIfNeeded() - let pixelAttributes = try XCTUnwrap(PixelFiringMock.lastParams) - - XCTAssertEqual(pixelAttributes, [:]) - XCTAssertEqual(PixelFiringMock.lastPixel?.name, "m_apple-ad-attribution_not-attributed") + XCTAssertNil(PixelFiringMock.lastPixel) XCTAssertTrue(fetcherStorage.wasAttributionReportSuccessful) XCTAssertTrue(result) }