@shotik/mcp 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -2
  3. package/README.ru.md +40 -0
  4. package/data/PROTOCOL.md +386 -0
  5. package/data/flutter/INTEGRATION.md +197 -0
  6. package/data/flutter/README.md +112 -0
  7. package/data/flutter/README.ru.md +165 -0
  8. package/data/flutter/guide.json +190 -0
  9. package/data/flutter/recipe.json +364 -0
  10. package/data/react-native/README.md +194 -0
  11. package/data/react-native/README.ru.md +192 -0
  12. package/data/react-native/guide.json +136 -0
  13. package/data/react-native/recipe.json +263 -0
  14. package/data/react-native/src/analytics/README.md +32 -0
  15. package/data/react-native/src/analytics/recipe.json +263 -0
  16. package/data/storecheck/packs/ai.json +1 -0
  17. package/data/storecheck/packs/dating.json +1 -0
  18. package/data/storecheck/packs/education.json +1 -0
  19. package/data/storecheck/packs/finance.json +1 -0
  20. package/data/storecheck/packs/fitness.json +1 -0
  21. package/data/storecheck/packs/health.json +1 -0
  22. package/data/storecheck/packs/kids.json +1 -0
  23. package/data/storecheck/packs/language.json +1 -0
  24. package/data/storecheck/packs/mindfulness.json +1 -0
  25. package/data/storecheck/packs/music.json +1 -0
  26. package/data/storecheck/packs/nutrition.json +1 -0
  27. package/data/storecheck/packs/photo-video.json +1 -0
  28. package/data/storecheck/packs/productivity.json +1 -0
  29. package/data/storecheck/packs/spirituality.json +1 -0
  30. package/data/storecheck/packs/taxonomy.json +1 -0
  31. package/data/storecheck/packs/utilities.json +1 -0
  32. package/data/storecheck/storecheck.browser.js +314 -0
  33. package/data/swift/README.md +327 -0
  34. package/data/swift/README.ru.md +333 -0
  35. package/data/swift/guide.json +189 -0
  36. package/data/swift/recipe.json +506 -0
  37. package/package.json +42 -4
  38. package/server.mjs +144 -0
  39. package/sources.json +86 -0
@@ -0,0 +1,364 @@
1
+ {
2
+ "schema": "shotik.recipe/1",
3
+ "id": "support-flutter",
4
+ "title": "Shotik Support and Analytics SDK in a Flutter app",
5
+ "package": "shotik",
6
+ "rules": [
7
+ "Follow the repo's own conventions (AGENTS.md, CLAUDE.md, analysis_options.yaml, file layout) when placing code.",
8
+ "Edit only the files a step names or detects. Never edit ios/Runner.xcodeproj or android/ Gradle files for the SDK: Flutter links the plugin itself. The only native edits are the URL scheme in step route.",
9
+ "Replace {{VARS}} before writing. Keep edits minimal and idempotent: skip a step whose `done` check already passes.",
10
+ "The SDK depends on flutter only; never add packages for it. Optional plugins (in_app_purchase, image_picker, firebase_messaging) are the app's choice, and the SDK only uses them when the app already has them.",
11
+ "Keep the app's minimum Flutter: the SDK supports Flutter 3.24 / Dart 3.5 and newer.",
12
+ "In Shotik, run add-swift-package and plist-* edits through the ios_project tool (it edits project.pbxproj and plists the way Xcode does, idempotently). Without that tool, or when it returns an error, make the edit by hand as the step's how describes."
13
+ ],
14
+ "variables": {
15
+ "APP_KEY": {
16
+ "required": true,
17
+ "desc": "Public SDK key from Shotik (Support → SDK), spk_…; safe to ship in the app"
18
+ },
19
+ "SERVER_URL": {
20
+ "required": true,
21
+ "desc": "Shotik server URL the phone can reach (iOS simulator: http://127.0.0.1:4590; Android emulator: http://10.0.2.2:4590; device: the Mac's LAN address or your deployment)"
22
+ }
23
+ },
24
+ "detect": [
25
+ {
26
+ "id": "legacy",
27
+ "how": "pubspec.yaml dependencies.shotik has a path: (a vendored copy) → true",
28
+ "result": "true | false"
29
+ },
30
+ {
31
+ "id": "flutter",
32
+ "how": "pubspec.yaml has dependencies.flutter.sdk: flutter",
33
+ "result": "true | false"
34
+ },
35
+ {
36
+ "id": "packageName",
37
+ "how": "pubspec.yaml name"
38
+ },
39
+ {
40
+ "id": "main",
41
+ "how": "The file with void main() that calls runApp: lib/main.dart, else the flavour entry (lib/main_*.dart) the default run configuration uses; with several flavours, every entry"
42
+ },
43
+ {
44
+ "id": "appWidget",
45
+ "how": "The widget that returns MaterialApp, MaterialApp.router, CupertinoApp, CupertinoApp.router or WidgetsApp, and its file",
46
+ "result": "{ file, kind: material | material.router | cupertino | cupertino.router | widgets }"
47
+ },
48
+ {
49
+ "id": "router",
50
+ "how": "go_router in pubspec dependencies → go_router (find the GoRouter(...) construction and every ShellRoute / StatefulShellRoute); auto_route → auto_route; else navigator (routes:, onGenerateRoute, home)"
51
+ },
52
+ {
53
+ "id": "existingBuilder",
54
+ "how": "Whether the app widget already passes builder: (e.g. a MediaQuery or ResponsiveBreakpoints wrapper)",
55
+ "result": "true | false"
56
+ },
57
+ {
58
+ "id": "scheme",
59
+ "how": "iOS: CFBundleURLSchemes in ios/Runner/Info.plist; Android: <data android:scheme> in android/app/src/main/AndroidManifest.xml; else none",
60
+ "optional": true
61
+ },
62
+ {
63
+ "id": "auth",
64
+ "how": "Where the app learns the signed-in user: authStateChanges()/onAuthStateChange listener, a session notifier or bloc, or the sign-in success handler; also its sign-out path",
65
+ "optional": true
66
+ },
67
+ {
68
+ "id": "push",
69
+ "how": "firebase_messaging in dependencies: the call to FirebaseMessaging.instance.getToken() / getAPNSToken() / onTokenRefresh",
70
+ "optional": true
71
+ },
72
+ {
73
+ "id": "helpEntry",
74
+ "how": "Every existing contact row on settings/profile screens (grep mailto:, launchUrl with mailto, 'Contact', 'Help', 'Support', 'Feedback'), else the list a new row belongs in"
75
+ },
76
+ {
77
+ "id": "purchases",
78
+ "how": "in_app_purchase in dependencies: where InAppPurchase.instance.purchaseStream is listened to, and the variable holding the queried ProductDetails list",
79
+ "optional": true
80
+ },
81
+ {
82
+ "id": "imagePicker",
83
+ "how": "image_picker in dependencies",
84
+ "result": "true | false"
85
+ },
86
+ {
87
+ "id": "brand",
88
+ "how": "The app's primary/accent color, base corner radius and font family from its ThemeData / theme constants; omit what you cannot find",
89
+ "optional": true
90
+ },
91
+ {
92
+ "id": "secrets",
93
+ "how": "How the app injects config: --dart-define / --dart-define-from-file (String.fromEnvironment), flutter_dotenv, flavour constants; reuse it for APP_KEY and SERVER_URL",
94
+ "optional": true
95
+ }
96
+ ],
97
+ "steps": [
98
+ {
99
+ "id": "dependency",
100
+ "title": "Add the package",
101
+ "edits": [
102
+ {
103
+ "op": "yaml-set",
104
+ "file": "pubspec.yaml",
105
+ "path": [
106
+ "dependencies",
107
+ "shotik"
108
+ ],
109
+ "value": "^0.1.0"
110
+ }
111
+ ],
112
+ "run": {
113
+ "any": "flutter pub get && flutter config --enable-swift-package-manager"
114
+ },
115
+ "done": "grep -q 'shotik' .dart_tool/package_config.json",
116
+ "note": "Installs from pub.dev (pub.dev/packages/shotik). SwiftPM must be enabled on the machine that builds iOS (the plugin ships ios/shotik/Package.swift, no podspec). Apps that also use CocoaPods for other plugins keep working.",
117
+ "migrate": "When detect.legacy is true: the yaml-set replaces the path: entry; delete the vendored folder it pointed at."
118
+ },
119
+ {
120
+ "id": "configure",
121
+ "title": "Configure before runApp and wrap the root",
122
+ "file": "{{detect.main}}",
123
+ "edits": [
124
+ {
125
+ "op": "add-import",
126
+ "code": "import 'package:shotik/shotik.dart';"
127
+ },
128
+ {
129
+ "op": "insert-before",
130
+ "anchor": "the runApp(...) call in main()",
131
+ "code": "Shotik.configure(appKey: {{appKeyExpr}}, serverUrl: {{serverUrlExpr}});"
132
+ },
133
+ {
134
+ "op": "wrap-call-arg",
135
+ "target": "The widget passed to runApp(...) (inside any ProviderScope / MultiProvider / BlocProvider the app already passes)",
136
+ "open": "ShotikRoot(child: ",
137
+ "close": ")"
138
+ }
139
+ ],
140
+ "done": "grep -q 'Shotik.configure(' {{detect.main}} && grep -q 'ShotikRoot(' {{detect.main}}",
141
+ "note": "appKeyExpr / serverUrlExpr: follow detect.secrets (e.g. const String.fromEnvironment('SHOTIK_APP_KEY')); with nothing to follow, use the literal '{{APP_KEY}}' and '{{SERVER_URL}}'. ShotikRoot must sit above MaterialApp so it sees deep links first. If WidgetsFlutterBinding.ensureInitialized() or Firebase.initializeApp() runs first, keep configure after them and before runApp."
142
+ },
143
+ {
144
+ "id": "widget",
145
+ "title": "Add the Support widget and the screen observer",
146
+ "file": "{{detect.appWidget.file}}",
147
+ "edits": [
148
+ {
149
+ "op": "add-import",
150
+ "code": "import 'package:shotik/shotik.dart';"
151
+ },
152
+ {
153
+ "op": "set-arg",
154
+ "target": "The MaterialApp / CupertinoApp / WidgetsApp builder: argument",
155
+ "when": "detect.existingBuilder == false",
156
+ "code": "builder: ShotikSupportWidget.builder(title: '<app name>'{{brandArgs}}),"
157
+ },
158
+ {
159
+ "op": "wrap-expr",
160
+ "target": "The body of the existing builder: callback",
161
+ "when": "detect.existingBuilder == true",
162
+ "open": "ShotikSupportWidget(title: '<app name>'{{brandArgs}}, child: ",
163
+ "close": ")"
164
+ },
165
+ {
166
+ "op": "append-list-arg",
167
+ "target": "navigatorObservers: of the app widget (create the list if missing)",
168
+ "when": "detect.router == navigator",
169
+ "code": "ShotikAnalytics.navigatorObserver"
170
+ },
171
+ {
172
+ "op": "append-list-arg",
173
+ "target": "observers: of the GoRouter(...) construction and of every ShellRoute / StatefulShellRoute branch navigator",
174
+ "when": "detect.router == go_router",
175
+ "code": "ShotikAnalytics.navigatorObserver"
176
+ }
177
+ ],
178
+ "otherwise": "auto_route: AutoRouterConfig(navigatorObservers: () => [ShotikAnalytics.navigatorObserver]).",
179
+ "done": "grep -rq 'ShotikSupportWidget' lib && grep -rq 'ShotikAnalytics.navigatorObserver' lib",
180
+ "note": "brandArgs: add `theme: const ShotikSupportTheme(accent: Color(0xFF…), radius: …, fontFamily: '…')` with only the values found in detect.brand; add `launcher: true` only if the app has no Help/Contact row, and then `launcherBottom: <px>` (distance above the bottom safe area) when screens have a bottom call to action or a tab bar. Never pass locale unless the app forces a language in-app (then pass its current language code). Routes without settings.name are not reported as screens: for unnamed routes and tab bodies, wrap the screen widget in ShotikScreen(name: '<Screen>', child: …)."
181
+ },
182
+ {
183
+ "id": "route",
184
+ "title": "Deep link <scheme>://support",
185
+ "edits": [
186
+ {
187
+ "op": "plist-add-url-scheme",
188
+ "file": "ios/Runner/Info.plist",
189
+ "when": "detect.scheme is none",
190
+ "value": "<scheme>",
191
+ "tool": {
192
+ "name": "ios_project",
193
+ "args": {
194
+ "action": "plist",
195
+ "file": "ios/Runner/Info.plist",
196
+ "path": [
197
+ "CFBundleURLTypes"
198
+ ],
199
+ "value": {
200
+ "CFBundleURLSchemes": [
201
+ "<scheme>"
202
+ ]
203
+ },
204
+ "mode": "append"
205
+ }
206
+ }
207
+ },
208
+ {
209
+ "op": "android-intent-filter",
210
+ "file": "android/app/src/main/AndroidManifest.xml",
211
+ "when": "detect.scheme is none and android/ exists",
212
+ "value": "<intent-filter><action android:name=\"android.intent.action.VIEW\"/><category android:name=\"android.intent.category.DEFAULT\"/><category android:name=\"android.intent.category.BROWSABLE\"/><data android:scheme=\"<scheme>\" android:host=\"support\"/></intent-filter>"
213
+ }
214
+ ],
215
+ "otherwise": "With an existing link handler (app_links, uni_links, a GoRouter redirect on /support), add `if (ShotikSupport.handleLink(uri)) return;` at its start.",
216
+ "done": "plutil -extract CFBundleURLTypes json -o - ios/Runner/Info.plist >/dev/null 2>&1",
217
+ "note": "<scheme>: detect.scheme when the app has one, else the pubspec name with underscores removed (myapp_pro → myapppro). ShotikRoot routes platform deep links (initial and while running) to ShotikSupport.handleLink before the app's router sees them."
218
+ },
219
+ {
220
+ "id": "help",
221
+ "title": "Help entry opens the chat",
222
+ "file": "{{detect.helpEntry}}",
223
+ "edits": [
224
+ {
225
+ "op": "add-import",
226
+ "code": "import 'package:shotik/shotik.dart';"
227
+ },
228
+ {
229
+ "op": "set-handler",
230
+ "target": "Each contact row's onTap / onPressed (replace the mailto / web form call), else a new row labelled Help built with the screen's own row widget and the app's localizations",
231
+ "code": "ShotikSupport.open()"
232
+ }
233
+ ],
234
+ "done": "grep -rq 'ShotikSupport.open(' lib"
235
+ },
236
+ {
237
+ "id": "identify",
238
+ "title": "Identify after the app's own sign-in",
239
+ "when": "detect.auth found",
240
+ "file": "{{detect.auth}}",
241
+ "edits": [
242
+ {
243
+ "op": "add-import",
244
+ "code": "import 'package:shotik/shotik.dart';"
245
+ },
246
+ {
247
+ "op": "insert-after",
248
+ "anchor": "the point where a signed-in user (id, email, name) is known",
249
+ "code": "ShotikSupport.identify(userId: user.id, email: user.email, name: user.displayName);\nShotikAnalytics.identify(user.id);"
250
+ },
251
+ {
252
+ "op": "insert-after",
253
+ "anchor": "the sign-out path",
254
+ "code": "ShotikSupport.reset();\nShotikAnalytics.reset();"
255
+ }
256
+ ],
257
+ "done": "grep -rq 'ShotikSupport.identify(' lib",
258
+ "note": "Safe before runApp and before configure: calls are held. Use the app's own field names for id, email and name. Anonymous users keep their chats after sign-in."
259
+ },
260
+ {
261
+ "id": "push",
262
+ "title": "Forward the push token",
263
+ "when": "detect.push found",
264
+ "file": "{{detect.push}}",
265
+ "edits": [
266
+ {
267
+ "op": "add-import",
268
+ "code": "import 'package:shotik/shotik.dart';"
269
+ },
270
+ {
271
+ "op": "add-import",
272
+ "code": "import 'dart:io' show Platform;",
273
+ "unless": "dart:io is already imported"
274
+ },
275
+ {
276
+ "op": "insert-after",
277
+ "anchor": "the line that obtains the token (final token = await FirebaseMessaging.instance.getToken();) and the onTokenRefresh listener",
278
+ "code": "ShotikSupport.setPushToken(token, platform: Platform.isIOS ? 'ios' : 'android');"
279
+ }
280
+ ],
281
+ "done": "grep -rq 'ShotikSupport.setPushToken(' lib"
282
+ },
283
+ {
284
+ "id": "purchases",
285
+ "title": "Purchases into Analytics",
286
+ "when": "detect.purchases found",
287
+ "file": "{{detect.purchases}}",
288
+ "edits": [
289
+ {
290
+ "op": "add-import",
291
+ "code": "import 'package:shotik/shotik.dart';"
292
+ },
293
+ {
294
+ "op": "insert-after",
295
+ "anchor": "where the app subscribes to InAppPurchase.instance.purchaseStream (once, at store setup)",
296
+ "code": "ShotikAnalytics.watchPurchases(InAppPurchase.instance.purchaseStream, products: <the ProductDetails list>);"
297
+ }
298
+ ],
299
+ "otherwise": "RevenueCat or a custom store: call ShotikAnalytics.purchase(product:, status: 'start' | 'done' | 'fail' | 'cancel', price:, currency:, trial:) where the app starts and finishes a purchase.",
300
+ "done": "grep -rqE 'ShotikAnalytics\\.(watchPurchases|purchase)\\(' lib"
301
+ },
302
+ {
303
+ "id": "mask",
304
+ "title": "Mask private views",
305
+ "edits": [
306
+ {
307
+ "op": "wrap-widget",
308
+ "target": "Widgets that show card numbers, balances, health data, addresses or other personal values as plain Text (text fields are masked already)",
309
+ "open": "ShotikMask(child: ",
310
+ "close": ")"
311
+ }
312
+ ],
313
+ "note": "Wireframes never carry characters; masking also drops tap labels inside. Skip when nothing qualifies."
314
+ },
315
+ {
316
+ "id": "attachments",
317
+ "title": "Photos",
318
+ "when": "detect.imagePicker == true",
319
+ "file": "{{detect.main}}",
320
+ "edits": [
321
+ {
322
+ "op": "insert-after",
323
+ "anchor": "Shotik.configure(...)",
324
+ "code": "ShotikSupport.attachmentPicker = () async {\n final x = await ImagePicker().pickImage(source: ImageSource.gallery, maxWidth: 2048);\n if (x == null) return null;\n return LocalAttachment(bytes: await x.readAsBytes(), type: x.mimeType ?? 'image/jpeg', name: x.name);\n};"
325
+ }
326
+ ],
327
+ "note": "Without image_picker the attach menu still offers Screenshot. Never add image_picker yourself; tell the founder instead."
328
+ }
329
+ ],
330
+ "verify": [
331
+ {
332
+ "id": "wired",
333
+ "run": "grep -rlE 'Shotik\\.configure|ShotikRoot|ShotikSupportWidget|ShotikAnalytics\\.navigatorObserver|ShotikSupport\\.(open|identify|setPushToken)' lib",
334
+ "expect": "lists main, the app widget and the help entry"
335
+ },
336
+ {
337
+ "id": "analyze",
338
+ "run": "flutter analyze",
339
+ "expect": "no errors, and no new warnings in the files this recipe touched"
340
+ },
341
+ {
342
+ "id": "server",
343
+ "run": "curl -sf {{SERVER_URL}}/health",
344
+ "expect": "\"ok\":true"
345
+ },
346
+ {
347
+ "id": "key",
348
+ "run": "curl -s -o /dev/null -w '%{http_code}' -X POST -H 'x-shotik-key: {{APP_KEY}}' -H 'content-type: application/json' -d '{}' {{SERVER_URL}}/support/v1/identify",
349
+ "expect": "400 (key known, empty body refused); 401 means a wrong key"
350
+ },
351
+ {
352
+ "id": "build",
353
+ "run": "flutter build ios --simulator --debug",
354
+ "expect": "✓ Built build/ios/iphonesimulator/Runner.app, with no CocoaPods step for shotik",
355
+ "needs": "macOS with Xcode; SwiftPM enabled"
356
+ },
357
+ {
358
+ "id": "device",
359
+ "run": "open the app and tap Help, or open <scheme>://support",
360
+ "expect": "The Support sheet opens; a sent message shows in Shotik → Support, and screens appear in Analytics",
361
+ "manual": true
362
+ }
363
+ ]
364
+ }
@@ -0,0 +1,194 @@
1
+ # @shotik/react-native
2
+
3
+ Shotik SDK for React Native and Expo: in-app support chat and product analytics in one package. Русская версия:
4
+ [README.ru.md](README.ru.md).
5
+
6
+ Support is in-app chat for your app. Users write from your app; the conversation lands in Shotik's
7
+ Support inbox on your Mac, where you (or the AI) answer. Replies arrive live, and push-ready events are recorded for
8
+ users who closed the app.
9
+
10
+ - Pure TypeScript with no native code, so it runs in any Expo dev client or bare RN app without a rebuild.
11
+ - Peer dependencies: `react`, `react-native`. It uses these when your app already has them: `expo-device`,
12
+ `expo-application`, `expo-localization` (device context), and `@react-native-async-storage/async-storage` or
13
+ `expo-secure-store` (persistence). Without them it falls back to `Platform`, `Intl` and in-memory storage.
14
+ - Anonymous users get a persisted id. When they sign in, their chats move to the signed-in user.
15
+ - Sends are optimistic and queued while offline. The stream reconnects with backoff and catches up when the app
16
+ returns to the foreground.
17
+ - A native-feeling chat sheet: drag handle, spring open and close, keyboard-avoiding, an optional floating launcher
18
+ with an unread badge, receipts (sending, sent, delivered, seen), a typing indicator while the AI drafts or you type
19
+ in Shotik, quick-reply chips, "Talk to a person", photos and screenshots, light and dark, Dynamic Type, VoiceOver
20
+ and RTL. Copy is English or Russian, picked from the device locale.
21
+ - Small: about 44 KB minified for the whole SDK (14 KB gzipped). Nothing renders until the first open except the
22
+ launcher, and every animation runs on the native driver.
23
+
24
+ ## 1. Install
25
+
26
+ ```sh
27
+ npx expo install @shotik/react-native # or: npm install / bun add / pnpm add / yarn add @shotik/react-native
28
+ ```
29
+
30
+ Moving from the vendored copy (`vendor/shotik-support-react-native`)? Remove that dependency and folder, then change
31
+ imports from `@shotik/support-react-native` to `@shotik/react-native`. The exports are the same.
32
+
33
+ ## 2. Wrap your root
34
+
35
+ Get the public key (`spk_…`) from Shotik → Support → SDK. It is a public app key, so it is safe in the bundle.
36
+
37
+ ```tsx
38
+ // app/_layout.tsx (Expo Router) or App.tsx
39
+ import { ShotikSupportProvider } from '@shotik/react-native'
40
+
41
+ export default function RootLayout() {
42
+ return (
43
+ <GestureHandlerRootView style={{ flex: 1 }}>
44
+ <ShotikSupportProvider appKey="spk_…" serverUrl="https://support.example.com">
45
+ <Stack />
46
+ </ShotikSupportProvider>
47
+ </GestureHandlerRootView>
48
+ )
49
+ }
50
+ ```
51
+
52
+ The provider identifies the user anonymously, keeps the live stream open while the app is in the foreground, and
53
+ renders `<SupportWidget/>`, a bottom sheet that mounts on the first open. Pass `widget={false}` to place
54
+ `<SupportWidget/>` yourself; it takes the same props.
55
+
56
+ ### Brand it
57
+
58
+ ```tsx
59
+ <ShotikSupportProvider
60
+ appKey="spk_…"
61
+ serverUrl="https://support.example.com"
62
+ launcher // floating button with the unread badge (default off)
63
+ title="Walkito" // header (default "Support" / "Поддержка")
64
+ teamName="Rahim" // label above your replies (default "Team" / "Команда")
65
+ quickReplies={['Billing', 'Report a bug']} // chips on a new conversation
66
+ theme={{ accent: '#FF5A1F', radius: 18, font: 'Inter-Regular', fontBold: 'Inter-SemiBold' }}
67
+ locale="ru" // default: the device locale; en is the fallback
68
+ >
69
+ ```
70
+
71
+ | `theme` | Default | |
72
+ |---|---|---|
73
+ | `accent` | iOS blue | Your bubbles, send button, launcher, links |
74
+ | `onAccent` | `#FFFFFF` | Text and glyphs on the accent |
75
+ | `radius` | `18` | Bubble radius; the sheet, chips and field follow it |
76
+ | `font`, `fontBold` | system | `fontFamily` for regular and semibold text |
77
+ | `scheme` | system | Force `'light'` or `'dark'` |
78
+ | `light`, `dark` | | Override colors: `bg raised line text sub faint danger ok warn backdrop` |
79
+
80
+ Light and dark follow the system. Text scales with Dynamic Type, every control has a VoiceOver label, new replies are
81
+ announced, and layouts use start/end so RTL works.
82
+
83
+ ### Attachments (optional)
84
+
85
+ The attach button appears only when the app already has one of these installed (both need a native build, so the SDK
86
+ never adds them for you):
87
+
88
+ - `expo-image-picker`: a photo from the library.
89
+ - `react-native-view-shot`: a screenshot of the app (the sheet steps aside while it is taken).
90
+
91
+ Images upload to the Shotik server (8 MB cap) and show in your Shotik inbox.
92
+
93
+ ### Icons (optional)
94
+
95
+ With `react-native-svg` installed (Expo apps usually have it), the widget draws its icons from the Hugeicons set.
96
+ Without it, simple built-in shapes stand in.
97
+
98
+ ## 3. Open it
99
+
100
+ ```tsx
101
+ import { ShotikSupport } from '@shotik/react-native'
102
+
103
+ <Row label="Help" onPress={() => ShotikSupport.open()} />
104
+ ```
105
+
106
+ Deep link (and push taps): with Expo Router, add `app/support.tsx`:
107
+
108
+ ```tsx
109
+ export { SupportRoute as default } from '@shotik/react-native'
110
+ ```
111
+
112
+ `myapp://support` then opens the chat over the current screen.
113
+
114
+ ## 4. Identify after sign-in
115
+
116
+ ```ts
117
+ ShotikSupport.identify({ userId: user.id, email: user.email, name: user.name, attributes: { plan: 'pro' } })
118
+ // sign-out
119
+ ShotikSupport.reset()
120
+ ```
121
+
122
+ You can call it anywhere, including at module scope before the provider mounts, because calls made before
123
+ `configure` are held until it runs. Every identify sends the device context: platform, OS version, model, app
124
+ version and build, locale and time zone.
125
+
126
+ ## 5. Push
127
+
128
+ ```ts
129
+ const { data: token } = await Notifications.getExpoPushTokenAsync({ projectId })
130
+ ShotikSupport.setPushToken(token, Platform.OS)
131
+ ```
132
+
133
+ Every founder or AI reply is recorded as a push-ready event (`GET /v1/support/events`) with the user's token and a
134
+ preview. A reply already delivered over the live stream is marked delivered.
135
+
136
+ ## Hook and API
137
+
138
+ ```ts
139
+ const { conversations, messages, unread, unreadBy, typing, status, open, send, retry, handoff, select, close } = useSupport()
140
+ ```
141
+
142
+ | | |
143
+ |---|---|
144
+ | `ShotikSupport.configure({ appKey, serverUrl })` | Done by the provider when it gets props. Call it yourself to use the hook without the provider's props. |
145
+ | `identify(user?)`, `reset()` | Signed-in user / sign-out (new anonymous id). |
146
+ | `setPushToken(token, platform?)` | Expo or APNs/FCM token; `null` clears it. |
147
+ | `open(conversationId?)`, `close()` | Show or hide the sheet. |
148
+ | `status` | `idle · identifying · connecting · live · offline · error` |
149
+ | `send(body, conversationId?, attachments?)` | Optimistic. Without an id it starts a new conversation. `attachments`: `[{ uri, type?, width?, height? }]` (file:// or data:). Returns the local message. |
150
+ | `retry(localId)` | Resend a message marked `pending: 'failed'`. |
151
+ | `handoff(conversationId)` | "Talk to a person": the conversation goes to your Needs-human list and the AI stops answering it. |
152
+ | `typing` | `{ [conversationId]: 'ai' \| 'founder' }` while the AI drafts or you type in Shotik. |
153
+ | `receiptOf(message, list, conversation, offline?)` | `sending · queued · failed · sent · delivered · seen` for your messages. Delivered = reached Shotik; seen = you read it there. |
154
+ | `SupportClient` (`@shotik/react-native/client`) | The platform-free core, usable outside React. |
155
+
156
+ Conversation status `needs_human` shows a "A person will reply" strip above the composer. Replies are labelled **AI** or
157
+ with `teamName`. After an AI answer the thread offers its quick replies (from the answer, or the defaults you set in
158
+ Shotik as `support.quickReplies:<appId>`) and "Talk to a person".
159
+
160
+ ## Analytics
161
+
162
+ The same package ships analytics at `@shotik/react-native/analytics`, using the same key. See
163
+ [src/analytics/README.md](src/analytics/README.md).
164
+
165
+ ## Troubleshooting
166
+
167
+ - **Status stays `offline`.** The phone can't reach `serverUrl`. A simulator reaches the Mac at `http://127.0.0.1:<port>`,
168
+ but a device needs the Mac's LAN address (`http://192.168.x.x:<port>`) or an HTTPS deployment. Check with
169
+ `curl <serverUrl>/health`.
170
+ - **Status is `error` with "unknown app key".** The key doesn't belong to this server. Create it again in Shotik.
171
+ - **Plain `http://` is blocked on a device.** iOS App Transport Security allows only HTTPS in release builds. Use HTTPS,
172
+ or add an ATS exception for development only.
173
+ - **Nothing persists between launches.** Install `expo-secure-store` or `@react-native-async-storage/async-storage`
174
+ (both are optional). Without one, the anonymous id resets on every launch.
175
+ - **TypeScript can't find the types.** They ship in `dist/` and resolve through `exports`. Use
176
+ `moduleResolution: "bundler"` (the Expo default). Metro reads the TypeScript source in `src/`.
177
+ - **`myapp://support` shows "not found".** The route file is missing, or your router root is `src/app`. Put
178
+ `support.tsx` next to your root `_layout.tsx`.
179
+ - **Messages sit at "Sending".** While offline, or while the server is unreachable or answers 5xx/429, they show
180
+ "Will send when you're back online" (clock) and the header counts them; they go out on their own once the server is
181
+ reachable. Only a 4xx answer shows "Not sent · Retry".
182
+ - **No attach button.** Neither `expo-image-picker` nor `react-native-view-shot` is in the dev client. Install one
183
+ and rebuild the dev client.
184
+
185
+ ## Tests
186
+
187
+ The client is tested against a real Shotik server and a founder's synced store: identify, the user message arriving as
188
+ synced rows, the founder reply arriving on the stream, push-ready events, the offline queue across a restart,
189
+ reconnect, the anonymous-to-identified merge, a bad key, receipts (delivered, seen), typing (founder, throttled, and
190
+ AI drafting), attachments through the offline queue, and a Russian-speaking user (AI answer, handoff note).
191
+
192
+ ```sh
193
+ node --disable-warning=ExperimentalWarning --test server/test/support.test.ts
194
+ ```