File tree Expand file tree Collapse file tree 10 files changed +36
-22
lines changed
app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/pixels
app/src/androidTest/java/com/duckduckgo/app
autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/engagement
network-protection/network-protection-impl/src/main/java/com/duckduckgo/networkprotection/impl/pixels
main/java/com/duckduckgo/app/statistics
test/java/com/duckduckgo/app/statistics/api
subscriptions/subscriptions-impl/src/main/java/com/duckduckgo/subscriptions/impl/pixels Expand file tree Collapse file tree 10 files changed +36
-22
lines changed Original file line number Diff line number Diff line change 1717package com.duckduckgo.mobile.android.vpn.pixels
1818
1919import com.duckduckgo.app.di.AppCoroutineScope
20- import com.duckduckgo.app.statistics.api.RefreshRetentionAtbPlugin
20+ import com.duckduckgo.app.statistics.api.AtbLifecyclePlugin
2121import com.duckduckgo.common.utils.DispatcherProvider
2222import com.duckduckgo.di.scopes.AppScope
2323import com.duckduckgo.mobile.android.vpn.AppTpVpnFeature
@@ -33,7 +33,7 @@ class DeviceShieldRetentionPixelSender @Inject constructor(
3333 private val vpnFeaturesRegistry : VpnFeaturesRegistry ,
3434 @AppCoroutineScope private val coroutineScope : CoroutineScope ,
3535 private val dispatcherProvider : DispatcherProvider ,
36- ) : RefreshRetentionAtbPlugin {
36+ ) : AtbLifecyclePlugin {
3737
3838 override fun onSearchRetentionAtbRefreshed () {
3939 coroutineScope.launch(dispatcherProvider.io()) {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ package com.duckduckgo.app.integration
1919import androidx.test.filters.LargeTest
2020import androidx.test.platform.app.InstrumentationRegistry
2121import com.duckduckgo.app.getDaggerComponent
22- import com.duckduckgo.app.statistics.api.RefreshRetentionAtbPlugin
22+ import com.duckduckgo.app.statistics.api.AtbLifecyclePlugin
2323import com.duckduckgo.app.statistics.api.StatisticsRequester
2424import com.duckduckgo.app.statistics.api.StatisticsService
2525import com.duckduckgo.app.statistics.model.Atb
@@ -68,8 +68,8 @@ class AtbIntegrationTest {
6868 whenever(mockVariantManager.getVariantKey()).thenReturn(" ma" )
6969 service = getDaggerComponent().retrofit().create(StatisticsService ::class .java)
7070
71- val plugins = object : PluginPoint <RefreshRetentionAtbPlugin > {
72- override fun getPlugins (): Collection <RefreshRetentionAtbPlugin > {
71+ val plugins = object : PluginPoint <AtbLifecyclePlugin > {
72+ override fun getPlugins (): Collection <AtbLifecyclePlugin > {
7373 return listOf ()
7474 }
7575 }
Original file line number Diff line number Diff line change @@ -74,8 +74,8 @@ class StatisticsRequesterJsonTest {
7474 statisticsStore = StatisticsSharedPreferences (InstrumentationRegistry .getInstrumentation().targetContext)
7575 statisticsStore.clearAtb()
7676
77- val plugins = object : PluginPoint <RefreshRetentionAtbPlugin > {
78- override fun getPlugins (): Collection <RefreshRetentionAtbPlugin > {
77+ val plugins = object : PluginPoint <AtbLifecyclePlugin > {
78+ override fun getPlugins (): Collection <AtbLifecyclePlugin > {
7979 return listOf ()
8080 }
8181 }
Original file line number Diff line number Diff line change 1717package com.duckduckgo.autofill.impl.engagement
1818
1919import com.duckduckgo.app.di.AppCoroutineScope
20- import com.duckduckgo.app.statistics.api.RefreshRetentionAtbPlugin
20+ import com.duckduckgo.app.statistics.api.AtbLifecyclePlugin
2121import com.duckduckgo.autofill.impl.engagement.store.AutofillEngagementRepository
2222import com.duckduckgo.common.utils.DispatcherProvider
2323import com.duckduckgo.di.scopes.AppScope
@@ -31,7 +31,7 @@ class AutofillRefreshRetentionListener @Inject constructor(
3131 private val engagementRepository : AutofillEngagementRepository ,
3232 @AppCoroutineScope private val coroutineScope : CoroutineScope ,
3333 private val dispatchers : DispatcherProvider ,
34- ) : RefreshRetentionAtbPlugin {
34+ ) : AtbLifecyclePlugin {
3535
3636 override fun onSearchRetentionAtbRefreshed () {
3737 coroutineScope.launch(dispatchers.io()) {
Original file line number Diff line number Diff line change 1717package com.duckduckgo.networkprotection.impl.pixels
1818
1919import com.duckduckgo.app.di.AppCoroutineScope
20- import com.duckduckgo.app.statistics.api.RefreshRetentionAtbPlugin
20+ import com.duckduckgo.app.statistics.api.AtbLifecyclePlugin
2121import com.duckduckgo.common.utils.DispatcherProvider
2222import com.duckduckgo.di.scopes.AppScope
2323import com.duckduckgo.networkprotection.api.NetworkProtectionState
@@ -32,7 +32,7 @@ class NetworkProtectionRetentionPixelSender @Inject constructor(
3232 private val networkProtectionPixels : NetworkProtectionPixels ,
3333 @AppCoroutineScope private val coroutineScope : CoroutineScope ,
3434 private val dispatcherProvider : DispatcherProvider ,
35- ) : RefreshRetentionAtbPlugin {
35+ ) : AtbLifecyclePlugin {
3636
3737 override fun onSearchRetentionAtbRefreshed () {
3838 coroutineScope.launch(dispatcherProvider.io()) {
Original file line number Diff line number Diff line change @@ -20,14 +20,25 @@ import com.duckduckgo.anvil.annotations.ContributesPluginPoint
2020import com.duckduckgo.di.scopes.AppScope
2121
2222@ContributesPluginPoint(AppScope ::class )
23- interface RefreshRetentionAtbPlugin {
23+ interface AtbLifecyclePlugin {
2424 /* *
2525 * Will be called right after we have refreshed the ATB retention on search
2626 */
27- fun onSearchRetentionAtbRefreshed ()
27+ fun onSearchRetentionAtbRefreshed () {
28+ // default is no-op
29+ }
2830
2931 /* *
3032 * Will be called right after we have refreshed the ATB retention on search
3133 */
32- fun onAppRetentionAtbRefreshed ()
34+ fun onAppRetentionAtbRefreshed () {
35+ // default is no-op
36+ }
37+
38+ /* *
39+ * Will be called right after the ATB is first initialized and successfully sent via exti call
40+ */
41+ fun onAppAtbInitialized () {
42+ // default is no-op
43+ }
3344}
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class StatisticsRequester @Inject constructor(
4343 private val store : StatisticsDataStore ,
4444 private val service : StatisticsService ,
4545 private val variantManager : VariantManager ,
46- private val plugins : PluginPoint <RefreshRetentionAtbPlugin >,
46+ private val plugins : PluginPoint <AtbLifecyclePlugin >,
4747 private val emailManager : EmailManager ,
4848 @AppCoroutineScope private val appCoroutineScope : CoroutineScope ,
4949 private val dispatchers : DispatcherProvider ,
@@ -86,7 +86,10 @@ class StatisticsRequester @Inject constructor(
8686 service.exti(atbWithVariant)
8787 }
8888 .subscribe(
89- { Timber .d(" Atb initialization succeeded" ) },
89+ {
90+ Timber .d(" Atb initialization succeeded" )
91+ plugins.getPlugins().forEach { it.onAppAtbInitialized() }
92+ },
9093 {
9194 store.clearAtb()
9295 Timber .w(" Atb initialization failed ${it.localizedMessage} " )
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ import android.content.Context
2020import android.content.SharedPreferences
2121import androidx.core.content.edit
2222import com.duckduckgo.app.di.AppCoroutineScope
23+ import com.duckduckgo.app.statistics.api.AtbLifecyclePlugin
2324import com.duckduckgo.app.statistics.api.BrowserFeatureStateReporterPlugin
24- import com.duckduckgo.app.statistics.api.RefreshRetentionAtbPlugin
2525import com.duckduckgo.app.statistics.pixels.Pixel.PixelParameter.LOCALE
2626import com.duckduckgo.app.statistics.pixels.Pixel.StatisticsPixelName
2727import com.duckduckgo.appbuildconfig.api.AppBuildConfig
@@ -45,7 +45,7 @@ class FeatureRetentionPixelSender @Inject constructor(
4545 private val dispatcherProvider : DispatcherProvider ,
4646 private val plugins : PluginPoint <BrowserFeatureStateReporterPlugin >,
4747 private val appBuildConfig : AppBuildConfig ,
48- ) : RefreshRetentionAtbPlugin {
48+ ) : AtbLifecyclePlugin {
4949
5050 private val preferences: SharedPreferences by lazy { context.getSharedPreferences(PIXELS_PREF_FILE , Context .MODE_PRIVATE ) }
5151
Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ class StatisticsRequesterTest {
4444 private var mockVariantManager: VariantManager = mock()
4545 private val mockEmailManager: EmailManager = mock()
4646
47- private val plugins = object : PluginPoint <RefreshRetentionAtbPlugin > {
48- override fun getPlugins (): Collection <RefreshRetentionAtbPlugin > {
47+ private val plugins = object : PluginPoint <AtbLifecyclePlugin > {
48+ override fun getPlugins (): Collection <AtbLifecyclePlugin > {
4949 return listOf ()
5050 }
5151 }
Original file line number Diff line number Diff line change 1717package com.duckduckgo.subscriptions.impl.pixels
1818
1919import com.duckduckgo.app.di.AppCoroutineScope
20- import com.duckduckgo.app.statistics.api.RefreshRetentionAtbPlugin
20+ import com.duckduckgo.app.statistics.api.AtbLifecyclePlugin
2121import com.duckduckgo.di.scopes.AppScope
2222import com.duckduckgo.subscriptions.impl.SubscriptionsManager
2323import com.duckduckgo.subscriptions.impl.repository.isActive
@@ -31,7 +31,7 @@ class SubscriptionRefreshRetentionAtbPlugin @Inject constructor(
3131 @AppCoroutineScope private val coroutineScope : CoroutineScope ,
3232 private val subscriptionsManager : SubscriptionsManager ,
3333 private val pixelSender : SubscriptionPixelSender ,
34- ) : RefreshRetentionAtbPlugin {
34+ ) : AtbLifecyclePlugin {
3535
3636 override fun onSearchRetentionAtbRefreshed () = Unit // no-op
3737
You can’t perform that action at this time.
0 commit comments