@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.
- package/lib/commonjs/api.js +61 -12
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/components/BottomSheet.js +1 -1
- package/lib/commonjs/components/BottomSheet.js.map +1 -1
- package/lib/commonjs/components/LauncherButton.js +4 -4
- package/lib/commonjs/components/LauncherButton.js.map +1 -1
- package/lib/commonjs/components/SupportButton.js +192 -66
- package/lib/commonjs/components/SupportButton.js.map +1 -1
- package/lib/commonjs/components/icons.js +117 -110
- package/lib/commonjs/components/icons.js.map +1 -1
- package/lib/commonjs/components/primitives.js +3 -154
- package/lib/commonjs/components/primitives.js.map +1 -1
- package/lib/commonjs/components/screens/ChatScreen.js +487 -0
- package/lib/commonjs/components/screens/ChatScreen.js.map +1 -0
- package/lib/commonjs/components/screens/LanguageScreen.js +150 -0
- package/lib/commonjs/components/screens/LanguageScreen.js.map +1 -0
- package/lib/commonjs/i18n/index.js +101 -0
- package/lib/commonjs/i18n/index.js.map +1 -0
- package/lib/commonjs/i18n/languages.js +95 -0
- package/lib/commonjs/i18n/languages.js.map +1 -0
- package/lib/commonjs/i18n/strings/de.js +75 -0
- package/lib/commonjs/i18n/strings/de.js.map +1 -0
- package/lib/commonjs/i18n/strings/en.js +91 -0
- package/lib/commonjs/i18n/strings/en.js.map +1 -0
- package/lib/commonjs/i18n/strings/es.js +75 -0
- package/lib/commonjs/i18n/strings/es.js.map +1 -0
- package/lib/commonjs/i18n/strings/fr.js +75 -0
- package/lib/commonjs/i18n/strings/fr.js.map +1 -0
- package/lib/commonjs/i18n/strings/hi.js +75 -0
- package/lib/commonjs/i18n/strings/hi.js.map +1 -0
- package/lib/commonjs/i18n/strings/it.js +75 -0
- package/lib/commonjs/i18n/strings/it.js.map +1 -0
- package/lib/commonjs/i18n/strings/ja.js +75 -0
- package/lib/commonjs/i18n/strings/ja.js.map +1 -0
- package/lib/commonjs/i18n/strings/ko.js +75 -0
- package/lib/commonjs/i18n/strings/ko.js.map +1 -0
- package/lib/commonjs/i18n/strings/nl.js +75 -0
- package/lib/commonjs/i18n/strings/nl.js.map +1 -0
- package/lib/commonjs/i18n/strings/pl.js +75 -0
- package/lib/commonjs/i18n/strings/pl.js.map +1 -0
- package/lib/commonjs/i18n/strings/pt.js +75 -0
- package/lib/commonjs/i18n/strings/pt.js.map +1 -0
- package/lib/commonjs/i18n/strings/ru.js +75 -0
- package/lib/commonjs/i18n/strings/ru.js.map +1 -0
- package/lib/commonjs/i18n/strings/tr.js +75 -0
- package/lib/commonjs/i18n/strings/tr.js.map +1 -0
- package/lib/commonjs/i18n/strings/zh.js +75 -0
- package/lib/commonjs/i18n/strings/zh.js.map +1 -0
- package/lib/commonjs/index.js +38 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/push.js +78 -3
- package/lib/commonjs/push.js.map +1 -1
- package/lib/commonjs/review.js +54 -0
- package/lib/commonjs/review.js.map +1 -0
- package/lib/commonjs/theme.js +142 -23
- package/lib/commonjs/theme.js.map +1 -1
- package/lib/commonjs/types.js +32 -3
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useSupportThreads.js +41 -24
- package/lib/commonjs/useSupportThreads.js.map +1 -1
- package/lib/commonjs/utils.js +25 -30
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/version.js +13 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/api.js +57 -10
- package/lib/module/api.js.map +1 -1
- package/lib/module/components/BottomSheet.js +1 -1
- package/lib/module/components/BottomSheet.js.map +1 -1
- package/lib/module/components/LauncherButton.js +5 -5
- package/lib/module/components/LauncherButton.js.map +1 -1
- package/lib/module/components/SupportButton.js +199 -73
- package/lib/module/components/SupportButton.js.map +1 -1
- package/lib/module/components/icons.js +115 -107
- package/lib/module/components/icons.js.map +1 -1
- package/lib/module/components/primitives.js +5 -147
- package/lib/module/components/primitives.js.map +1 -1
- package/lib/module/components/screens/ChatScreen.js +485 -0
- package/lib/module/components/screens/ChatScreen.js.map +1 -0
- package/lib/module/components/screens/LanguageScreen.js +147 -0
- package/lib/module/components/screens/LanguageScreen.js.map +1 -0
- package/lib/module/i18n/index.js +56 -0
- package/lib/module/i18n/index.js.map +1 -0
- package/lib/module/i18n/languages.js +88 -0
- package/lib/module/i18n/languages.js.map +1 -0
- package/lib/module/i18n/strings/de.js +71 -0
- package/lib/module/i18n/strings/de.js.map +1 -0
- package/lib/module/i18n/strings/en.js +87 -0
- package/lib/module/i18n/strings/en.js.map +1 -0
- package/lib/module/i18n/strings/es.js +71 -0
- package/lib/module/i18n/strings/es.js.map +1 -0
- package/lib/module/i18n/strings/fr.js +71 -0
- package/lib/module/i18n/strings/fr.js.map +1 -0
- package/lib/module/i18n/strings/hi.js +71 -0
- package/lib/module/i18n/strings/hi.js.map +1 -0
- package/lib/module/i18n/strings/it.js +71 -0
- package/lib/module/i18n/strings/it.js.map +1 -0
- package/lib/module/i18n/strings/ja.js +71 -0
- package/lib/module/i18n/strings/ja.js.map +1 -0
- package/lib/module/i18n/strings/ko.js +71 -0
- package/lib/module/i18n/strings/ko.js.map +1 -0
- package/lib/module/i18n/strings/nl.js +71 -0
- package/lib/module/i18n/strings/nl.js.map +1 -0
- package/lib/module/i18n/strings/pl.js +71 -0
- package/lib/module/i18n/strings/pl.js.map +1 -0
- package/lib/module/i18n/strings/pt.js +71 -0
- package/lib/module/i18n/strings/pt.js.map +1 -0
- package/lib/module/i18n/strings/ru.js +71 -0
- package/lib/module/i18n/strings/ru.js.map +1 -0
- package/lib/module/i18n/strings/tr.js +71 -0
- package/lib/module/i18n/strings/tr.js.map +1 -0
- package/lib/module/i18n/strings/zh.js +71 -0
- package/lib/module/i18n/strings/zh.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/push.js +77 -3
- package/lib/module/push.js.map +1 -1
- package/lib/module/review.js +48 -0
- package/lib/module/review.js.map +1 -0
- package/lib/module/theme.js +141 -23
- package/lib/module/theme.js.map +1 -1
- package/lib/module/types.js +32 -3
- package/lib/module/types.js.map +1 -1
- package/lib/module/useSupportThreads.js +41 -24
- package/lib/module/useSupportThreads.js.map +1 -1
- package/lib/module/utils.js +24 -29
- package/lib/module/utils.js.map +1 -1
- package/lib/module/version.js +9 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/api.d.ts +40 -10
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/components/SupportButton.d.ts +2 -2
- package/lib/typescript/components/SupportButton.d.ts.map +1 -1
- package/lib/typescript/components/icons.d.ts +10 -14
- package/lib/typescript/components/icons.d.ts.map +1 -1
- package/lib/typescript/components/primitives.d.ts +3 -30
- package/lib/typescript/components/primitives.d.ts.map +1 -1
- package/lib/typescript/components/screens/ChatScreen.d.ts +21 -0
- package/lib/typescript/components/screens/ChatScreen.d.ts.map +1 -0
- package/lib/typescript/components/screens/LanguageScreen.d.ts +30 -0
- package/lib/typescript/components/screens/LanguageScreen.d.ts.map +1 -0
- package/lib/typescript/i18n/index.d.ts +15 -0
- package/lib/typescript/i18n/index.d.ts.map +1 -0
- package/lib/typescript/i18n/languages.d.ts +36 -0
- package/lib/typescript/i18n/languages.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/de.d.ts +3 -0
- package/lib/typescript/i18n/strings/de.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/en.d.ts +86 -0
- package/lib/typescript/i18n/strings/en.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/es.d.ts +3 -0
- package/lib/typescript/i18n/strings/es.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/fr.d.ts +3 -0
- package/lib/typescript/i18n/strings/fr.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/hi.d.ts +3 -0
- package/lib/typescript/i18n/strings/hi.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/it.d.ts +3 -0
- package/lib/typescript/i18n/strings/it.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/ja.d.ts +3 -0
- package/lib/typescript/i18n/strings/ja.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/ko.d.ts +3 -0
- package/lib/typescript/i18n/strings/ko.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/nl.d.ts +3 -0
- package/lib/typescript/i18n/strings/nl.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/pl.d.ts +3 -0
- package/lib/typescript/i18n/strings/pl.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/pt.d.ts +3 -0
- package/lib/typescript/i18n/strings/pt.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/ru.d.ts +3 -0
- package/lib/typescript/i18n/strings/ru.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/tr.d.ts +3 -0
- package/lib/typescript/i18n/strings/tr.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/zh.d.ts +3 -0
- package/lib/typescript/i18n/strings/zh.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +4 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/push.d.ts +14 -2
- package/lib/typescript/push.d.ts.map +1 -1
- package/lib/typescript/review.d.ts +15 -0
- package/lib/typescript/review.d.ts.map +1 -0
- package/lib/typescript/theme.d.ts +23 -5
- package/lib/typescript/theme.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +86 -13
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/useSupportThreads.d.ts +20 -4
- package/lib/typescript/useSupportThreads.d.ts.map +1 -1
- package/lib/typescript/utils.d.ts +8 -6
- package/lib/typescript/utils.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +7 -0
- package/lib/typescript/version.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/api.ts +75 -23
- package/src/components/BottomSheet.tsx +1 -1
- package/src/components/LauncherButton.tsx +4 -4
- package/src/components/SupportButton.tsx +244 -86
- package/src/components/icons.tsx +96 -101
- package/src/components/primitives.tsx +9 -161
- package/src/components/screens/ChatScreen.tsx +541 -0
- package/src/components/screens/LanguageScreen.tsx +172 -0
- package/src/i18n/index.ts +81 -0
- package/src/i18n/languages.ts +106 -0
- package/src/i18n/strings/de.ts +81 -0
- package/src/i18n/strings/en.ts +97 -0
- package/src/i18n/strings/es.ts +80 -0
- package/src/i18n/strings/fr.ts +81 -0
- package/src/i18n/strings/hi.ts +80 -0
- package/src/i18n/strings/it.ts +80 -0
- package/src/i18n/strings/ja.ts +80 -0
- package/src/i18n/strings/ko.ts +79 -0
- package/src/i18n/strings/nl.ts +80 -0
- package/src/i18n/strings/pl.ts +80 -0
- package/src/i18n/strings/pt.ts +80 -0
- package/src/i18n/strings/ru.ts +80 -0
- package/src/i18n/strings/tr.ts +80 -0
- package/src/i18n/strings/zh.ts +78 -0
- package/src/index.tsx +13 -0
- package/src/push.ts +100 -2
- package/src/review.ts +54 -0
- package/src/theme.ts +182 -28
- package/src/types.ts +85 -13
- package/src/useSupportThreads.ts +61 -28
- package/src/utils.ts +27 -29
- package/src/version.ts +6 -0
- package/lib/commonjs/components/screens/ComposeScreen.js +0 -228
- package/lib/commonjs/components/screens/ComposeScreen.js.map +0 -1
- package/lib/commonjs/components/screens/HomeScreen.js +0 -286
- package/lib/commonjs/components/screens/HomeScreen.js.map +0 -1
- package/lib/commonjs/components/screens/ThreadScreen.js +0 -327
- package/lib/commonjs/components/screens/ThreadScreen.js.map +0 -1
- package/lib/module/components/screens/ComposeScreen.js +0 -224
- package/lib/module/components/screens/ComposeScreen.js.map +0 -1
- package/lib/module/components/screens/HomeScreen.js +0 -282
- package/lib/module/components/screens/HomeScreen.js.map +0 -1
- package/lib/module/components/screens/ThreadScreen.js +0 -325
- package/lib/module/components/screens/ThreadScreen.js.map +0 -1
- package/lib/typescript/components/screens/ComposeScreen.d.ts +0 -10
- package/lib/typescript/components/screens/ComposeScreen.d.ts.map +0 -1
- package/lib/typescript/components/screens/HomeScreen.d.ts +0 -14
- package/lib/typescript/components/screens/HomeScreen.d.ts.map +0 -1
- package/lib/typescript/components/screens/ThreadScreen.d.ts +0 -10
- package/lib/typescript/components/screens/ThreadScreen.d.ts.map +0 -1
- package/src/components/screens/ComposeScreen.tsx +0 -233
- package/src/components/screens/HomeScreen.tsx +0 -287
- package/src/components/screens/ThreadScreen.tsx +0 -397
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ApiConfig } from './api';
|
|
2
|
-
import type {
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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;
|
|
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,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAepD,eAAO,MAAM,YAAY,QAAS,CAAC;AA8CnC,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,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,iEAAiE;IACjE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,4DAA4D;IAC5D,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3B,8DAA8D;IAC9D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,sEAAsE;IACtE,MAAM,EAAE,MAAM,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
|
-
|
|
2
|
-
|
|
3
|
-
export declare function formatDate(iso: string): string;
|
|
4
|
-
/** "14:32" in the
|
|
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,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKrD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAMnE;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAKnE;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAQvD;AAED,8DAA8D;AAC9D,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAYjE;AAID,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,QAAQ,CAEpD;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
155
|
+
message: string;
|
|
156
|
+
language: string;
|
|
157
|
+
user: ReportedUser;
|
|
124
158
|
},
|
|
125
|
-
): Promise<{ query_id: string }> {
|
|
126
|
-
return request(config, '
|
|
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
|
-
|
|
164
|
+
revenuecat_id: input.revenuecatId,
|
|
131
165
|
message: input.message,
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
186
|
+
user: reportedUser(input.user),
|
|
136
187
|
}),
|
|
137
188
|
});
|
|
138
189
|
}
|
|
139
190
|
|
|
140
|
-
|
|
191
|
+
/** Records a tap on a review request's store button, for the dashboard. */
|
|
192
|
+
export function reviewOpened(
|
|
141
193
|
config: ApiConfig,
|
|
142
|
-
input: {
|
|
143
|
-
): Promise<{
|
|
144
|
-
return request(config, '
|
|
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
|
-
|
|
199
|
+
app_name: config.appName,
|
|
148
200
|
revenuecat_id: input.revenuecatId,
|
|
149
|
-
|
|
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.
|
|
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 {
|
|
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
|
-
//
|
|
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.
|
|
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
|
-
<
|
|
170
|
+
<ConversationMark color={markColor} holeColor={markHoleColor} size={markSize} />
|
|
171
171
|
{label !== undefined && (
|
|
172
172
|
<Text
|
|
173
173
|
style={{
|