|
17 | 17 | package com.duckduckgo.app.widget.experiment |
18 | 18 |
|
19 | 19 | import com.duckduckgo.anvil.annotations.ContributesRemoteFeature |
20 | | -import com.duckduckgo.app.widget.experiment.PostCtaExperienceToggles.Companion.BASE_EXPERIMENT_NAME |
21 | 20 | import com.duckduckgo.di.scopes.AppScope |
22 | | -import com.duckduckgo.feature.toggles.api.ConversionWindow |
23 | | -import com.duckduckgo.feature.toggles.api.MetricsPixel |
24 | | -import com.duckduckgo.feature.toggles.api.MetricsPixelPlugin |
25 | 21 | import com.duckduckgo.feature.toggles.api.Toggle |
26 | | -import com.duckduckgo.feature.toggles.api.Toggle.State.CohortName |
27 | | -import com.squareup.anvil.annotations.ContributesMultibinding |
28 | | -import dagger.SingleInstanceIn |
29 | | -import javax.inject.Inject |
30 | 22 |
|
31 | 23 | @ContributesRemoteFeature( |
32 | 24 | scope = AppScope::class, |
33 | | - featureName = BASE_EXPERIMENT_NAME, |
| 25 | + featureName = "postCtaExperience", |
34 | 26 | ) |
35 | 27 | interface PostCtaExperienceToggles { |
36 | 28 |
|
37 | 29 | @Toggle.DefaultValue(Toggle.DefaultFeatureValue.FALSE) |
38 | 30 | fun self(): Toggle |
39 | 31 |
|
40 | 32 | @Toggle.DefaultValue(Toggle.DefaultFeatureValue.FALSE) |
41 | | - fun postCtaExperienceExperimentJun25(): Toggle |
42 | | - |
43 | | - enum class Cohorts(override val cohortName: String) : CohortName { |
44 | | - CONTROL("control"), // Search and Favorites widget prompt |
45 | | - VARIANT_SIMPLE_SEARCH_WIDGET_PROMPT("simpleSearchWidgetPrompt"), // Simple Search widget prompt |
46 | | - } |
47 | | - |
48 | | - companion object { |
49 | | - internal const val BASE_EXPERIMENT_NAME = "postCtaExperience" |
50 | | - } |
51 | | -} |
52 | | - |
53 | | -@ContributesMultibinding(AppScope::class) |
54 | | -@SingleInstanceIn(AppScope::class) |
55 | | -class PostCtaExperiencePixelsPlugin @Inject constructor( |
56 | | - private val toggles: PostCtaExperienceToggles, |
57 | | -) : MetricsPixelPlugin { |
58 | | - |
59 | | - override suspend fun getMetrics(): List<MetricsPixel> { |
60 | | - return listOf( |
61 | | - MetricsPixel( |
62 | | - metric = METRIC_SETTINGS_WIDGET_DISPLAY, |
63 | | - value = "1", |
64 | | - toggle = toggles.postCtaExperienceExperimentJun25(), |
65 | | - conversionWindow = listOf( |
66 | | - ConversionWindow(lowerWindow = 0, upperWindow = 0), |
67 | | - ), |
68 | | - ), |
69 | | - MetricsPixel( |
70 | | - metric = METRIC_SETTINGS_WIDGET_ADD, |
71 | | - value = "1", |
72 | | - toggle = toggles.postCtaExperienceExperimentJun25(), |
73 | | - conversionWindow = listOf( |
74 | | - ConversionWindow(lowerWindow = 0, upperWindow = 0), |
75 | | - ), |
76 | | - ), |
77 | | - MetricsPixel( |
78 | | - metric = METRIC_SETTINGS_WIDGET_DISMISS, |
79 | | - value = "1", |
80 | | - toggle = toggles.postCtaExperienceExperimentJun25(), |
81 | | - conversionWindow = listOf( |
82 | | - ConversionWindow(lowerWindow = 0, upperWindow = 0), |
83 | | - ), |
84 | | - ), |
85 | | - MetricsPixel( |
86 | | - metric = METRIC_WIDGET_SEARCH, |
87 | | - value = "1", |
88 | | - toggle = toggles.postCtaExperienceExperimentJun25(), |
89 | | - conversionWindow = listOf( |
90 | | - ConversionWindow(lowerWindow = 5, upperWindow = 7), |
91 | | - ConversionWindow(lowerWindow = 8, upperWindow = 14), |
92 | | - ), |
93 | | - ), |
94 | | - MetricsPixel( |
95 | | - metric = METRIC_WIDGET_SEARCH_3X, |
96 | | - value = "1", |
97 | | - toggle = toggles.postCtaExperienceExperimentJun25(), |
98 | | - conversionWindow = listOf( |
99 | | - ConversionWindow(lowerWindow = 5, upperWindow = 7), |
100 | | - ), |
101 | | - ), |
102 | | - MetricsPixel( |
103 | | - metric = METRIC_WIDGET_SEARCH_5X, |
104 | | - value = "1", |
105 | | - toggle = toggles.postCtaExperienceExperimentJun25(), |
106 | | - conversionWindow = listOf( |
107 | | - ConversionWindow(lowerWindow = 5, upperWindow = 7), |
108 | | - ), |
109 | | - ), |
110 | | - ) |
111 | | - } |
112 | | - |
113 | | - suspend fun getSettingsWidgetDisplayMetric(): MetricsPixel? { |
114 | | - return this.getMetrics().firstOrNull { it.metric == METRIC_SETTINGS_WIDGET_DISPLAY } |
115 | | - } |
116 | | - |
117 | | - suspend fun getSettingsWidgetAddMetric(): MetricsPixel? { |
118 | | - return this.getMetrics().firstOrNull { it.metric == METRIC_SETTINGS_WIDGET_ADD } |
119 | | - } |
120 | | - |
121 | | - suspend fun getSettingsWidgetDismissMetric(): MetricsPixel? { |
122 | | - return this.getMetrics().firstOrNull { it.metric == METRIC_SETTINGS_WIDGET_DISMISS } |
123 | | - } |
124 | | - |
125 | | - suspend fun getWidgetSearchMetric(): MetricsPixel? { |
126 | | - return this.getMetrics().firstOrNull { it.metric == METRIC_WIDGET_SEARCH } |
127 | | - } |
128 | | - |
129 | | - suspend fun getWidgetSearch3xMetric(): MetricsPixel? { |
130 | | - return this.getMetrics().firstOrNull { it.metric == METRIC_WIDGET_SEARCH_3X } |
131 | | - } |
132 | | - |
133 | | - suspend fun getWidgetSearch5xMetric(): MetricsPixel? { |
134 | | - return this.getMetrics().firstOrNull { it.metric == METRIC_WIDGET_SEARCH_5X } |
135 | | - } |
136 | | - |
137 | | - companion object { |
138 | | - internal const val METRIC_SETTINGS_WIDGET_DISPLAY = "settingsWidgetDisplay" |
139 | | - internal const val METRIC_SETTINGS_WIDGET_ADD = "settingsWidgetAdd" |
140 | | - internal const val METRIC_SETTINGS_WIDGET_DISMISS = "settingsWidgetDismiss" |
141 | | - internal const val METRIC_WIDGET_SEARCH = "widgetSearch" |
142 | | - internal const val METRIC_WIDGET_SEARCH_3X = "widgetSearch3x" |
143 | | - internal const val METRIC_WIDGET_SEARCH_5X = "widgetSearch5x" |
144 | | - } |
| 33 | + fun simpleSearchWidgetPrompt(): Toggle |
145 | 34 | } |
0 commit comments