MicroSurvey), one widget
(InsitoProvider), and one navigator observer (InsitoNavigatorObserver).
Everything else is a type or theme helper.
Import
MicroSurvey, InsitoConfig,
UserProperties, InsitoProvider, InsitoAppearance,
InsitoNavigatorObserver, the InsitoEvent enum + InsitoEventPayload, the
theme types (ThemePreset, InsitoTheme, InsitoThemeOverrides, …,
resolveTheme, themePresets), BrandConfig, and the survey types
(ActiveSurvey, Answer, SurveyQuestion, QuestionType, SdkState, …).
MicroSurvey
A static facade over the SDK singleton. Holds the state machine and the
imperative methods you call from your app.
MicroSurvey.init(config) → Future<void>
Boots the SDK. Call once, as early as possible (top of main() after
WidgetsFlutterBinding.ensureInitialized()). Subsequent calls are ignored with
a debug warning.
Override the API base URL — useful for staging or self-hosted instances.
Per-request timeout in milliseconds. Lowering this on flaky networks routes
more responses through the offline queue.
Send nothing until
MicroSurvey.optIn() is called, for apps that ask for
consent first. The decision is stored on the device. See
Consent.Base preset for the survey modal. See Theming.
Override built-in UI chrome strings. See Labels.
Declare trigger events for the dashboard registry. See
Configure.
MicroSurvey.identify(user) → Future<void>
Associates subsequent triggers with a stable user. Cached for 24 hours per
userId, so repeat calls don’t hit the network. Takes a UserProperties:
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). Discovered into the dashboard
User Properties registry as type-aware audience
filters. Only String / num / bool values are kept. Call identify()
again whenever a value changes — the API always uses the most recent value.MicroSurvey.trigger(eventName) → Future<void>
Fires a trigger by name. The server decides whether to show a survey; if so, the
modal renders inside InsitoProvider.
Lowercase snake_case event name configured against a survey in the dashboard
(e.g.
"checkout_completed"). 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.evaluate([reason, options]) → Future<void>
Re-checks the auto-evaluated trigger types for the current user (e.g. session
count / days-since-install rules) without a specific event name.
MicroSurvey.submitResponse(surveyId, answers, [options]) → Future<SubmitResponseResult>
Used internally by the built-in modal. Call it directly only if you’re rendering
your own question UI.
List of
Answer(questionId, type, value). See Answer below.status is SubmitStatus.success, queued or failed.
queued means the answers are saved on the device and will be delivered later
(see Offline delivery).
MicroSurvey.savePartialProgress(surveyId, answers, [existingResponseId]) → Future<String?>
Persists partial answers (autosave) mid-survey, returning the response ID so
subsequent saves update the same row.
MicroSurvey.dismissSurvey() → void
Closes the active modal without submitting. Emits surveyDismissed. Used by the
built-in close button.
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()→Future<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()→Future<void>allows collection again, or for the first time withdeferCollection. Callidentify()afterwards.MicroSurvey.reset()→Future<void>forgets the identified user, for example on logout. Queued answers are still delivered and the consent decision is kept.MicroSurvey.consent→ConsentState:granted,denied, orpending(withdeferCollectionbeforeoptIn()).
submitResponse() returns SubmitStatus.failed
with reason collection_disabled and stores nothing.
MicroSurvey.recordScreenVisit(name) → void
Records a screen visit and fires screen_viewed:<name> when a user is
identified. InsitoNavigatorObserver calls this for you; use it directly for
routing that isn’t Navigator-driven. See
Screen tracking.
Read-only state
Widgets
InsitoProvider
Renders the survey modal above your app. Wrap it around your MaterialApp.
Drives the light/dark scheme for
themeMode: "auto" surveys. system follows
the device; light / dark mirror your app’s own theme. See
Theming.InsitoNavigatorObserver
A NavigatorObserver that reports screen visits. Add it to
MaterialApp(navigatorObservers: [InsitoNavigatorObserver()]). See
Screen tracking.
Theme helpers
resolveTheme(preset, [overrides]) → InsitoTheme
Builds a fully-populated InsitoTheme from a ThemePreset plus optional
InsitoThemeOverrides. Useful for previewing a theme outside the SDK.
themePresets
The raw preset map: Map<ThemePreset, InsitoTheme>. Each entry is a complete
InsitoTheme.
Types
Answer
nps:valueis anint0–10.rating:valueis anint1–5.multipleChoice:valueis aString(single-select) orList<String>(multi-select).openText:valueis aString.
SdkState
idle→ user can firetrigger().loading→ trigger in flight to the server.surveyActive→ modal is on screen.completed→ response submitted, modal closed (transient).
QuestionType
welcomeScreen / endScreen are
copy/CTA-only steps. Each maps to a wire value (nps, rating,
multiple_choice, open_text, welcome_screen, end_screen).