@appsupportkit/support-sdk 0.2.0 → 0.4.0

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 (242) hide show
  1. package/lib/commonjs/api.js +61 -12
  2. package/lib/commonjs/api.js.map +1 -1
  3. package/lib/commonjs/components/BottomSheet.js +1 -1
  4. package/lib/commonjs/components/BottomSheet.js.map +1 -1
  5. package/lib/commonjs/components/LauncherButton.js +4 -4
  6. package/lib/commonjs/components/LauncherButton.js.map +1 -1
  7. package/lib/commonjs/components/SupportButton.js +192 -66
  8. package/lib/commonjs/components/SupportButton.js.map +1 -1
  9. package/lib/commonjs/components/icons.js +117 -110
  10. package/lib/commonjs/components/icons.js.map +1 -1
  11. package/lib/commonjs/components/primitives.js +3 -154
  12. package/lib/commonjs/components/primitives.js.map +1 -1
  13. package/lib/commonjs/components/screens/ChatScreen.js +487 -0
  14. package/lib/commonjs/components/screens/ChatScreen.js.map +1 -0
  15. package/lib/commonjs/components/screens/LanguageScreen.js +150 -0
  16. package/lib/commonjs/components/screens/LanguageScreen.js.map +1 -0
  17. package/lib/commonjs/i18n/index.js +101 -0
  18. package/lib/commonjs/i18n/index.js.map +1 -0
  19. package/lib/commonjs/i18n/languages.js +95 -0
  20. package/lib/commonjs/i18n/languages.js.map +1 -0
  21. package/lib/commonjs/i18n/strings/de.js +75 -0
  22. package/lib/commonjs/i18n/strings/de.js.map +1 -0
  23. package/lib/commonjs/i18n/strings/en.js +91 -0
  24. package/lib/commonjs/i18n/strings/en.js.map +1 -0
  25. package/lib/commonjs/i18n/strings/es.js +75 -0
  26. package/lib/commonjs/i18n/strings/es.js.map +1 -0
  27. package/lib/commonjs/i18n/strings/fr.js +75 -0
  28. package/lib/commonjs/i18n/strings/fr.js.map +1 -0
  29. package/lib/commonjs/i18n/strings/hi.js +75 -0
  30. package/lib/commonjs/i18n/strings/hi.js.map +1 -0
  31. package/lib/commonjs/i18n/strings/it.js +75 -0
  32. package/lib/commonjs/i18n/strings/it.js.map +1 -0
  33. package/lib/commonjs/i18n/strings/ja.js +75 -0
  34. package/lib/commonjs/i18n/strings/ja.js.map +1 -0
  35. package/lib/commonjs/i18n/strings/ko.js +75 -0
  36. package/lib/commonjs/i18n/strings/ko.js.map +1 -0
  37. package/lib/commonjs/i18n/strings/nl.js +75 -0
  38. package/lib/commonjs/i18n/strings/nl.js.map +1 -0
  39. package/lib/commonjs/i18n/strings/pl.js +75 -0
  40. package/lib/commonjs/i18n/strings/pl.js.map +1 -0
  41. package/lib/commonjs/i18n/strings/pt.js +75 -0
  42. package/lib/commonjs/i18n/strings/pt.js.map +1 -0
  43. package/lib/commonjs/i18n/strings/ru.js +75 -0
  44. package/lib/commonjs/i18n/strings/ru.js.map +1 -0
  45. package/lib/commonjs/i18n/strings/tr.js +75 -0
  46. package/lib/commonjs/i18n/strings/tr.js.map +1 -0
  47. package/lib/commonjs/i18n/strings/zh.js +75 -0
  48. package/lib/commonjs/i18n/strings/zh.js.map +1 -0
  49. package/lib/commonjs/index.js +38 -0
  50. package/lib/commonjs/index.js.map +1 -1
  51. package/lib/commonjs/push.js +78 -3
  52. package/lib/commonjs/push.js.map +1 -1
  53. package/lib/commonjs/review.js +54 -0
  54. package/lib/commonjs/review.js.map +1 -0
  55. package/lib/commonjs/theme.js +142 -23
  56. package/lib/commonjs/theme.js.map +1 -1
  57. package/lib/commonjs/types.js +32 -3
  58. package/lib/commonjs/types.js.map +1 -1
  59. package/lib/commonjs/useSupportThreads.js +41 -24
  60. package/lib/commonjs/useSupportThreads.js.map +1 -1
  61. package/lib/commonjs/utils.js +25 -30
  62. package/lib/commonjs/utils.js.map +1 -1
  63. package/lib/commonjs/version.js +13 -0
  64. package/lib/commonjs/version.js.map +1 -0
  65. package/lib/module/api.js +57 -10
  66. package/lib/module/api.js.map +1 -1
  67. package/lib/module/components/BottomSheet.js +1 -1
  68. package/lib/module/components/BottomSheet.js.map +1 -1
  69. package/lib/module/components/LauncherButton.js +5 -5
  70. package/lib/module/components/LauncherButton.js.map +1 -1
  71. package/lib/module/components/SupportButton.js +199 -73
  72. package/lib/module/components/SupportButton.js.map +1 -1
  73. package/lib/module/components/icons.js +115 -107
  74. package/lib/module/components/icons.js.map +1 -1
  75. package/lib/module/components/primitives.js +5 -147
  76. package/lib/module/components/primitives.js.map +1 -1
  77. package/lib/module/components/screens/ChatScreen.js +485 -0
  78. package/lib/module/components/screens/ChatScreen.js.map +1 -0
  79. package/lib/module/components/screens/LanguageScreen.js +147 -0
  80. package/lib/module/components/screens/LanguageScreen.js.map +1 -0
  81. package/lib/module/i18n/index.js +56 -0
  82. package/lib/module/i18n/index.js.map +1 -0
  83. package/lib/module/i18n/languages.js +88 -0
  84. package/lib/module/i18n/languages.js.map +1 -0
  85. package/lib/module/i18n/strings/de.js +71 -0
  86. package/lib/module/i18n/strings/de.js.map +1 -0
  87. package/lib/module/i18n/strings/en.js +87 -0
  88. package/lib/module/i18n/strings/en.js.map +1 -0
  89. package/lib/module/i18n/strings/es.js +71 -0
  90. package/lib/module/i18n/strings/es.js.map +1 -0
  91. package/lib/module/i18n/strings/fr.js +71 -0
  92. package/lib/module/i18n/strings/fr.js.map +1 -0
  93. package/lib/module/i18n/strings/hi.js +71 -0
  94. package/lib/module/i18n/strings/hi.js.map +1 -0
  95. package/lib/module/i18n/strings/it.js +71 -0
  96. package/lib/module/i18n/strings/it.js.map +1 -0
  97. package/lib/module/i18n/strings/ja.js +71 -0
  98. package/lib/module/i18n/strings/ja.js.map +1 -0
  99. package/lib/module/i18n/strings/ko.js +71 -0
  100. package/lib/module/i18n/strings/ko.js.map +1 -0
  101. package/lib/module/i18n/strings/nl.js +71 -0
  102. package/lib/module/i18n/strings/nl.js.map +1 -0
  103. package/lib/module/i18n/strings/pl.js +71 -0
  104. package/lib/module/i18n/strings/pl.js.map +1 -0
  105. package/lib/module/i18n/strings/pt.js +71 -0
  106. package/lib/module/i18n/strings/pt.js.map +1 -0
  107. package/lib/module/i18n/strings/ru.js +71 -0
  108. package/lib/module/i18n/strings/ru.js.map +1 -0
  109. package/lib/module/i18n/strings/tr.js +71 -0
  110. package/lib/module/i18n/strings/tr.js.map +1 -0
  111. package/lib/module/i18n/strings/zh.js +71 -0
  112. package/lib/module/i18n/strings/zh.js.map +1 -0
  113. package/lib/module/index.js +2 -0
  114. package/lib/module/index.js.map +1 -1
  115. package/lib/module/push.js +77 -3
  116. package/lib/module/push.js.map +1 -1
  117. package/lib/module/review.js +48 -0
  118. package/lib/module/review.js.map +1 -0
  119. package/lib/module/theme.js +141 -23
  120. package/lib/module/theme.js.map +1 -1
  121. package/lib/module/types.js +32 -3
  122. package/lib/module/types.js.map +1 -1
  123. package/lib/module/useSupportThreads.js +41 -24
  124. package/lib/module/useSupportThreads.js.map +1 -1
  125. package/lib/module/utils.js +24 -29
  126. package/lib/module/utils.js.map +1 -1
  127. package/lib/module/version.js +9 -0
  128. package/lib/module/version.js.map +1 -0
  129. package/lib/typescript/api.d.ts +40 -10
  130. package/lib/typescript/api.d.ts.map +1 -1
  131. package/lib/typescript/components/SupportButton.d.ts +2 -2
  132. package/lib/typescript/components/SupportButton.d.ts.map +1 -1
  133. package/lib/typescript/components/icons.d.ts +10 -14
  134. package/lib/typescript/components/icons.d.ts.map +1 -1
  135. package/lib/typescript/components/primitives.d.ts +3 -30
  136. package/lib/typescript/components/primitives.d.ts.map +1 -1
  137. package/lib/typescript/components/screens/ChatScreen.d.ts +21 -0
  138. package/lib/typescript/components/screens/ChatScreen.d.ts.map +1 -0
  139. package/lib/typescript/components/screens/LanguageScreen.d.ts +30 -0
  140. package/lib/typescript/components/screens/LanguageScreen.d.ts.map +1 -0
  141. package/lib/typescript/i18n/index.d.ts +15 -0
  142. package/lib/typescript/i18n/index.d.ts.map +1 -0
  143. package/lib/typescript/i18n/languages.d.ts +36 -0
  144. package/lib/typescript/i18n/languages.d.ts.map +1 -0
  145. package/lib/typescript/i18n/strings/de.d.ts +3 -0
  146. package/lib/typescript/i18n/strings/de.d.ts.map +1 -0
  147. package/lib/typescript/i18n/strings/en.d.ts +86 -0
  148. package/lib/typescript/i18n/strings/en.d.ts.map +1 -0
  149. package/lib/typescript/i18n/strings/es.d.ts +3 -0
  150. package/lib/typescript/i18n/strings/es.d.ts.map +1 -0
  151. package/lib/typescript/i18n/strings/fr.d.ts +3 -0
  152. package/lib/typescript/i18n/strings/fr.d.ts.map +1 -0
  153. package/lib/typescript/i18n/strings/hi.d.ts +3 -0
  154. package/lib/typescript/i18n/strings/hi.d.ts.map +1 -0
  155. package/lib/typescript/i18n/strings/it.d.ts +3 -0
  156. package/lib/typescript/i18n/strings/it.d.ts.map +1 -0
  157. package/lib/typescript/i18n/strings/ja.d.ts +3 -0
  158. package/lib/typescript/i18n/strings/ja.d.ts.map +1 -0
  159. package/lib/typescript/i18n/strings/ko.d.ts +3 -0
  160. package/lib/typescript/i18n/strings/ko.d.ts.map +1 -0
  161. package/lib/typescript/i18n/strings/nl.d.ts +3 -0
  162. package/lib/typescript/i18n/strings/nl.d.ts.map +1 -0
  163. package/lib/typescript/i18n/strings/pl.d.ts +3 -0
  164. package/lib/typescript/i18n/strings/pl.d.ts.map +1 -0
  165. package/lib/typescript/i18n/strings/pt.d.ts +3 -0
  166. package/lib/typescript/i18n/strings/pt.d.ts.map +1 -0
  167. package/lib/typescript/i18n/strings/ru.d.ts +3 -0
  168. package/lib/typescript/i18n/strings/ru.d.ts.map +1 -0
  169. package/lib/typescript/i18n/strings/tr.d.ts +3 -0
  170. package/lib/typescript/i18n/strings/tr.d.ts.map +1 -0
  171. package/lib/typescript/i18n/strings/zh.d.ts +3 -0
  172. package/lib/typescript/i18n/strings/zh.d.ts.map +1 -0
  173. package/lib/typescript/index.d.ts +4 -2
  174. package/lib/typescript/index.d.ts.map +1 -1
  175. package/lib/typescript/push.d.ts +14 -2
  176. package/lib/typescript/push.d.ts.map +1 -1
  177. package/lib/typescript/review.d.ts +15 -0
  178. package/lib/typescript/review.d.ts.map +1 -0
  179. package/lib/typescript/theme.d.ts +23 -5
  180. package/lib/typescript/theme.d.ts.map +1 -1
  181. package/lib/typescript/types.d.ts +86 -13
  182. package/lib/typescript/types.d.ts.map +1 -1
  183. package/lib/typescript/useSupportThreads.d.ts +20 -4
  184. package/lib/typescript/useSupportThreads.d.ts.map +1 -1
  185. package/lib/typescript/utils.d.ts +8 -6
  186. package/lib/typescript/utils.d.ts.map +1 -1
  187. package/lib/typescript/version.d.ts +7 -0
  188. package/lib/typescript/version.d.ts.map +1 -0
  189. package/package.json +2 -2
  190. package/src/api.ts +75 -23
  191. package/src/components/BottomSheet.tsx +1 -1
  192. package/src/components/LauncherButton.tsx +4 -4
  193. package/src/components/SupportButton.tsx +244 -86
  194. package/src/components/icons.tsx +96 -101
  195. package/src/components/primitives.tsx +9 -161
  196. package/src/components/screens/ChatScreen.tsx +541 -0
  197. package/src/components/screens/LanguageScreen.tsx +172 -0
  198. package/src/i18n/index.ts +81 -0
  199. package/src/i18n/languages.ts +106 -0
  200. package/src/i18n/strings/de.ts +81 -0
  201. package/src/i18n/strings/en.ts +97 -0
  202. package/src/i18n/strings/es.ts +80 -0
  203. package/src/i18n/strings/fr.ts +81 -0
  204. package/src/i18n/strings/hi.ts +80 -0
  205. package/src/i18n/strings/it.ts +80 -0
  206. package/src/i18n/strings/ja.ts +80 -0
  207. package/src/i18n/strings/ko.ts +79 -0
  208. package/src/i18n/strings/nl.ts +80 -0
  209. package/src/i18n/strings/pl.ts +80 -0
  210. package/src/i18n/strings/pt.ts +80 -0
  211. package/src/i18n/strings/ru.ts +80 -0
  212. package/src/i18n/strings/tr.ts +80 -0
  213. package/src/i18n/strings/zh.ts +78 -0
  214. package/src/index.tsx +13 -0
  215. package/src/push.ts +100 -2
  216. package/src/review.ts +54 -0
  217. package/src/theme.ts +182 -28
  218. package/src/types.ts +85 -13
  219. package/src/useSupportThreads.ts +61 -28
  220. package/src/utils.ts +27 -29
  221. package/src/version.ts +6 -0
  222. package/lib/commonjs/components/screens/ComposeScreen.js +0 -228
  223. package/lib/commonjs/components/screens/ComposeScreen.js.map +0 -1
  224. package/lib/commonjs/components/screens/HomeScreen.js +0 -286
  225. package/lib/commonjs/components/screens/HomeScreen.js.map +0 -1
  226. package/lib/commonjs/components/screens/ThreadScreen.js +0 -327
  227. package/lib/commonjs/components/screens/ThreadScreen.js.map +0 -1
  228. package/lib/module/components/screens/ComposeScreen.js +0 -224
  229. package/lib/module/components/screens/ComposeScreen.js.map +0 -1
  230. package/lib/module/components/screens/HomeScreen.js +0 -282
  231. package/lib/module/components/screens/HomeScreen.js.map +0 -1
  232. package/lib/module/components/screens/ThreadScreen.js +0 -325
  233. package/lib/module/components/screens/ThreadScreen.js.map +0 -1
  234. package/lib/typescript/components/screens/ComposeScreen.d.ts +0 -10
  235. package/lib/typescript/components/screens/ComposeScreen.d.ts.map +0 -1
  236. package/lib/typescript/components/screens/HomeScreen.d.ts +0 -14
  237. package/lib/typescript/components/screens/HomeScreen.d.ts.map +0 -1
  238. package/lib/typescript/components/screens/ThreadScreen.d.ts +0 -10
  239. package/lib/typescript/components/screens/ThreadScreen.d.ts.map +0 -1
  240. package/src/components/screens/ComposeScreen.tsx +0 -233
  241. package/src/components/screens/HomeScreen.tsx +0 -287
  242. package/src/components/screens/ThreadScreen.tsx +0 -397
@@ -1,5 +1,6 @@
1
1
  import { type ApiConfig } from './api';
2
- import type { Thread } from './types';
2
+ import type { StringKey } from './i18n';
3
+ import type { StoreListing, Thread } from './types';
3
4
  export declare const IDLE_POLL_MS = 60000;
4
5
  export interface SupportThreadsState {
5
6
  /** Server threads with unread counts narrowed by local reads. */
@@ -10,19 +11,34 @@ export interface SupportThreadsState {
10
11
  /** User-pulled refresh with content already on screen. */
11
12
  refreshing: boolean;
12
13
  /** Set only when there is nothing cached; background failures stay quiet. */
13
- error: string | null;
14
+ errorKey: StringKey | null;
15
+ /** The language this user picked, or null if they never have. */
16
+ serverLanguage: string | null;
17
+ /**
18
+ * False until the first successful load. `serverLanguage === null` only
19
+ * means "never picked" once this is true — before that it means "don't
20
+ * know yet", and showing the picker on a guess would nag a user who
21
+ * answered on another device.
22
+ */
23
+ languageLoaded: boolean;
24
+ /** The app's store listings, for review request buttons. */
25
+ store: StoreListing | null;
14
26
  /** User-initiated refresh (pull-to-refresh, retry button). */
15
27
  refresh: () => void;
16
28
  /** Awaited by send/submit handlers so the list reflects the write. */
17
29
  reload: () => Promise<void>;
18
30
  }
19
- export declare function useSupportThreads({ config, revenuecatId, enabled, sheetOpen, activeThreadId, idlePollMs, }: {
31
+ export declare function useSupportThreads({ config, revenuecatId, enabled, sheetOpen, chatVisible, idlePollMs, }: {
20
32
  config: ApiConfig;
21
33
  revenuecatId: string;
22
34
  /** False when props failed validation — no requests are made. */
23
35
  enabled: boolean;
24
36
  sheetOpen: boolean;
25
- activeThreadId: string | null;
37
+ /**
38
+ * The chat is on screen. It shows every conversation at once, so all of
39
+ * them are read while it is — including replies that arrive meanwhile.
40
+ */
41
+ chatVisible: boolean;
26
42
  idlePollMs: number;
27
43
  }): SupportThreadsState;
28
44
  //# sourceMappingURL=useSupportThreads.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSupportThreads.d.ts","sourceRoot":"","sources":["../../src/useSupportThreads.ts"],"names":[],"mappings":"AAgBA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAetC,eAAO,MAAM,YAAY,QAAS,CAAC;AA0CnC,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,UAAU,EAAE,OAAO,CAAC;IACpB,6EAA6E;IAC7E,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,IAAI,CAAC;IAC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M,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,YAAY,EACZ,OAAO,EACP,SAAS,EACT,WAAW,EACX,UAAU,GACX,EAAE;IACD,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,mBAAmB,CAiRtB"}
@@ -1,11 +1,13 @@
1
- /** "2h ago" relative time — mirrors the web dashboard's formatting. */
2
- export declare function relativeTime(iso: string): string;
3
- export declare function formatDate(iso: string): string;
4
- /** "14:32" in the device's locale — shown under a group of messages. */
5
- export declare function formatTime(iso: string): string;
1
+ import type { Translator } from './i18n';
2
+ import type { SupportUser, UserPlan } from './types';
3
+ export declare function formatDate(iso: string, strings: Translator): string;
4
+ /** "14:32" in the user's locale — shown under a group of messages. */
5
+ export declare function formatTime(iso: string, strings: Translator): string;
6
6
  export declare function isSameDay(a: string, b: string): boolean;
7
7
  /** Date separator label: Today / Yesterday / "Mon, 5 Jan". */
8
- export declare function dayLabel(iso: string): string;
8
+ export declare function dayLabel(iso: string, strings: Translator): string;
9
+ /** The user's plan, reading the deprecated `isPaid` when `plan` is absent. */
10
+ export declare function userPlan(user: SupportUser): UserPlan;
9
11
  /** Dev-mode prop validation with actionable messages. */
10
12
  export declare function validateProps(props: {
11
13
  appName?: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAehD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED,wEAAwE;AACxE,wBAAg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ACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,GAAG,MAAM,GAAG,IAAI,CAiChB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Sent as `x-sdk-version` on every request. The backend uses its presence to
3
+ * tell 0.4+ (one support chat) from older builds still in the App Store, so
4
+ * keep it in step with package.json.
5
+ */
6
+ export declare const SDK_VERSION = "0.4.0";
7
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,WAAW,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@appsupportkit/support-sdk",
3
- "version": "0.2.0",
4
- "description": "In-app customer support for React Native: feedback, feature requests, and bug reports with two-way threads.",
3
+ "version": "0.4.0",
4
+ "description": "In-app customer support for React Native: feedback, feature requests, and bug reports with two-way threads, in the user's own language.",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
7
7
  "types": "./lib/typescript/index.d.ts",
package/src/api.ts CHANGED
@@ -1,10 +1,7 @@
1
1
  // Thin client for the Supabase Edge Functions. Every call authenticates with
2
2
  // the per-app x-api-key header; no Supabase JS client is needed on-device.
3
- import type {
4
- PushPermissionStatus,
5
- QueryType,
6
- ThreadsResponse,
7
- } from './types';
3
+ import type { PushPermissionStatus, ThreadsResponse, UserPlan } from './types';
4
+ import { SDK_VERSION } from './version';
8
5
 
9
6
  export interface ApiConfig {
10
7
  supabaseUrl: string;
@@ -38,6 +35,8 @@ async function request<T>(
38
35
  headers: {
39
36
  'Content-Type': 'application/json',
40
37
  'x-api-key': config.apiKey,
38
+ // Tells the backend this build speaks the single support chat.
39
+ 'x-sdk-version': SDK_VERSION,
41
40
  ...init.headers,
42
41
  },
43
42
  });
@@ -112,41 +111,94 @@ export function registerPush(
112
111
  });
113
112
  }
114
113
 
115
- export function submitQuery(
114
+ /** Records the language the user reads and writes support messages in. */
115
+ export function setLanguage(
116
+ config: ApiConfig,
117
+ input: { revenuecatId: string; language: string },
118
+ ): Promise<{ language: string }> {
119
+ return request(config, 'set-language', {
120
+ method: 'POST',
121
+ body: JSON.stringify({
122
+ revenuecat_id: input.revenuecatId,
123
+ language: input.language,
124
+ }),
125
+ });
126
+ }
127
+
128
+ /** What the backend is told about the current user. */
129
+ export interface ReportedUser {
130
+ name: string;
131
+ plan: UserPlan;
132
+ appVersion: string;
133
+ /** Decides which store a review request opens. */
134
+ platform?: 'ios' | 'android';
135
+ }
136
+
137
+ function reportedUser(user: ReportedUser) {
138
+ return {
139
+ name: user.name,
140
+ plan: user.plan,
141
+ app_version: user.appVersion,
142
+ platform: user.platform,
143
+ };
144
+ }
145
+
146
+ /**
147
+ * Sends one chat message. The server appends it to the user's open
148
+ * conversation, or starts one if none is open (a first message, or the first
149
+ * after a resolve).
150
+ */
151
+ export function sendMessage(
116
152
  config: ApiConfig,
117
153
  input: {
118
- queryType: QueryType;
119
- message: string;
120
- userName: string;
121
- isPaid: boolean;
122
154
  revenuecatId: string;
123
- appVersion: string;
155
+ message: string;
156
+ language: string;
157
+ user: ReportedUser;
124
158
  },
125
- ): Promise<{ query_id: string }> {
126
- return request(config, 'submit-query', {
159
+ ): Promise<{ query_id: string; message_id: string; started: boolean }> {
160
+ return request(config, 'send-message', {
127
161
  method: 'POST',
128
162
  body: JSON.stringify({
129
163
  app_name: config.appName,
130
- query_type: input.queryType,
164
+ revenuecat_id: input.revenuecatId,
131
165
  message: input.message,
132
- user_name: input.userName,
133
- is_paid: input.isPaid,
166
+ // Sent on every write so a lost set-language call self-heals.
167
+ language: input.language,
168
+ user: reportedUser(input.user),
169
+ }),
170
+ });
171
+ }
172
+
173
+ /**
174
+ * Records the user in the app's directory, so the team can find and message
175
+ * them before they ever open support. Called on every load.
176
+ */
177
+ export function registerUser(
178
+ config: ApiConfig,
179
+ input: { revenuecatId: string; user: ReportedUser },
180
+ ): Promise<{ ok: boolean }> {
181
+ return request(config, 'register-user', {
182
+ method: 'POST',
183
+ body: JSON.stringify({
184
+ app_name: config.appName,
134
185
  revenuecat_id: input.revenuecatId,
135
- app_version: input.appVersion,
186
+ user: reportedUser(input.user),
136
187
  }),
137
188
  });
138
189
  }
139
190
 
140
- export function postMessage(
191
+ /** Records a tap on a review request's store button, for the dashboard. */
192
+ export function reviewOpened(
141
193
  config: ApiConfig,
142
- input: { queryId: string; revenuecatId: string; message: string },
143
- ): Promise<{ message_id: string }> {
144
- return request(config, 'post-message', {
194
+ input: { revenuecatId: string; messageId: string },
195
+ ): Promise<{ ok: boolean }> {
196
+ return request(config, 'review-opened', {
145
197
  method: 'POST',
146
198
  body: JSON.stringify({
147
- query_id: input.queryId,
199
+ app_name: config.appName,
148
200
  revenuecat_id: input.revenuecatId,
149
- message: input.message,
201
+ message_id: input.messageId,
150
202
  }),
151
203
  });
152
204
  }
@@ -155,7 +155,7 @@ export function BottomSheet({
155
155
  <Animated.View
156
156
  style={{
157
157
  height: sheetHeight,
158
- backgroundColor: theme.colors.bg,
158
+ backgroundColor: theme.colors.sheet,
159
159
  borderTopLeftRadius: theme.radii.sheet,
160
160
  borderTopRightRadius: theme.radii.sheet,
161
161
  borderWidth: 1,
@@ -14,7 +14,7 @@ import {
14
14
  } from 'react-native';
15
15
  import type { SupportTheme } from '../theme';
16
16
  import type { LauncherVariant } from '../types';
17
- import { ChatBubbleMark } from './icons';
17
+ import { ConversationMark } from './icons';
18
18
 
19
19
  const PRESS_SCALE = 0.93;
20
20
 
@@ -87,7 +87,7 @@ export function LauncherButton({
87
87
  : soft
88
88
  ? theme.colors.accent
89
89
  : theme.launcher.minimalMark;
90
- // Dots are punched out of the bubble in whatever sits behind the mark —
90
+ // The gap between the bubbles is cut in whatever sits behind the mark —
91
91
  // the button's own fill, or the app background when there isn't one.
92
92
  const markHoleColor = solid
93
93
  ? theme.colors.accent
@@ -106,7 +106,7 @@ export function LauncherButton({
106
106
  const badgeFg = solid ? theme.colors.accent : theme.colors.accentForeground;
107
107
 
108
108
  const height = label ? Math.max(44, size * 0.84) : size;
109
- const markSize = Math.round(size * (label ? 0.36 : 0.42));
109
+ const markSize = Math.round(size * (label ? 0.4 : 0.46));
110
110
 
111
111
  return (
112
112
  <Animated.View
@@ -167,7 +167,7 @@ export function LauncherButton({
167
167
  ...(variant === 'minimal' ? null : theme.shadows.launcher),
168
168
  }}
169
169
  >
170
- <ChatBubbleMark color={markColor} dotColor={markHoleColor} size={markSize} />
170
+ <ConversationMark color={markColor} holeColor={markHoleColor} size={markSize} />
171
171
  {label !== undefined && (
172
172
  <Text
173
173
  style={{