Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions PixelDefinitions/pixels/subscription_pixels.json5
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,24 @@
"enum": ["true", "false"]
}
]
},
"m_privacy-pro_app_subscription_active": {
Copy link
Contributor

@lmac012 lmac012 Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is always fired as a "daily" pixel, and as such, it has the _d suffix. This is not accounted for in this definition and will most likely cause validation errors. You could add "daily_count_short" to "suffixes", but this is never fired as a "count" type of pixel, so it's probably better to just include the type suffix in the name:

Suggested change
"m_privacy-pro_app_subscription_active": {
"m_privacy-pro_app_subscription_active_d": {

"description": "Fired once daily on app start for an active subscription",
"owners": ["lmac012"],
"triggers": ["other"],
"suffixes": ["form_factor"],
"parameters": [
"appVersion",
{
"key": "os_version",
"description": "OS version of the device",
"type": "integer"
},
{
"key": "petal",
"description": "Signals the pixel processing pipeline",
"type": "boolean"
}
Comment on lines +29 to +33
Copy link
Contributor

@lmac012 lmac012 Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the best practices here, but shouldn't we add "enum": ["true"] to indicate that this is the only possible value for the petal param? cc @nshuba

Regardless, I think it would make sense to add this parameter to params_dictionary.json, since it's not specific to this pixel and will likely get reused on other pixels as well.

]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum class SubscriptionPixel(
SUBSCRIPTION_ACTIVE(
baseName = "m_privacy-pro_app_subscription_active",
type = Daily(),
includedParameters = setOf(ATB, APP_VERSION),
includedParameters = setOf(APP_VERSION),
),
OFFER_SCREEN_SHOWN(
baseName = "m_privacy-pro_offer_screen_impression",
Expand Down Expand Up @@ -272,6 +272,8 @@ enum class SubscriptionPixel(
object SubscriptionPixelParameter {
const val ERROR_TYPE = "errorType"
const val REASON = "reason"
const val OS_VERSION = "os_version"
const val PETAL = "petal"
}

internal val PixelType.pixelNameSuffix: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ interface SubscriptionPixelSender {
fun reportSubscriptionActive()
fun reportOfferScreenShown()
fun reportOfferSubscribeClick()
fun reportPurchaseFailureOther(errorType: String, reason: String? = null)
fun reportPurchaseFailureOther(
errorType: String,
reason: String? = null,
)

fun reportPurchaseFailureStore(errorType: String)
fun reportPurchaseFailureBackend()
fun reportPurchaseFailureAccountCreation()
Expand Down Expand Up @@ -123,15 +127,24 @@ class SubscriptionPixelSenderImpl @Inject constructor(
) : SubscriptionPixelSender {

override fun reportSubscriptionActive() =
fire(SUBSCRIPTION_ACTIVE)
fire(
SUBSCRIPTION_ACTIVE,
mapOf(
SubscriptionPixelParameter.OS_VERSION to appBuildConfig.sdkInt.toString(),
SubscriptionPixelParameter.PETAL to "true",
),
)

override fun reportOfferScreenShown() =
fire(OFFER_SCREEN_SHOWN)

override fun reportOfferSubscribeClick() =
fire(OFFER_SUBSCRIBE_CLICK)

override fun reportPurchaseFailureOther(errorType: String, reason: String?) =
override fun reportPurchaseFailureOther(
errorType: String,
reason: String?,
) =
fire(
PURCHASE_FAILURE_OTHER,
mapOf(
Expand Down Expand Up @@ -280,7 +293,10 @@ class SubscriptionPixelSenderImpl @Inject constructor(
fire(SUBSCRIPTION_WEBVIEW_RENDER_PROCESS_CRASH, mapOf("is_repeated" to isRepeated.toString()))
}

private fun fire(pixel: SubscriptionPixel, params: Map<String, String> = emptyMap()) {
private fun fire(
pixel: SubscriptionPixel,
params: Map<String, String> = emptyMap(),
) {
pixel.getPixelNames().forEach { (pixelType, pixelName) ->
pixelSender.fire(pixelName = pixelName, type = pixelType, parameters = params)
}
Expand Down
Loading