Skip to content

Commit 7bb0755

Browse files
authored
Rq Pixel should only be fired in SERP Header removal experiment (#875)
* this pixel should only be fired in the serp header removal variant
1 parent a8885d4 commit 7bb0755

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ import kotlinx.coroutines.Job
9292
import kotlinx.coroutines.launch
9393
import kotlinx.coroutines.withContext
9494
import timber.log.Timber
95-
import java.lang.UnsupportedOperationException
9695
import java.util.Locale
9796
import java.util.concurrent.TimeUnit
9897

@@ -451,25 +450,19 @@ class BrowserTabViewModel(
451450
}
452451

453452
private fun fireQueryChangedPixel(omnibarText: String) {
454-
val oldUri = currentOmnibarViewState().omnibarText.toUri()
455-
val newUri = omnibarText.toUri()
456-
457-
val oldParameter = try {
458-
oldUri.getQueryParameter(AppUrl.ParamKey.QUERY)
459-
} catch (e: UnsupportedOperationException) {
460-
null
461-
}
462-
val newParameter = try {
463-
newUri.getQueryParameter(AppUrl.ParamKey.QUERY)
464-
} catch (e: UnsupportedOperationException) {
465-
null
453+
if (!variantManager.getVariant().hasFeature(VariantManager.VariantFeature.SerpHeaderRemoval)) {
454+
return
466455
}
467456

468-
if (oldParameter == newParameter) {
457+
val oldQuery = currentOmnibarViewState().omnibarText.toUri()
458+
val newQuery = omnibarText.toUri()
459+
460+
if (oldQuery == newQuery) {
469461
pixel.fire(String.format(Locale.US, PixelName.SERP_REQUERY.pixelName, PixelParameter.SERP_QUERY_NOT_CHANGED))
470462
} else {
471463
pixel.fire(String.format(Locale.US, PixelName.SERP_REQUERY.pixelName, PixelParameter.SERP_QUERY_CHANGED))
472464
}
465+
473466
}
474467

475468
private fun shouldClearHistoryOnNewQuery(): Boolean {

0 commit comments

Comments
 (0)