Skip to content

Commit fcbc537

Browse files
committed
Integrate 21 day confirmation pixel
1 parent 4b9ed49 commit fcbc537

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

pir/pir-impl/src/main/java/com/duckduckgo/pir/impl/pixels/OptOutConfirmationReporter.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ class RealOptOutConfirmationReporter @Inject constructor(
7373
pirSchedulingRepository.markOptOutDay14ConfirmationPixelSent(jobRecord.extractedProfileId, now)
7474
},
7575
)
76+
77+
it.attemptFirePixelForConfirmationDay(
78+
activeBrokers,
79+
21,
80+
{ jobRecord -> jobRecord.confirmation21dayReportSentDateMs == 0L },
81+
{ brokerUrl -> pixelSender.reportBrokerOptOutConfirmed21Days(brokerUrl) },
82+
{ brokerUrl -> pixelSender.reportBrokerOptOutUnconfirmed21Days(brokerUrl) },
83+
{ jobRecord, now ->
84+
pirSchedulingRepository.markOptOutDay21ConfirmationPixelSent(jobRecord.extractedProfileId, now)
85+
},
86+
)
7687
}
7788
}
7889
}

pir/pir-impl/src/main/java/com/duckduckgo/pir/impl/store/PirSchedulingRepository.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ interface PirSchedulingRepository {
135135
extractedProfileId: Long,
136136
timestampMs: Long,
137137
)
138+
139+
suspend fun markOptOutDay21ConfirmationPixelSent(
140+
extractedProfileId: Long,
141+
timestampMs: Long,
142+
)
138143
}
139144

140145
@ContributesBinding(
@@ -348,6 +353,15 @@ class RealPirSchedulingRepository @Inject constructor(
348353
}
349354
}
350355

356+
override suspend fun markOptOutDay21ConfirmationPixelSent(
357+
extractedProfileId: Long,
358+
timestampMs: Long,
359+
) {
360+
withContext(dispatcherProvider.io()) {
361+
jobSchedulingDao()?.update21DayConfirmationReportSentDate(extractedProfileId, timestampMs)
362+
}
363+
}
364+
351365
private fun ScanJobRecordEntity.toRecord(): ScanJobRecord =
352366
ScanJobRecord(
353367
brokerName = this.brokerName,

pir/pir-impl/src/main/java/com/duckduckgo/pir/impl/store/db/JobSchedulingDao.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,16 @@ interface JobSchedulingDao {
142142
extractedProfileId: Long,
143143
newDate: Long,
144144
)
145+
146+
@Query(
147+
"""
148+
UPDATE pir_optout_job_record
149+
SET reporting_twentyOneDayConfirmationReportSentDateMs = :newDate
150+
WHERE extractedProfileId = :extractedProfileId
151+
""",
152+
)
153+
fun update21DayConfirmationReportSentDate(
154+
extractedProfileId: Long,
155+
newDate: Long,
156+
)
145157
}

0 commit comments

Comments
 (0)