@mrrocket/sdk 0.16.0 → 0.18.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 +25 -0
- package/README.md +11 -2
- package/dist/api-client.d.ts +7 -1
- package/dist/api-client.js.map +1 -1
- package/dist/browser/mrrocket-flows.js +16 -2
- package/dist/browser/mrrocket-messenger.js +43 -44
- package/dist/browser/mrrocket.js +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -1
- package/dist/browser.js.map +1 -1
- package/dist/client.d.ts +23 -3
- package/dist/client.js +15 -1
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +3 -1
- package/dist/context.js.map +1 -1
- package/dist/core.d.ts +3 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/finish-web.d.ts +18 -0
- package/dist/finish-web.js +139 -0
- package/dist/finish-web.js.map +1 -0
- package/dist/flows-ui.d.ts +1 -10
- package/dist/flows-ui.js +165 -16
- package/dist/flows-ui.js.map +1 -1
- package/dist/flows-web.d.ts +8 -1
- package/dist/flows-web.js +8 -0
- package/dist/flows-web.js.map +1 -1
- package/dist/flows.d.ts +203 -5
- package/dist/flows.js +306 -15
- package/dist/flows.js.map +1 -1
- package/dist/icons.d.ts +24 -0
- package/dist/icons.js +61 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/messenger-ui.d.ts +10 -2
- package/dist/messenger-ui.js +134 -98
- package/dist/messenger-ui.js.map +1 -1
- package/dist/onboarding-state.d.ts +23 -0
- package/dist/onboarding-state.js +43 -0
- package/dist/onboarding-state.js.map +1 -0
- package/dist/react-native/index.d.cts +216 -15
- package/dist/react-native/index.d.ts +216 -15
- package/dist/react-native/index.js +880 -270
- package/dist/react-native/index.js.map +1 -1
- package/dist/styles-css.d.ts +1 -1
- package/dist/styles-css.js +40 -41
- package/dist/styles-css.js.map +1 -1
- package/package.json +1 -1
package/dist/flows.d.ts
CHANGED
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
* `onCancel`, and only after they succeed is the outcome recorded.
|
|
12
12
|
* - `$onboarding` `{flow, step?, action: "started" | "shown" | "completed" | "dismissed"}`; since 0.11.0 a wait records
|
|
13
13
|
* "shown" when the person reaches it and "completed" when it is over, a condition `{action: "answered", answer: "yes"
|
|
14
|
-
* | "no"}` once it is decided.
|
|
14
|
+
* | "no"}` once it is decided; since 0.17.0 a tour a checklist task started records `{action: "started", from}` with
|
|
15
|
+
* the checklist's id; since 0.18.0 a question records `{kind: "question", action: "completed", question, answer,
|
|
16
|
+
* label}` (the question's key, the option's id or the typed text, the option's words), which MRRocket keeps on the
|
|
17
|
+
* contact, and a checklist task that opens something `{action: "opened", opens}`.
|
|
15
18
|
* - `$inapp` `{message, journey, action: "shown" | "clicked" | "dismissed"}`; the journey moves the person on.
|
|
16
19
|
*/
|
|
17
20
|
import type { CockpitConfig } from "./core.js";
|
|
@@ -85,7 +88,65 @@ export interface CancelFlowConfig {
|
|
|
85
88
|
*/
|
|
86
89
|
offersFor: "business";
|
|
87
90
|
}
|
|
88
|
-
|
|
91
|
+
/** "question" (0.18.0): one question of a Questions item, a slide of its window. */
|
|
92
|
+
export type OnboardingStepKind = "tour" | "checklist" | "modal" | "question";
|
|
93
|
+
/**
|
|
94
|
+
* 0.18.0: what a checklist task opens. `page`: a path or address on the web, a deep link (`myapp://…`) or a screen name
|
|
95
|
+
* in an app, handed to the app's `onNavigate` when it passes one; `tour` / `modal`: another item of the config, after
|
|
96
|
+
* which the checklist comes back; `code`: the app's `onTask(taskId, item)`.
|
|
97
|
+
*/
|
|
98
|
+
export type TaskOpens = {
|
|
99
|
+
kind: "page";
|
|
100
|
+
target: string;
|
|
101
|
+
} | {
|
|
102
|
+
kind: "tour";
|
|
103
|
+
id: string;
|
|
104
|
+
} | {
|
|
105
|
+
kind: "modal";
|
|
106
|
+
id: string;
|
|
107
|
+
} | {
|
|
108
|
+
kind: "code";
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* 0.18.0: a small picture beside a checklist task or above a modal's or the questions' heading: one of the SDK's own
|
|
112
|
+
* line icons (`FLOW_ICON_NAMES`, icons.ts), an emoji, or a picture (http(s)).
|
|
113
|
+
*/
|
|
114
|
+
export type FlowIcon = {
|
|
115
|
+
kind: "builtin";
|
|
116
|
+
name: string;
|
|
117
|
+
} | {
|
|
118
|
+
kind: "emoji";
|
|
119
|
+
value: string;
|
|
120
|
+
} | {
|
|
121
|
+
kind: "image";
|
|
122
|
+
url: string;
|
|
123
|
+
};
|
|
124
|
+
/** 0.18.0: what plays when someone finishes a checklist, a tour or the questions. */
|
|
125
|
+
export type FinishAnimation = "none" | "confetti" | "fireworks" | "stars";
|
|
126
|
+
/** 0.18.0: one question of a Questions item: one choice of 2 to 6 options, or a short text. */
|
|
127
|
+
export interface OnboardingQuestion {
|
|
128
|
+
/** The answer's name on the contact (`onboarding.<key>`) and in "People who answered …". */
|
|
129
|
+
key: string;
|
|
130
|
+
type: "choice" | "text";
|
|
131
|
+
/** Choice: the options, in order; `id` is what is stored, `label` what people read. */
|
|
132
|
+
options?: {
|
|
133
|
+
id: string;
|
|
134
|
+
label: string;
|
|
135
|
+
}[];
|
|
136
|
+
/** Text: the field's hint. */
|
|
137
|
+
placeholder?: string;
|
|
138
|
+
}
|
|
139
|
+
/** 0.17.0: where a tour bubble sits next to its element; "auto" (and no value) puts it below, else above, as before. */
|
|
140
|
+
export type TourPlacement = "auto" | "top" | "bottom" | "left" | "right";
|
|
141
|
+
/**
|
|
142
|
+
* 0.17.0: a picture or a video above a tour step's or a modal's text. A video is a YouTube, Vimeo or Loom link (shown
|
|
143
|
+
* through their privacy-friendly players, see `videoEmbed`) or a video file (mp4, webm).
|
|
144
|
+
*/
|
|
145
|
+
export interface FlowMedia {
|
|
146
|
+
kind: "image" | "video";
|
|
147
|
+
url: string;
|
|
148
|
+
alt?: string;
|
|
149
|
+
}
|
|
89
150
|
export interface OnboardingStep {
|
|
90
151
|
id: string;
|
|
91
152
|
kind: OnboardingStepKind;
|
|
@@ -96,6 +157,20 @@ export interface OnboardingStep {
|
|
|
96
157
|
target?: string;
|
|
97
158
|
/** Checklist items: the event that ticks them (`track("<event>")`). Without it the person ticks it themselves. */
|
|
98
159
|
event?: string;
|
|
160
|
+
/** 0.17.0, tour steps: which side of the element the bubble takes (flips when there is no room). */
|
|
161
|
+
placement?: TourPlacement;
|
|
162
|
+
/** 0.17.0, tour steps and modals: a picture or a video above the text. */
|
|
163
|
+
media?: FlowMedia;
|
|
164
|
+
/** 0.17.0, modals: where the button goes (http(s) or a path of the app). */
|
|
165
|
+
url?: string;
|
|
166
|
+
/** 0.17.0, checklist items: the id of a tour (another flow) the item starts; finishing the tour ticks the item. */
|
|
167
|
+
startsTour?: string;
|
|
168
|
+
/** 0.18.0, checklist items: what the task opens (read before `startsTour`, which MRRocket still sends for a tour). */
|
|
169
|
+
opens?: TaskOpens;
|
|
170
|
+
/** 0.18.0, checklist items: the task's icon. */
|
|
171
|
+
icon?: FlowIcon;
|
|
172
|
+
/** 0.18.0, question steps: the question (the step's `title` is what people read). */
|
|
173
|
+
question?: OnboardingQuestion;
|
|
99
174
|
}
|
|
100
175
|
/** A pause in a flow (0.11.0): the next step shows this long after the one before was done. */
|
|
101
176
|
export interface OnboardingWait {
|
|
@@ -121,11 +196,40 @@ export type OnboardingNode = OnboardingStep | OnboardingWait | OnboardingConditi
|
|
|
121
196
|
/** A live onboarding flow's in-app steps (MRRocket › Conversion › Onboarding); its emails go out from MRRocket. */
|
|
122
197
|
export interface OnboardingFlow {
|
|
123
198
|
id: string;
|
|
199
|
+
/** A checklist's heading; for tours and modals the name MRRocket knows them by. */
|
|
124
200
|
name: string;
|
|
125
|
-
/**
|
|
201
|
+
/**
|
|
202
|
+
* When it starts: an event's words ("Signed up", "First export"), "First launch" / "First visit", since 0.17.0 a page
|
|
203
|
+
* of the app ("/settings", "/projects/*"), or "From a checklist" (only a checklist task starts it).
|
|
204
|
+
*/
|
|
126
205
|
trigger: string;
|
|
206
|
+
/**
|
|
207
|
+
* 0.17.0: "signed_in" starts it on its own only for someone the app identified. 0.18.0: "answered" only for someone
|
|
208
|
+
* who gave `answered.option` to the question `answered.question` (its key).
|
|
209
|
+
*/
|
|
210
|
+
audience?: "signed_in" | "answered";
|
|
211
|
+
/** 0.18.0: with `audience: "answered"`, the question's key and the option's id (or the typed text). */
|
|
212
|
+
answered?: {
|
|
213
|
+
question: string;
|
|
214
|
+
option: string;
|
|
215
|
+
};
|
|
127
216
|
/** What every version shows: with `nodes`, only the in-app steps before the first wait or condition. */
|
|
128
217
|
steps: OnboardingStep[];
|
|
218
|
+
/** 0.18.0: the icon above a modal's or the questions' heading. */
|
|
219
|
+
icon?: FlowIcon;
|
|
220
|
+
/** 0.18.0: what plays when the person finishes it (a checklist, a tour, the questions). */
|
|
221
|
+
finish?: FinishAnimation;
|
|
222
|
+
/**
|
|
223
|
+
* 0.18.0: "code": the app draws it itself (`useOnboarding(id)`, `mrrocket.onboarding.get(id)`); the SDK draws
|
|
224
|
+
* nothing for it, never starts it, and still records what the app reports. Such an item's `trigger` is
|
|
225
|
+
* "From your code" (older versions never start it).
|
|
226
|
+
*/
|
|
227
|
+
shownBy?: "code";
|
|
228
|
+
/**
|
|
229
|
+
* 0.18.0: the item's real moment (read instead of `trigger`, see `momentOf`) when `trigger` is one older versions
|
|
230
|
+
* never start: "From your code", or `NEEDS_NEWER` for questions and items that follow another or ask for an answer.
|
|
231
|
+
*/
|
|
232
|
+
when?: string;
|
|
129
233
|
/** 0.11.0+: the whole flow with its waits and conditions. Read instead of `steps` when it is there. */
|
|
130
234
|
nodes?: OnboardingNode[];
|
|
131
235
|
}
|
|
@@ -157,6 +261,8 @@ export interface InAppState {
|
|
|
157
261
|
messages: InAppMessage[];
|
|
158
262
|
/** 0.11.0: the events the flows' conditions ask about that this person did (as `eventSlug`s). */
|
|
159
263
|
events?: string[];
|
|
264
|
+
/** 0.18.0: the person's answers to onboarding questions, by the question's key (an option's id or the text). */
|
|
265
|
+
answers?: Record<string, string>;
|
|
160
266
|
/**
|
|
161
267
|
* 0.16.0: a live review request may ask this person now. The React Native client's `requestReview()` opens the
|
|
162
268
|
* store's own rating dialog (expo-store-review) and reports `$review_prompt`; websites have no store dialog.
|
|
@@ -221,19 +327,31 @@ export type FlowView = {
|
|
|
221
327
|
/** The step for the dots, 1 to `steps`. */
|
|
222
328
|
step: number;
|
|
223
329
|
steps: number;
|
|
224
|
-
}
|
|
330
|
+
}
|
|
331
|
+
/** `answer` (0.18.0): a question's answer so far (an option's id or the typed text); `back`: an earlier question to go back to. */
|
|
332
|
+
| {
|
|
225
333
|
type: "step";
|
|
226
334
|
flow: OnboardingFlow;
|
|
227
335
|
step: OnboardingStep;
|
|
228
336
|
index: number;
|
|
229
337
|
total: number;
|
|
230
338
|
last: boolean;
|
|
231
|
-
|
|
339
|
+
answer?: string;
|
|
340
|
+
back?: boolean;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* `tour`: the tour the item starts (0.17.0), when the config has it. `opens` (0.18.0): what tapping the task opens
|
|
344
|
+
* (a tour or modal only when the config has it); `target` the item it opens.
|
|
345
|
+
*/
|
|
346
|
+
| {
|
|
232
347
|
type: "checklist";
|
|
233
348
|
flow: OnboardingFlow;
|
|
234
349
|
items: {
|
|
235
350
|
step: OnboardingStep;
|
|
236
351
|
done: boolean;
|
|
352
|
+
tour?: OnboardingFlow;
|
|
353
|
+
opens?: TaskOpens;
|
|
354
|
+
target?: OnboardingFlow;
|
|
237
355
|
}[];
|
|
238
356
|
} | {
|
|
239
357
|
type: "message";
|
|
@@ -257,6 +375,13 @@ export interface FlowsEnv {
|
|
|
257
375
|
auto?: boolean;
|
|
258
376
|
/** The page the person is on (a path), for "Is on <page>?" conditions; without it they answer no. */
|
|
259
377
|
path?: () => string | undefined;
|
|
378
|
+
/**
|
|
379
|
+
* 0.18.0: opens what a checklist task's "page or screen" names (a path, an address, a deep link, a screen name).
|
|
380
|
+
* The web and React Native clients pass the app's `onNavigate`, else their own default.
|
|
381
|
+
*/
|
|
382
|
+
navigate?: (target: string) => void;
|
|
383
|
+
/** 0.18.0: a checklist task that runs the app's own code (`onTask(taskId, item)`). */
|
|
384
|
+
task?: (taskId: string, item: OnboardingFlow) => void;
|
|
260
385
|
/** The clock, for tests. */
|
|
261
386
|
now?: () => number;
|
|
262
387
|
}
|
|
@@ -282,15 +407,54 @@ export interface FlowsController {
|
|
|
282
407
|
confirm(comment?: string): void;
|
|
283
408
|
close(): void;
|
|
284
409
|
};
|
|
410
|
+
/**
|
|
411
|
+
* `startTour(stepId)` (0.17.0): the tour a checklist item starts; the checklist comes back when it ends.
|
|
412
|
+
* 0.18.0: `open(stepId)` does what the task opens (a page, a tour, a modal, the app's code); `answer(value)` picks an
|
|
413
|
+
* option or types the text of the question on screen, `back()` returns to the question before. `item(id)` and the
|
|
414
|
+
* calls after it are for an item the app draws itself (`shownBy: "code"`).
|
|
415
|
+
*/
|
|
285
416
|
onboarding: {
|
|
286
417
|
next(): void;
|
|
287
418
|
check(stepId: string): void;
|
|
288
419
|
dismiss(): void;
|
|
420
|
+
startTour(stepId: string): boolean;
|
|
421
|
+
open(stepId: string): boolean;
|
|
422
|
+
answer(value: string): void;
|
|
423
|
+
back(): void;
|
|
424
|
+
item(id: string): OnboardingItemState | null;
|
|
425
|
+
seen(id: string): void;
|
|
426
|
+
complete(id: string, stepId: string): void;
|
|
427
|
+
dismissItem(id: string): void;
|
|
428
|
+
answerItem(id: string, question: string, value: string): void;
|
|
289
429
|
};
|
|
290
430
|
message: {
|
|
291
431
|
click(): void;
|
|
292
432
|
dismiss(): void;
|
|
293
433
|
};
|
|
434
|
+
/** 0.18.0: the animation to play now that someone finished an item (a new `key` each time), or null. */
|
|
435
|
+
finale(): {
|
|
436
|
+
kind: Exclude<FinishAnimation, "none">;
|
|
437
|
+
key: string;
|
|
438
|
+
} | null;
|
|
439
|
+
/** 0.18.0: the product's brand color from MRRocket, for the dialogs when the app passes no accent of its own. */
|
|
440
|
+
accent(): string | undefined;
|
|
441
|
+
/** 0.18.0: the person's answers to onboarding questions, by key. */
|
|
442
|
+
answers(): Record<string, string>;
|
|
443
|
+
}
|
|
444
|
+
/** 0.18.0: an item the app draws itself (`shownBy: "code"`), with the person's progress. */
|
|
445
|
+
export interface OnboardingItemState {
|
|
446
|
+
item: OnboardingFlow;
|
|
447
|
+
/** Its steps (a tour's steps, a checklist's tasks, the questions), each with whether the person did it. */
|
|
448
|
+
steps: (OnboardingStep & {
|
|
449
|
+
done: boolean;
|
|
450
|
+
answer?: string;
|
|
451
|
+
})[];
|
|
452
|
+
/** Every step is done. */
|
|
453
|
+
done: boolean;
|
|
454
|
+
/** The person closed it. */
|
|
455
|
+
dismissed: boolean;
|
|
456
|
+
/** Its moment has come for this person (the trigger MRRocket set, and who it is for); your code may ignore it. */
|
|
457
|
+
eligible: boolean;
|
|
294
458
|
}
|
|
295
459
|
/** The plain confirmation, when the product has no live cancel flow (or MRRocket was not reachable). */
|
|
296
460
|
export declare const PLAIN_CANCEL: CancelFlowConfig;
|
|
@@ -300,6 +464,40 @@ export declare const eventSlug: (s: string) => string;
|
|
|
300
464
|
export declare const matchesTrigger: (trigger: string, event: string) => boolean;
|
|
301
465
|
/** Triggers that mean "the first time the person opens the app": the flow starts on load until it is done. */
|
|
302
466
|
export declare const startsOnLoad: (trigger: string) => boolean;
|
|
467
|
+
/** 0.17.0: the trigger of a tour only a checklist task starts. */
|
|
468
|
+
export declare const FROM_CHECKLIST = "From a checklist";
|
|
469
|
+
/** 0.17.0: a trigger that is a page of the app ("/settings", "/projects/*"): the flow starts when the person opens it. */
|
|
470
|
+
export declare const isPageTrigger: (trigger: string) => boolean;
|
|
471
|
+
/** 0.18.0: the trigger of an item the app draws itself (`shownBy: "code"`); older versions never start it. */
|
|
472
|
+
export declare const FROM_CODE = "From your code";
|
|
473
|
+
/**
|
|
474
|
+
* 0.18.0: the trigger MRRocket sends for an item older versions could not show right (questions, "After <item> ends",
|
|
475
|
+
* "People who answered …"), so they never start it; its real moment is in `when`.
|
|
476
|
+
*/
|
|
477
|
+
export declare const NEEDS_NEWER = "Needs tracking code 0.18.0";
|
|
478
|
+
/** An item's moment: `when` (0.18.0) where MRRocket sent one, else its trigger. */
|
|
479
|
+
export declare const momentOf: (f: Pick<OnboardingFlow, "trigger" | "when">) => string;
|
|
480
|
+
/** 0.18.0: the trigger "after:<item id>": the item starts once that item ended (finished or closed). */
|
|
481
|
+
export declare const AFTER_PREFIX = "after:";
|
|
482
|
+
/** The item an "after:<id>" trigger follows, or null. */
|
|
483
|
+
export declare const afterOf: (trigger: string | undefined) => string | null;
|
|
484
|
+
/** 0.18.0: what a task opens; a 0.17.0 `startsTour` reads as opening that tour. */
|
|
485
|
+
export declare const opensOf: (step: Pick<OnboardingStep, "opens" | "startsTour">) => TaskOpens | undefined;
|
|
486
|
+
/** 0.18.0: a usable answer to a question: one of its options' ids, or a text of 1 to 500 characters. */
|
|
487
|
+
export declare const answerOk: (q: OnboardingQuestion | undefined, value: string | undefined) => boolean;
|
|
488
|
+
/** The option's words for an answer (a text answer is its own words). */
|
|
489
|
+
export declare const answerLabel: (q: OnboardingQuestion | undefined, value: string) => string;
|
|
490
|
+
/**
|
|
491
|
+
* 0.17.0: how a video link plays. YouTube, Vimeo and Loom through their players without tracking cookies
|
|
492
|
+
* (youtube-nocookie.com, Vimeo's `dnt=1`), a file (mp4, webm, mov, or an upload in MRRocket) in a plain video element;
|
|
493
|
+
* anything else is not shown. Regular expressions only, so React Native can use it too.
|
|
494
|
+
*/
|
|
495
|
+
export declare const videoEmbed: (url: string | undefined) => {
|
|
496
|
+
kind: "iframe" | "file";
|
|
497
|
+
src: string;
|
|
498
|
+
} | null;
|
|
499
|
+
/** 0.17.0: a step's picture or video when the dialogs may load it (http(s), a video they can play), else undefined. */
|
|
500
|
+
export declare const mediaOf: (step: Pick<OnboardingStep, "media">) => FlowMedia | undefined;
|
|
303
501
|
/** A random id for one cancel flow run. */
|
|
304
502
|
export declare const runId: () => string;
|
|
305
503
|
/** The money a discount leaves: `29 EUR` at 30 % → `20.30`. */
|