From a4a7867a6c80506a5642c012da43beefab79b7dc Mon Sep 17 00:00:00 2001 From: Roger Yang Date: Wed, 26 Jan 2022 11:03:50 -0500 Subject: [PATCH] No issue: Add null as valid code --- .../mozilla/components/feature/search/telemetry/Utils.kt | 4 ++-- .../search/telemetry/incontent/InContentTelemetryTest.kt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) 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 4070a32126e..73812ceb0c1 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 @@ -20,7 +20,7 @@ private val validCodeSet = setOf( "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" + "ftas", "ftsa", "newext", "1000969a", null ) /** @@ -48,7 +48,7 @@ internal fun getTrackKey( // For Bug 1751920 if (!validCodeSet.contains(code)) { - code = null + code = "other" } // Glean doesn't allow code starting with a figure 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 1a6597863dd..4f21fdd5ee7 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 @@ -128,7 +128,7 @@ class InContentTelemetryTest { } @Test - fun `GIVEN a Bing search WHEN trackPartnerUrlTypeMetric is called THEN emit an appropriate IN_CONTENT_SEARCH fact`() { + fun `GIVEN an invalid Bing search WHEN trackPartnerUrlTypeMetric is called THEN emit an appropriate IN_CONTENT_SEARCH fact`() { val url = "https://www.bing.com/search?q=aaa&pc=MOZMBA" val facts = mutableListOf() Facts.registerProcessor(object : FactProcessor { @@ -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.none", facts[0].value) + assertEquals("bing.in-content.sap.other", facts[0].value) } @Test @@ -166,7 +166,7 @@ class InContentTelemetryTest { } @Test - fun `GIVEN a invalid Google sap-follow-on WHEN trackPartnerUrlTypeMetric is called THEN emit an appropriate IN_CONTENT_SEARCH fact`() { + fun `GIVEN an 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() Facts.registerProcessor(object : FactProcessor { @@ -181,7 +181,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("google.in-content.sap-follow-on.none", facts[0].value) + assertEquals("google.in-content.sap-follow-on.other", facts[0].value) } @Test