ScaleBun
Skip to article

Methods

react-nativeDeveloperv0.1.0-alpha.4

All 26 top-level methods on the ScaleBun facade.

Updated Reviewed

Signatures are extracted from the SDK source. Every facade method is wrapped so it never throws — before init() resolves, calls are buffered or become no-ops rather than failing.

Index#

MethodSignature
initinit(rawConfig: SimplifiedInitConfig | ScaleBunInitConfig | any)
trackPurchasetrackPurchase(input: { revenue: number; currency: string; transactionId: string; [k: string]: any }): void
updateSkanConversionValueupdateSkanConversionValue(value: number, coarseValue?: SkanCoarseValue, lockWindow?: boolean): void
getFeatureFlagsgetFeatureFlags(): ScaleBunFeatures
identifyidentify(userId: string, traits?: Record<string, any>)
identifyUseridentifyUser(userId: string, traits?: Record<string, any>)
setUsersetUser(user: ScaleBunUser)
clearUserclearUser()
submitRatingsubmitRating(input: { rating: number; comment?: string; source?: 'in_app' | 'prompt' | 'manual'; /** [ADDITIVE] client-generated UUID for app-rating idempotency (contract §1.4, D8). */ clientRatingId?: string; })
enablePushenablePush(options?: EnablePushOptions): Promise<EnablePushResult>
onForegroundNotificationonForegroundNotification(cb: (notification: PushNotification) => void): () => void
onNotificationOpenedonNotificationOpened(cb: (notification: PushNotification) => void): () => void
trackPermissiontrackPermission(permission: string, status: 'granted' | 'denied' | 'blocked' | 'undetermined' | 'limited', details?: Record<string, any>)
tracktrack(name: string, payload?: Record<string, any>)
loglog(level: 'debug' | 'info' | 'warn' | 'error', message: string, data?: Record<string, unknown>)
captureErrorcaptureError(error: Error | string, context?: { screenName?: string; fatal?: boolean; type?: string; metadata?: Record<string, unknown> })
nativeCrashnativeCrash()
reportBugreportBug(description: string, metadata?: Record<string, unknown>)
setAttributesetAttribute(key: string, value: string | number | boolean)
flushflush()
enableDebugenableDebug(config: DebugConfig)
disableDebugdisableDebug()
setCalibrationTargetsetCalibrationTarget(target: { targetId: string; expectedNX: number; expectedNY: number }): void
startSessionstartSession(metadata?: Record<string, unknown>): boolean
stopSessionstopSession(reason?: 'ended' | 'timeout'): boolean
setNavigationRefsetNavigationRef(ref: any): void

Reference#

init#

TypeScript
ScaleBun.init(rawConfig: SimplifiedInitConfig | ScaleBunInitConfig | any)

Initialize the ScaleBun SDK.

trackPurchase#

TypeScript
ScaleBun.trackPurchase(input: { revenue: number; currency: string; transactionId: string; [k: string]: any }): void

Convenience: emit a Phase 1 purchase event (revenue + currency + transaction_id).

updateSkanConversionValue#

TypeScript
ScaleBun.updateSkanConversionValue(value: number, coarseValue?: SkanCoarseValue, lockWindow?: boolean): void

Phase 3: set the SKAdNetwork fine conversion value (0–63), optionally with a SKAN 4.0 coarse value and window-lock. iOS only — a no-op on Android / Expo Go.

getFeatureFlags#

TypeScript
ScaleBun.getFeatureFlags(): ScaleBunFeatures

Get the current feature flags (consumed by enableDebug)

identify#

TypeScript
ScaleBun.identify(userId: string, traits?: Record<string, any>)

Identify a user by ID and optional traits

identifyUser#

TypeScript
ScaleBun.identifyUser(userId: string, traits?: Record<string, any>)

Stable public alias for {@link identify}. Part of the minimal public push API surface (ScaleBun.init / identifyUser / enablePush) that stays identical across RN versions and future platforms.

setUser#

TypeScript
ScaleBun.setUser(user: ScaleBunUser)

Set user identity (for session context)

clearUser#

TypeScript
ScaleBun.clearUser()

Clear user identity

submitRating#

TypeScript
ScaleBun.submitRating(input: { rating: number; comment?: string; source?: 'in_app' | 'prompt' | 'manual'; /** [ADDITIVE] client-generated UUID for app-rating idempotency (contract §1.4, D8). */ clientRatingId?: string; })

Submit in-app rating (1-5 stars). Attaches to current session when available; otherwise sends standalone. Never throws.

enablePush#

TypeScript
ScaleBun.enablePush(options?: EnablePushOptions): Promise<EnablePushResult>

Enable push notifications with smart, version-aware adapter selection.

onForegroundNotification#

TypeScript
ScaleBun.onForegroundNotification(cb: (notification: PushNotification) => void): () => void

Subscribe to notifications received while the app is foregrounded. Thin, platform-agnostic alias for enablePush({ onForegroundNotification }); use it to attach a handler after enablePush. Returns an unsubscribe function. Inert until push is enabled. (iOS direct APNs delivers these via the native UNUserNotificationCenter surface.)

onNotificationOpened#

TypeScript
ScaleBun.onNotificationOpened(cb: (notification: PushNotification) => void): () => void

Subscribe to the user tapping a notification (open / deep-link), including the cold-start notification that launched the app. Thin alias for enablePush({ onNotificationOpened }). Returns an unsubscribe function. The event shape ({ data, title?, body? }) matches across Android and iOS.

trackPermission#

TypeScript
ScaleBun.trackPermission(permission: string, status: 'granted' | 'denied' | 'blocked' | 'undetermined' | 'limited', details?: Record<string, any>)

Report the outcome of an OS permission prompt.

track#

TypeScript
ScaleBun.track(name: string, payload?: Record<string, any>)

Track a named event with optional payload

log#

TypeScript
ScaleBun.log(level: 'debug' | 'info' | 'warn' | 'error', message: string, data?: Record<string, unknown>)

Log a message (convenience wrapper over track)

captureError#

TypeScript
ScaleBun.captureError(error: Error | string, context?: { screenName?: string; fatal?: boolean; type?: string; metadata?: Record<string, unknown> })

Capture a handled error/exception and deliver it to the backend errors endpoint (shows up in the dashboard Crashes view).

nativeCrash#

TypeScript
ScaleBun.nativeCrash()

DEV/TEST ONLY — trigger a real native crash to validate the native capture → next-launch drain → backend pipeline. No-op when the native module is unavailable. Do not ship calls to this in production code.

reportBug#

TypeScript
ScaleBun.reportBug(description: string, metadata?: Record<string, unknown>)

Report a bug (convenience wrapper over track)

setAttribute#

TypeScript
ScaleBun.setAttribute(key: string, value: string | number | boolean)

Set a custom attribute on the current session

flush#

TypeScript
ScaleBun.flush()

Force-flush all pending events

enableDebug#

TypeScript
ScaleBun.enableDebug(config: DebugConfig)

Enable the debug subsystem.

disableDebug#

TypeScript
ScaleBun.disableDebug()

Disable the debug subsystem and clean up

setCalibrationTarget#

TypeScript
ScaleBun.setCalibrationTarget(target: { targetId: string; expectedNX: number; expectedNY: number }): void

Diagnostic-only: stamp the expected target for the very next gesture event. Calibration screens call this immediately before their onPress fires so SessionManager merges expectedTargetId / expectedNX / expectedNY into the stored gesture payload. Pure observability — never affects capture, normalization, or marker placement. TTL ≈ 500 ms.

startSession#

TypeScript
ScaleBun.startSession(metadata?: Record<string, unknown>): boolean

Start a session (delegates to session namespace)

stopSession#

TypeScript
ScaleBun.stopSession(reason?: 'ended' | 'timeout'): boolean

Stop the current session (delegates to session namespace)

setNavigationRef#

TypeScript
ScaleBun.setNavigationRef(ref: any): void

Set the React Navigation container ref for automatic screen detection.

Methods · API reference · React Native SDK · ScaleBun