From f9edcd68b146f744fa47dad68d206e1cbcc007e1 Mon Sep 17 00:00:00 2001 From: Daosheng Mu Date: Tue, 2 Jun 2020 03:15:26 -0700 Subject: [PATCH] Resolve label metrics are _other_ and add legacy client id (#3384) * Fixes FxA.receivedTab and Tab.opened metric are null in the dataset. * Add legacy client id in deletion request ping of Glean. --- app/metrics.yaml | 20 ++++++++++++++++- .../telemetry/GleanMetricsService.java | 9 ++++++-- .../vrbrowser/GleanMetricsServiceTest.kt | 22 ++++++++++++++----- docs/metrics.md | 9 ++++++++ 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index 32275c72c..6d155db58 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -80,7 +80,8 @@ searches: counts: type: labeled_counter description: > - Counting how many searches are queried in a specific search engine. The search engine `identifier`s are used as keys for this metric. + Counting how many searches are queried in a specific search engine. + The search engine `identifier`s are used as keys for this metric. bugs: - https://github.com/MozillaReality/FirefoxReality/issues/2230 data_reviews: @@ -254,3 +255,20 @@ control: - fxr-telemetry@mozilla.com - dmu@mozilla.com expires: "2020-11-01" + +legacy_telemetry: + client_id: + type: uuid + description: > + A UUID uniquely identifying the legacy telemetry client id. + This is used for supporting legacy telemetry in the `deletion-request` ping. + send_in_pings: + - deletion-request + bugs: + - https://github.com/MozillaReality/FirefoxReality/issues/2347 + data_reviews: + - https://github.com/MozillaReality/FirefoxReality/pull/2348#issuecomment-564736919 + notification_emails: + - fxr-telemetry@mozilla.com + - dmu@mozilla.com + expires: "2020-11-01" diff --git a/app/src/common/shared/org/mozilla/vrbrowser/telemetry/GleanMetricsService.java b/app/src/common/shared/org/mozilla/vrbrowser/telemetry/GleanMetricsService.java index 969736f28..f1f4b1318 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/telemetry/GleanMetricsService.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/telemetry/GleanMetricsService.java @@ -7,9 +7,11 @@ import androidx.annotation.UiThread; import androidx.annotation.VisibleForTesting; +import org.mozilla.telemetry.TelemetryHolder; import org.mozilla.vrbrowser.BuildConfig; import org.mozilla.vrbrowser.GleanMetrics.Distribution; import org.mozilla.vrbrowser.GleanMetrics.FirefoxAccount; +import org.mozilla.vrbrowser.GleanMetrics.LegacyTelemetry; import org.mozilla.vrbrowser.GleanMetrics.Pings; import org.mozilla.vrbrowser.GleanMetrics.Searches; import org.mozilla.vrbrowser.GleanMetrics.Url; @@ -24,6 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.UUID; import mozilla.components.service.glean.Glean; import mozilla.components.service.glean.config.Configuration; @@ -51,6 +54,8 @@ public static void init(Context aContext) { } else { GleanMetricsService.stop(); } + + LegacyTelemetry.INSTANCE.clientId().set(UUID.fromString(TelemetryHolder.get().getClientId())); Configuration config = new Configuration(Configuration.DEFAULT_TELEMETRY_ENDPOINT, BuildConfig.BUILD_TYPE); Glean.INSTANCE.initialize(aContext, true, config); } @@ -194,7 +199,7 @@ public static void sentTab() { } public static void receivedTab(@NonNull mozilla.components.concept.sync.DeviceType source) { - FirefoxAccount.INSTANCE.getReceivedTab().get(source.name()).add(); + FirefoxAccount.INSTANCE.getReceivedTab().get(source.name().toLowerCase()).add(); } } @@ -213,7 +218,7 @@ public enum TabSource { } public static void openedCounter(@NonNull TabSource source) { - org.mozilla.vrbrowser.GleanMetrics.Tabs.INSTANCE.getOpened().get(source.name()).add(); + org.mozilla.vrbrowser.GleanMetrics.Tabs.INSTANCE.getOpened().get(source.name().toLowerCase()).add(); } public static void activatedEvent() { diff --git a/app/src/test/java/org/mozilla/vrbrowser/GleanMetricsServiceTest.kt b/app/src/test/java/org/mozilla/vrbrowser/GleanMetricsServiceTest.kt index ea9af385f..1bcf0d342 100644 --- a/app/src/test/java/org/mozilla/vrbrowser/GleanMetricsServiceTest.kt +++ b/app/src/test/java/org/mozilla/vrbrowser/GleanMetricsServiceTest.kt @@ -7,8 +7,10 @@ import org.junit.Assert.* import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.mozilla.telemetry.TelemetryHolder import org.mozilla.vrbrowser.GleanMetrics.Distribution import org.mozilla.vrbrowser.GleanMetrics.FirefoxAccount +import org.mozilla.vrbrowser.GleanMetrics.LegacyTelemetry import org.mozilla.vrbrowser.GleanMetrics.Tabs import org.mozilla.vrbrowser.GleanMetrics.Url import org.mozilla.vrbrowser.telemetry.GleanMetricsService @@ -119,22 +121,30 @@ class GleanMetricsServiceTest { assertTrue(FirefoxAccount.tabSent.testHasValue()) assertEquals(FirefoxAccount.tabSent.testGetValue(), 1) - assertFalse(FirefoxAccount.receivedTab[DeviceType.MOBILE.name].testHasValue()) + assertFalse(FirefoxAccount.receivedTab[DeviceType.MOBILE.name.toLowerCase()].testHasValue()) GleanMetricsService.FxA.receivedTab(DeviceType.MOBILE) - assertTrue(FirefoxAccount.receivedTab[DeviceType.MOBILE.name].testHasValue()) - assertEquals(FirefoxAccount.receivedTab[DeviceType.MOBILE.name].testGetValue(), 1) + assertTrue(FirefoxAccount.receivedTab[DeviceType.MOBILE.name.toLowerCase()].testHasValue()) + assertEquals(FirefoxAccount.receivedTab[DeviceType.MOBILE.name.toLowerCase()].testGetValue(), 1) } @Test fun testTabTelemetry() { - assertFalse(Tabs.opened[GleanMetricsService.Tabs.TabSource.BOOKMARKS.name].testHasValue()) + assertFalse(Tabs.opened[GleanMetricsService.Tabs.TabSource.BOOKMARKS.name.toLowerCase()].testHasValue()) GleanMetricsService.Tabs.openedCounter(GleanMetricsService.Tabs.TabSource.BOOKMARKS) - assertTrue(Tabs.opened[GleanMetricsService.Tabs.TabSource.BOOKMARKS.name].testHasValue()) - assertEquals(Tabs.opened[GleanMetricsService.Tabs.TabSource.BOOKMARKS.name].testGetValue(), 1) + assertTrue(Tabs.opened[GleanMetricsService.Tabs.TabSource.BOOKMARKS.name.toLowerCase()].testHasValue()) + assertEquals(Tabs.opened[GleanMetricsService.Tabs.TabSource.BOOKMARKS.name.toLowerCase()].testGetValue(), 1) assertFalse(Tabs.activated.testHasValue()) GleanMetricsService.Tabs.activatedEvent() assertTrue(Tabs.activated.testHasValue()) assertEquals(Tabs.activated.testGetValue(), 1) } + + @Test + fun testLegacyTelemetry() { + assertFalse(LegacyTelemetry.clientId.testHasValue()) + LegacyTelemetry.clientId.set(java.util.UUID.fromString(TelemetryHolder.get().getClientId())) + assertTrue(LegacyTelemetry.clientId.testHasValue()) + assertEquals(LegacyTelemetry.clientId.testGetValue().toString(), TelemetryHolder.get().getClientId()) + } } diff --git a/docs/metrics.md b/docs/metrics.md index 8a5354014..9fb51c06d 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -8,6 +8,7 @@ This means you might have to go searching through the dependency tree to get a f # Pings - [baseline](#baseline) + - [deletion-request](#deletion-request) - [events](#events) - [metrics](#metrics) - [session-end](#session-end) @@ -25,6 +26,14 @@ The following metrics are added to the ping: | --- | --- | --- | --- | --- | --- | | distribution.channel_name |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The distribution channel name of this application. We use this field to recognize Firefox Reality is distributed to which channels, such as wavevr, oculusvr, etc. |[1](https://github.com/MozillaReality/FirefoxReality/pull/1854#issuecomment-546214568), [2](https://github.com/MozillaReality/FirefoxReality/pull/3199#issuecomment-617938749)||2020-11-01 | +## deletion-request + +The following metrics are added to the ping: + +| Name | Type | Description | Data reviews | Extras | Expiration | +| --- | --- | --- | --- | --- | --- | +| legacy_telemetry.client_id |[uuid](https://mozilla.github.io/glean/book/user/metrics/uuid.html) |A UUID uniquely identifying the legacy telemetry client id. This is used for supporting legacy telemetry in the `deletion-request` ping. |[1](https://github.com/MozillaReality/FirefoxReality/pull/2348#issuecomment-564736919)||2020-11-01 | + ## events This is a built-in ping that is assembled out of the box by the Glean SDK.