Expo / React Native
@fictura/sdk 0.8.0The complete public surface of @fictura/sdk — three members on Growth, the core components, and the helpers around them.
Growth
Configures the SDK, installs press and error capture (each can be disabled), starts lifecycle tracking, hydrates the cached config, and fetches a fresh one.
The client-side gate — see Client-side gating. Fails closed before the first config.
Explicit error report; context is serialized into the message.
init config
Your Fictura host.
The SDK app key (gk_…) from Dashboard → Setup. Sent as x-api-key.
Your store wrapper: getPackages(), purchase(id), restore(), optional isSubscribed(). Without it, paywalls render with no packages and nothing can be purchased (block designs disable the CTA; locked templates surface a configuration error on tap). mockPurchasesAdapter ships for development.
Your user id — joins events, errors and entitlements to a person.
The RevenueCat app user id, for identity stitching with billing webhooks.
A bundled fallback config. Precedence: network > cache > defaults.
A change in the returned value triggers a config refetch without a restart.
Fires just before the user leaves for the browser — the place to arm a subscription re-check.
Observe every event as it queues.
Automatic element_tapped capture.
Crash / rejection / console.error capture.
Event batching: flush interval and batch-size trigger.
Components
<GrowthProvider>— mounts screen tracking and tap capture (both gated on the event-tracking tool) and the cancel-survey modal (gated on cancel-survey).<GrowthPaywall placement onClose onPurchaseComplete fallback assets />— renders whatever is live for the placement; see Served designs and Native templates.<GrowthOnboarding placement onComplete onStepView onAnswer fallback assets />— see Onboarding flows.<CancelSurveyModal />— polls for a pending cancel survey 4s after mount and on each foreground, throttled to five minutes.
Events
import { logEvent, setUserContext, setAttributes, flush } from "@fictura/sdk";
logEvent("generation_success", "success", { model: "large" });
// Super-properties merged into every event:
setUserContext({ plan: "trial" });
// Targeting attributes — max 20 keys, values ≤200 chars:
setAttributes({ onboarding_cohort: "b" });Events batch on device — 25 events or 4 seconds, whichever first, plus a flush on background — and POST to /api/v1/events/log. Status is one of success, failure, info. Events disabled on the dashboard are dropped before they're sent.
Automatic events
| Event | When |
|---|---|
first_open | Once per install. |
app_open | Launch and every foreground. |
screen_viewed / screen_closed | Route changes, with screen, from/to, and duration_ms. |
element_tapped | Any pressable, named by testID → accessibility label → child text → icon name → component name; dead taps fall back to coordinates. |
paywall_shown / paywall_screen_viewed / paywall_cta_tapped / paywall_dismissed | The paywall funnel. |
purchase_completed | With status success or failure from the block, flow and served-design renderers; single-screen locked templates (v3 configs) log it as info from the subscribe callback — filter on status with that in mind. |
onboarding_started / _step_viewed / _question_answered / _completed / _skipped | The onboarding funnel. |
web_checkout_opened / web_checkout_open_failed | The hand-off to the browser. |
Everything else
- Web checkout —
openWebCheckout(),isWebCheckoutAvailable(),tryWebCheckoutFirst()— the intercept the block (v1/v2), flow (v4) and served-design buy buttons run first. Single-screen locked templates (v3 configs) purchase directly through the adapter and skip it. - Push —
registerForPush()(a top-level export) prompts and registers an Expo push token; the SDK never prompts on its own. - Attribution —
claimAttribution(clickId),onConversionData(fn),onDeepLink(fn),getConversionData(); late subscribers are replayed the last payload. - Surveys —
checkPendingSurvey(),submitCancelSurvey(). - Errors —
captureError(),flushErrors(); see React Native. - Preview —
isPreviewMode(); in dashboard previews, events, surveys, errors and push are all suppressed.