@mrrocket/sdk 0.18.0 → 0.22.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/CHANGELOG.md +29 -0
- package/README.md +36 -1
- package/dist/api-client.d.ts +28 -4
- package/dist/api-client.js +30 -13
- package/dist/api-client.js.map +1 -1
- package/dist/browser/mrrocket-flows.js +8 -3
- package/dist/browser/mrrocket-messenger.js +38 -5
- package/dist/browser/mrrocket.js +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -1
- package/dist/browser.js.map +1 -1
- package/dist/client.d.ts +17 -1
- package/dist/client.js +25 -5
- package/dist/client.js.map +1 -1
- package/dist/core.d.ts +5 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/feedback.js +161 -119
- package/dist/feedback.js.map +1 -1
- package/dist/flows-ui.d.ts +1 -1
- package/dist/flows-ui.js +100 -72
- package/dist/flows-ui.js.map +1 -1
- package/dist/flows-web.js +2 -1
- package/dist/flows-web.js.map +1 -1
- package/dist/flows.d.ts +38 -6
- package/dist/flows.js +51 -17
- package/dist/flows.js.map +1 -1
- package/dist/i18n.d.ts +22 -0
- package/dist/i18n.js +74 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/messenger-ui.d.ts +9 -3
- package/dist/messenger-ui.js +324 -152
- package/dist/messenger-ui.js.map +1 -1
- package/dist/messenger.d.ts +3 -1
- package/dist/messenger.js +3 -2
- package/dist/messenger.js.map +1 -1
- package/dist/onboarding-report.d.ts +19 -0
- package/dist/onboarding-report.js +23 -0
- package/dist/onboarding-report.js.map +1 -0
- package/dist/onboarding-state.d.ts +3 -0
- package/dist/onboarding-state.js +7 -1
- package/dist/onboarding-state.js.map +1 -1
- package/dist/paywall.js +2 -1
- package/dist/paywall.js.map +1 -1
- package/dist/react-native/index.d.cts +93 -8
- package/dist/react-native/index.d.ts +93 -8
- package/dist/react-native/index.js +819 -511
- package/dist/react-native/index.js.map +1 -1
- package/dist/server.d.ts +4 -2
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/styles-css.d.ts +1 -1
- package/dist/styles-css.js +35 -2
- package/dist/styles-css.js.map +1 -1
- package/dist/survey.js +18 -14
- package/dist/survey.js.map +1 -1
- package/dist/ui.d.ts +2 -0
- package/dist/ui.js +15 -12
- package/dist/ui.js.map +1 -1
- package/package.json +6 -3
|
@@ -61,6 +61,11 @@ interface SurveyQuestion {
|
|
|
61
61
|
description?: string;
|
|
62
62
|
required: boolean;
|
|
63
63
|
options?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* 0.21.0: what each option says in the visitor's language, parallel to `options`. An answer is still recorded as the
|
|
66
|
+
* `options` value, so rules and numbers do not split by language.
|
|
67
|
+
*/
|
|
68
|
+
labels?: string[];
|
|
64
69
|
scale?: number;
|
|
65
70
|
low?: string;
|
|
66
71
|
high?: string;
|
|
@@ -165,6 +170,8 @@ interface MessengerLook {
|
|
|
165
170
|
/** A round chat button in the app (React Native) too. */
|
|
166
171
|
appLauncher?: boolean;
|
|
167
172
|
help: boolean;
|
|
173
|
+
/** The Updates tab with the published changelog (MRRocket from 0.22; older servers leave it out). */
|
|
174
|
+
updates?: boolean;
|
|
168
175
|
sound: boolean;
|
|
169
176
|
preview: boolean;
|
|
170
177
|
askEmail: boolean;
|
|
@@ -185,13 +192,24 @@ interface MessengerLook {
|
|
|
185
192
|
/** The AI agent's picture beside its answers (from 0.17). */
|
|
186
193
|
agentPhoto?: string;
|
|
187
194
|
}
|
|
188
|
-
/**
|
|
195
|
+
/** One of the visitor's conversations in their list (0.19). */
|
|
196
|
+
interface ChatSummary {
|
|
197
|
+
id: string;
|
|
198
|
+
status: "open" | "solved";
|
|
199
|
+
/** The visitor's first words. */
|
|
200
|
+
subject: string;
|
|
201
|
+
/** The newest message, its body cut to a preview. */
|
|
202
|
+
last: ChatMessage | null;
|
|
203
|
+
}
|
|
204
|
+
/** One chat (the one asked for, else the visitor's newest, open or closed) and its messages. */
|
|
189
205
|
interface ChatThread {
|
|
190
206
|
conversation: {
|
|
191
207
|
id: string;
|
|
192
208
|
status: "open" | "solved";
|
|
193
209
|
} | null;
|
|
194
210
|
messages: ChatMessage[];
|
|
211
|
+
/** All the visitor's conversations, the latest activity first (0.19). */
|
|
212
|
+
conversations?: ChatSummary[];
|
|
195
213
|
/** The visitor gave an email already: the messenger stops asking. */
|
|
196
214
|
hasEmail: boolean;
|
|
197
215
|
}
|
|
@@ -243,10 +261,15 @@ declare const createApi: (c: Conn) => {
|
|
|
243
261
|
completed: boolean;
|
|
244
262
|
seconds: number;
|
|
245
263
|
}) => Promise<unknown>;
|
|
246
|
-
chat
|
|
247
|
-
|
|
264
|
+
/** One chat by id, else the visitor's newest; `conversations` lists them all. */
|
|
265
|
+
chat: (signal?: AbortSignal, conversation?: string) => Promise<ChatThread>;
|
|
266
|
+
/**
|
|
267
|
+
* A message; `attachments` are upload ids from `uploadChatFile` (then the body may be empty). `conversation` is
|
|
268
|
+
* the chat it answers, or "new" to start one; without it, the running chat or else a new one.
|
|
269
|
+
*/
|
|
248
270
|
sendChat: (m: {
|
|
249
271
|
body: string;
|
|
272
|
+
conversation?: string;
|
|
250
273
|
email?: string;
|
|
251
274
|
url?: string;
|
|
252
275
|
attachments?: string[];
|
|
@@ -303,8 +326,10 @@ interface CancelOffer {
|
|
|
303
326
|
/** 0.15.0: a second question after an answer ("What would be a fair price?"); no answers means a free text. */
|
|
304
327
|
interface CancelFollowUp {
|
|
305
328
|
question: string;
|
|
306
|
-
/** The choices, in order; empty for a free text. */
|
|
329
|
+
/** The choices, in order; empty for a free text. What is recorded and what rules compare, whatever the language. */
|
|
307
330
|
answers: string[];
|
|
331
|
+
/** 0.21.0: what each choice says in the visitor's language, parallel to `answers`; shown instead of them. */
|
|
332
|
+
answerLabels?: string[];
|
|
308
333
|
}
|
|
309
334
|
/**
|
|
310
335
|
* 0.15.0: a different offer for some customers of one answer. Every condition that is set must hold; the first rule
|
|
@@ -387,11 +412,15 @@ type FlowIcon = {
|
|
|
387
412
|
};
|
|
388
413
|
/** 0.18.0: what plays when someone finishes a checklist, a tour or the questions. */
|
|
389
414
|
type FinishAnimation = "none" | "confetti" | "fireworks" | "stars";
|
|
390
|
-
/**
|
|
415
|
+
/**
|
|
416
|
+
* 0.18.0: one question of a Questions item: one choice of 2 to 6 options, or a short text. 0.21.0: a number scale, an
|
|
417
|
+
* "Other" with the person's own words, and a Skip button. An older app shows a scale as a text field, leaves "Other"
|
|
418
|
+
* out, and offers no Skip (its close button still ends the window).
|
|
419
|
+
*/
|
|
391
420
|
interface OnboardingQuestion {
|
|
392
421
|
/** The answer's name on the contact (`onboarding.<key>`) and in "People who answered …". */
|
|
393
422
|
key: string;
|
|
394
|
-
type: "choice" | "text";
|
|
423
|
+
type: "choice" | "text" | "scale";
|
|
395
424
|
/** Choice: the options, in order; `id` is what is stored, `label` what people read. */
|
|
396
425
|
options?: {
|
|
397
426
|
id: string;
|
|
@@ -399,6 +428,19 @@ interface OnboardingQuestion {
|
|
|
399
428
|
}[];
|
|
400
429
|
/** Text: the field's hint. */
|
|
401
430
|
placeholder?: string;
|
|
431
|
+
/** 0.21.0, choice: one more option where people type their own words, stored as `other:<words>`. */
|
|
432
|
+
other?: boolean;
|
|
433
|
+
/** 0.21.0: the words of that option; "Other" when unset. */
|
|
434
|
+
otherLabel?: string;
|
|
435
|
+
/** 0.21.0, scale: the lowest and highest number, and the words under both ends. */
|
|
436
|
+
min?: number;
|
|
437
|
+
max?: number;
|
|
438
|
+
lowLabel?: string;
|
|
439
|
+
highLabel?: string;
|
|
440
|
+
/** 0.21.0: people may go on without answering. */
|
|
441
|
+
optional?: boolean;
|
|
442
|
+
/** 0.21.0: the words of that button; "Skip" when unset. */
|
|
443
|
+
skipLabel?: string;
|
|
402
444
|
}
|
|
403
445
|
/** 0.17.0: where a tour bubble sits next to its element; "auto" (and no value) puts it below, else above, as before. */
|
|
404
446
|
type TourPlacement = "auto" | "top" | "bottom" | "left" | "right";
|
|
@@ -628,6 +670,8 @@ interface FlowsController {
|
|
|
628
670
|
startTour(stepId: string): boolean;
|
|
629
671
|
open(stepId: string): boolean;
|
|
630
672
|
answer(value: string): void;
|
|
673
|
+
/** 0.21.0: goes on from an optional question without an answer. */
|
|
674
|
+
skip(): void;
|
|
631
675
|
back(): void;
|
|
632
676
|
item(id: string): OnboardingItemState | null;
|
|
633
677
|
seen(id: string): void;
|
|
@@ -782,7 +826,7 @@ interface PaywallHost {
|
|
|
782
826
|
|
|
783
827
|
type VariantId = string;
|
|
784
828
|
/** This build of the SDK. Sent with the config request so MRRocket knows what the site runs (error tracking, flags). */
|
|
785
|
-
declare const SDK_VERSION = "0.
|
|
829
|
+
declare const SDK_VERSION = "0.22.0";
|
|
786
830
|
/** One variant of an experiment. `changes` replaces texts that the page marks with `<Text id>`. */
|
|
787
831
|
interface VariantConfig {
|
|
788
832
|
id: VariantId;
|
|
@@ -816,6 +860,10 @@ interface RedirectConfig {
|
|
|
816
860
|
interface CockpitConfig {
|
|
817
861
|
/** The product the public key belongs to. */
|
|
818
862
|
project: string;
|
|
863
|
+
/** The language the server chose for the words below, like "de" (`lang` on the request). SDK 0.21.0+. */
|
|
864
|
+
lang?: string;
|
|
865
|
+
/** The SDK's own words: English source word to translation (see words.ts). Absent for English. SDK 0.21.0+. */
|
|
866
|
+
words?: Record<string, string>;
|
|
819
867
|
experiments: ExperimentConfig[];
|
|
820
868
|
/** The product's affiliate program: how many days a partner's referral is kept. Missing without a program. */
|
|
821
869
|
referral?: {
|
|
@@ -983,6 +1031,11 @@ interface MRRocketOptions {
|
|
|
983
1031
|
maxQueue?: number;
|
|
984
1032
|
/** Log what the SDK does to the console. */
|
|
985
1033
|
debug?: boolean;
|
|
1034
|
+
/**
|
|
1035
|
+
* 0.21.0: the language of the SDK's words and of what the server answers, like "de-AT", for an app with its own
|
|
1036
|
+
* language switch. Default: the phone's. `setLocale` does the same from anywhere.
|
|
1037
|
+
*/
|
|
1038
|
+
locale?: string;
|
|
986
1039
|
/** Onboarding flows start on their own when the person does their trigger (default true). False: only `startOnboarding()`. */
|
|
987
1040
|
onboarding?: boolean;
|
|
988
1041
|
/**
|
|
@@ -1137,6 +1190,24 @@ interface MRRocketClient {
|
|
|
1137
1190
|
/** The name of the screen a React Navigation state shows: the focused route, followed into nested navigators. */
|
|
1138
1191
|
declare const activeRouteName: (state: unknown) => string | undefined;
|
|
1139
1192
|
|
|
1193
|
+
type OnboardingReportType = "questions" | "checklist" | "tour";
|
|
1194
|
+
interface OnboardingReportOptions {
|
|
1195
|
+
/** Every step's id in the order people meet them, so a step only some people see keeps its place. */
|
|
1196
|
+
order?: string[];
|
|
1197
|
+
/** "questions" (the default), a "checklist" or a "tour". */
|
|
1198
|
+
type?: OnboardingReportType;
|
|
1199
|
+
}
|
|
1200
|
+
interface OnboardingReport {
|
|
1201
|
+
/** The person sees this step; `title` is its name in MRRocket. Sent once per step and page. */
|
|
1202
|
+
saw(step: string, title: string): void;
|
|
1203
|
+
/** The person answered a question with one of its options: its id, and its words in MRRocket. */
|
|
1204
|
+
answered(question: string, answer: string, label?: string): void;
|
|
1205
|
+
/** The person did this task or tour step. */
|
|
1206
|
+
done(step: string): void;
|
|
1207
|
+
/** The person closed it or skipped the rest, at this step if you name one. */
|
|
1208
|
+
closed(step?: string): void;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1140
1211
|
interface UseOnboarding {
|
|
1141
1212
|
/** The item as MRRocket published it, or null while the config is loading, or when it is not live. */
|
|
1142
1213
|
item: OnboardingFlow | null;
|
|
@@ -1251,6 +1322,11 @@ declare const MRRocketMessenger: ({ client, appearance, options: given }: {
|
|
|
1251
1322
|
options?: NativeMessengerOptions;
|
|
1252
1323
|
}) => react.FunctionComponentElement<Record<string, unknown>> | null;
|
|
1253
1324
|
|
|
1325
|
+
/** An app with its own language switch says the language here; undefined goes back to the device's. Re-reads the config. */
|
|
1326
|
+
declare const setLocale: (locale?: string) => void;
|
|
1327
|
+
/** The app's choice, else the phone's (React Native), else the browser's. */
|
|
1328
|
+
declare const currentLocale: () => string | undefined;
|
|
1329
|
+
|
|
1254
1330
|
/**
|
|
1255
1331
|
* Hides what it wraps in session recordings: its area is painted black on every frame before the frame is stored. Use
|
|
1256
1332
|
* it for anything private on screen (balances, addresses, messages). Text fields need no wrapper: nothing is recorded
|
|
@@ -1375,6 +1451,15 @@ declare const useReview: () => {
|
|
|
1375
1451
|
* if (!item || done) return null;
|
|
1376
1452
|
*/
|
|
1377
1453
|
declare const useOnboarding: (id?: string) => UseOnboarding;
|
|
1454
|
+
/**
|
|
1455
|
+
* 0.22.0: for an onboarding that lives in your own code. Nothing to set up in MRRocket: the first report makes the item
|
|
1456
|
+
* under Onboarding, and MRRocket shows who saw each step and what they answered. It follows the person's consent.
|
|
1457
|
+
*
|
|
1458
|
+
* const report = useOnboardingReport("Welcome questions", { order: ["goal", "role"] });
|
|
1459
|
+
* report.saw("goal", "What brings you here?");
|
|
1460
|
+
* report.answered("goal", "dream", "Dream game");
|
|
1461
|
+
*/
|
|
1462
|
+
declare const useOnboardingReport: (name: string, options?: OnboardingReportOptions) => OnboardingReport;
|
|
1378
1463
|
/** A feature flag from MRRocket › Build › Feature flags: true while it is on for this person; false while off, unknown or loading. */
|
|
1379
1464
|
declare const useFlag: (key: string) => boolean;
|
|
1380
1465
|
/** The variant of a multivariate flag ("control", "test" …), or null while it is off. */
|
|
@@ -1409,4 +1494,4 @@ declare const useExpoRouterTracking: () => void;
|
|
|
1409
1494
|
*/
|
|
1410
1495
|
declare const useNavigationTracking: () => (state: unknown) => void;
|
|
1411
1496
|
|
|
1412
|
-
export { type AppContext, type CancelFlowConfig, type CancelFlowOptions, type CancelFlowResult, type CancelOffer, type ChatMessage, type ChatThread, type CockpitConfig, type FeedbackPost, type FinishAnimation, type FlagConfig, type FlowIcon, type FlowMedia, type FlowView, type IdentifyOptions, type InAppMessage, type KeyValueStorage, type MRRocketClient, MRRocketFeedback, MRRocketFlows, MRRocketMask, MRRocketMessenger, type MRRocketOptions, MRRocketProvider, type MRRocketProviderProps, MRRocketSurveys, type NativeAppearance, type NativeConsent, type NativeFeedbackOptions, type NativeMessengerOptions, type NativePushResult, type NativePushStatus, type NativeReviewResult, type OnboardingFlow, type OnboardingItemState, type OnboardingQuestion, type OnboardingStep, type PaywallConfig, type PaywallOptions, type PaywallPage, type PaywallPlan, type PaywallResult, type RegisterForPushOptions, SDK_VERSION, type SurveyDefinition, type TaskOpens, type TourPlacement, type UseOnboarding, type VariantId, activeRouteName, createMRRocket, getMRRocket, useCancelFlow, useExpoRouterTracking, useFeedback, useFlag, useFlagVariant, useMRRocket, useMessenger, useNavigationTracking, useOnboarding, usePaywall, usePush, useReview, useText, useVariant };
|
|
1497
|
+
export { type AppContext, type CancelFlowConfig, type CancelFlowOptions, type CancelFlowResult, type CancelOffer, type ChatMessage, type ChatThread, type CockpitConfig, type FeedbackPost, type FinishAnimation, type FlagConfig, type FlowIcon, type FlowMedia, type FlowView, type IdentifyOptions, type InAppMessage, type KeyValueStorage, type MRRocketClient, MRRocketFeedback, MRRocketFlows, MRRocketMask, MRRocketMessenger, type MRRocketOptions, MRRocketProvider, type MRRocketProviderProps, MRRocketSurveys, type NativeAppearance, type NativeConsent, type NativeFeedbackOptions, type NativeMessengerOptions, type NativePushResult, type NativePushStatus, type NativeReviewResult, type OnboardingFlow, type OnboardingItemState, type OnboardingQuestion, type OnboardingReport, type OnboardingReportOptions, type OnboardingReportType, type OnboardingStep, type PaywallConfig, type PaywallOptions, type PaywallPage, type PaywallPlan, type PaywallResult, type RegisterForPushOptions, SDK_VERSION, type SurveyDefinition, type TaskOpens, type TourPlacement, type UseOnboarding, type VariantId, activeRouteName, createMRRocket, currentLocale, getMRRocket, setLocale, useCancelFlow, useExpoRouterTracking, useFeedback, useFlag, useFlagVariant, useMRRocket, useMessenger, useNavigationTracking, useOnboarding, useOnboardingReport, usePaywall, usePush, useReview, useText, useVariant };
|