Skip to main content

Android APIs for React Native

Pulse on React Native Android uses the same Pulse Android SDK APIs as a standalone Android app. Follow those docs for behavior, options, and troubleshooting — this page only explains how to call them from a React Native project.

Caller name

Everything matches the Android docs except the entry point:

// Pure Android (Pulse Android SDK)
PulseSDK.INSTANCE.someMethod(...)

// React Native — same methods, different class (import com.pulsereactnativeotel.Pulse)
Pulse.someMethod(...)

When you read PulseSDK.INSTANCE in the Android documentation, substitute Pulse in your code. Method names and parameters stay the same.


Initialization

Place this in MainApplication.onCreate(). The SDK ignores any subsequent initialize() calls, so call it once, as early as possible.

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

Pulse.initialize(
application = this,
apiKey = "your-api-key",
dataCollectionState = PulseDataCollectionConsent.ALLOWED
)

For all initialize parameters — globalAttributes, the instrumentations { } block, consent states, Remote config, and Shutdown — see the Android SDK configuration guide.


Android Guide

Instrumentations

Several native instrumentations are on by default — crashes, ANR, screen lifecycle, slow frames, interactions, app startup, and network connectivity. Others like HTTP tracking, session replay, and click tracking need extra setup.

Use the instrumentations block to disable or configure them:

Pulse.initialize(...) {
fragment { enabled(false) } // recommended for RN — avoids double-counting screens
}

Key guides: Screen lifecycle · Network (OkHttp) · Crashes · ANR

Native-only APIs

For calls that originate from Kotlin/Java — custom spans, custom events, error tracking — see the Android API reference.

Identity and global metadata

Set user identity and global attributes from native code via User identification and Global attributes.

Android data collection consent covers the native side. See React Native data collection for the JS bridge.

Release builds

Upload a JS source map and a ProGuard mapping for native Kotlin/Java before shipping. See Upload mapping file.


Suggested reading order

  1. Android overview — what the SDK collects and how it fits together
  2. Android installation — Gradle, min SDK, desugaring if minSdk < 26
  3. Android SDK configuration — full initialize DSL
  4. Android API reference — all public methods (swap PulseSDK.INSTANCEPulse)
  5. One instrumentation guide — screen lifecycle or network are the most common starting points for RN apps
  6. Upload mapping file — before shipping a release build

Only writing JS? You still need the native Pulse.initialize in MainApplication, but everything else can stay on the React Native API reference and RN-specific pages.