Teardown

API Reference

Complete API reference for the Teardown React Native SDK.

TeardownCore

The main SDK class that orchestrates all clients.

Constructor

new TeardownCore(options: TeardownCoreOptions)

TeardownCoreOptions

PropertyTypeRequiredDescription
org_idstringYesOrganization ID from dashboard
project_idstringYesProject ID from dashboard
api_keystringYesAPI key from dashboard
storageAdapterStorageAdapterYesStorage adapter instance
deviceAdapterDeviceInfoAdapterYesDevice info adapter instance
forceUpdateForceUpdateClientOptionsNoForce update configuration

Methods

MethodReturnsDescription
setLogLevel(level)voidSet logging verbosity
shutdown()voidCleanup SDK resources

Properties

PropertyTypeDescription
apiApiClientBackend API client
deviceDeviceClientDevice information client
identityIdentityClientIdentity management client
forceUpdateForceUpdateClientVersion checking client

IdentityClient

Manages user and device identification.

Methods

MethodReturnsDescription
identify(persona?)AsyncResult<IdentityUser>Identify user/device
refresh()AsyncResult<IdentityUser>Re-identify current user
reset()voidClear session data
getIdentifyState()IdentifyStateGet current state
getSessionState()Session | nullGet current session
onIdentifyStateChange(listener)() => voidSubscribe to state changes
shutdown()voidCleanup listeners

Persona

interface Persona {
  user_id?: string;
  email?: string;
  name?: string;
}

Session

interface Session {
  session_id: string;
  device_id: string;
  user_id: string;
  token: string;
}

IdentifyState

type IdentifyState =
  | { type: 'unidentified' }
  | { type: 'identifying' }
  | { type: 'identified'; session: Session; version_info: VersionInfo };

ForceUpdateClient

Manages version checking and force updates.

Methods

MethodReturnsDescription
getVersionStatus()VersionStatusGet current version status
onVersionStatusChange(listener)() => voidSubscribe to status changes
shutdown()voidCleanup listeners

ForceUpdateClientOptions

PropertyTypeDefaultDescription
checkIntervalMsnumber300000Min time between checks. 0 = every foreground, -1 = disabled
checkOnForegroundbooleantrueCheck when app foregrounds
identifyAnonymousDevicebooleanfalseCheck when not identified

VersionStatus

type VersionStatus =
  | { type: 'initializing' }
  | { type: 'checking' }
  | { type: 'up_to_date' }
  | { type: 'update_available' }
  | { type: 'update_recommended' }
  | { type: 'update_required' }
  | { type: 'disabled' };

DeviceClient

Collects device information.

Methods

MethodReturnsDescription
getDeviceId()Promise<string>Get stable device UUID
getDeviceInfo()Promise<DeviceInfo>Get full device info

DeviceInfo

interface DeviceInfo {
  timestamp: string;
  os: OSInfo;
  hardware: HardwareInfo;
  application: ApplicationInfo;
}

StorageAdapter

Abstract class for storage implementations.

Methods

MethodReturnsDescription
createStorage(key)SupportedStorageCreate namespaced storage

SupportedStorage

interface SupportedStorage {
  preload(): void;
  getItem(key: string): string | null;
  setItem(key: string, value: string): void;
  removeItem(key: string): void;
  clear(): void;
  keys(): string[];
}

DeviceInfoAdapter

Interface for device information adapters.

Properties

PropertyTypeDescription
applicationInfoApplicationInfoApp version info
hardwareInfoHardwareInfoDevice hardware info
osInfoOSInfoOperating system info

ApplicationInfo

interface ApplicationInfo {
  version: string;
  buildNumber: string;
  bundleId: string;
}

HardwareInfo

interface HardwareInfo {
  deviceName: string;
  brand: string;
  deviceType: string;
}

OSInfo

interface OSInfo {
  osName: string;
  osVersion: string;
}

AsyncResult

Type-safe result type for async operations.

type AsyncResult<T> =
  | { success: true; data: T }
  | { success: false; error: string };

Usage

const result = await core.identity.identify({ user_id: '123' });

if (result.success) {
  console.log(result.data.session_id);
} else {
  console.error(result.error);
}