android-components / mozilla.components.service.glean / Glean


object Glean (source)

In contrast with other glean-ac classes (i.e. Configuration), we can’t use typealias to export mozilla.telemetry.glean.Glean, as we need to provide a different default Configuration. Moreover, we can’t simply delegate other methods or inherit, since that doesn’t work for object in Kotlin.


Name Summary
getUploadEnabled fun getUploadEnabled(): Boolean
Get whether or not Glean is allowed to record and upload data.
initialize fun initialize(applicationContext: <ERROR CLASS>, uploadEnabled: Boolean, configuration: Configuration = Configuration()): Unit
Initialize Glean.
registerPings fun registerPings(pings: Any): Unit
Register the pings generated from pings.yaml with Glean.
setExperimentActive fun setExperimentActive(experimentId: String, branch: String, extra: Map<String, String>? = null): Unit
Indicate that an experiment is running. Glean will then add an experiment annotation to the environment which is sent with pings. This information is not persisted between runs.
setExperimentInactive fun setExperimentInactive(experimentId: String): Unit
Indicate that an experiment is no longer running.
setUploadEnabled fun setUploadEnabled(enabled: Boolean): Unit
Enable or disable Glean collection and upload.
testGetExperimentData fun testGetExperimentData(experimentId: String): RecordedExperimentData
Returns the stored data for the requested active experiment, for testing purposes only.
testIsExperimentActive fun testIsExperimentActive(experimentId: String): Boolean
Tests whether an experiment is active, for testing purposes only.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.