Skip to main content

Data Collection Consent

Control when the SDK collects and exports telemetry, for GDPR and App Store privacy compliance.

StateBehavior
ALLOWEDTelemetry collected and exported
PENDINGSDK initialized — telemetry buffered in memory, nothing exported
DENIEDTerminal — 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):

In AppDelegate.swift:

PulseSDK.initialize(
apiKey: "your-api-key",
dataCollectionState: .pending
)

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​

FromTo ALLOWEDTo DENIED
PENDING✅ Flushes buffer, starts exporting✅ Clears buffer, shuts down
ALLOWED— (no-op)✅ Clears buffer, shuts down
DENIED❌ Terminal — restart app to re-initialize—
warning

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).

import com.pulsereactnativeotel.Pulse
import com.pulsereactnativeotel.PulseDataCollectionConsent

Pulse.setDataCollectionState(PulseDataCollectionConsent.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