Data Collection Consent
Control when Pulse exports telemetry — useful for GDPR compliance flows or apps that require explicit user consent before collecting analytics.
States
| State | Behavior |
|---|---|
PENDING | Telemetry is buffered in memory. No data is exported. |
ALLOWED | Buffered telemetry is flushed and new telemetry is exported normally. |
DENIED | Buffered 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
| From | To | Allowed |
|---|---|---|
PENDING | ALLOWED | ✅ |
PENDING | DENIED | ✅ |
ALLOWED | DENIED | ✅ |
DENIED | anything | ❌ |
Next Steps
- API Reference — Full
PulseSDKmethod signatures