android-components / org.mozilla.telemetry.config / TelemetryConfiguration

# TelemetryConfiguration

`open class TelemetryConfiguration` (source)

The TelemetryConfiguration class collects the information describing the telemetry setup of an app. There are some parts that every app needs to configure: Where should measurements store data? What servers are we actually uploading pings to? This class should provide good defaults so that in the best case it is not needed to modify the configuration.

### Constructors

<init> | `TelemetryConfiguration(context: Context)`

### Functions

getAppName | `open fun getAppName(): String` Get the name of the app. This value is used as one dimension when uploading telemetry to the HTTP Edge server.
getAppVersion | `open fun getAppVersion(): String` Get the version of the app (e.g. 45.0.1). This value is used as one dimension when uploading telemetry to the HTTP Edge server.
getBuildId | `open fun getBuildId(): String` Get the build id of the app (e.g. 20150125030202). This value is used as one dimension when uploading telemetry to the HTTP Edge server.
getClassLoadTimestampMillis | `open fun getClassLoadTimestampMillis(): Long`
getConnectTimeout | `open fun getConnectTimeout(): Int` Returns setting for connect timeout (milliseconds). A value of 0 implies that the option is disabled (i.e., timeout of infinity).
getContext | `open fun getContext(): Context` Application context this library is running in.
getDataDirectory | `open fun getDataDirectory(): File` Get the root directory where telemetry components should store data.
getInitialBackoffForUpload | `open fun getInitialBackoffForUpload(): Long` Get the interval (in milliseconds) to wait initially after a ping upload has failed.
getMaximumNumberOfEventsPerPing | `open fun getMaximumNumberOfEventsPerPing(): Int` Get the maximum number of events per ping.
getMaximumNumberOfPingUploadsPerDay | `open fun getMaximumNumberOfPingUploadsPerDay(): Int` Get the maximum number of pings that should be uploaded per day.
getMaximumNumberOfPingsPerType | `open fun getMaximumNumberOfPingsPerType(): Int` Get the maximum number of pings that will be stored (for upload).
getMinimumEventsForUpload | `open fun getMinimumEventsForUpload(): Int` Get the minimum number of telemetry events that need to be fired before even trying to upload an event ping.
getPreferencesImportantForTelemetry | `open fun getPreferencesImportantForTelemetry(): MutableSet<String>` Get a list of preference keys that are important for telemetry.
getReadTimeout | `open fun getReadTimeout(): Int` Returns setting for read timeout. 0 return implies that the option is disabled (i.e., timeout of infinity).
getServerEndpoint | `open fun getServerEndpoint(): String` Set the server endpoint to upload telemetry pings to.
getSettingsProvider | `open fun getSettingsProvider(): SettingsProvider` Get the provider for reading app settings.
getSharedPreferences | `open fun getSharedPreferences(): SharedPreferences` Get shared preference for storing telemetry related data.
getUpdateChannel | `open fun getUpdateChannel(): String` Get the update channel of the app (e.g. beta, release). This value is used as one dimension when uploading telemetry to the HTTP Edge server.
getUserAgent | `open fun getUserAgent(): String` Get the user agent used when communicating with the telemetry endpoint.
isCollectionEnabled | `open fun isCollectionEnabled(): Boolean` Is collecting telemetry data enabled?
isUploadEnabled | `open fun isUploadEnabled(): Boolean` Is uploading collected telemetry data enable?
setAppName | `open fun setAppName(appName: String): TelemetryConfiguration` Set the name of the app. This value is used as one dimension when uploading telemetry to the HTTP Edge server.
setAppVersion | `open fun setAppVersion(appVersion: String): TelemetryConfiguration` Set the version of the app (e.g. 45.0.1). This value is used as one dimension when uploading telemetry to the HTTP Edge server.
setBuildId | `open fun setBuildId(buildId: String): TelemetryConfiguration` Get the build id of the app (e.g. 20150125030202). This value is used as one dimension when uploading telemetry to the HTTP Edge server.
setCollectionEnabled | `open fun setCollectionEnabled(collectionEnabled: Boolean): TelemetryConfiguration` Enable or disable collection of telemetry data. Local dev builds should disable this to avoid collecting and sending any data.
setConnectTimeout | `open fun setConnectTimeout(connectTimeout: Int): TelemetryConfiguration` Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the telemetry endpoint. If the timeout expires before the connection can be established, the ping upload will be retried at a later time. A timeout of zero is interpreted as an infinite timeout.
setDataDirectory | `open fun setDataDirectory(dataDirectory: File): TelemetryConfiguration` Set the root directory where telemetry components should store data.
setInitialBackoffForUpload | `open fun setInitialBackoffForUpload(initialBackoffForUpload: Long): TelemetryConfiguration` Set the interval (in milliseconds) to wait initially after a ping upload has failed.
setMaximumNumberOfEventsPerPing | `open fun setMaximumNumberOfEventsPerPing(maximumNumberOfEventsPerPing: Int): TelemetryConfiguration` Set the maximum number of events per ping. If this limit is reached a ping will built and stored automatically. The number of stored and uploaded pings might be limited too.
setMaximumNumberOfPingUploadsPerDay | `open fun setMaximumNumberOfPingUploadsPerDay(maximumNumberOfPingUploadsPerDay: Int): TelemetryConfiguration` Set the maximum number of pings uploaded per day. This limit is enforced for every type. If you have 2 ping types and set a limit of 100 pings per day then in total 200 pings per day could be uploaded.
setMaximumNumberOfPingsPerType | `open fun setMaximumNumberOfPingsPerType(maximumNumberOfPingsPerType: Int): TelemetryConfiguration` Set the maximum number of pings that will be stored for a given ping type. If more types are in the local store then pings will be removed (oldest first). For this to happen the maximum needs to be reached without any successful upload.
setMinimumEventsForUpload | `open fun setMinimumEventsForUpload(minimumEventsForUpload: Int): TelemetryConfiguration` Set the minimum number of telemetry events that need to be fired before even trying to upload an event ping. The default value is 3. The minimum needs to be >= 1.
setPreferencesImportantForTelemetry | `open fun setPreferencesImportantForTelemetry(vararg preferences: String): TelemetryConfiguration` Set a list of preference keys that are important for telemetry. Some measurements and pings might use this to determine what preferences should be reported.
setReadTimeout | `open fun setReadTimeout(readTimeout: Int): TelemetryConfiguration` Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from the telemetry endpoint. If the timeout expires before there is data available for read, the ping upload will be retried later. A timeout of zero is interpreted as an infinite timeout.
setServerEndpoint | `open fun setServerEndpoint(endpoint: String): TelemetryConfiguration` Set the server endpoint to upload telemetry pings to. And endpoint value should include the schema and no trailing slash, e.g.: https://telemetry.example.org
setSettingsProvider | `open fun setSettingsProvider(settingsProvider: SettingsProvider): TelemetryConfiguration` Set a provider for reading app settings.
setUpdateChannel | `open fun setUpdateChannel(updateChannel: String): TelemetryConfiguration` Set the update channel of the app (e.g. beta, release). This value is used as one dimension when uploading telemetry to the HTTP Edge server.
setUploadEnabled | `open fun setUploadEnabled(uploadEnabled: Boolean): TelemetryConfiguration` Enable or disable the upload of collected telemetry data. This is usually set based on a user visible preference.
setUserAgent | `open fun setUserAgent(userAgent: String): TelemetryConfiguration` Set the user agent used when communicating with the telemetry endpoint.