Skip to content

Commit acd4f9a

Browse files
committed
Add pixel and pixel send for broker optout success rate
1 parent dbefa07 commit acd4f9a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ enum class PirPixel(
135135
PIR_OPTOUT_SUBMIT_FAILURE(
136136
baseName = "dbp_optout_process_failure",
137137
types = setOf(Count),
138+
),
139+
140+
PIR_BROKER_CUSTOM_STATS_OPTOUT_SUBMIT_SUCCESSRATE(
141+
baseName = "dbp_databroker_custom_stats_optoutsubmit",
142+
type = Count,
138143
), ;
139144

140145
constructor(

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.duckduckgo.pir.impl.pixels
1818

1919
import com.duckduckgo.app.statistics.pixels.Pixel
2020
import com.duckduckgo.di.scopes.AppScope
21+
import com.duckduckgo.pir.impl.pixels.PirPixel.PIR_BROKER_CUSTOM_STATS_OPTOUT_SUBMIT_SUCCESSRATE
2122
import com.duckduckgo.pir.impl.pixels.PirPixel.PIR_EMAIL_CONFIRMATION_ATTEMPT_FAILED
2223
import com.duckduckgo.pir.impl.pixels.PirPixel.PIR_EMAIL_CONFIRMATION_ATTEMPT_START
2324
import com.duckduckgo.pir.impl.pixels.PirPixel.PIR_EMAIL_CONFIRMATION_ATTEMPT_SUCCESS
@@ -321,6 +322,17 @@ interface PirPixelSender {
321322
* Emits a pixel to signal that PIR encrypted database is unavailable.
322323
*/
323324
fun reportSecureStorageUnavailable()
325+
326+
/**
327+
* Emits a pixel containing the opt-out submit success rate for a broker for the last 24 hours
328+
*
329+
* @param brokerUrl url of the Broker for which the opt-out submit rate is for
330+
* @param optOutSuccessRate opt out submit success rate for the past 24 hours
331+
*/
332+
fun reportBrokerCustomStateOptOutSubmitRate(
333+
brokerUrl: String,
334+
optOutSuccessRate: Double,
335+
)
324336
}
325337

326338
@ContributesBinding(AppScope::class)
@@ -603,6 +615,18 @@ class RealPirPixelSender @Inject constructor(
603615
fire(PIR_INTERNAL_SECURE_STORAGE_UNAVAILABLE)
604616
}
605617

618+
override fun reportBrokerCustomStateOptOutSubmitRate(
619+
brokerUrl: String,
620+
optOutSuccessRate: Double,
621+
) {
622+
val params = mapOf(
623+
PARAM_KEY_BROKER to brokerUrl,
624+
PARAM_KEY_OPTOUT_SUBMIT_SUCCESS_RATE to optOutSuccessRate.toString(),
625+
)
626+
627+
fire(PIR_BROKER_CUSTOM_STATS_OPTOUT_SUBMIT_SUCCESSRATE, params)
628+
}
629+
606630
private fun fire(
607631
pixel: PirPixel,
608632
params: Map<String, String> = emptyMap(),
@@ -638,5 +662,6 @@ class RealPirPixelSender @Inject constructor(
638662
private const val PARAM_KEY_STAGE = "stage"
639663
private const val PARAM_KEY_PATTERN = "pattern"
640664
private const val PARAM_KEY_ACTION_TYPE = "action_type"
665+
private const val PARAM_KEY_OPTOUT_SUBMIT_SUCCESS_RATE = "optout_submit_success_rate"
641666
}
642667
}

0 commit comments

Comments
 (0)