Skip to content

Datadog

Xavier F. Gouchet edited this page Sep 4, 2024 · 1 revision

object Datadog

This class initializes the Datadog SDK, and sets up communication with the server.

Functions

_internalProxy

fun _internalProxy(instanceName: String? = null): _InternalProxy

For Datadog internal use only.

See also
_InternalProxy

addUserProperties

@JvmStatic

@JvmOverloads

fun addUserProperties(extraInfo: Map<String, Any?>, sdkCore: SdkCore = getInstance())

Sets additional information on the UserInfo object

If properties had originally been set with SdkCore.setUserInfo, they will be preserved. In the event of a conflict on key, the new property will prevail.

Parameters
extraInfo additional information. An extra information can be nested up to 8 levels deep. Keys using more than 8 levels will be sanitized by SDK.
sdkCore SDK instance to add user properties. If not provided, default SDK instance will be used.

clearAllData

@JvmStatic

@JvmOverloads

@AnyThread

fun clearAllData(sdkCore: SdkCore = getInstance())

Clears all unsent data in all registered features.

Parameters
sdkCore SDK instance to clear the data. If not provided, default SDK instance will be used.

getInstance

@JvmStatic

@JvmOverloads

fun getInstance(instanceName: String? = null): SdkCore

Retrieve the initialized SDK instance attached to the given name, or the default instance if the name is null.

Return

the existing instance linked with the given name, or no-op instance if instance with given name is not yet initialized.

Parameters
instanceName the name of the instance to retrieve, or null to get the default instance

getVerbosity

@JvmStatic

fun getVerbosity(): Int

Gets the verbosity of this instance of the Datadog SDK.

Messages with a priority level equal or above the given level will be sent to Android's Logcat.

initialize

@JvmStatic

fun initialize(instanceName: String?, context: Context, configuration: Configuration, trackingConsent: TrackingConsent): SdkCore?

Initializes a named instance of the Datadog SDK.

Return

the initialized SDK instance, or null if something prevents the SDK from being initialized

Parameters
instanceName the name of the instance (or null to initialize the default instance). Note that the instance name should be stable across builds.
context your application context
configuration the configuration for the SDK library
trackingConsent as the initial state of the tracking consent flag
See also
Configuration
TrackingConsent
Throws
IllegalArgumentException if the env name is using illegal characters and your application is in debug mode otherwise returns null and stops initializing the SDK

@JvmStatic

fun initialize(context: Context, configuration: Configuration, trackingConsent: TrackingConsent): SdkCore?

Initializes the Datadog SDK.

Return

the initialized SDK instance, or null if something prevents the SDK from being initialized

Parameters
context your application context
configuration the configuration for the SDK library
trackingConsent as the initial state of the tracking consent flag
See also
Configuration
TrackingConsent
Throws
IllegalArgumentException if the env name is using illegal characters and your application is in debug mode otherwise returns null and stops initializing the SDK

isInitialized

@JvmStatic

@JvmOverloads

fun isInitialized(instanceName: String? = null): Boolean

Checks if SDK instance with a given name is initialized.

Return

whenever the instance with given name is initialized or not.

Parameters
instanceName the name of the instance to retrieve, or null to check the default instance

setTrackingConsent

@JvmStatic

@JvmOverloads

fun setTrackingConsent(consent: TrackingConsent, sdkCore: SdkCore = getInstance())

Sets the tracking consent regarding the data collection for this instance of the Datadog SDK.

Parameters
consent which can take one of the values (TrackingConsent.PENDING, TrackingConsent.GRANTED, TrackingConsent.NOT_GRANTED)
sdkCore SDK instance to set tracking consent in. If not provided, default SDK instance will be used.

setUserInfo

@JvmStatic

@JvmOverloads

fun setUserInfo(id: String? = null, name: String? = null, email: String? = null, extraInfo: Map<String, Any?> = emptyMap(), sdkCore: SdkCore = getInstance())

Sets the user information.

Parameters
id (nullable) a unique user identifier (relevant to your business domain)
name (nullable) the user name or alias
email (nullable) the user email
extraInfo additional information. An extra information can be nested up to 8 levels deep. Keys using more than 8 levels will be sanitized by SDK.
sdkCore SDK instance to set user info in. If not provided, default SDK instance will be used.

setVerbosity

@JvmStatic

fun setVerbosity(level: Int)

Sets the verbosity of this instance of the Datadog SDK.

Messages with a priority level equal or above the given level will be sent to Android's Logcat.

Parameters
level one of the Android android.util.Log constants (android.util.Log.VERBOSE, android.util.Log.DEBUG, android.util.Log.INFO, android.util.Log.WARN, android.util.Log.ERROR, android.util.Log.ASSERT).

stopInstance

@JvmStatic

@JvmOverloads

fun stopInstance(instanceName: String? = null)

Stop the initialized SDK instance attached to the given name, or the default instance if the name is null.

Parameters
instanceName the name of the instance to stop, or null to stop the default instance
Clone this wiki locally