Skip to content

Commit

Permalink
Remove checking for negative attribution case (#3355)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dus7 authored Sep 12, 2024
1 parent 966fa49 commit 1ead3fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
2 changes: 0 additions & 2 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,6 @@ extension Pixel {

// MARK: Apple Ad Attribution
case appleAdAttribution
case appleAdAttributionNotAttributed

// MARK: Secure Vault
case secureVaultL1KeyMigration
Expand Down Expand Up @@ -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"
Expand Down
24 changes: 12 additions & 12 deletions DuckDuckGo/AdAttribution/AdAttributionPixelReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Core

final actor AdAttributionPixelReporter {

static let isAdAttributionReportingEnabled = true
static let isAdAttributionReportingEnabled = false

static var shared = AdAttributionPixelReporter()

Expand Down Expand Up @@ -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()
Expand Down
7 changes: 2 additions & 5 deletions DuckDuckGoTests/AdAttributionPixelReporterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 1ead3fc

Please sign in to comment.