diff --git a/components/feature/search/src/main/java/mozilla/components/feature/search/telemetry/Utils.kt b/components/feature/search/src/main/java/mozilla/components/feature/search/telemetry/Utils.kt index 73812ceb0c1..0841e001628 100644 --- a/components/feature/search/src/main/java/mozilla/components/feature/search/telemetry/Utils.kt +++ b/components/feature/search/src/main/java/mozilla/components/feature/search/telemetry/Utils.kt @@ -22,6 +22,7 @@ private val validCodeSet = setOf( "ffab", "ffcm", "ffhp", "ffip", "ffit", "ffnt", "ffocus", "ffos", "ffsb", "fpas", "fpsa", "ftas", "ftsa", "newext", "1000969a", null ) +private val validChannelSet = setOf("ts") /** * Get a String in a specific format allowing to identify how an ads/search provider was used. @@ -70,7 +71,13 @@ internal fun getTrackKey( // For Bing if it didn't have a valid cookie and for all the other search engines if (hasValidCode(uri.getQueryParameter(provider.codeParam), provider)) { - val channel = uri.getQueryParameter(CHANNEL_KEY) + var channel = uri.getQueryParameter(CHANNEL_KEY) + + // For Bug 1751955 + if (!validChannelSet.contains(channel)) { + channel = null + } + val type = getSapType(provider.followOnParams, paramSet) return TrackKeyInfo(provider.name, type, code, channel).createTrackKey() } diff --git a/components/feature/search/src/test/java/mozilla/components/feature/search/telemetry/incontent/InContentTelemetryTest.kt b/components/feature/search/src/test/java/mozilla/components/feature/search/telemetry/incontent/InContentTelemetryTest.kt index 4f21fdd5ee7..b2373cee91f 100644 --- a/components/feature/search/src/test/java/mozilla/components/feature/search/telemetry/incontent/InContentTelemetryTest.kt +++ b/components/feature/search/src/test/java/mozilla/components/feature/search/telemetry/incontent/InContentTelemetryTest.kt @@ -203,6 +203,25 @@ class InContentTelemetryTest { assertEquals("google.in-content.sap-follow-on.firefox-b-m.ts", facts[0].value) } + @Test + fun `GIVEN an invalid Google channel from topSite WHEN trackPartnerUrlTypeMetric is called THEN emit an appropriate IN_CONTENT_SEARCH fact`() { + val url = "https://www.google.com/search?q=aaa&client=firefox-b-m&channel=tsTest&oq=random" + val facts = mutableListOf() + Facts.registerProcessor(object : FactProcessor { + override fun process(fact: Fact) { + facts.add(fact) + } + }) + + telemetry.trackPartnerUrlTypeMetric(url, listOf()) + + assertEquals(1, facts.size) + assertEquals(Component.FEATURE_SEARCH, facts[0].component) + assertEquals(Action.INTERACTION, facts[0].action) + assertEquals(InContentTelemetry.IN_CONTENT_SEARCH, facts[0].item) + assertEquals("google.in-content.sap-follow-on.firefox-b-m", facts[0].value) + } + @Test fun `GIVEN a Baidu sap-follow-on WHEN trackPartnerUrlTypeMetric is called THEN emit an appropriate IN_CONTENT_SEARCH fact`() { val url = "https://m.baidu.com/s?from=1000969a&word=aaa&oq=random"