Methods
All 30 top-level methods on the ScaleBun facade.
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#
| Method | Signature |
|---|---|
init | init(rawConfig: SimplifiedInitConfig | ScaleBunInitConfig | any) |
trackPurchase | trackPurchase(input: { revenue: number; currency: string; transactionId: string; [k: string]: any }): void |
updateSkanConversionValue | updateSkanConversionValue(value: number, coarseValue?: SkanCoarseValue, lockWindow?: boolean): void |
getFeatureFlags | getFeatureFlags(): ScaleBunFeatures |
identify | identify(userId: string, traits?: Record<string, any>) |
identifyUser | identifyUser(userId: string, traits?: Record<string, any>) |
setUser | setUser(user: ScaleBunUser) |
clearUser | clearUser(options?: { purgeLocal?: boolean }) |
eraseLocalData | eraseLocalData(): Promise<void> |
setConsent | setConsent(enabled: boolean, options?: { purgeLocal?: boolean }): void |
getEffectivePrivacyPolicy | getEffectivePrivacyPolicy(): Required< Pick<PrivacyConfig, 'maskTextInputs' | 'maskImages' | 'redactAuth' | 'redactCookies' | 'redactBodies'> > |
submitRating | 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; }) |
reportBugDetailed | reportBugDetailed(input: { message: string; title?: string; email?: string; clientReportId?: string; }): Promise<BugSubmitResult> |
enablePush | enablePush(options?: EnablePushOptions): Promise<EnablePushResult> |
onForegroundNotification | onForegroundNotification(cb: (notification: PushNotification) => void): () => void |
onNotificationOpened | onNotificationOpened(cb: (notification: PushNotification) => void): () => void |
trackPermission | trackPermission(permission: string, status: 'granted' | 'denied' | 'blocked' | 'undetermined' | 'limited', details?: Record<string, any>) |
track | track(name: string, payload?: Record<string, any>) |
log | log(level: 'debug' | 'info' | 'warn' | 'error', message: string, data?: Record<string, unknown>) |
captureError | captureError(error: Error | string, context?: { screenName?: string; fatal?: boolean; type?: string; metadata?: Record<string, unknown> }) |
nativeCrash | nativeCrash() |
reportBug | reportBug(description: string, metadata?: Record<string, unknown>) |
setAttribute | setAttribute(key: string, value: string | number | boolean) |
flush | flush() |
enableDebug | enableDebug(config: DebugConfig) |
disableDebug | disableDebug() |
setCalibrationTarget | setCalibrationTarget(target: { targetId: string; expectedNX: number; expectedNY: number }): void |
startSession | startSession(metadata?: Record<string, unknown>): boolean |
stopSession | stopSession(reason?: 'ended' | 'timeout'): boolean |
setNavigationRef | setNavigationRef(ref: any): void |
Reference#
init#
ScaleBun.init(rawConfig: SimplifiedInitConfig | ScaleBunInitConfig | any)Initialize the ScaleBun SDK.
trackPurchase#
ScaleBun.trackPurchase(input: { revenue: number; currency: string; transactionId: string; [k: string]: any }): voidConvenience: emit a Phase 1 purchase event (revenue + currency + transaction_id).
updateSkanConversionValue#
ScaleBun.updateSkanConversionValue(value: number, coarseValue?: SkanCoarseValue, lockWindow?: boolean): voidPhase 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#
ScaleBun.getFeatureFlags(): ScaleBunFeaturesGet the current feature flags (consumed by enableDebug)
identify#
ScaleBun.identify(userId: string, traits?: Record<string, any>)Identify a user by ID and optional traits
identifyUser#
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#
ScaleBun.setUser(user: ScaleBunUser)Set user identity (for session context)
clearUser#
ScaleBun.clearUser(options?: { purgeLocal?: boolean })Clear user identity.
eraseLocalData#
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#
ScaleBun.setConsent(enabled: boolean, options?: { purgeLocal?: boolean }): voidSB-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#
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#
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#
ScaleBun.reportBugDetailed(input: { message: string; title?: string; email?: string; clientReportId?: string; }): Promise<BugSubmitResult>Submit a bug report against the CURRENT session.
enablePush#
ScaleBun.enablePush(options?: EnablePushOptions): Promise<EnablePushResult>Enable push notifications with smart, version-aware adapter selection.
onForegroundNotification#
ScaleBun.onForegroundNotification(cb: (notification: PushNotification) => void): () => voidSubscribe 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#
ScaleBun.onNotificationOpened(cb: (notification: PushNotification) => void): () => voidSubscribe 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#
ScaleBun.trackPermission(permission: string, status: 'granted' | 'denied' | 'blocked' | 'undetermined' | 'limited', details?: Record<string, any>)Report the outcome of an OS permission prompt.
track#
ScaleBun.track(name: string, payload?: Record<string, any>)Track a named event with optional payload
log#
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#
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#
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#
ScaleBun.reportBug(description: string, metadata?: Record<string, unknown>)Report a bug (convenience wrapper over track)
setAttribute#
ScaleBun.setAttribute(key: string, value: string | number | boolean)Set a custom attribute on the current session
flush#
ScaleBun.flush()Force-flush all pending events
enableDebug#
ScaleBun.enableDebug(config: DebugConfig)Enable the debug subsystem.
disableDebug#
ScaleBun.disableDebug()Disable the debug subsystem and clean up
setCalibrationTarget#
ScaleBun.setCalibrationTarget(target: { targetId: string; expectedNX: number; expectedNY: number }): voidDiagnostic-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#
ScaleBun.startSession(metadata?: Record<string, unknown>): booleanStart a session (delegates to session namespace)
stopSession#
ScaleBun.stopSession(reason?: 'ended' | 'timeout'): booleanStop the current session (delegates to session namespace)
setNavigationRef#
ScaleBun.setNavigationRef(ref: any): voidSet the React Navigation container ref for automatic screen detection.