Data Collection Consent
The Data Collection Consent API is currently in development. This page will be updated when the feature is available in the SDK.
The data collection consent API will let you defer or suppress telemetry export until you have explicit user consent. This is planned for use in:
- Apps that display a consent dialog before collecting analytics
- GDPR/privacy-compliance flows where data collection must be opt-in
- Scenarios where you want to initialize the SDK early but hold telemetry until the user grants permission
Planned Behavior
The consent system will support three states:
| State | Description |
|---|---|
PENDING | Telemetry signals are buffered in memory. No data is sent. |
ALLOWED | Buffered signals are flushed and subsequent signals are exported normally. |
DENIED | Buffered data is cleared and the SDK is shut down. |
Current Workaround
Until the consent API is available, you can control data collection by deferring SDK initialization until after the user grants consent.
Bare React Native
Defer Pulse.initialize() in MainApplication.kt until consent is confirmed:
import android.app.Application
import com.pulsereactnativeotel.Pulse
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
if (userHasGrantedConsent()) {
Pulse.initialize(
application = this,
projectId = "your-project-id"
)
}
}
}
Expo
For Expo apps, the plugin initializes the SDK at app startup. To defer, you can conditionally call Pulse.start() in your JavaScript code after the user grants consent:
import { Pulse } from '@dreamhorizonorg/pulse-react-native';
if (userHasGrantedConsent) {
Pulse.start();
}
To stop collection after initialization, call Pulse.shutdown(). Note that shutdown is terminal in the current process — the SDK cannot be re-initialized without an app restart.
Next Steps
- Installation — Standard React Native installation guide
- Expo Setup — Expo plugin configuration reference
- Android Data Collection Consent — Android-specific details