@mrrocket/sdk 0.21.0 → 0.23.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 +14 -0
- package/README.md +12 -0
- package/dist/api-client.d.ts +14 -1
- package/dist/api-client.js +13 -4
- package/dist/api-client.js.map +1 -1
- package/dist/browser/mrrocket-flows.js +2 -2
- package/dist/browser/mrrocket-messenger.js +14 -5
- 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 +11 -0
- package/dist/client.js +10 -3
- package/dist/client.js.map +1 -1
- package/dist/core.d.ts +3 -1
- package/dist/core.js +3 -1
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/messenger-ui.d.ts +2 -0
- package/dist/messenger-ui.js +138 -25
- package/dist/messenger-ui.js.map +1 -1
- package/dist/messenger.js +1 -0
- 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/react-native/index.d.cts +33 -3
- package/dist/react-native/index.d.ts +33 -3
- package/dist/react-native/index.js +248 -211
- package/dist/react-native/index.js.map +1 -1
- package/dist/styles-css.d.ts +1 -1
- package/dist/styles-css.js +11 -2
- package/dist/styles-css.js.map +1 -1
- package/package.json +1 -1
package/dist/messenger.js
CHANGED
|
@@ -19,6 +19,7 @@ var Messenger = ({ position, title, greeting, askEmail, label, launcher, help, u
|
|
|
19
19
|
const who = useRef({ distinctId: ctx.distinctId, user: ctx.user, userHash: ctx.userHash });
|
|
20
20
|
who.current = { distinctId: ctx.distinctId, user: ctx.user, userHash: ctx.userHash };
|
|
21
21
|
const { apiKey, host, embedded } = ctx;
|
|
22
|
+
useEffect(() => handle?.refresh(), [ctx.distinctId, ctx.userHash]);
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
if (embedded || !apiKey) return;
|
|
24
25
|
let gone = false;
|
package/dist/messenger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/messenger.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport type { MessengerCorners, MessengerPosition } from \"./api-client\";\nimport { useCtx } from \"./context\";\nimport type { MessengerHandle, MessengerView } from \"./messenger-ui\";\nimport type { Theme } from \"./ui\";\n\n/**\n * The messenger, after Featurebase's: a launcher and a panel with Home, Messages (a chat with the product's team) and\n * Help (the product's published help articles). A visitor's messages become a Support conversation (channel \"chat\")\n * in MRRocket's inbox, where the owner answers or the Customer experience agent does (Support › Automation › AI\n * answers). A new answer plays a short sound and shows a preview above the closed launcher.\n *\n * The panel is plain DOM (messenger-ui.ts, shared with the script tag), loaded with a dynamic import after the page\n * rendered. The visitor is the provider's id; a person the site identified carries their name and email.\n */\n\nlet handle: MessengerHandle | null = null;\n/** A call made before the panel loaded runs once it has. */\nlet waiting: ((h: MessengerHandle) => void) | null = null;\nconst withHandle = (fn: (h: MessengerHandle) => void) => {\n if (handle) fn(handle);\n else waiting = fn;\n};\n\n/** Open (on Home, a tab or an article), close or toggle the messenger from your own button (or mark any element `data-ck-messenger`). */\nexport const useMessenger = () => ({\n open: (view?: MessengerView | { article: string }) => withHandle((h) => h.open(view)),\n close: () => handle?.close(),\n toggle: () => withHandle((h) => h.toggle()),\n});\n\nexport interface MessengerProps {\n /** A corner, the middle of the top or bottom edge, or the middle of a side (default \"bottom-right\"). */\n position?: MessengerPosition;\n /** The team's name beside its mark on Home (default: the product's name). */\n title?: string;\n /** The big line on Home and the first line of an empty chat. */\n greeting?: string;\n /** Ask anonymous visitors for an email (optional for them). Default true. */\n askEmail?: boolean;\n /** Text on the launcher; empty shows the icon only. */\n label?: string;\n /** Show the round launcher (default true). False: open it with `useMessenger()` or `data-ck-messenger`. */\n launcher?: boolean;\n /** The Help tab with your published help articles (default true; hidden while there are none). */\n help?: boolean;\n /** The Updates tab with your published changelog (default true; hidden while there are none). */\n updates?: boolean;\n /** A short sound when an answer arrives (default true). */\n sound?: boolean;\n /** A preview of a new answer above the closed launcher (default true). */\n preview?: boolean;\n theme?: Theme;\n accent?: string;\n /** \"round\" (default), \"soft\" or \"square\". */\n corners?: MessengerCorners;\n /** Your site's font (default) or \"system\". */\n font?: \"site\" | \"system\";\n /** Home's top: \"plain\" (default) or \"color\" (the accent). */\n header?: \"plain\" | \"color\";\n}\n\n/**\n * A floating launcher that opens the messenger. Put it once inside `<CockpitProvider>`:\n *\n * <Messenger title=\"Acme\" greeting=\"Hi! How can we help?\" />\n */\nexport const Messenger = ({ position, title, greeting, askEmail, label, launcher, help, updates, sound, preview, theme, accent, corners, font, header }: MessengerProps) => {\n const ctx = useCtx();\n // The panel reads the visitor at each request, so a later identify or reset needs no remount.\n const who = useRef({ distinctId: ctx.distinctId, user: ctx.user, userHash: ctx.userHash });\n who.current = { distinctId: ctx.distinctId, user: ctx.user, userHash: ctx.userHash };\n const { apiKey, host, embedded } = ctx;\n\n useEffect(() => {\n if (embedded || !apiKey) return;\n let gone = false;\n let mine: MessengerHandle | null = null;\n void import(\"./messenger-ui\").then(({ mountMessenger }) => {\n if (gone) return;\n mine = mountMessenger({\n host,\n apiKey,\n distinctId: () => who.current.distinctId,\n user: () => who.current.user as { id?: string; name?: string; email?: string } | undefined,\n userHash: () => who.current.userHash,\n launcher,\n position,\n title,\n greeting,\n askEmail,\n label,\n help,\n updates,\n sound,\n preview,\n theme,\n accent,\n corners,\n font,\n header,\n });\n handle = mine;\n waiting?.(mine);\n waiting = null;\n });\n const click = (e: MouseEvent) => {\n if ((e.target as HTMLElement | null)?.closest(\"[data-ck-messenger]\")) {\n e.preventDefault();\n withHandle((h) => h.open());\n }\n };\n document.addEventListener(\"click\", click);\n return () => {\n gone = true;\n document.removeEventListener(\"click\", click);\n mine?.destroy();\n if (handle === mine) handle = null;\n };\n }, [apiKey, host, embedded, launcher, position, title, greeting, askEmail, label, help, updates, sound, preview, theme, accent, corners, font, header]);\n\n return null;\n};\n"],"mappings":";;;AAEA,SAAS,WAAW,cAAc;AAElC,SAAS,cAAc;AAcvB,IAAI,SAAiC;AAErC,IAAI,UAAiD;AACrD,IAAM,aAAa,CAAC,OAAqC;AACrD,MAAI,OAAQ,IAAG,MAAM;AAAA,MAChB,WAAU;AACnB;AAGO,IAAM,eAAe,OAAO;AAAA,EAC/B,MAAM,CAAC,SAA+C,WAAW,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC;AAAA,EACpF,OAAO,MAAM,QAAQ,MAAM;AAAA,EAC3B,QAAQ,MAAM,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC;AAC9C;AAsCO,IAAM,YAAY,CAAC,EAAE,UAAU,OAAO,UAAU,UAAU,OAAO,UAAU,MAAM,SAAS,OAAO,SAAS,OAAO,QAAQ,SAAS,MAAM,OAAO,MAAsB;AACxK,QAAM,MAAM,OAAO;AAEnB,QAAM,MAAM,OAAO,EAAE,YAAY,IAAI,YAAY,MAAM,IAAI,MAAM,UAAU,IAAI,SAAS,CAAC;AACzF,MAAI,UAAU,EAAE,YAAY,IAAI,YAAY,MAAM,IAAI,MAAM,UAAU,IAAI,SAAS;AACnF,QAAM,EAAE,QAAQ,MAAM,SAAS,IAAI;AAEnC,YAAU,MAAM;AACZ,QAAI,YAAY,CAAC,OAAQ;AACzB,QAAI,OAAO;AACX,QAAI,OAA+B;AACnC,SAAK,OAAO,mBAAgB,EAAE,KAAK,CAAC,EAAE,eAAe,MAAM;AACvD,UAAI,KAAM;AACV,aAAO,eAAe;AAAA,QAClB;AAAA,QACA;AAAA,QACA,YAAY,MAAM,IAAI,QAAQ;AAAA,QAC9B,MAAM,MAAM,IAAI,QAAQ;AAAA,QACxB,UAAU,MAAM,IAAI,QAAQ;AAAA,QAC5B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACJ,CAAC;AACD,eAAS;AACT,gBAAU,IAAI;AACd,gBAAU;AAAA,IACd,CAAC;AACD,UAAM,QAAQ,CAAC,MAAkB;AAC7B,UAAK,EAAE,QAA+B,QAAQ,qBAAqB,GAAG;AAClE,UAAE,eAAe;AACjB,mBAAW,CAAC,MAAM,EAAE,KAAK,CAAC;AAAA,MAC9B;AAAA,IACJ;AACA,aAAS,iBAAiB,SAAS,KAAK;AACxC,WAAO,MAAM;AACT,aAAO;AACP,eAAS,oBAAoB,SAAS,KAAK;AAC3C,YAAM,QAAQ;AACd,UAAI,WAAW,KAAM,UAAS;AAAA,IAClC;AAAA,EACJ,GAAG,CAAC,QAAQ,MAAM,UAAU,UAAU,UAAU,OAAO,UAAU,UAAU,OAAO,MAAM,SAAS,OAAO,SAAS,OAAO,QAAQ,SAAS,MAAM,MAAM,CAAC;AAEtJ,SAAO;AACX;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/messenger.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport type { MessengerCorners, MessengerPosition } from \"./api-client\";\nimport { useCtx } from \"./context\";\nimport type { MessengerHandle, MessengerView } from \"./messenger-ui\";\nimport type { Theme } from \"./ui\";\n\n/**\n * The messenger, after Featurebase's: a launcher and a panel with Home, Messages (a chat with the product's team) and\n * Help (the product's published help articles). A visitor's messages become a Support conversation (channel \"chat\")\n * in MRRocket's inbox, where the owner answers or the Customer experience agent does (Support › Automation › AI\n * answers). A new answer plays a short sound and shows a preview above the closed launcher.\n *\n * The panel is plain DOM (messenger-ui.ts, shared with the script tag), loaded with a dynamic import after the page\n * rendered. The visitor is the provider's id; a person the site identified carries their name and email.\n */\n\nlet handle: MessengerHandle | null = null;\n/** A call made before the panel loaded runs once it has. */\nlet waiting: ((h: MessengerHandle) => void) | null = null;\nconst withHandle = (fn: (h: MessengerHandle) => void) => {\n if (handle) fn(handle);\n else waiting = fn;\n};\n\n/** Open (on Home, a tab or an article), close or toggle the messenger from your own button (or mark any element `data-ck-messenger`). */\nexport const useMessenger = () => ({\n open: (view?: MessengerView | { article: string }) => withHandle((h) => h.open(view)),\n close: () => handle?.close(),\n toggle: () => withHandle((h) => h.toggle()),\n});\n\nexport interface MessengerProps {\n /** A corner, the middle of the top or bottom edge, or the middle of a side (default \"bottom-right\"). */\n position?: MessengerPosition;\n /** The team's name beside its mark on Home (default: the product's name). */\n title?: string;\n /** The big line on Home and the first line of an empty chat. */\n greeting?: string;\n /** Ask anonymous visitors for an email (optional for them). Default true. */\n askEmail?: boolean;\n /** Text on the launcher; empty shows the icon only. */\n label?: string;\n /** Show the round launcher (default true). False: open it with `useMessenger()` or `data-ck-messenger`. */\n launcher?: boolean;\n /** The Help tab with your published help articles (default true; hidden while there are none). */\n help?: boolean;\n /** The Updates tab with your published changelog (default true; hidden while there are none). */\n updates?: boolean;\n /** A short sound when an answer arrives (default true). */\n sound?: boolean;\n /** A preview of a new answer above the closed launcher (default true). */\n preview?: boolean;\n theme?: Theme;\n accent?: string;\n /** \"round\" (default), \"soft\" or \"square\". */\n corners?: MessengerCorners;\n /** Your site's font (default) or \"system\". */\n font?: \"site\" | \"system\";\n /** Home's top: \"plain\" (default) or \"color\" (the accent). */\n header?: \"plain\" | \"color\";\n}\n\n/**\n * A floating launcher that opens the messenger. Put it once inside `<CockpitProvider>`:\n *\n * <Messenger title=\"Acme\" greeting=\"Hi! How can we help?\" />\n */\nexport const Messenger = ({ position, title, greeting, askEmail, label, launcher, help, updates, sound, preview, theme, accent, corners, font, header }: MessengerProps) => {\n const ctx = useCtx();\n // The panel reads the visitor at each request, so a later identify or reset needs no remount.\n const who = useRef({ distinctId: ctx.distinctId, user: ctx.user, userHash: ctx.userHash });\n who.current = { distinctId: ctx.distinctId, user: ctx.user, userHash: ctx.userHash };\n const { apiKey, host, embedded } = ctx;\n // Whoever signs in after the page loaded gets their conversations now, not at the panel's next slow read.\n useEffect(() => handle?.refresh(), [ctx.distinctId, ctx.userHash]);\n\n useEffect(() => {\n if (embedded || !apiKey) return;\n let gone = false;\n let mine: MessengerHandle | null = null;\n void import(\"./messenger-ui\").then(({ mountMessenger }) => {\n if (gone) return;\n mine = mountMessenger({\n host,\n apiKey,\n distinctId: () => who.current.distinctId,\n user: () => who.current.user as { id?: string; name?: string; email?: string } | undefined,\n userHash: () => who.current.userHash,\n launcher,\n position,\n title,\n greeting,\n askEmail,\n label,\n help,\n updates,\n sound,\n preview,\n theme,\n accent,\n corners,\n font,\n header,\n });\n handle = mine;\n waiting?.(mine);\n waiting = null;\n });\n const click = (e: MouseEvent) => {\n if ((e.target as HTMLElement | null)?.closest(\"[data-ck-messenger]\")) {\n e.preventDefault();\n withHandle((h) => h.open());\n }\n };\n document.addEventListener(\"click\", click);\n return () => {\n gone = true;\n document.removeEventListener(\"click\", click);\n mine?.destroy();\n if (handle === mine) handle = null;\n };\n }, [apiKey, host, embedded, launcher, position, title, greeting, askEmail, label, help, updates, sound, preview, theme, accent, corners, font, header]);\n\n return null;\n};\n"],"mappings":";;;AAEA,SAAS,WAAW,cAAc;AAElC,SAAS,cAAc;AAcvB,IAAI,SAAiC;AAErC,IAAI,UAAiD;AACrD,IAAM,aAAa,CAAC,OAAqC;AACrD,MAAI,OAAQ,IAAG,MAAM;AAAA,MAChB,WAAU;AACnB;AAGO,IAAM,eAAe,OAAO;AAAA,EAC/B,MAAM,CAAC,SAA+C,WAAW,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC;AAAA,EACpF,OAAO,MAAM,QAAQ,MAAM;AAAA,EAC3B,QAAQ,MAAM,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC;AAC9C;AAsCO,IAAM,YAAY,CAAC,EAAE,UAAU,OAAO,UAAU,UAAU,OAAO,UAAU,MAAM,SAAS,OAAO,SAAS,OAAO,QAAQ,SAAS,MAAM,OAAO,MAAsB;AACxK,QAAM,MAAM,OAAO;AAEnB,QAAM,MAAM,OAAO,EAAE,YAAY,IAAI,YAAY,MAAM,IAAI,MAAM,UAAU,IAAI,SAAS,CAAC;AACzF,MAAI,UAAU,EAAE,YAAY,IAAI,YAAY,MAAM,IAAI,MAAM,UAAU,IAAI,SAAS;AACnF,QAAM,EAAE,QAAQ,MAAM,SAAS,IAAI;AAEnC,YAAU,MAAM,QAAQ,QAAQ,GAAG,CAAC,IAAI,YAAY,IAAI,QAAQ,CAAC;AAEjE,YAAU,MAAM;AACZ,QAAI,YAAY,CAAC,OAAQ;AACzB,QAAI,OAAO;AACX,QAAI,OAA+B;AACnC,SAAK,OAAO,mBAAgB,EAAE,KAAK,CAAC,EAAE,eAAe,MAAM;AACvD,UAAI,KAAM;AACV,aAAO,eAAe;AAAA,QAClB;AAAA,QACA;AAAA,QACA,YAAY,MAAM,IAAI,QAAQ;AAAA,QAC9B,MAAM,MAAM,IAAI,QAAQ;AAAA,QACxB,UAAU,MAAM,IAAI,QAAQ;AAAA,QAC5B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACJ,CAAC;AACD,eAAS;AACT,gBAAU,IAAI;AACd,gBAAU;AAAA,IACd,CAAC;AACD,UAAM,QAAQ,CAAC,MAAkB;AAC7B,UAAK,EAAE,QAA+B,QAAQ,qBAAqB,GAAG;AAClE,UAAE,eAAe;AACjB,mBAAW,CAAC,MAAM,EAAE,KAAK,CAAC;AAAA,MAC9B;AAAA,IACJ;AACA,aAAS,iBAAiB,SAAS,KAAK;AACxC,WAAO,MAAM;AACT,aAAO;AACP,eAAS,oBAAoB,SAAS,KAAK;AAC3C,YAAM,QAAQ;AACd,UAAI,WAAW,KAAM,UAAS;AAAA,IAClC;AAAA,EACJ,GAAG,CAAC,QAAQ,MAAM,UAAU,UAAU,UAAU,OAAO,UAAU,UAAU,OAAO,MAAM,SAAS,OAAO,SAAS,OAAO,QAAQ,SAAS,MAAM,MAAM,CAAC;AAEtJ,SAAO;AACX;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type OnboardingReportType = "questions" | "checklist" | "tour";
|
|
2
|
+
export interface OnboardingReportOptions {
|
|
3
|
+
/** Every step's id in the order people meet them, so a step only some people see keeps its place. */
|
|
4
|
+
order?: string[];
|
|
5
|
+
/** "questions" (the default), a "checklist" or a "tour". */
|
|
6
|
+
type?: OnboardingReportType;
|
|
7
|
+
}
|
|
8
|
+
export interface OnboardingReport {
|
|
9
|
+
/** The person sees this step; `title` is its name in MRRocket. Sent once per step and page. */
|
|
10
|
+
saw(step: string, title: string): void;
|
|
11
|
+
/** The person answered a question with one of its options: its id, and its words in MRRocket. */
|
|
12
|
+
answered(question: string, answer: string, label?: string): void;
|
|
13
|
+
/** The person did this task or tour step. */
|
|
14
|
+
done(step: string): void;
|
|
15
|
+
/** The person closed it or skipped the rest, at this step if you name one. */
|
|
16
|
+
closed(step?: string): void;
|
|
17
|
+
}
|
|
18
|
+
/** The report behind `useOnboardingReport` and the script tag's `onboarding.report`, over the SDK's `track`. */
|
|
19
|
+
export declare const createOnboardingReport: (track: (event: string, props?: Record<string, unknown>) => void, name: string, options?: OnboardingReportOptions) => OnboardingReport;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/onboarding-report.ts
|
|
2
|
+
import { ONBOARDING_EVENT, eventSlug } from "./flows.js";
|
|
3
|
+
var KIND = { questions: "question", checklist: "checklist", tour: "tour" };
|
|
4
|
+
var createOnboardingReport = (track, name, options = {}) => {
|
|
5
|
+
const type = options.type ?? "questions";
|
|
6
|
+
const kind = KIND[type] ?? "question";
|
|
7
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8
|
+
const send = (props) => track(ONBOARDING_EVENT, { code: eventSlug(name), name, type, ...options.order?.length ? { order: options.order } : {}, ...props });
|
|
9
|
+
return {
|
|
10
|
+
saw: (step, title) => {
|
|
11
|
+
if (seen.has(step)) return;
|
|
12
|
+
seen.add(step);
|
|
13
|
+
send({ step, title, kind, action: "shown" });
|
|
14
|
+
},
|
|
15
|
+
answered: (question, answer, label) => send({ step: question, kind: "question", action: "completed", question, answer, label: label ?? answer }),
|
|
16
|
+
done: (step) => send({ step, kind, action: "completed" }),
|
|
17
|
+
closed: (step) => send({ ...step ? { step } : {}, kind, action: "dismissed" })
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
createOnboardingReport
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=onboarding-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/onboarding-report.ts"],"sourcesContent":["/**\n * 0.22.0: an onboarding the app keeps in its own code. There is nothing to set up in MRRocket: the app reports its\n * steps by name, and the first report makes the item (Win customers › Onboarding, \"From your code\"). MRRocket then shows\n * who saw each step, who did it and what they answered, and keeps the answers on the contact. It never draws such an\n * item and has no say in when it shows; that stays in the app.\n *\n * const report = useOnboardingReport(\"Welcome questions\", { order: [\"goal\", \"role\", \"source\"] });\n * report.saw(\"goal\", \"What brings you here?\");\n * report.answered(\"goal\", \"dream\", \"Dream game\");\n * report.closed(\"goal\"); // the person skipped the rest\n *\n * Everything goes through `track`, so it follows the visitor's consent like any other event. Report the words in one\n * language, whatever the visitor reads: the ids count the people, the words only name them in MRRocket.\n */\nimport { ONBOARDING_EVENT, eventSlug } from \"./flows\";\n\nexport type OnboardingReportType = \"questions\" | \"checklist\" | \"tour\";\n\nexport interface OnboardingReportOptions {\n /** Every step's id in the order people meet them, so a step only some people see keeps its place. */\n order?: string[];\n /** \"questions\" (the default), a \"checklist\" or a \"tour\". */\n type?: OnboardingReportType;\n}\n\nexport interface OnboardingReport {\n /** The person sees this step; `title` is its name in MRRocket. Sent once per step and page. */\n saw(step: string, title: string): void;\n /** The person answered a question with one of its options: its id, and its words in MRRocket. */\n answered(question: string, answer: string, label?: string): void;\n /** The person did this task or tour step. */\n done(step: string): void;\n /** The person closed it or skipped the rest, at this step if you name one. */\n closed(step?: string): void;\n}\n\nconst KIND = { questions: \"question\", checklist: \"checklist\", tour: \"tour\" } as const;\n\n/** The report behind `useOnboardingReport` and the script tag's `onboarding.report`, over the SDK's `track`. */\nexport const createOnboardingReport = (track: (event: string, props?: Record<string, unknown>) => void, name: string, options: OnboardingReportOptions = {}): OnboardingReport => {\n const type = options.type ?? \"questions\";\n const kind = KIND[type] ?? \"question\";\n const seen = new Set<string>();\n const send = (props: Record<string, unknown>) =>\n track(ONBOARDING_EVENT, { code: eventSlug(name), name, type, ...(options.order?.length ? { order: options.order } : {}), ...props });\n return {\n saw: (step, title) => {\n if (seen.has(step)) return;\n seen.add(step);\n send({ step, title, kind, action: \"shown\" });\n },\n answered: (question, answer, label) => send({ step: question, kind: \"question\", action: \"completed\", question, answer, label: label ?? answer }),\n done: (step) => send({ step, kind, action: \"completed\" }),\n closed: (step) => send({ ...(step ? { step } : {}), kind, action: \"dismissed\" }),\n };\n};\n"],"mappings":";AAcA,SAAS,kBAAkB,iBAAiB;AAsB5C,IAAM,OAAO,EAAE,WAAW,YAAY,WAAW,aAAa,MAAM,OAAO;AAGpE,IAAM,yBAAyB,CAAC,OAAiE,MAAc,UAAmC,CAAC,MAAwB;AAC9K,QAAM,OAAO,QAAQ,QAAQ;AAC7B,QAAM,OAAO,KAAK,IAAI,KAAK;AAC3B,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,OAAO,CAAC,UACV,MAAM,kBAAkB,EAAE,MAAM,UAAU,IAAI,GAAG,MAAM,MAAM,GAAI,QAAQ,OAAO,SAAS,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC,GAAI,GAAG,MAAM,CAAC;AACvI,SAAO;AAAA,IACH,KAAK,CAAC,MAAM,UAAU;AAClB,UAAI,KAAK,IAAI,IAAI,EAAG;AACpB,WAAK,IAAI,IAAI;AACb,WAAK,EAAE,MAAM,OAAO,MAAM,QAAQ,QAAQ,CAAC;AAAA,IAC/C;AAAA,IACA,UAAU,CAAC,UAAU,QAAQ,UAAU,KAAK,EAAE,MAAM,UAAU,MAAM,YAAY,QAAQ,aAAa,UAAU,QAAQ,OAAO,SAAS,OAAO,CAAC;AAAA,IAC/I,MAAM,CAAC,SAAS,KAAK,EAAE,MAAM,MAAM,QAAQ,YAAY,CAAC;AAAA,IACxD,QAAQ,CAAC,SAAS,KAAK,EAAE,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC,GAAI,MAAM,QAAQ,YAAY,CAAC;AAAA,EACnF;AACJ;","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FlowsController, OnboardingFlow, OnboardingItemState } from "./flows.js";
|
|
2
|
+
import { type OnboardingReport, type OnboardingReportOptions } from "./onboarding-report.js";
|
|
2
3
|
export interface UseOnboarding {
|
|
3
4
|
/** The item as MRRocket published it, or null while the config is loading, or when it is not live. */
|
|
4
5
|
item: OnboardingFlow | null;
|
|
@@ -21,3 +22,5 @@ export interface UseOnboarding {
|
|
|
21
22
|
}
|
|
22
23
|
/** The hook behind `useOnboarding` on both platforms. */
|
|
23
24
|
export declare const useOnboardingItem: (flows: FlowsController | null | undefined, id: string | undefined, start: (id?: string) => boolean) => UseOnboarding;
|
|
25
|
+
/** 0.22.0: the hook behind `useOnboardingReport` on both platforms: one report per name and options. */
|
|
26
|
+
export declare const useReportWith: (track: (event: string, props?: Record<string, unknown>) => void, name: string, options?: OnboardingReportOptions) => OnboardingReport;
|
package/dist/onboarding-state.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/onboarding-state.ts
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { createOnboardingReport } from "./onboarding-report.js";
|
|
3
4
|
var none = [];
|
|
4
5
|
var useOnboardingItem = (flows, id, start) => {
|
|
5
6
|
const [state, setState] = useState(() => flows && id ? flows.onboarding.item(id) : null);
|
|
@@ -37,7 +38,12 @@ var useOnboardingItem = (flows, id, start) => {
|
|
|
37
38
|
[state, flows, id, start]
|
|
38
39
|
);
|
|
39
40
|
};
|
|
41
|
+
var useReportWith = (track, name, options) => {
|
|
42
|
+
const key = JSON.stringify(options ?? null);
|
|
43
|
+
return useMemo(() => createOnboardingReport(track, name, options), [track, name, key]);
|
|
44
|
+
};
|
|
40
45
|
export {
|
|
41
|
-
useOnboardingItem
|
|
46
|
+
useOnboardingItem,
|
|
47
|
+
useReportWith
|
|
42
48
|
};
|
|
43
49
|
//# sourceMappingURL=onboarding-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/onboarding-state.ts"],"sourcesContent":["/**\n * 0.18.0: `useOnboarding(id)` for an onboarding item the app draws itself (\"Shown by: your code\" in MRRocket): its\n * content and the person's progress, and the calls that report what they did. Shared by the Next.js provider and React\n * Native (only React here). The SDK draws nothing for such an item and never starts it; what the app reports still\n * reaches MRRocket (who saw it, who finished it, the answers on the contact), and the item after it follows as usual.\n *\n * const { item, steps, done, complete, dismiss, answer } = useOnboarding(\"flow_123\");\n * if (!item || done) return null;\n * return steps.map((s) => <Task key={s.id} title={s.title} done={s.done} onPress={() => complete(s.id)} />);\n */\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { FlowsController, OnboardingFlow, OnboardingItemState } from \"./flows\";\n\nexport interface UseOnboarding {\n /** The item as MRRocket published it, or null while the config is loading, or when it is not live. */\n item: OnboardingFlow | null;\n /** Its steps (a tour's steps, a checklist's tasks, the questions), each with `done` (and a question's `answer`). */\n steps: OnboardingItemState[\"steps\"];\n /** Every step is done. */\n done: boolean;\n /** The person closed it. */\n dismissed: boolean;\n /** Its moment has come for this person (the trigger MRRocket set, and who it is for). */\n eligible: boolean;\n /** Marks a step done (a tour step, a task). */\n complete(stepId: string): void;\n /** The person closed it; the item after it follows. */\n dismiss(): void;\n /** Answers a question (its step id or its key) with an option's id or a text; it is kept on the contact. */\n answer(question: string, value: string): void;\n /** Starts an item the SDK draws (the first live one without an id). */\n start(id?: string): boolean;\n}\n\nconst none: OnboardingItemState[\"steps\"] = [];\n\n/** The hook behind `useOnboarding` on both platforms. */\nexport const useOnboardingItem = (flows: FlowsController | null | undefined, id: string | undefined, start: (id?: string) => boolean): UseOnboarding => {\n const [state, setState] = useState<OnboardingItemState | null>(() => (flows && id ? flows.onboarding.item(id) : null));\n useEffect(() => {\n if (!flows || !id) {\n setState(null);\n return;\n }\n const up = () => {\n const s = flows.onboarding.item(id);\n setState(s);\n // Asked for by the app: counted as seen (started, and its first open steps), once per page.\n if (s && !s.done && !s.dismissed) flows.onboarding.seen(id);\n };\n up();\n return flows.subscribe(up);\n }, [flows, id]);\n return useMemo(\n () => ({\n item: state?.item ?? null,\n steps: state?.steps ?? none,\n done: !!state?.done,\n dismissed: !!state?.dismissed,\n eligible: !!state?.eligible,\n complete: (stepId: string) => {\n if (flows && id) flows.onboarding.complete(id, stepId);\n },\n dismiss: () => {\n if (flows && id) flows.onboarding.dismissItem(id);\n },\n answer: (question: string, value: string) => {\n if (flows && id) flows.onboarding.answerItem(id, question, value);\n },\n start,\n }),\n [state, flows, id, start],\n );\n};\n"],"mappings":";AAUA,SAAS,WAAW,SAAS,gBAAgB;
|
|
1
|
+
{"version":3,"sources":["../src/onboarding-state.ts"],"sourcesContent":["/**\n * 0.18.0: `useOnboarding(id)` for an onboarding item the app draws itself (\"Shown by: your code\" in MRRocket): its\n * content and the person's progress, and the calls that report what they did. Shared by the Next.js provider and React\n * Native (only React here). The SDK draws nothing for such an item and never starts it; what the app reports still\n * reaches MRRocket (who saw it, who finished it, the answers on the contact), and the item after it follows as usual.\n *\n * const { item, steps, done, complete, dismiss, answer } = useOnboarding(\"flow_123\");\n * if (!item || done) return null;\n * return steps.map((s) => <Task key={s.id} title={s.title} done={s.done} onPress={() => complete(s.id)} />);\n */\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { FlowsController, OnboardingFlow, OnboardingItemState } from \"./flows\";\nimport { type OnboardingReport, type OnboardingReportOptions, createOnboardingReport } from \"./onboarding-report\";\n\nexport interface UseOnboarding {\n /** The item as MRRocket published it, or null while the config is loading, or when it is not live. */\n item: OnboardingFlow | null;\n /** Its steps (a tour's steps, a checklist's tasks, the questions), each with `done` (and a question's `answer`). */\n steps: OnboardingItemState[\"steps\"];\n /** Every step is done. */\n done: boolean;\n /** The person closed it. */\n dismissed: boolean;\n /** Its moment has come for this person (the trigger MRRocket set, and who it is for). */\n eligible: boolean;\n /** Marks a step done (a tour step, a task). */\n complete(stepId: string): void;\n /** The person closed it; the item after it follows. */\n dismiss(): void;\n /** Answers a question (its step id or its key) with an option's id or a text; it is kept on the contact. */\n answer(question: string, value: string): void;\n /** Starts an item the SDK draws (the first live one without an id). */\n start(id?: string): boolean;\n}\n\nconst none: OnboardingItemState[\"steps\"] = [];\n\n/** The hook behind `useOnboarding` on both platforms. */\nexport const useOnboardingItem = (flows: FlowsController | null | undefined, id: string | undefined, start: (id?: string) => boolean): UseOnboarding => {\n const [state, setState] = useState<OnboardingItemState | null>(() => (flows && id ? flows.onboarding.item(id) : null));\n useEffect(() => {\n if (!flows || !id) {\n setState(null);\n return;\n }\n const up = () => {\n const s = flows.onboarding.item(id);\n setState(s);\n // Asked for by the app: counted as seen (started, and its first open steps), once per page.\n if (s && !s.done && !s.dismissed) flows.onboarding.seen(id);\n };\n up();\n return flows.subscribe(up);\n }, [flows, id]);\n return useMemo(\n () => ({\n item: state?.item ?? null,\n steps: state?.steps ?? none,\n done: !!state?.done,\n dismissed: !!state?.dismissed,\n eligible: !!state?.eligible,\n complete: (stepId: string) => {\n if (flows && id) flows.onboarding.complete(id, stepId);\n },\n dismiss: () => {\n if (flows && id) flows.onboarding.dismissItem(id);\n },\n answer: (question: string, value: string) => {\n if (flows && id) flows.onboarding.answerItem(id, question, value);\n },\n start,\n }),\n [state, flows, id, start],\n );\n};\n\n/** 0.22.0: the hook behind `useOnboardingReport` on both platforms: one report per name and options. */\nexport const useReportWith = (track: (event: string, props?: Record<string, unknown>) => void, name: string, options?: OnboardingReportOptions): OnboardingReport => {\n const key = JSON.stringify(options ?? null);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => createOnboardingReport(track, name, options), [track, name, key]);\n};\n"],"mappings":";AAUA,SAAS,WAAW,SAAS,gBAAgB;AAE7C,SAA8D,8BAA8B;AAuB5F,IAAM,OAAqC,CAAC;AAGrC,IAAM,oBAAoB,CAAC,OAA2C,IAAwB,UAAmD;AACpJ,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAqC,MAAO,SAAS,KAAK,MAAM,WAAW,KAAK,EAAE,IAAI,IAAK;AACrH,YAAU,MAAM;AACZ,QAAI,CAAC,SAAS,CAAC,IAAI;AACf,eAAS,IAAI;AACb;AAAA,IACJ;AACA,UAAM,KAAK,MAAM;AACb,YAAM,IAAI,MAAM,WAAW,KAAK,EAAE;AAClC,eAAS,CAAC;AAEV,UAAI,KAAK,CAAC,EAAE,QAAQ,CAAC,EAAE,UAAW,OAAM,WAAW,KAAK,EAAE;AAAA,IAC9D;AACA,OAAG;AACH,WAAO,MAAM,UAAU,EAAE;AAAA,EAC7B,GAAG,CAAC,OAAO,EAAE,CAAC;AACd,SAAO;AAAA,IACH,OAAO;AAAA,MACH,MAAM,OAAO,QAAQ;AAAA,MACrB,OAAO,OAAO,SAAS;AAAA,MACvB,MAAM,CAAC,CAAC,OAAO;AAAA,MACf,WAAW,CAAC,CAAC,OAAO;AAAA,MACpB,UAAU,CAAC,CAAC,OAAO;AAAA,MACnB,UAAU,CAAC,WAAmB;AAC1B,YAAI,SAAS,GAAI,OAAM,WAAW,SAAS,IAAI,MAAM;AAAA,MACzD;AAAA,MACA,SAAS,MAAM;AACX,YAAI,SAAS,GAAI,OAAM,WAAW,YAAY,EAAE;AAAA,MACpD;AAAA,MACA,QAAQ,CAAC,UAAkB,UAAkB;AACzC,YAAI,SAAS,GAAI,OAAM,WAAW,WAAW,IAAI,UAAU,KAAK;AAAA,MACpE;AAAA,MACA;AAAA,IACJ;AAAA,IACA,CAAC,OAAO,OAAO,IAAI,KAAK;AAAA,EAC5B;AACJ;AAGO,IAAM,gBAAgB,CAAC,OAAiE,MAAc,YAAwD;AACjK,QAAM,MAAM,KAAK,UAAU,WAAW,IAAI;AAE1C,SAAO,QAAQ,MAAM,uBAAuB,OAAO,MAAM,OAAO,GAAG,CAAC,OAAO,MAAM,GAAG,CAAC;AACzF;","names":[]}
|
|
@@ -261,7 +261,10 @@ declare const createApi: (c: Conn) => {
|
|
|
261
261
|
completed: boolean;
|
|
262
262
|
seconds: number;
|
|
263
263
|
}) => Promise<unknown>;
|
|
264
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* One chat by id, else the visitor's newest; `conversations` lists them all. `aiLabel`: the messenger says "AI agent"
|
|
266
|
+
* beside an answer's name, so the answer comes without its AI notice line (from 0.22.0).
|
|
267
|
+
*/
|
|
265
268
|
chat: (signal?: AbortSignal, conversation?: string) => Promise<ChatThread>;
|
|
266
269
|
/**
|
|
267
270
|
* A message; `attachments` are upload ids from `uploadChatFile` (then the body may be empty). `conversation` is
|
|
@@ -826,7 +829,7 @@ interface PaywallHost {
|
|
|
826
829
|
|
|
827
830
|
type VariantId = string;
|
|
828
831
|
/** This build of the SDK. Sent with the config request so MRRocket knows what the site runs (error tracking, flags). */
|
|
829
|
-
declare const SDK_VERSION = "0.
|
|
832
|
+
declare const SDK_VERSION = "0.23.0";
|
|
830
833
|
/** One variant of an experiment. `changes` replaces texts that the page marks with `<Text id>`. */
|
|
831
834
|
interface VariantConfig {
|
|
832
835
|
id: VariantId;
|
|
@@ -1190,6 +1193,24 @@ interface MRRocketClient {
|
|
|
1190
1193
|
/** The name of the screen a React Navigation state shows: the focused route, followed into nested navigators. */
|
|
1191
1194
|
declare const activeRouteName: (state: unknown) => string | undefined;
|
|
1192
1195
|
|
|
1196
|
+
type OnboardingReportType = "questions" | "checklist" | "tour";
|
|
1197
|
+
interface OnboardingReportOptions {
|
|
1198
|
+
/** Every step's id in the order people meet them, so a step only some people see keeps its place. */
|
|
1199
|
+
order?: string[];
|
|
1200
|
+
/** "questions" (the default), a "checklist" or a "tour". */
|
|
1201
|
+
type?: OnboardingReportType;
|
|
1202
|
+
}
|
|
1203
|
+
interface OnboardingReport {
|
|
1204
|
+
/** The person sees this step; `title` is its name in MRRocket. Sent once per step and page. */
|
|
1205
|
+
saw(step: string, title: string): void;
|
|
1206
|
+
/** The person answered a question with one of its options: its id, and its words in MRRocket. */
|
|
1207
|
+
answered(question: string, answer: string, label?: string): void;
|
|
1208
|
+
/** The person did this task or tour step. */
|
|
1209
|
+
done(step: string): void;
|
|
1210
|
+
/** The person closed it or skipped the rest, at this step if you name one. */
|
|
1211
|
+
closed(step?: string): void;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1193
1214
|
interface UseOnboarding {
|
|
1194
1215
|
/** The item as MRRocket published it, or null while the config is loading, or when it is not live. */
|
|
1195
1216
|
item: OnboardingFlow | null;
|
|
@@ -1433,6 +1454,15 @@ declare const useReview: () => {
|
|
|
1433
1454
|
* if (!item || done) return null;
|
|
1434
1455
|
*/
|
|
1435
1456
|
declare const useOnboarding: (id?: string) => UseOnboarding;
|
|
1457
|
+
/**
|
|
1458
|
+
* 0.22.0: for an onboarding that lives in your own code. Nothing to set up in MRRocket: the first report makes the item
|
|
1459
|
+
* under Onboarding, and MRRocket shows who saw each step and what they answered. It follows the person's consent.
|
|
1460
|
+
*
|
|
1461
|
+
* const report = useOnboardingReport("Welcome questions", { order: ["goal", "role"] });
|
|
1462
|
+
* report.saw("goal", "What brings you here?");
|
|
1463
|
+
* report.answered("goal", "dream", "Dream game");
|
|
1464
|
+
*/
|
|
1465
|
+
declare const useOnboardingReport: (name: string, options?: OnboardingReportOptions) => OnboardingReport;
|
|
1436
1466
|
/** A feature flag from MRRocket › Build › Feature flags: true while it is on for this person; false while off, unknown or loading. */
|
|
1437
1467
|
declare const useFlag: (key: string) => boolean;
|
|
1438
1468
|
/** The variant of a multivariate flag ("control", "test" …), or null while it is off. */
|
|
@@ -1467,4 +1497,4 @@ declare const useExpoRouterTracking: () => void;
|
|
|
1467
1497
|
*/
|
|
1468
1498
|
declare const useNavigationTracking: () => (state: unknown) => void;
|
|
1469
1499
|
|
|
1470
|
-
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, currentLocale, getMRRocket, setLocale, useCancelFlow, useExpoRouterTracking, useFeedback, useFlag, useFlagVariant, useMRRocket, useMessenger, useNavigationTracking, useOnboarding, usePaywall, usePush, useReview, useText, useVariant };
|
|
1500
|
+
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 };
|
|
@@ -261,7 +261,10 @@ declare const createApi: (c: Conn) => {
|
|
|
261
261
|
completed: boolean;
|
|
262
262
|
seconds: number;
|
|
263
263
|
}) => Promise<unknown>;
|
|
264
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* One chat by id, else the visitor's newest; `conversations` lists them all. `aiLabel`: the messenger says "AI agent"
|
|
266
|
+
* beside an answer's name, so the answer comes without its AI notice line (from 0.22.0).
|
|
267
|
+
*/
|
|
265
268
|
chat: (signal?: AbortSignal, conversation?: string) => Promise<ChatThread>;
|
|
266
269
|
/**
|
|
267
270
|
* A message; `attachments` are upload ids from `uploadChatFile` (then the body may be empty). `conversation` is
|
|
@@ -826,7 +829,7 @@ interface PaywallHost {
|
|
|
826
829
|
|
|
827
830
|
type VariantId = string;
|
|
828
831
|
/** This build of the SDK. Sent with the config request so MRRocket knows what the site runs (error tracking, flags). */
|
|
829
|
-
declare const SDK_VERSION = "0.
|
|
832
|
+
declare const SDK_VERSION = "0.23.0";
|
|
830
833
|
/** One variant of an experiment. `changes` replaces texts that the page marks with `<Text id>`. */
|
|
831
834
|
interface VariantConfig {
|
|
832
835
|
id: VariantId;
|
|
@@ -1190,6 +1193,24 @@ interface MRRocketClient {
|
|
|
1190
1193
|
/** The name of the screen a React Navigation state shows: the focused route, followed into nested navigators. */
|
|
1191
1194
|
declare const activeRouteName: (state: unknown) => string | undefined;
|
|
1192
1195
|
|
|
1196
|
+
type OnboardingReportType = "questions" | "checklist" | "tour";
|
|
1197
|
+
interface OnboardingReportOptions {
|
|
1198
|
+
/** Every step's id in the order people meet them, so a step only some people see keeps its place. */
|
|
1199
|
+
order?: string[];
|
|
1200
|
+
/** "questions" (the default), a "checklist" or a "tour". */
|
|
1201
|
+
type?: OnboardingReportType;
|
|
1202
|
+
}
|
|
1203
|
+
interface OnboardingReport {
|
|
1204
|
+
/** The person sees this step; `title` is its name in MRRocket. Sent once per step and page. */
|
|
1205
|
+
saw(step: string, title: string): void;
|
|
1206
|
+
/** The person answered a question with one of its options: its id, and its words in MRRocket. */
|
|
1207
|
+
answered(question: string, answer: string, label?: string): void;
|
|
1208
|
+
/** The person did this task or tour step. */
|
|
1209
|
+
done(step: string): void;
|
|
1210
|
+
/** The person closed it or skipped the rest, at this step if you name one. */
|
|
1211
|
+
closed(step?: string): void;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1193
1214
|
interface UseOnboarding {
|
|
1194
1215
|
/** The item as MRRocket published it, or null while the config is loading, or when it is not live. */
|
|
1195
1216
|
item: OnboardingFlow | null;
|
|
@@ -1433,6 +1454,15 @@ declare const useReview: () => {
|
|
|
1433
1454
|
* if (!item || done) return null;
|
|
1434
1455
|
*/
|
|
1435
1456
|
declare const useOnboarding: (id?: string) => UseOnboarding;
|
|
1457
|
+
/**
|
|
1458
|
+
* 0.22.0: for an onboarding that lives in your own code. Nothing to set up in MRRocket: the first report makes the item
|
|
1459
|
+
* under Onboarding, and MRRocket shows who saw each step and what they answered. It follows the person's consent.
|
|
1460
|
+
*
|
|
1461
|
+
* const report = useOnboardingReport("Welcome questions", { order: ["goal", "role"] });
|
|
1462
|
+
* report.saw("goal", "What brings you here?");
|
|
1463
|
+
* report.answered("goal", "dream", "Dream game");
|
|
1464
|
+
*/
|
|
1465
|
+
declare const useOnboardingReport: (name: string, options?: OnboardingReportOptions) => OnboardingReport;
|
|
1436
1466
|
/** A feature flag from MRRocket › Build › Feature flags: true while it is on for this person; false while off, unknown or loading. */
|
|
1437
1467
|
declare const useFlag: (key: string) => boolean;
|
|
1438
1468
|
/** The variant of a multivariate flag ("control", "test" …), or null while it is off. */
|
|
@@ -1467,4 +1497,4 @@ declare const useExpoRouterTracking: () => void;
|
|
|
1467
1497
|
*/
|
|
1468
1498
|
declare const useNavigationTracking: () => (state: unknown) => void;
|
|
1469
1499
|
|
|
1470
|
-
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, currentLocale, getMRRocket, setLocale, useCancelFlow, useExpoRouterTracking, useFeedback, useFlag, useFlagVariant, useMRRocket, useMessenger, useNavigationTracking, useOnboarding, usePaywall, usePush, useReview, useText, useVariant };
|
|
1500
|
+
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 };
|