Skip to main content
This guide walks you through configuring the AppDNA SDK, identifying users, and tracking your first event in a React Native application.

1. Configure the SDK

Initialize AppDNA as early as possible in your app lifecycle. Place the call in your root component or app entry point:
import { AppDNA } from '@appdna/react-native-sdk';

await AppDNA.configure("adn_live_xxx", "production", {
  logLevel: "debug",
});
Call AppDNA.configure(...) exactly once before using any other SDK methods. Calling it multiple times will result in undefined behavior.

Configuration Options

The AppDNAOptions interface lets you customize SDK behavior:
ParameterTypeDefaultDescription
flushIntervalnumber30Seconds between automatic event flushes
batchSizenumber20Number of events to batch before flushing
configTTLnumber300Seconds before cached config is considered stale
logLevelAppDNALogLevel'warning'Verbosity of SDK console logs
billingProviderAppDNABillingProviderundefinedBilling integration to use

Environment

The AppDNAEnvironment type controls which backend environment the SDK targets:
ValueDescription
'production'Production API and configuration
'staging'Staging API for testing

Log Level

The AppDNALogLevel type controls console log verbosity:
ValueDescription
'none'No logging
'error'Errors only
'warning'Errors and warnings
'info'Errors, warnings, and info
'debug'All messages including debug
Use 'debug' during development to see all SDK activity. Switch to 'warning' or 'none' for production builds.

Billing Provider

The AppDNABillingProvider type specifies which billing system to use:
ValueDescription
'storeKit2'Native StoreKit 2 (iOS) / Google Play (Android)
'revenueCat'RevenueCat integration
'none'Disable billing module

2. Wait for Ready State

The SDK fetches remote configuration asynchronously. Use onReady to know when the SDK is fully initialized:
await AppDNA.onReady();
console.log("SDK ready -- remote config loaded");

3. Identify Users

Once a user signs in, call identify to associate events with their user ID:
await AppDNA.identify("user-123", {
  plan: "premium",
  signup_date: "2025-01-15",
});
Traits are merged with any previously set traits. You do not need to pass all traits on every call — only the ones that have changed.

4. Track Events

Track user actions with track:
await AppDNA.track("workout_completed", {
  duration: 45,
  type: "strength",
});
Events are batched and flushed automatically based on your flushInterval and batchSize settings.

5. Flush Events Manually

Force an immediate flush of all queued events:
await AppDNA.flush();
This is useful before the app enters the background or when you need to ensure events are sent immediately. Control whether the SDK collects and sends analytics data:
await AppDNA.setConsent(true);
When consent is set to false, events are silently dropped and not queued. No data is sent to AppDNA servers until consent is granted.

7. Change Log Level at Runtime

Adjust the log level without reconfiguring the SDK:
AppDNA.setLogLevel("debug");
setLogLevel is the only synchronous method on the AppDNA class. All other methods return Promises and should be awaited.

8. Remote Config and Feature Flags

Retrieve server-side configuration values:
const welcomeMessage = await AppDNA.getRemoteConfig("welcome_message");
Check whether a feature flag is enabled:
const darkModeEnabled = await AppDNA.isFeatureEnabled("dark_mode");

9. Experiments

Get the variant assigned to a user for an experiment:
const variant = await AppDNA.getExperimentVariant("paywall_test");
Check if the user is in a specific variant:
const isInVariantB = await AppDNA.isInVariant("paywall_test", "b");

10. Web Entitlements

Retrieve the current web entitlement for the user:
const entitlement = await AppDNA.getWebEntitlement();
Listen for web entitlement changes:
const unsubscribe = AppDNA.onWebEntitlementChanged((entitlement) => {
  console.log("Web entitlement changed:", entitlement);
});

// Later, when you no longer need the listener:
unsubscribe();
Check for a deferred deep link that led to the app install:
const link = await AppDNA.checkDeferredDeepLink();
if (link) {
  console.log("Deep link:", link);
}

12. Reset on Logout

When a user signs out, call reset to clear the user identity and flush any remaining events:
await AppDNA.reset();
This clears the identified user, generates a new anonymous ID, and flushes queued events.

13. Shutdown

When your app is terminating or you need to fully tear down the SDK:
await AppDNA.shutdown();
You now have the SDK configured, user identification, event tracking, remote config, and experiments working. Continue to the module-specific guides for Push Notifications, Billing, Onboarding, and Paywalls.