API Reference Complete API reference for the Teardown React Native SDK.
The main SDK class that orchestrates all clients.
new TeardownCore (options: TeardownCoreOptions)
Property Type Required Description org_idstringYes Organization ID from dashboard project_idstringYes Project ID from dashboard api_keystringYes API key from dashboard environment_slugstringNo Environment slug (default: "production") ingestUrlstringNo Custom ingest API URL for local/staging storageAdapterStorageAdapterYes Storage adapter instance deviceAdapterDeviceInfoAdapterYes Device info adapter instance notificationAdapterNotificationAdapterNo Push notification adapter instance forceUpdateForceUpdateClientOptionsNo Force update configuration
Method Returns Description setLogLevel(level)voidSet logging verbosity shutdown()voidCleanup SDK resources
Property Type Description apiApiClientBackend API client deviceDeviceClientDevice information client eventsEventsClientEvent tracking client identityIdentityClientIdentity management client forceUpdateForceUpdateClientVersion checking client notificationsNotificationsClient | undefinedPush notifications client (if adapter provided)
Manages user and device identification.
Method Returns Description identify(persona?)AsyncResult<IdentityUser>Identify user/device refresh()AsyncResult<IdentityUser>Re-identify current user signOut(options?)AsyncResult<void>Sign out user, preserve device signOutAll(options?)AsyncResult<void>Sign out and reset device getIdentifyState()IdentifyStateGet current state getSessionState()Session | nullGet current session onIdentifyStateChange(listener)() => voidSubscribe to state changes shutdown()voidCleanup listeners
interface Persona {
user_id ?: string ;
email ?: string ;
name ?: string ;
}
interface Session {
session_id : string ;
device_id : string ;
user_id : string ;
token : string ;
}
type IdentifyState =
| { type : 'unidentified' }
| { type : 'identifying' }
| { type : 'identified' ; session : Session ; version_info : VersionInfo };
interface SignOutOptions {
// Additional properties to include in the sign out event
properties ?: Record < string , unknown >;
// Wait for event to be sent before clearing state (default: true)
waitForEvent ?: boolean ;
}
Manages version checking and force updates.
Method Returns Description getVersionStatus()VersionStatusGet current version status onVersionStatusChange(listener)() => voidSubscribe to status changes shutdown()voidCleanup listeners
Property Type Default Description checkIntervalMsnumber300000Min time between checks. 0 = every foreground, -1 = disabled checkOnForegroundbooleantrueCheck when app foregrounds identifyAnonymousDevicebooleanfalseCheck when not identified
type VersionStatus =
| { type : 'initializing' }
| { type : 'checking' }
| { type : 'up_to_date' }
| { type : 'update_available' ; releaseNotes ?: string | null }
| { type : 'update_recommended' ; releaseNotes ?: string | null }
| { type : 'update_required' ; releaseNotes ?: string | null }
| { type : 'disabled' };
Tracks events to the backend.
Method Returns Description track(event, sessionId?)AsyncResult<void>Track a single event trackBatch(events, sessionId?)AsyncResult<void>Track multiple events
interface EventPayload {
/** Name of the event (e.g., "button_clicked", "page_viewed") */
event_name : string ;
/** Type of event */
event_type ?: "action" | "screen_view" | "custom" ;
/** Additional properties to attach to the event */
properties ?: Record < string , unknown >;
/** ISO timestamp. Defaults to current time if not provided */
timestamp ?: string ;
}
const { core } = useTeardown ();
// Track a single event
await core.events. track ({
event_name: 'button_clicked' ,
event_type: 'action' ,
properties: { button_id: 'submit-form' }
});
// Track multiple events
await core.events. trackBatch ([
{ event_name: 'page_viewed' , event_type: 'screen_view' , properties: { page: 'home' } },
{ event_name: 'cta_shown' , event_type: 'action' }
]);
Manages push notifications across different providers. Only available if notificationAdapter is provided in TeardownCore options.
Method Returns Description requestPermissions()Promise<PermissionStatus>Request notification permissions getToken()Promise<string | null>Get push notification token onTokenChange(listener)UnsubscribeSubscribe to token changes onNotificationReceived(listener)UnsubscribeSubscribe to foreground notifications onNotificationOpened(listener)UnsubscribeSubscribe to notification taps onDataMessage(listener)UnsubscribeSubscribe to silent/data messages destroy()voidCleanup resources
Property Type Description platformNotificationPlatformEnumNotification platform (APNS, FCM, EXPO)
interface PermissionStatus {
granted : boolean ;
canAskAgain : boolean ;
}
interface PushNotification {
title ?: string ;
body ?: string ;
data ?: Record < string , unknown >;
}
interface DataMessage {
data : Record < string , unknown >;
}
enum NotificationPlatformEnum {
APNS = "APNS" , // Apple Push Notification Service
FCM = "FCM" , // Firebase Cloud Messaging
EXPO = "EXPO" , // Expo Push Notifications
}
const { core } = useTeardown ();
if (core.notifications) {
// Request permissions
const status = await core.notifications. requestPermissions ();
// Get token for backend
const token = await core.notifications. getToken ();
// Listen for foreground notifications
const unsub = core.notifications. onNotificationReceived (( notification ) => {
console. log ( 'Notification:' , notification.title);
});
// Cleanup
unsub ();
}
Collects device information.
Method Returns Description getDeviceId()Promise<string>Get stable device UUID getDeviceInfo()Promise<DeviceInfo>Get full device info reset()voidClear stored deviceId (new ID on next call)
interface DeviceInfo {
timestamp ?: Date ;
os : OSInfo ;
hardware : HardwareInfo ;
application : ApplicationInfo ;
update : DeviceUpdateInfo | null ;
notifications ?: NotificationsInfo ;
}
Abstract class for storage implementations.
Method Returns Description createStorage(key)SupportedStorageCreate namespaced storage
interface SupportedStorage {
preload () : void ;
getItem ( key : string ) : string | null ;
setItem ( key : string , value : string ) : void ;
removeItem ( key : string ) : void ;
clear () : void ;
keys () : string [];
}
Interface for device information adapters.
Property Type Description applicationInfoApplicationInfoApp version info hardwareInfoHardwareInfoDevice hardware info osInfoOSInfoOperating system info
interface ApplicationInfo {
version : string ;
build_number : number ;
}
interface HardwareInfo {
device_name : string ;
device_brand : string ;
device_type : string ;
}
interface OSInfo {
platform : DevicePlatformEnum ;
name : string ;
version : string ;
}
enum DevicePlatformEnum {
IOS = "IOS" ,
ANDROID = "ANDROID" ,
WEB = "WEB" ,
WINDOWS = "WINDOWS" ,
MACOS = "MACOS" ,
LINUX = "LINUX" ,
UNKNOWN = "UNKNOWN" ,
// ... and more
}
Type-safe result type for async operations.
type AsyncResult < T > =
| { success : true ; data : T }
| { success : false ; error : string };
const result = await core.identity. identify ({ user_id: '123' });
if (result.success) {
console. log (result.data.session_id);
} else {
console. error (result.error);
}