shotik 0.2.0
shotik: ^0.2.0 copied to clipboard
Shotik SDK for Flutter. In-app support chat answered from Shotik and product analytics, with no third-party dependencies.
shotik (Flutter) #
Shotik's Support chat and Analytics for Flutter apps. Users write from your app and the conversation lands in Shotik's Support inbox on your Mac, where you or the AI answer; replies arrive live. Analytics records sessions, screens, taps (with rage and dead taps), scroll depth, errors, stalls, purchases and your own events, packed in the same wire format as the React Native and Swift SDKs.
- Zero third-party dependencies:
flutteronly. HTTP and WebSocket usedart:io; the session token lives in the Keychain (iOS) or private app storage (Android) through a small native plugin. Shotik.configuredoes no I/O. It stores the key and URL and returns; the modules start on the next event-loop turn. Calls made before it (an auth listener at startup, a push token on launch) are held and replayed in order.- Import only what you use:
package:shotik/support.dart(client),support_ui.dart(client + widget),analytics.dart, orshotik.dartfor everything. - Support: anonymous id that moves to the user on sign-in, optimistic sends with an offline queue that survives restarts, a live stream with backoff, receipts (sending, queued, sent, delivered, seen, failed), typing, quick replies, "Talk to a person", photos and screenshots, unread counts, push token.
- The widget: a bottom sheet built from plain Flutter widgets (no Material or Cupertino look), a spring open and drag to dismiss, an optional launcher with an unread badge, light and dark, text scaling, semantics labels, RTL, English and Russian copy from the device locale. v1.1 screens: the AI consent line, action buttons under replies (in progress, done, didn't work), the friction chip, "Did this help?", the Subscription screen with an honest cancel (one optional reason, "Cancel in App Store" or Google Play on the same screen, at most one founder alternative at equal weight), a help-first refund screen, "Rate {app}" and Delete my data with a confirm.
- Analytics: screens from a
NavigatorObserver(MaterialApp, CupertinoApp, GoRouter), taps identified by widget names, keys andSemantics(identifier:), wireframes that never contain characters,ShotikMaskfor anything private, consent, one-linein_app_purchasewiring, tap response times, and failed or slow requests throughHttpOverrides(chained to any you set; method, host, a templated path, status and duration only). - On-device privacy: tap labels from
Semantics(label:)or the key only (labels: Labels.visiblebrings visible text back), emails, phones, ids and tokens redacted from labels, errors and custom props, personal-data keys dropped, no tap position inside a mask or a secure field. - UI-state changes on one screen (pagers, steppers) as
stateevents, text field focus spans without their text, and store-truth purchases (renewals and trial conversions) from RevenueCat's customer info orin_app_purchase. - Touches as one of tap, long press, swipe, pan, pinch or scroll (
gestureevents carry no position), onescrollper container once it settles (with the page of aPageView), and the SDK's own cost onclose(perf). - Wireframe replay: keyed wireframe frames and diffs, no text and no field contents. Sampled sessions stream them; the
rest keep the last 30 s on the device and send them only after a rage, dead or unresponsive tap, a failed request
right after a tap, an error or a crash.
enable(replay: false)turns it off;wifiOnly: trueholds uploads until yourwificallback answers true (the SDK adds no connectivity dependency). For the App Store privacy label (Product Interaction, not linked to the user, analytics), replay collects screen layouts as boxes (kind, position, size, background color, corner radius), the screen name, scroll offsets, gesture kinds with distances, and the session and install ids; never text, input values, images, web content or touch positions. The server keeps chunks 30 days. - Flutter 3.24+ and Dart 3.5+. iOS 13+ as a Swift package (no CocoaPods); Android minSdk 21.
The full walkthrough, with troubleshooting, is in INTEGRATION.md. Русская версия: README.ru.md.
Quick start #
# flutter pub add shotik
dependencies:
shotik: ^0.2.0
import 'package:shotik/shotik.dart';
void main() {
Shotik.configure(appKey: 'spk_…', serverUrl: 'https://support.example.com');
runApp(const ShotikRoot(child: MyApp()));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) => MaterialApp(
navigatorObservers: [ShotikAnalytics.navigatorObserver],
builder: ShotikSupportWidget.builder(title: 'Walkito', quickReplies: const ['Billing', 'Report a bug']),
home: const Home(),
);
}
// Help row
onTap: () => ShotikSupport.open(),
// After your own sign-in / on sign-out
ShotikSupport.identify(userId: user.id, email: user.email, name: user.name);
ShotikAnalytics.identify(user.id);
ShotikSupport.reset();
ShotikAnalytics.reset();
The iOS app needs Swift Package Manager support enabled once on the machine that builds it:
flutter config --enable-swift-package-manager.
API #
Shotik.configure(appKey:, serverUrl:, debug:) |
Once, as early as you like. No I/O on the calling isolate. serverUrl is optional and defaults to DEFAULT_SERVER (https://ingest.shotik.app). In release builds plain http is allowed only for private networks (loopback, *.local, 10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7); anything else sends nothing and warns once. |
ShotikAnalytics.enable(healthTerms:) |
Extra health terms (stems, en or ru). Tap and rage labels containing a built-in or app term are sent as [health]; the filter cannot be turned off. 429/503 Retry-After and 413 batch halving are handled for you. |
ShotikRoot(child:) |
Wrap the app once (around MaterialApp). Deep links, the screenshot boundary, the root that taps are described against, and the scroll layer. |
ShotikSupportWidget.builder(...) |
For MaterialApp / CupertinoApp / WidgetsApp builder:. title, teamName, theme, launcher, launcherBottom (distance above the bottom safe area, to clear a bottom button or tab bar), quickReplies, locale, appName (for "Rate {app}"), frictionChip (default true). |
ShotikFrictionChip(theme:, locale:) |
The "Something wrong? Write to us" chip on its own, for apps that place it (set frictionChip: false on the widget). |
ShotikSupport.open([conversationId]), close() |
Show or hide the sheet. |
ShotikSupport.identify(userId:, name:, email:, attributes:), reset() |
Signed-in user / sign-out (new anonymous id). |
ShotikSupport.setPushToken(token, platform:) |
APNs or FCM token; null clears it. |
ShotikSupport.handleLink(uri) |
<scheme>://support opens the sheet. ShotikRoot already routes platform links here. |
ShotikSupport.attachmentPicker |
Your image picker; with it set the attach menu offers "Photo". "Screenshot" needs nothing. |
ShotikSupport.setAiConsent(allowed), aiConsent |
The user's answer to AI-drafted replies (Apple 5.1.2(i)); aiConsent is consent your app already collected. Unset, the widget asks once. |
ShotikSupport.setSubscription(Subscription(...)) |
The plan from RevenueCat or your billing code (null: none). The founder sees it next to the chat. |
ShotikSupport.onAction, openUrl, appStoreId |
Buttons under founder and AI messages (manage, restore, redeem, change plan, refund, review, custom). onAction returns ActionResult; without it the store pages open through openUrl. |
ShotikSupport.reviewMoment(name), requestReview |
A success moment. Calls your review prompt only when the founder's rules pass (count, days since install, once per version, 3 a year, quiet after friction, refund or cancel). |
ShotikSupport.friction(Friction(kind:, screen:, element:)) |
purchase_fail, rage or error: may show the "Something wrong?" chip, once per session. |
ShotikSupport.deleteMyData() |
Delete my data (Apple 5.1.1(v), GDPR): wipes chats, ids, consent, the review ledger, the push token and the install's analytics on the device at once, then has the server erase them. EraseResult.pending offline: retried with backoff on foreground and after a restart. |
ShotikSupport.client, clientListenable |
The SupportClient: state (conversations, messages, unread, typing, status, aiConsent, subscription, widget, friction), send, retry, handoff, runAction, rate, track, openFriction, dismissFriction, askForOffer(reason) (the device only has an offer's label; asking opens a conversation for the founder). |
ShotikAnalytics.navigatorObserver |
One per navigator. Starts analytics. |
ShotikScreen(name:, child:) |
Names a screen explicitly (tabs, pages without a route name). |
ShotikMask(child:), key: const ShotikMaskKey() |
Hidden from tap labels, tap positions, wireframes and replay; the key does the same as a flag on any widget (ShotikMaskKey('pan') tells masked siblings apart). Text fields are always masked; secure ones lose the tap position too. Masking can't be turned off. |
ShotikAnalytics.track(name, props), screen(name), identify(userId, traits) |
Custom events, manual screens, the user. Keys like email, phone, name, token are dropped and strings redacted. |
ShotikAnalytics.purchase(...), watchPurchases(stream, products:) |
Purchases, by hand or from in_app_purchase (at from the transaction; renewals through the watermark on iOS). |
ShotikAnalytics.customerInfo(info, quiet:), entitled([Entitled(...)]) |
Store truth: Purchases.addCustomerInfoUpdateListener(ShotikAnalytics.customerInfo); renewals (renew) and trial conversions (conv) once each. |
ShotikAnalytics.enable(consent:, snapshots:, flushMs:, sessionTimeoutMs:, debug:, labels:, replay:, wifiOnly:, wifi:) |
Options; labels is Labels.a11y (default), visible or none; replay (default on) is wireframe replay, wifiOnly holds its uploads until wifi: () async => onWifi answers true. optIn() / optOut() / setConsent(). |
ShotikAnalytics.flush(), reset(), ids |
Send now, new anonymous id, current ids. |
ShotikAnalytics.forget() |
A user's data deletion request: drops the queue, wireframes and replay on the device, has the server delete the install's events, wireframes and replay, then starts a new anonymous install. false when the server can't be reached (the id is kept; call again to retry). Works whatever the consent. |
ShotikSupportTheme |
Default | |
|---|---|---|
accent |
iOS blue | Your bubbles, send button, launcher, links |
onAccent |
white | Text and glyphs on the accent |
radius |
18 |
Bubble radius; the sheet, chips and field follow it |
fontFamily, fontFamilyBold |
system | Regular and semibold families |
brightness |
platform | Force light or dark |
light, dark |
ShotikColors overrides |
Sample #
example/ is "Shotik Sample" (bundle id ai.shotik.sample.flutter, URL scheme shotiksampleflutter). See
example/README.md.
Tests #
flutter analyze
flutter test
50 tests: the PROTOCOL.md section 9 conformance cases against a fake Shotik server, the packed batch compared byte for
byte with the reference wire.ts output, the sheet (open, optimistic send, receipts, typing, quick replies, light and
dark, 2x text, Russian copy), tap identity and wireframes, and [perf] timings for configure, batch encoding and tap
description.