This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Glean baseline pings integration. (stage 1) (#1854)
- Loading branch information
1 parent
6d2aa2e
commit 425f01f
Showing
7 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
|
||
$schema: moz://mozilla.org/schemas/glean/metrics/1-0-0 | ||
|
||
distribution: | ||
channel_name: | ||
type: string | ||
lifetime: application | ||
description: > | ||
The distribution channel name of this application. We use this field to recognize Firefox Reality | ||
is distributed to which channels, such as wavevr, oculusvr, googlevr, etc. | ||
send_in_pings: | ||
- baseline | ||
- events | ||
- metrics | ||
bugs: | ||
- https://github.com/MozillaReality/FirefoxReality/issues/1420 | ||
data_reviews: | ||
- https://github.com/MozillaReality/FirefoxReality/pull/1854#issuecomment-546214568 | ||
notification_emails: | ||
- [email protected] | ||
expires: "2020-05-01" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
app/src/common/shared/org/mozilla/vrbrowser/telemetry/GleanMetricsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.mozilla.vrbrowser.telemetry; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
import androidx.annotation.UiThread; | ||
|
||
import org.mozilla.vrbrowser.browser.SettingsStore; | ||
import org.mozilla.vrbrowser.utils.DeviceType; | ||
import org.mozilla.vrbrowser.utils.SystemUtils; | ||
import org.mozilla.vrbrowser.BuildConfig; | ||
import org.mozilla.vrbrowser.GleanMetrics.Distribution; | ||
|
||
import mozilla.components.service.glean.Glean; | ||
import mozilla.components.service.glean.config.Configuration; | ||
|
||
|
||
public class GleanMetricsService { | ||
|
||
private final static String APP_NAME = "FirefoxReality"; | ||
private static boolean initialized = false; | ||
private final static String LOGTAG = SystemUtils.createLogtag(GleanMetricsService.class); | ||
private static Context context = null; | ||
|
||
// We should call this at the application initial stage. | ||
public static void init(Context aContext) { | ||
if (initialized) | ||
return; | ||
|
||
context = aContext; | ||
initialized = true; | ||
|
||
final boolean telemetryEnabled = SettingsStore.getInstance(aContext).isTelemetryEnabled(); | ||
if (telemetryEnabled) { | ||
GleanMetricsService.start(); | ||
} else { | ||
GleanMetricsService.stop(); | ||
} | ||
Configuration config = new Configuration(Configuration.DEFAULT_TELEMETRY_ENDPOINT, | ||
BuildConfig.BUILD_TYPE); | ||
Glean.INSTANCE.initialize(aContext, config); | ||
} | ||
|
||
// It would be called when users turn on/off the setting of telemetry. | ||
// e.g., SettingsStore.getInstance(context).setTelemetryEnabled(); | ||
public static void start() { | ||
Glean.INSTANCE.setUploadEnabled(true); | ||
setStartupMetrics(); | ||
} | ||
|
||
// It would be called when users turn on/off the setting of telemetry. | ||
// e.g., SettingsStore.getInstance(context).setTelemetryEnabled(); | ||
public static void stop() { | ||
Glean.INSTANCE.setUploadEnabled(false); | ||
} | ||
|
||
private static void setStartupMetrics() { | ||
Distribution.INSTANCE.getChannelName().set(DeviceType.isOculusBuild() ? "oculusvr" : BuildConfig.FLAVOR_platform); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!-- AUTOGENERATED BY glean_parser. DO NOT EDIT. --> | ||
|
||
# Metrics | ||
This document enumerates the metrics collected by this project. | ||
This project may depend on other projects which also collect metrics. | ||
This means you might have to go searching through the dependency tree to get a full picture of everything collected by this project. | ||
Sorry about that. | ||
|
||
# Pings | ||
|
||
- [baseline](#baseline) | ||
- [events](#events) | ||
- [metrics](#metrics) | ||
|
||
|
||
## baseline | ||
This is a built-in ping that is assembled out of the box by the Glean SDK. | ||
See the Glean SDK documentation for the [`baseline` ping](https://mozilla.github.io/glean/book/user/pings/baseline.html). | ||
The following metrics are added to the ping: | ||
|
||
| Name | Type | Description | Data reviews | Extras | Expiration | | ||
| --- | --- | --- | --- | --- | --- | | ||
| 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, googlevr, etc. |[1](https://github.com/MozillaReality/FirefoxReality/pull/1854#issuecomment-546214568)||2020-05-01 | | ||
|
||
## events | ||
This is a built-in ping that is assembled out of the box by the Glean SDK. | ||
See the Glean SDK documentation for the [`events` ping](https://mozilla.github.io/glean/book/user/pings/events.html). | ||
The following metrics are added to the ping: | ||
|
||
| Name | Type | Description | Data reviews | Extras | Expiration | | ||
| --- | --- | --- | --- | --- | --- | | ||
| 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, googlevr, etc. |[1](https://github.com/MozillaReality/FirefoxReality/pull/1854#issuecomment-546214568)||2020-05-01 | | ||
|
||
## metrics | ||
This is a built-in ping that is assembled out of the box by the Glean SDK. | ||
See the Glean SDK documentation for the [`metrics` ping](https://mozilla.github.io/glean/book/user/pings/metrics.html). | ||
The following metrics are added to the ping: | ||
|
||
| Name | Type | Description | Data reviews | Extras | Expiration | | ||
| --- | --- | --- | --- | --- | --- | | ||
| 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, googlevr, etc. |[1](https://github.com/MozillaReality/FirefoxReality/pull/1854#issuecomment-546214568)||2020-05-01 | | ||
|
||
|
||
<!-- AUTOGENERATED BY glean_parser. DO NOT EDIT. --> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters