Skip to main content

Data Collection Consent

Control when Pulse exports telemetry — useful for GDPR compliance flows or apps that require explicit user consent before collecting analytics.

States​

StateBehavior
PENDINGTelemetry is buffered in memory. No data is exported.
ALLOWEDBuffered telemetry is flushed and new telemetry is exported normally.
DENIEDBuffered data is cleared and the SDK stops collecting. Terminal — cannot be reversed.
warning

Transitioning to DENIED is permanent for the current process. The SDK cannot be re-enabled without an app restart.

Setting Initial State​

Pass the initial state in initialize():

import com.pulse.android.api.otel.PulseDataCollectionConsent

PulseSDK.INSTANCE.initialize(
application = this,

apiKey = "your-api-key",
dataCollectionState = PulseDataCollectionConsent.PENDING,
)

Updating State​

Call setDataCollectionState() after the user makes a consent decision:

// User granted consent
PulseSDK.INSTANCE.setDataCollectionState(PulseDataCollectionConsent.ALLOWED)

// User denied consent
PulseSDK.INSTANCE.setDataCollectionState(PulseDataCollectionConsent.DENIED)

Typical Flow​

// 1. Initialize with PENDING — SDK starts but holds all telemetry
PulseSDK.INSTANCE.initialize(
application = this,

apiKey = "your-api-key",
dataCollectionState = PulseDataCollectionConsent.PENDING,
)

// 2. Show your consent dialog...

// 3. On user decision, update state
fun onConsentResult(granted: Boolean) {
val state = if (granted) {
PulseDataCollectionConsent.ALLOWED
} else {
PulseDataCollectionConsent.DENIED
}
PulseSDK.INSTANCE.setDataCollectionState(state)
}

State Transitions​

FromToAllowed
PENDINGALLOWED✅
PENDINGDENIED✅
ALLOWEDDENIED✅
DENIEDanything❌

Next Steps​