Data Collection Consent
Control when the SDK collects and exports telemetry, for GDPR and App Store privacy compliance.
Consent States
| State | Behavior |
|---|---|
ALLOWED | Telemetry collected and exported |
PENDING | SDK initialized — telemetry buffered in memory, nothing exported |
DENIED | Terminal — buffer cleared, SDK shuts down. Cannot be undone in the same process. |
Setting the Initial State
Pass dataCollectionState during native initialization. For Expo, set the top-level dataCollectionState field in the plugin config in app.json.
Android (MainApplication.kt):
Pulse.initialize(
application = this,
apiKey = "your-api-key",
dataCollectionState = PulseDataCollectionConsent.PENDING
)
iOS — pass the initial state at native init (see iOS Native API for Objective-C):
- Swift
- Objective-C
In AppDelegate.swift:
PulseSDK.initialize(
apiKey: "your-api-key",
dataCollectionState: .pending
)
In AppDelegate.m:
#import <PulseReactNativeOtel-Swift.h>
[PulseSDK pulseInitialize:@"your-api-key"
dataCollectionState:@"PENDING"
globalAttributes:nil
configuration:nil
instrumentations:nil];
Updating State at Runtime
Use setDataCollectionState from JavaScript after the user makes a consent choice:
import { Pulse, PulseDataCollectionConsent } from '@dreamhorizonorg/pulse-react-native';
// User granted consent — flushes buffer and starts exporting
Pulse.setDataCollectionState(PulseDataCollectionConsent.ALLOWED);
// User denied consent — clears buffer and shuts down the SDK
Pulse.setDataCollectionState(PulseDataCollectionConsent.DENIED);
Valid Transitions
| From | To ALLOWED | To DENIED |
|---|---|---|
PENDING | ✅ Flushes buffer, starts exporting | ✅ Clears buffer, shuts down |
ALLOWED | — (no-op) | ✅ Clears buffer, shuts down |
DENIED | ❌ Terminal — restart app to re-initialize | — |
DENIED is terminal. Once set, the SDK is shut down for the lifetime of the process.
Native side
Call the native setDataCollectionState entry points when your consent UI or ATT-style prompt lives in Kotlin or Swift, when you must flip state during startup before the JavaScript runtime loads, or when only native receives the signal (for example a deep link into settings).
- Kotlin (Android)
- Swift (iOS)
import com.pulsereactnativeotel.Pulse
import com.pulsereactnativeotel.PulseDataCollectionConsent
Pulse.setDataCollectionState(PulseDataCollectionConsent.ALLOWED)
import PulseReactNativeOtel
PulseSDK.setDataCollectionState(.allowed)
Same transition rules as JavaScript — Android APIs · iOS APIs.
Typical Flow
Initialize with PENDING at native startup, then apply the user's choice from JS:
import { Pulse, PulseDataCollectionConsent } from '@dreamhorizonorg/pulse-react-native';
function onConsentGranted() {
Pulse.setDataCollectionState(PulseDataCollectionConsent.ALLOWED);
}
function onConsentDenied() {
Pulse.setDataCollectionState(PulseDataCollectionConsent.DENIED);
}
Next Steps
- Source Maps — Upload JS source maps for readable stack traces
- CodePush Tracking — Track OTA bundle versions