Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Resolve label metrics are _other_ and add legacy client id #3384

Merged
merged 2 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}
}

Expand All @@ -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() {
Expand Down
22 changes: 16 additions & 6 deletions app/src/test/java/org/mozilla/vrbrowser/GleanMetricsServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
}
}
9 changes: 9 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down