MicroSurvey), one
React provider (<InsitoProvider>), one hook (useInsito), and one
navigation helper (useInsitoScreenTracking), plus theme/label helpers.
Imports
MicroSurvey
The named-export singleton (import { MicroSurvey }). Holds the SDK state
machine and the imperative methods you call from your app.
MicroSurvey.init(config)
Boots the SDK. Call once, as early as possible (module top-level is
fine). Subsequent calls are silently ignored; a console warning is emitted only
when debug: true was set on the first successful init().
Override the API base URL — useful for staging environments or
self-hosted instances. Default points to production.
Per-request timeout in milliseconds. Lowering this on flaky
networks will route more responses through the offline queue.
Optional environment tag (e.g.
"production", "staging") sent as device
metadata and usable in audience filters.Send nothing until
MicroSurvey.optIn() is called, for apps that ask for
consent first. The decision is stored on the device. See
Consent.{ preset?: 'light' | 'dark' | 'minimal' | 'rounded', overrides?: Partial<InsitoTheme> }.
See Theming.In-code overrides for the built-in UI strings. See
Labels.
MicroSurvey.identify(args)
Associates subsequent triggers with a stable user. Cached for 24
hours per userId so repeat calls don’t hit the network.
Stable, unique identifier for your user, such as the user’s ID in your
database. Don’t pass an email address, phone number or name: an opaque ID
keeps answers pseudonymous. See Privacy.
Your app’s build version, e.g.
"2.7.0". Surfaces in the
dashboard so you can correlate feedback with releases.Free-form device-level key/value pairs. Merged on top of the SDK’s
auto-captured device metadata
— your keys win on a collision.
Custom, business-level user properties (e.g.
plan: "premium",
transactionsThisMonth: 14, hasLinkedCard: true). Stored on the respondent
and discovered into the dashboard
User Properties registry, where they become
type-aware audience filters. Only string / number / boolean values are
kept. Call identify() again whenever a value changes — the API always uses
the most recent value.Even with no
metadata or properties, every identify() auto-captures
device + lifecycle metadata (locale, timezone, osVersion,
sessionCount, daysSinceInstall). See
Configure.MicroSurvey.trigger(eventName)
Fires a trigger by name. The server decides whether to show a survey.
trigger() is async (Promise<void>) and sets the state to loading while
the request is in flight; the modal appears once the server responds. Fire it
fire-and-forget with void.
Event name configured against a survey in the dashboard (e.g.
"checkout_completed"). Allowed characters are A–Z a–z 0–9 _; keys are
case-sensitive. See Triggers.- Not initialised → no-op + debug warning.
- No
identify()call yet → no-op + debug warning. - A survey is already active → no-op + debug log.
MicroSurvey.submitResponse(surveyId, answers, options?)
Used internally by the built-in modal. You’d only call this directly
if you’re rendering your own question UI.
Array of
{ questionId, type, value }. See Answer type
below.{ keepModalOpen?: boolean; responseId?: string }. Pass responseId to
complete an existing partial response.Promise<SubmitResponseResult>:
queued means the answers are saved on the device and will be delivered later
(see Offline delivery).
MicroSurvey.evaluate(reason?, options?)
Runs the auto-evaluated trigger check (app open, session start, screen visit).
The SDK calls this automatically on identify and screen visits; call it directly
only for custom lifecycle hooks. Returns Promise<void>.
MicroSurvey.savePartialProgress(surveyId, answers, existingResponseId?)
Persists in-progress answers for autosave-enabled surveys. Used internally by
the modal as the user advances; returns the partial response id.
MicroSurvey.dismissSurvey()
Closes the active modal without submitting. Emits survey_dismissed.
Used by the close button in the built-in UI.
MicroSurvey.on(event, listener) / MicroSurvey.off(event, listener)
Subscribe to lifecycle events. on() returns an unsubscribe function.
Consent and data
Requires 0.3.0+. See Privacy and data requests.MicroSurvey.optOut(): Promise<void>stops all collection on this device untiloptIn(): no identify, triggers, screen tracking or responses. Queued responses and the cached identity are deleted, and an open survey closes. The decision is stored, and it can be called beforeinit().MicroSurvey.optIn(): Promise<void>allows collection again, or for the first time withdeferCollection. Callidentify()afterwards.MicroSurvey.reset(): Promise<void>forgets the identified user, for example on logout. Queued answers are still delivered and the consent decision is kept.MicroSurvey.consentis"granted","denied"or"pending"(withdeferCollectionbeforeoptIn()).
submitResponse() resolves to
{ status: "failed", reason: "collection_disabled" } and stores nothing.
MicroSurvey.onNavigationStateChange(state)
Bridges React Navigation v6/v7 state into the screen-map system.
Subscribe in your NavigationContainer.onStateChange:
useInsitoScreenTracking() instead.
Read-only state
MicroSurvey.config returns only the runtime API settings (apiKey, apiUrl,
requestTimeoutMs, debug, environment, deferCollection) — not the
theme, labels, events, or screens you passed to init().
React layer
<InsitoProvider>
Renders the survey bottom sheet. Wrap your app inside one (under a
GestureHandlerRootView). Children render normally; the survey sheet mounts on
top via @gorhom/bottom-sheet.
appearance prop drives the light/dark scheme for
themeMode: "auto" surveys. Defaults to "system" (follow the device); pass
"light" / "dark" to mirror your app’s own theme. See
Theming.
useInsito()
Hook that returns reactive state:
{ activeSurvey, dismissSurvey, theme, sdkState, labels }. Re-renders when any
of them change. Throws if called outside <InsitoProvider>.
useInsitoScreenTracking()
Auto-tracks screen visits for Expo Router apps. Call it in your root
layout — no arguments needed.
Theme helpers
resolveTheme(preset, overrides?)
Builds an InsitoTheme from a preset name ('light' | 'dark' | 'minimal' | 'rounded')
plus optional overrides. Useful if you want to preview a theme
outside the SDK.
themePresets
The raw preset map: { light, dark, minimal, rounded }. Each entry is
a complete InsitoTheme. Use this if you want to start from a preset
and tweak it deeply.
Types
Answer
nps:valueis a number 0–10.rating:valueis a number 1–5.multiple_choice:valueis a string (single-select) or string[] (multi-select).open_text:valueis a string.
SdkState
idle→ user can firetrigger().loading→ trigger in flight to the server.survey_active→ modal is on screen.completed→ response submitted, modal closed (transient).