insightdive_sdk 0.2.0
insightdive_sdk: ^0.2.0 copied to clipboard
Drop-in Flutter SDK that embeds in-app feedback surveys served by the Insightdive platform. Hosts the survey in a modal bottom sheet, listens to lifecycle events (viewed / started / completed / dismis [...]
insightdive_sdk #
Drop-in Flutter SDK for Insightdive — the in-app
feedback platform. Two integration modes: a modal bottom sheet (one line)
or an embedded SurveyView widget (place it anywhere in your tree).
Install #
dependencies:
insightdive_sdk: ^0.2.0
Configure #
Call once at app startup, before runApp:
import 'package:insightdive_sdk/insightdive_sdk.dart';
void main() {
Insightdive.configure(
tenant: 'acme', // workspace slug — subdomain on insightdive.com
survey: 'onboarding', // project slug from the admin
sdkToken: 'sdk_abc123…', // Admin → Project → SDK Token
);
runApp(const MyApp());
}
Modal integration #
Open the survey as a bottom sheet from any BuildContext:
final result = await Insightdive.show(context);
if (result.status == FeedbackStatus.completed) {
print('Submitted — id: ${result.submissionId}');
} else {
print('Dismissed after ${result.duration.inSeconds}s');
}
Embedded widget #
Place SurveyView directly in any widget tree — a Card, a dedicated page,
a side panel, or a custom showDialog:
import 'package:insightdive_sdk/insightdive_sdk.dart';
// Inside a build() or a showDialog builder:
SizedBox(
height: 480,
child: SurveyView(
onResult: (result) {
if (result.status == FeedbackStatus.completed) {
Navigator.of(context).pop();
}
},
),
)
SurveyView takes two optional callbacks:
| Callback | Type | Description |
|---|---|---|
onEvent |
void Function(FeedbackEvent) |
Every lifecycle event, same as Insightdive.events |
onResult |
void Function(FeedbackResult) |
Terminal result — completed or dismissed |
Lifecycle events #
Subscribe to Insightdive.events to react to user progress. The stream is
shared between the modal and any SurveyView instances:
Insightdive.events.listen((event) {
switch (event) {
case FeedbackReady(): // webview loaded, bridge alive
case FeedbackViewed(): // survey session registered as viewed
case FeedbackStarted(): // user clicked the start button
case FeedbackCompleted(:final submissionId):
analytics.track('feedback_completed', {'id': submissionId});
case FeedbackDismissed():
analytics.track('feedback_dismissed');
}
});
Programmatic control #
// Close the modal sheet from code (e.g. on logout):
Insightdive.hide(context);
// Trigger by event name — maps to show() in v1, server-side routing in v2:
await Insightdive.trigger(context, 'ssh_failed_3x');
Configuration reference #
| Field | Type | Description |
|---|---|---|
tenant |
String |
Workspace slug — the subdomain on insightdive.com (e.g. 'acme'). |
survey |
String |
Project slug from the admin (e.g. 'onboarding'). Always serves the currently active deployment. |
sdkToken |
String |
Authentication token — Admin → Project → SDK Token. Required. |
baseUrl |
String? |
Full URL override for staging or self-hosted instances. |
productVersion |
String? |
App version stamped on every submission. |
productIdentifier |
String? |
Surface slug — useful when one app embeds the SDK in several places. |
locale |
String? |
Force a specific locale. Falls back to the survey's default. |
theme |
String? |
'light' or 'dark'. Falls back to the survey's authored theme. |
Platform support #
| Platform | Status |
|---|---|
| iOS | ✅ Supported |
| Android | ✅ Supported |
| macOS | ✅ Supported |
| Windows | ✅ Supported |
| Web | ⚠️ Untested — webview_flutter on Flutter web requires extra setup |
| Linux | ⚠️ Untested |
Privacy #
The SDK does not collect or transmit any user-identifying data. Only the
deploymentId, optional productVersion, optional productIdentifier,
locale, and theme fields are forwarded to the server. Submissions are
linked server-side via an opaque session id that never carries personal data.
License #
MIT. See LICENSE.