Loading components/feature/search/src/main/java/mozilla/components/feature/search/telemetry/Utils.kt +16 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,17 @@ private const val SEARCH_TYPE_SAP_FOLLOW_ON = "sap-follow-on" private const val SEARCH_TYPE_SAP = "sap" private const val SEARCH_TYPE_ORGANIC = "organic" private const val CHANNEL_KEY = "channel" private val validCodeSet = setOf( "MOZ2", "MOZ4", "MOZ5", "MOZA", "MOZB", "MOZD", "MOZE", "MOZI", "MOZM", "MOZO", "MOZT", "MOZW", "MOZSL01", "MOZSL02", "MOZSL03", "monline_dg", "monline_3_dg", "monline_4_dg", "monline_7_dg", "firefox-a", "firefox-b", "firefox-b-1", "firefox-b-ab", "firefox-b-1-ab", "firefox-b-d", "firefox-b-1-d", "firefox-b-e", "firefox-b-1-e", "firefox-b-m", "firefox-b-1-m", "firefox-b-o", "firefox-b-1-o", "firefox-b-lm", "firefox-b-1-lm", "firefox-b-lg", "firefox-b-huawei-h1611", "firefox-b-is-oem1", "firefox-b-oem1", "firefox-b-oem2", "firefox-b-tinno", "firefox-b-pn-wt", "firefox-b-pn-wt-us", "ubuntu", "ffab", "ffcm", "ffhp", "ffip", "ffit", "ffnt", "ffocus", "ffos", "ffsb", "fpas", "fpsa", "ftas", "ftsa", "newext", "1000969a" ) /** * Get a String in a specific format allowing to identify how an ads/search provider was used. Loading @@ -35,6 +46,11 @@ internal fun getTrackKey( .substringBefore("/", "") } // For Bug 1751920 if (!validCodeSet.contains(code)) { code = null } // Glean doesn't allow code starting with a figure if (code != null && code.isNotEmpty()) { val codeStart = code.first() Loading components/feature/search/src/test/java/mozilla/components/feature/search/telemetry/incontent/InContentTelemetryTest.kt +20 −1 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ class InContentTelemetryTest { assertEquals(Component.FEATURE_SEARCH, facts[0].component) assertEquals(Action.INTERACTION, facts[0].action) assertEquals(InContentTelemetry.IN_CONTENT_SEARCH, facts[0].item) assertEquals("bing.in-content.sap.mozmba", facts[0].value) assertEquals("bing.in-content.sap.none", facts[0].value) } @Test Loading @@ -165,6 +165,25 @@ class InContentTelemetryTest { assertEquals("google.in-content.sap-follow-on.firefox-b-m", facts[0].value) } @Test fun `GIVEN a invalid Google sap-follow-on WHEN trackPartnerUrlTypeMetric is called THEN emit an appropriate IN_CONTENT_SEARCH fact`() { val url = "https://www.google.com/search?q=aaa&client=firefox-b-mTesting&oq=random" val facts = mutableListOf<Fact>() 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.none", facts[0].value) } @Test fun `GIVEN a Google sap-follow-on 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=ts&oq=random" Loading Loading
components/feature/search/src/main/java/mozilla/components/feature/search/telemetry/Utils.kt +16 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,17 @@ private const val SEARCH_TYPE_SAP_FOLLOW_ON = "sap-follow-on" private const val SEARCH_TYPE_SAP = "sap" private const val SEARCH_TYPE_ORGANIC = "organic" private const val CHANNEL_KEY = "channel" private val validCodeSet = setOf( "MOZ2", "MOZ4", "MOZ5", "MOZA", "MOZB", "MOZD", "MOZE", "MOZI", "MOZM", "MOZO", "MOZT", "MOZW", "MOZSL01", "MOZSL02", "MOZSL03", "monline_dg", "monline_3_dg", "monline_4_dg", "monline_7_dg", "firefox-a", "firefox-b", "firefox-b-1", "firefox-b-ab", "firefox-b-1-ab", "firefox-b-d", "firefox-b-1-d", "firefox-b-e", "firefox-b-1-e", "firefox-b-m", "firefox-b-1-m", "firefox-b-o", "firefox-b-1-o", "firefox-b-lm", "firefox-b-1-lm", "firefox-b-lg", "firefox-b-huawei-h1611", "firefox-b-is-oem1", "firefox-b-oem1", "firefox-b-oem2", "firefox-b-tinno", "firefox-b-pn-wt", "firefox-b-pn-wt-us", "ubuntu", "ffab", "ffcm", "ffhp", "ffip", "ffit", "ffnt", "ffocus", "ffos", "ffsb", "fpas", "fpsa", "ftas", "ftsa", "newext", "1000969a" ) /** * Get a String in a specific format allowing to identify how an ads/search provider was used. Loading @@ -35,6 +46,11 @@ internal fun getTrackKey( .substringBefore("/", "") } // For Bug 1751920 if (!validCodeSet.contains(code)) { code = null } // Glean doesn't allow code starting with a figure if (code != null && code.isNotEmpty()) { val codeStart = code.first() Loading
components/feature/search/src/test/java/mozilla/components/feature/search/telemetry/incontent/InContentTelemetryTest.kt +20 −1 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ class InContentTelemetryTest { assertEquals(Component.FEATURE_SEARCH, facts[0].component) assertEquals(Action.INTERACTION, facts[0].action) assertEquals(InContentTelemetry.IN_CONTENT_SEARCH, facts[0].item) assertEquals("bing.in-content.sap.mozmba", facts[0].value) assertEquals("bing.in-content.sap.none", facts[0].value) } @Test Loading @@ -165,6 +165,25 @@ class InContentTelemetryTest { assertEquals("google.in-content.sap-follow-on.firefox-b-m", facts[0].value) } @Test fun `GIVEN a invalid Google sap-follow-on WHEN trackPartnerUrlTypeMetric is called THEN emit an appropriate IN_CONTENT_SEARCH fact`() { val url = "https://www.google.com/search?q=aaa&client=firefox-b-mTesting&oq=random" val facts = mutableListOf<Fact>() 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.none", facts[0].value) } @Test fun `GIVEN a Google sap-follow-on 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=ts&oq=random" Loading