Skip to content

Commit fd28655

Browse files
authored
Enqueue free trial vpn activation pixel (#7721)
Task/Issue URL: https://app.asana.com/1/137249556945/task/1213218785316169 ### Description This PR fixes the issue where sending a pixel shortly after enabling VPN may fail. ### Steps to test this PR - [x] Apply patch on https://app.asana.com/1/137249556945/task/1210448620621729 - [x] Fresh install - [x] Purchase a test subscription (Free Trial) - [x] Before it expires activate VPN - [x] Check in logcat that `subscription_free_trial_vpn_activation` pixel is fired with the new `platform` parameter ### No UI changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Small, localized change to pixel delivery behavior; risk is limited to analytics event timing/delivery for pixels using the new `enqueue` flag. > > **Overview** > Adds an `enqueue` flag to `SubscriptionPixel` and updates `SubscriptionPixelSenderImpl.fire` to *conditionally* send pixels via `pixelSender.enqueueFire` instead of immediate `fire`. > > Marks `FREE_TRIAL_VPN_ACTIVATION` to use the queued send path, reducing the chance the pixel is lost when VPN is enabled and network conditions are transient. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit daeb405. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent a9f946c commit fd28655

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

subscriptions/subscriptions-impl/src/main/java/com/duckduckgo/subscriptions/impl/pixels/SubscriptionPixel.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ enum class SubscriptionPixel(
2929
private val types: Set<PixelType>,
3030
private val withSuffix: Boolean = true,
3131
val includedParameters: Set<PixelParameter> = emptySet(),
32+
val enqueue: Boolean = false,
3233
) {
3334
SUBSCRIPTION_ACTIVE(
3435
baseName = "m_privacy-pro_app_subscription_active",
@@ -265,6 +266,7 @@ enum class SubscriptionPixel(
265266
baseName = "subscription_free_trial_vpn_activation",
266267
type = Unique(),
267268
includedParameters = setOf(APP_VERSION),
269+
enqueue = true,
268270
),
269271
;
270272

@@ -273,7 +275,8 @@ enum class SubscriptionPixel(
273275
type: PixelType,
274276
withSuffix: Boolean = true,
275277
includedParameters: Set<PixelParameter> = emptySet(),
276-
) : this(baseName, setOf(type), withSuffix, includedParameters)
278+
enqueue: Boolean = false,
279+
) : this(baseName, setOf(type), withSuffix, includedParameters, enqueue)
277280

278281
fun getPixelNames(): Map<PixelType, String> =
279282
types.associateWith { type -> if (withSuffix) "${baseName}_${type.pixelNameSuffix}" else baseName }

subscriptions/subscriptions-impl/src/main/java/com/duckduckgo/subscriptions/impl/pixels/SubscriptionPixelSender.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ class SubscriptionPixelSenderImpl @Inject constructor(
312312
params: Map<String, String> = emptyMap(),
313313
) {
314314
pixel.getPixelNames().forEach { (pixelType, pixelName) ->
315-
pixelSender.fire(pixelName = pixelName, type = pixelType, parameters = params)
315+
if (pixel.enqueue) {
316+
pixelSender.enqueueFire(pixelName = pixelName, type = pixelType, parameters = params)
317+
} else {
318+
pixelSender.fire(pixelName = pixelName, type = pixelType, parameters = params)
319+
}
316320
}
317321
}
318322
}

0 commit comments

Comments
 (0)