ScaleBun
Skip to article

Methods

react-nativeDeveloper

All 30 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(options?: { purgeLocal?: boolean })
eraseLocalDataeraseLocalData(): Promise<void>
setConsentsetConsent(enabled: boolean, options?: { purgeLocal?: boolean }): void
getEffectivePrivacyPolicygetEffectivePrivacyPolicy(): Required< Pick<PrivacyConfig, 'maskTextInputs' | 'maskImages' | 'redactAuth' | 'redactCookies' | 'redactBodies'> >
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; })
reportBugDetailedreportBugDetailed(input: { message: string; title?: string; email?: string; clientReportId?: string; }): Promise<BugSubmitResult>
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(options?: { purgeLocal?: boolean })

Clear user identity.

eraseLocalData#

TypeScript
ScaleBun.eraseLocalData(): Promise<void>

SB-11: erase all locally-stored SDK data from the device — the durable event queue, the pre-init buffer, and the first-party KV store (cached install / anonymous / session IDs, plus any queued payloads including SB-26 disk data).

setConsent#

TypeScript
ScaleBun.setConsent(enabled: boolean, options?: { purgeLocal?: boolean }): void

SB-11: record the user's data-collection consent. When enabled is false, capture is stopped immediately; pass { purgeLocal: true } to also erase everything already stored locally. Never throws.

getEffectivePrivacyPolicy#

TypeScript
ScaleBun.getEffectivePrivacyPolicy(): Required< Pick<PrivacyConfig, 'maskTextInputs' | 'maskImages' | 'redactAuth' | 'redactCookies' | 'redactBodies'> >

SB-10: return the effective privacy policy actually in force, resolving the public config against the SDK's safe defaults. Lets callers and tests assert what is active rather than guessing from the (previously dead) config object.

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.

reportBugDetailed#

TypeScript
ScaleBun.reportBugDetailed(input: { message: string; title?: string; email?: string; clientReportId?: string; }): Promise<BugSubmitResult>

Submit a bug report against the CURRENT session.

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. Delivered to BOTH lanes: - the Diagnose → Logs lane (tagged source: 'sdk'), so an explicit log() call shows up where a developer looks for logs. The method name promised this, but it previously only emitted a $log analytics EVENT and never reached the Logs page. - the analytics $log event (unchanged), so anything already built on it keeps working. queueLog self-gates on clientKey, so the Logs-lane write is a no-op outside SaaS mode.

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