@mx-cartographer/experiences 9.7.71-alpha-ram-usp-2 → 9.7.72
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 +2 -5
- package/dist/core/stores/GlobalCopyStore.d.ts +0 -6
- package/dist/core/stores/GlobalCopyStore.es.js +8 -14
- package/dist/core/stores/GlobalCopyStore.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +0 -24
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +11 -11
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +3 -3
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +59 -92
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.d.ts +1 -9
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js +5 -9
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +5 -5
- package/dist/insights-v2/components/BaseLayout.es.js +146 -160
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/components/CtaStatus.d.ts +1 -14
- package/dist/insights-v2/components/CtaStatus.es.js +38 -76
- package/dist/insights-v2/components/CtaStatus.es.js.map +1 -1
- package/dist/insights-v2/components/InsightTransactionRow.d.ts +1 -3
- package/dist/insights-v2/components/InsightTransactionRow.es.js +20 -36
- package/dist/insights-v2/components/InsightTransactionRow.es.js.map +1 -1
- package/dist/insights-v2/components/TransactionListCard.d.ts +1 -5
- package/dist/insights-v2/components/TransactionListCard.es.js +49 -69
- package/dist/insights-v2/components/TransactionListCard.es.js.map +1 -1
- package/dist/insights-v2/components/WithdrawalCard.es.js +8 -10
- package/dist/insights-v2/components/WithdrawalCard.es.js.map +1 -1
- package/dist/insights-v2/components/shared/StatusSnackbar.d.ts +1 -10
- package/dist/insights-v2/components/shared/StatusSnackbar.es.js +11 -27
- package/dist/insights-v2/components/shared/StatusSnackbar.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/ctaConfig.es.js +9 -23
- package/dist/insights-v2/ctaActions/ctaConfig.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/runCtaAction.d.ts +0 -7
- package/dist/insights-v2/ctaActions/runCtaAction.es.js +62 -73
- package/dist/insights-v2/ctaActions/runCtaAction.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/subscriptionAnswer.d.ts +1 -10
- package/dist/insights-v2/ctaActions/types.d.ts +2 -5
- package/dist/insights-v2/ctaActions/useCtaAction.d.ts +0 -6
- package/dist/insights-v2/ctaActions/useCtaAction.es.js +27 -32
- package/dist/insights-v2/ctaActions/useCtaAction.es.js.map +1 -1
- package/dist/insights-v2/mappings/actionBlocksKey.d.ts +0 -1
- package/dist/insights-v2/mappings/actionBlocksKey.es.js +0 -1
- package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +68 -74
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/microinsights/MicroCardTemplate.es.js +17 -21
- package/dist/microinsights/MicroCardTemplate.es.js.map +1 -1
- package/dist/microinsights/cards/InsightCard.es.js +86 -91
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/dist/microinsights/stores/CopyStore.d.ts +1 -4
- package/dist/microinsights/stores/CopyStore.es.js +10 -13
- package/dist/microinsights/stores/CopyStore.es.js.map +1 -1
- package/package.json +1 -1
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.d.ts +0 -6
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +0 -168
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js.map +0 -1
- package/dist/insights-v2/components/SubscriptionStatus/subscriptionFrequency.d.ts +0 -4
- package/dist/insights-v2/components/SubscriptionStatus/subscriptionFrequency.es.js +0 -10
- package/dist/insights-v2/components/SubscriptionStatus/subscriptionFrequency.es.js.map +0 -1
- package/dist/insights-v2/components/shared/elevation.d.ts +0 -16
- package/dist/insights-v2/components/shared/elevation.es.js +0 -15
- package/dist/insights-v2/components/shared/elevation.es.js.map +0 -1
- package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js +0 -115
- package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js.map +0 -1
- package/dist/microinsights/cards/MicroCtaStatus.d.ts +0 -18
- package/dist/microinsights/cards/MicroCtaStatus.es.js +0 -44
- package/dist/microinsights/cards/MicroCtaStatus.es.js.map +0 -1
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How the snackbar is drawn. `standard` (default): the mxui Toast as is (the tone's `main` fill).
|
|
3
|
-
* `strong`: Figma's `<Snackbar>` (`_components/snackbar/<tone>/background`): the tone's 600 step with
|
|
4
|
-
* white words in light and dark, `elevation/16`, a 24px message line and a 15/20 semibold action. A
|
|
5
|
-
* new design adds a variant here; a surface picks one with the `variant` prop.
|
|
6
|
-
*/
|
|
7
|
-
export type StatusSnackbarVariant = 'standard' | 'strong';
|
|
8
1
|
export interface StatusSnackbarProps {
|
|
9
2
|
open: boolean;
|
|
10
3
|
/** Snackbar tone — success (green, Figma 1941:167636) or error (red, Figma 1941:167637). */
|
|
11
4
|
severity?: 'success' | 'error';
|
|
12
|
-
/** Which snackbar design to draw; defaults to `standard`. */
|
|
13
|
-
variant?: StatusSnackbarVariant;
|
|
14
5
|
/** Status description, e.g. "Your feedback has been submitted.". */
|
|
15
6
|
message: string;
|
|
16
7
|
/** ARIA label for the close button. */
|
|
@@ -33,5 +24,5 @@ export interface StatusSnackbarProps {
|
|
|
33
24
|
* so every surface renders the same Figma variants instead of re-wiring
|
|
34
25
|
* Toast props.
|
|
35
26
|
*/
|
|
36
|
-
declare const StatusSnackbar: ({ actionText, autoHideDuration, closeAriaLabel, message, onActionClick, onClose, open, severity,
|
|
27
|
+
declare const StatusSnackbar: ({ actionText, autoHideDuration, closeAriaLabel, message, onActionClick, onClose, open, severity, }: StatusSnackbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
28
|
export default StatusSnackbar;
|
|
@@ -1,35 +1,19 @@
|
|
|
1
|
-
import { ELEVATION_SHADOW as c } from "./elevation.es.js";
|
|
2
1
|
import { Toast as u } from "@mxenabled/mxui";
|
|
3
|
-
import { jsx as
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
"& .MuiAlert-icon, & .MuiAlert-action .MuiIconButton-root": { color: "common.white" },
|
|
11
|
-
"& .MuiAlert-message p": { lineHeight: "24px" },
|
|
12
|
-
"& .MuiAlert-message .MuiButton-root": {
|
|
13
|
-
color: "common.white",
|
|
14
|
-
fontSize: 15,
|
|
15
|
-
fontWeight: 600,
|
|
16
|
-
lineHeight: "20px"
|
|
17
|
-
}
|
|
18
|
-
}), d = ({ actionText: o, autoHideDuration: t, closeAriaLabel: e, message: a, onActionClick: i, onClose: n, open: l, severity: r = "success", variant: s = "standard" }) => /* @__PURE__ */ m(u, {
|
|
19
|
-
actionText: o,
|
|
20
|
-
autoHideDuration: t,
|
|
21
|
-
closeAriaLabel: e,
|
|
22
|
-
handleClose: n,
|
|
2
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
3
|
+
var p = ({ actionText: s, autoHideDuration: o, closeAriaLabel: r, message: a, onActionClick: t, onClose: e, open: l, severity: m = "success" }) => /* @__PURE__ */ c(u, {
|
|
4
|
+
actionText: s,
|
|
5
|
+
autoHideDuration: o,
|
|
6
|
+
closeAriaLabel: r,
|
|
7
|
+
handleClose: e,
|
|
23
8
|
message: a,
|
|
24
|
-
onActionClick:
|
|
9
|
+
onActionClick: t,
|
|
25
10
|
open: l,
|
|
26
|
-
severity:
|
|
27
|
-
showAction: !!
|
|
28
|
-
showClose: !0
|
|
29
|
-
...s === "strong" && { snackbarSx: h(r) }
|
|
11
|
+
severity: m,
|
|
12
|
+
showAction: !!s,
|
|
13
|
+
showClose: !0
|
|
30
14
|
});
|
|
31
15
|
export {
|
|
32
|
-
|
|
16
|
+
p as default
|
|
33
17
|
};
|
|
34
18
|
|
|
35
19
|
//# sourceMappingURL=StatusSnackbar.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusSnackbar.es.js","names":[],"sources":["../../../../src/insights-v2/components/shared/StatusSnackbar.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"StatusSnackbar.es.js","names":[],"sources":["../../../../src/insights-v2/components/shared/StatusSnackbar.tsx"],"sourcesContent":["import { Toast } from '@mxenabled/mxui'\n\nexport interface StatusSnackbarProps {\n open: boolean\n /** Snackbar tone — success (green, Figma 1941:167636) or error (red, Figma 1941:167637). */\n severity?: 'success' | 'error'\n /** Status description, e.g. \"Your feedback has been submitted.\". */\n message: string\n /** ARIA label for the close button. */\n closeAriaLabel: string\n /** Fired on close / auto-hide. */\n onClose: () => void\n /**\n * Optional action button label (e.g. \"Try Again\"). The button renders only\n * when this is provided.\n */\n actionText?: string\n onActionClick?: () => void\n /** Auto-hide in ms; defaults to the mxui Toast default (3s). */\n autoHideDuration?: number\n}\n\n/**\n * Shared status snackbar for insights-v2 (Figma `<Snackbar>`): a filled\n * success/error toast with a message, a close button, and an optional action\n * (e.g. the feedback modal's Try Again). Thin wrapper over the mxui `Toast`\n * so every surface renders the same Figma variants instead of re-wiring\n * Toast props.\n */\nconst StatusSnackbar = ({\n actionText,\n autoHideDuration,\n closeAriaLabel,\n message,\n onActionClick,\n onClose,\n open,\n severity = 'success',\n}: StatusSnackbarProps) => (\n <Toast\n actionText={actionText}\n autoHideDuration={autoHideDuration}\n closeAriaLabel={closeAriaLabel}\n handleClose={onClose}\n message={message}\n onActionClick={onActionClick}\n open={open}\n severity={severity}\n showAction={!!actionText}\n showClose={true}\n />\n)\n\nexport default StatusSnackbar\n"],"mappings":";;AA6BA,IAAM,IAAA,CAAkB,EACtB,YAAA,GACA,kBAAA,GACA,gBAAA,GACA,SAAA,GACA,eAAA,GACA,SAAA,GACA,MAAA,GACA,UAAA,IAAW,UAAA,MAEX,gBAAA,EAAC,GAAD;AAAA,EACc,YAAA;AAAA,EACM,kBAAA;AAAA,EACF,gBAAA;AAAA,EAChB,aAAa;AAAA,EACJ,SAAA;AAAA,EACM,eAAA;AAAA,EACT,MAAA;AAAA,EACI,UAAA;AAAA,EACV,YAAY,CAAC,CAAC;AAAA,EACd,WAAW;AACZ,CAAA"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { ANALYTICS_EVENTS_CONFIG as a } from "../analytics/analyticsEventsConfig.es.js";
|
|
2
|
-
import { CTA_STATUS_CONTENT_CLASS as r } from "../components/CtaStatus.es.js";
|
|
3
2
|
import { HOST_ACTIONS as o } from "./hostActions.es.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, g = {
|
|
3
|
+
var n = ({ beat: e, stores: i }) => {
|
|
4
|
+
const s = i.insightsV2Store.beatContext[e.guid]?.selected_account_guid;
|
|
5
|
+
if (typeof s == "string")
|
|
6
|
+
return i.accountStore.visibleSavingsAccounts.some((t) => t.guid === s && !t.is_closed && !t.is_deleted) ? s : void 0;
|
|
7
|
+
}, _ = {
|
|
10
8
|
dismiss_beat: {
|
|
11
9
|
run: "delegateToHost",
|
|
12
10
|
params: { hostAction: o.dismissBeat }
|
|
13
11
|
},
|
|
14
12
|
select_savings_account: {
|
|
15
13
|
run: "updateUserInsightProfile",
|
|
16
|
-
params: (
|
|
17
|
-
disabledWhen: (
|
|
14
|
+
params: (e) => ({ fields: { emergency_savings_account_guid: n(e) } }),
|
|
15
|
+
disabledWhen: (e) => !n(e),
|
|
18
16
|
onSuccess: ["refreshBeat"],
|
|
19
17
|
analytics: a.EMERGENCY_SAVINGS_ACCT_SAVED
|
|
20
18
|
},
|
|
@@ -22,22 +20,10 @@ var n = ({ beat: s, stores: e }) => {
|
|
|
22
20
|
atomic_flow: {
|
|
23
21
|
run: "delegateToHost",
|
|
24
22
|
params: { hostAction: o.atomicTransact }
|
|
25
|
-
}
|
|
26
|
-
confirm_subscription_status: c({
|
|
27
|
-
statusLabels: {
|
|
28
|
-
positive: "subscribed",
|
|
29
|
-
negative: "not_subscribed"
|
|
30
|
-
},
|
|
31
|
-
statusVariant: "alert",
|
|
32
|
-
sx: {
|
|
33
|
-
minHeight: 56,
|
|
34
|
-
[`& .${r}`]: { gap: 10 }
|
|
35
|
-
},
|
|
36
|
-
answeredTitle: (s) => s.insights_feed?.subscription_status_modal?.reviewed_title
|
|
37
|
-
})
|
|
23
|
+
}
|
|
38
24
|
};
|
|
39
25
|
export {
|
|
40
|
-
|
|
26
|
+
_ as ctaActions
|
|
41
27
|
};
|
|
42
28
|
|
|
43
29
|
//# sourceMappingURL=ctaConfig.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ctaConfig.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/ctaConfig.ts"],"sourcesContent":["import { ANALYTICS_EVENTS_CONFIG } from '../analytics/analyticsEventsConfig'\nimport {
|
|
1
|
+
{"version":3,"file":"ctaConfig.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/ctaConfig.ts"],"sourcesContent":["import { ANALYTICS_EVENTS_CONFIG } from '../analytics/analyticsEventsConfig'\nimport { HOST_ACTIONS } from './hostActions'\nimport type { CtaStateContext, CtaStep } from './types'\n\n/**\n * The account the svg_image_block picker wrote into this beat's context, and only while it is\n * still one the user can save into (visible, open, not deleted) — a pick that went stale between\n * pick and Save never reaches the API.\n */\nconst pickedSavingsAccountGuid = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) => {\n const picked = stores.insightsV2Store.beatContext[beat.guid]?.selected_account_guid\n\n if (typeof picked !== 'string') return undefined\n\n const usable = stores.accountStore.visibleSavingsAccounts.some(\n (account) => account.guid === picked && !account.is_closed && !account.is_deleted,\n )\n\n return usable ? picked : undefined\n}\n\n/**\n * Steps keyed by the backend-named `cta.action_key` (ditto `*_cta_action`, via tupac). No key or\n * an unknown key = default: open the CTA's block drawer, if any. Its post message, when one\n * resolves (`cta.metadata` / `ctaPostMessages`), is sent either way. A new key is registered in\n * ditto and here in the same change; most CTAs need none. See README.md.\n */\nexport const ctaActions: Record<string, CtaStep> = {\n /** ConnectDiscoveredAccounts \"I don't have any\": dismiss through the host, then stop. */\n dismiss_beat: {\n run: 'delegateToHost',\n params: { hostAction: HOST_ACTIONS.dismissBeat },\n },\n\n /**\n * Designate Emergency Savings Account \"Save\": designates the account picked in the\n * svg_image_block picker (kept in the per-beat context), then refreshes the beat. The beat is\n * sampled, so the refresh re-reads its sample, which the backend rebuilds as the saved card\n * (change_account: \"Account Saved!\", no CTA). Disabled until a pick is made.\n */\n select_savings_account: {\n run: 'updateUserInsightProfile',\n params: (ctx) => ({\n fields: { emergency_savings_account_guid: pickedSavingsAccountGuid(ctx) },\n }),\n disabledWhen: (ctx) => !pickedSavingsAccountGuid(ctx),\n onSuccess: ['refreshBeat'],\n analytics: ANALYTICS_EVENTS_CONFIG.EMERGENCY_SAVINGS_ACCT_SAVED,\n },\n\n /**\n * Designate Emergency Savings Account \"Open a Savings Account\": no handler. The op_1 post\n * message comes from `ctaPostMessages`; this step adds the Created event.\n */\n open_savings_account: {\n analytics: ANALYTICS_EVENTS_CONFIG.EMERGENCY_SAVINGS_ACCT_CREATED,\n },\n\n /**\n * SetUpDirectDeposit `not_set_up`: hand the press to the host, which owns the Atomic SDK and its\n * lifecycle. No drawer, no `refreshBeat`, and no interim post message is registered for the\n * template (a backend-supplied `cta.metadata` would still post).\n */\n atomic_flow: {\n run: 'delegateToHost',\n params: { hostAction: HOST_ACTIONS.atomicTransact },\n },\n}\n"],"mappings":";;AASA,IAAM,IAAA,CAA4B,EAAE,MAAA,GAAM,QAAA,EAAA,MAAuD;AAC/F,QAAM,IAAS,EAAO,gBAAgB,YAAY,EAAK,IAAA,GAAO;AAE9D,MAAI,OAAO,KAAW;AAMtB,WAJe,EAAO,aAAa,uBAAuB,KAAA,CACvD,MAAY,EAAQ,SAAS,KAAU,CAAC,EAAQ,aAAa,CAAC,EAAQ,UAGlE,IAAS,IAAS;AAC3B,GAQa,IAAsC;AAAA,EAEjD,cAAc;AAAA,IACZ,KAAK;AAAA,IACL,QAAQ,EAAE,YAAY,EAAa,YAAY;AAAA,EACjD;AAAA,EAQA,wBAAwB;AAAA,IACtB,KAAK;AAAA,IACL,QAAA,CAAS,OAAS,EAChB,QAAQ,EAAE,gCAAgC,EAAyB,CAAG,EAAE,EAC1E;AAAA,IACA,cAAA,CAAe,MAAQ,CAAC,EAAyB,CAAG;AAAA,IACpD,WAAW,CAAC,aAAa;AAAA,IACzB,WAAW,EAAwB;AAAA,EACrC;AAAA,EAMA,sBAAsB,EACpB,WAAW,EAAwB,+BACrC;AAAA,EAOA,aAAa;AAAA,IACX,KAAK;AAAA,IACL,QAAQ,EAAE,YAAY,EAAa,eAAe;AAAA,EACpD;AACF"}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { AnalyticsEventConfigEntry } from '../analytics/analyticsEventsConfig';
|
|
2
2
|
import { CtaHandlerName } from './ctaHandlers';
|
|
3
|
-
import { InsightsPayload, PrimaryCTA } from '../../core';
|
|
4
3
|
import { CtaContext, CtaHandlerContext, CtaState, CtaStateContext, CtaStep, RunHandlerOptions } from './types';
|
|
5
4
|
/** The beat's own context (input a block collected for it), `{}` until something is written. */
|
|
6
5
|
export declare const beatContextOf: ({ beat, stores }: Pick<CtaStateContext, "beat" | "stores">) => Record<string, unknown>;
|
|
7
6
|
/** The step named by the CTA's `action_key`, or the empty default (no key / unknown key). */
|
|
8
7
|
export declare const resolveStep: ({ cta }: Pick<CtaStateContext, "cta">) => CtaStep;
|
|
9
|
-
/**
|
|
10
|
-
* The CTA whose step drives the card's state on every widget: `primary_cta` when it names a step
|
|
11
|
-
* (full), else `in_description_cta` (mini and micro send their action there). The one place that
|
|
12
|
-
* choice is made, so full, mini and micro show the same state for the same answer.
|
|
13
|
-
*/
|
|
14
|
-
export declare const cardActionCta: (payload?: InsightsPayload | null) => PrimaryCTA;
|
|
15
8
|
/** Pending always disables, as may the step's `disabledWhen`; its `presenter` may replace the button. */
|
|
16
9
|
export declare const resolveCtaState: (ctx: CtaStateContext) => CtaState;
|
|
17
10
|
type AnalyticsCtx = Pick<CtaContext, 'beat' | 'stores' | 'hostActions'>;
|
|
@@ -1,118 +1,107 @@
|
|
|
1
1
|
import { sendBeatCta as m } from "../../common/utils/PostMessage.es.js";
|
|
2
|
-
import { ANALYTICS_EVENTS_CONFIG as
|
|
2
|
+
import { ANALYTICS_EVENTS_CONFIG as n } from "../analytics/analyticsEventsConfig.es.js";
|
|
3
3
|
import { resolveAnalyticsEvent as f } from "../analytics/resolveAnalyticsEvent.es.js";
|
|
4
|
-
import { HOST_ACTIONS as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { resolveCtaMetadata as
|
|
8
|
-
import { hasDrawerBlock as
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
block: ""
|
|
12
|
-
}, B = (t) => {
|
|
13
|
-
const a = t?.primary_cta, e = t?.in_description_cta;
|
|
14
|
-
return a?.action_key || !e?.action_key ? a ?? S : {
|
|
15
|
-
label: e.label,
|
|
16
|
-
block: e.block ?? "",
|
|
17
|
-
action_key: e.action_key
|
|
18
|
-
};
|
|
19
|
-
}, F = (t) => {
|
|
20
|
-
const a = c(t), e = t.stores.insightsV2Store.ctaStatus[t.beat.guid] === "pending", r = a.presenter?.(t);
|
|
4
|
+
import { HOST_ACTIONS as v } from "./hostActions.es.js";
|
|
5
|
+
import { ctaActions as _ } from "./ctaConfig.es.js";
|
|
6
|
+
import { ctaHandlers as A } from "./ctaHandlers.es.js";
|
|
7
|
+
import { resolveCtaMetadata as E } from "./ctaPostMessages.es.js";
|
|
8
|
+
import { hasDrawerBlock as S } from "../mappings/hasDrawerBlock.es.js";
|
|
9
|
+
var y = {}, c = ({ cta: t }) => t.action_key && _[t.action_key] || y, B = (t) => {
|
|
10
|
+
const a = c(t), r = t.stores.insightsV2Store.ctaStatus[t.beat.guid] === "pending", e = a.presenter?.(t);
|
|
21
11
|
return {
|
|
22
|
-
disabled:
|
|
23
|
-
...
|
|
12
|
+
disabled: r || (a.disabledWhen?.(t) ?? !1),
|
|
13
|
+
...e && { presentation: e }
|
|
24
14
|
};
|
|
25
|
-
}, l = ({ beat: t, slot: a, stores:
|
|
26
|
-
|
|
27
|
-
}, g = ({ beat: t, stores: a },
|
|
28
|
-
const { is_mobile_webview:
|
|
15
|
+
}, l = ({ beat: t, slot: a, stores: r }) => {
|
|
16
|
+
r.insightsV2Store.openCtaDrawer(t.guid, a === "primary" ? "primaryCta" : "secondaryCta");
|
|
17
|
+
}, g = ({ beat: t, stores: a }, r) => {
|
|
18
|
+
const { is_mobile_webview: e, clientConfig: s } = a.appDataStore.appConfig, { event: i, action: u, payload: C } = r;
|
|
29
19
|
m(t, {
|
|
30
|
-
event:
|
|
20
|
+
event: i ?? void 0,
|
|
31
21
|
op: u ?? void 0,
|
|
32
22
|
extras: C ?? void 0,
|
|
33
|
-
isMobileWebview:
|
|
34
|
-
webviewScheme:
|
|
23
|
+
isMobileWebview: e,
|
|
24
|
+
webviewScheme: s?.master?.ui_message_webview_url_scheme,
|
|
35
25
|
userGuid: t.insights_payload?.user_guid ?? t.user_guid
|
|
36
26
|
});
|
|
37
27
|
}, h = (t) => {
|
|
38
|
-
|
|
39
|
-
}, w = (t, { beat: a, stores:
|
|
40
|
-
t === "refreshBeat" &&
|
|
41
|
-
},
|
|
28
|
+
S(t.cta.block) && l(t);
|
|
29
|
+
}, w = (t, { beat: a, stores: r }) => {
|
|
30
|
+
t === "refreshBeat" && r.emitUpdate({ staleBeatGuid: a.guid });
|
|
31
|
+
}, o = (t, a) => {
|
|
42
32
|
try {
|
|
43
33
|
t.hostActions.onAnalyticsEvent?.(f(a, t.beat));
|
|
44
|
-
} catch (
|
|
45
|
-
t.stores.captureException(
|
|
34
|
+
} catch (r) {
|
|
35
|
+
t.stores.captureException(r, {
|
|
46
36
|
store: "ctaActions",
|
|
47
37
|
template: t.beat.template,
|
|
48
38
|
handler: "sendCtaAnalytics"
|
|
49
39
|
});
|
|
50
40
|
}
|
|
51
|
-
},
|
|
52
|
-
const { beat: a, slot:
|
|
53
|
-
|
|
41
|
+
}, k = (t) => {
|
|
42
|
+
const { beat: a, slot: r, hostActions: e, stores: s } = t;
|
|
43
|
+
r !== "primary" || a.cta_clicked_at || (o(t, n.FIRST_TIME_PRIMARY_ACTION_SELECTED), Promise.resolve().then(() => e.onCtaAction?.({
|
|
54
44
|
beatGuid: a.guid,
|
|
55
|
-
name:
|
|
56
|
-
})).catch((
|
|
45
|
+
name: v.markCtaClicked
|
|
46
|
+
})).catch((i) => s.captureException(i, {
|
|
57
47
|
store: "ctaActions",
|
|
58
48
|
template: a.template,
|
|
59
49
|
handler: "markCtaClicked"
|
|
60
50
|
})));
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
}, p = async (t, a,
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
66
|
-
await
|
|
67
|
-
for (const
|
|
68
|
-
}, d = async ({ beat: t, stores: a },
|
|
69
|
-
const { insightsV2Store:
|
|
70
|
-
|
|
51
|
+
}, T = (t, { skipCtaClicked: a = !1 } = {}) => {
|
|
52
|
+
o(t, t.slot === "primary" ? n.PRIMARY_ACTION_SELECTED : n.SECONDARY_ACTION_SELECTED), a || k(t);
|
|
53
|
+
}, p = async (t, a, r) => {
|
|
54
|
+
const e = A[a];
|
|
55
|
+
if (!e) throw new Error(`Unknown CTA handler "${a}"`);
|
|
56
|
+
await e(t);
|
|
57
|
+
for (const s of r) w(s, t);
|
|
58
|
+
}, d = async ({ beat: t, stores: a }, r, e = {}) => {
|
|
59
|
+
const { insightsV2Store: s } = a;
|
|
60
|
+
s.setCtaStatus(t.guid, "pending");
|
|
71
61
|
try {
|
|
72
|
-
return await
|
|
73
|
-
} catch (
|
|
74
|
-
return
|
|
62
|
+
return await r(), s.setCtaStatus(t.guid, "done"), !0;
|
|
63
|
+
} catch (i) {
|
|
64
|
+
return s.setCtaStatus(t.guid, "error"), a.captureException(i, {
|
|
75
65
|
store: "ctaActions",
|
|
76
66
|
template: t.template,
|
|
77
|
-
...
|
|
67
|
+
...e
|
|
78
68
|
}), !1;
|
|
79
69
|
}
|
|
80
|
-
},
|
|
81
|
-
const a = c(t),
|
|
70
|
+
}, F = async (t) => {
|
|
71
|
+
const a = c(t), r = typeof a.params == "function" ? a.params(t) : a.params, e = {
|
|
82
72
|
...t,
|
|
83
73
|
params: {
|
|
84
|
-
...
|
|
74
|
+
...r,
|
|
85
75
|
...t.params
|
|
86
76
|
}
|
|
87
77
|
};
|
|
88
|
-
|
|
89
|
-
a.run && await p(
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
78
|
+
T(e, { skipCtaClicked: a.skipCtaClicked }), await d(e, async () => {
|
|
79
|
+
a.run && await p(e, a.run, a.onSuccess ?? []), a.analytics && o(e, a.analytics);
|
|
80
|
+
const s = E(e);
|
|
81
|
+
s && g(e, s);
|
|
82
|
+
const i = a.next ?? (a.run ? "none" : "default");
|
|
83
|
+
i === "default" ? h(e) : i === "drawer" && l(e);
|
|
94
84
|
});
|
|
95
|
-
},
|
|
85
|
+
}, b = {
|
|
96
86
|
label: "",
|
|
97
87
|
block: ""
|
|
98
|
-
},
|
|
99
|
-
const
|
|
88
|
+
}, G = (t, a, { onSuccess: r = [], analytics: e } = {}) => {
|
|
89
|
+
const s = {
|
|
100
90
|
...t,
|
|
101
|
-
cta:
|
|
91
|
+
cta: b,
|
|
102
92
|
slot: "primary"
|
|
103
93
|
};
|
|
104
|
-
return d(
|
|
105
|
-
await p(
|
|
94
|
+
return d(s, async () => {
|
|
95
|
+
await p(s, a, r), e && o(s, e);
|
|
106
96
|
}, { handler: a });
|
|
107
97
|
};
|
|
108
98
|
export {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
F as resolveCtaState,
|
|
99
|
+
T as reportCtaClick,
|
|
100
|
+
B as resolveCtaState,
|
|
112
101
|
c as resolveStep,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
102
|
+
F as runCtaAction,
|
|
103
|
+
G as runCtaHandler,
|
|
104
|
+
o as sendCtaAnalytics
|
|
116
105
|
};
|
|
117
106
|
|
|
118
107
|
//# sourceMappingURL=runCtaAction.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/runCtaAction.ts"],"sourcesContent":["import { sendBeatCta } from '../../common/utils/PostMessage'\nimport {\n ANALYTICS_EVENTS_CONFIG,\n type AnalyticsEventConfigEntry,\n} from '../analytics/analyticsEventsConfig'\nimport { resolveAnalyticsEvent } from '../analytics/resolveAnalyticsEvent'\nimport { hasDrawerBlock } from '../mappings/hasDrawerBlock'\nimport { ctaActions } from './ctaConfig'\nimport { resolveCtaMetadata } from './ctaPostMessages'\nimport { ctaHandlers, type CtaHandlerName } from './ctaHandlers'\nimport { HOST_ACTIONS } from './hostActions'\nimport type { CtaPostMessageMetadata, InsightsPayload, PrimaryCTA } from '../../core'\nimport type {\n CtaContext,\n CtaEffect,\n CtaHandler,\n CtaHandlerContext,\n CtaState,\n CtaStateContext,\n CtaStep,\n RunHandlerOptions,\n} from './types'\n\nconst DEFAULT_STEP: CtaStep = {}\n\n// ─── Resolution ─────────────────────────────────────────────────────────────\n\n/** The beat's own context (input a block collected for it), `{}` until something is written. */\nexport const beatContextOf = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) =>\n stores.insightsV2Store.beatContext[beat.guid] ?? {}\n\n/** The step named by the CTA's `action_key`, or the empty default (no key / unknown key). */\nexport const resolveStep = ({ cta }: Pick<CtaStateContext, 'cta'>): CtaStep =>\n (cta.action_key && ctaActions[cta.action_key]) || DEFAULT_STEP\n\nconst EMPTY_CTA: PrimaryCTA = { label: '', block: '' }\n\n/**\n * The CTA whose step drives the card's state on every widget: `primary_cta` when it names a step\n * (full), else `in_description_cta` (mini and micro send their action there). The one place that\n * choice is made, so full, mini and micro show the same state for the same answer.\n */\nexport const cardActionCta = (payload?: InsightsPayload | null): PrimaryCTA => {\n const primary = payload?.primary_cta\n const inDescription = payload?.in_description_cta\n\n if (primary?.action_key || !inDescription?.action_key) return primary ?? EMPTY_CTA\n\n return {\n label: inDescription.label,\n block: inDescription.block ?? '',\n action_key: inDescription.action_key,\n }\n}\n\n/** Pending always disables, as may the step's `disabledWhen`; its `presenter` may replace the button. */\nexport const resolveCtaState = (ctx: CtaStateContext): CtaState => {\n const step = resolveStep(ctx)\n const pending = ctx.stores.insightsV2Store.ctaStatus[ctx.beat.guid] === 'pending'\n const presentation = step.presenter?.(ctx)\n\n return {\n disabled: pending || (step.disabledWhen?.(ctx) ?? false),\n ...(presentation && { presentation }),\n }\n}\n\n// ─── Targets and effects ────────────────────────────────────────────────────\n\n/** Opens the beat's drawer for whichever slot triggered the current step. */\nconst openDrawerForSlot = ({\n beat,\n slot,\n stores,\n}: Pick<CtaContext, 'beat' | 'slot' | 'stores'>) => {\n stores.insightsV2Store.openCtaDrawer(\n beat.guid,\n slot === 'primary' ? 'primaryCta' : 'secondaryCta',\n )\n}\n\n/**\n * Posts this CTA's resolved message (event, op and beat-specific payload, from the backend's\n * `cta.metadata` or the template's `ctaPostMessages` entry) to the host.\n */\nconst postCtaMessage = ({ beat, stores }: CtaContext, metadata: CtaPostMessageMetadata) => {\n const { is_mobile_webview, clientConfig } = stores.appDataStore.appConfig\n const { event, action, payload } = metadata\n\n sendBeatCta(beat, {\n event: event ?? undefined,\n op: action ?? undefined,\n extras: payload ?? undefined,\n isMobileWebview: is_mobile_webview,\n webviewScheme: clientConfig?.master?.ui_message_webview_url_scheme,\n userGuid: beat.insights_payload?.user_guid ?? beat.user_guid,\n })\n}\n\n/**\n * Default target: open the drawer for a real block, otherwise nothing. A post message is never\n * implied by a missing block; it is sent only when one resolves (see runCtaAction).\n */\nconst runDefaultTarget = (ctx: CtaContext) => {\n if (hasDrawerBlock(ctx.cta.block)) openDrawerForSlot(ctx)\n}\n\nconst runEffect = (effect: CtaEffect, { beat, stores }: CtaContext) => {\n switch (effect) {\n case 'refreshBeat':\n stores.emitUpdate({ staleBeatGuid: beat.guid })\n break\n }\n}\n\ntype AnalyticsCtx = Pick<CtaContext, 'beat' | 'stores' | 'hostActions'>\n\n/**\n * The one way to fire a catalogued analytics event. Takes the catalogue entry itself (e.g.\n * `ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED`), not a lookup key — the call site already\n * has the entry via property access, so there is no key to look up or mistype. Resolves the\n * payload and hands it to the host directly. Never throws: a failed fire is captured, it\n * cannot fail or disable anything.\n */\nexport const sendCtaAnalytics = (ctx: AnalyticsCtx, event: AnalyticsEventConfigEntry): void => {\n try {\n ctx.hostActions.onAnalyticsEvent?.(resolveAnalyticsEvent(event, ctx.beat))\n } catch (error) {\n ctx.stores.captureException(error, {\n store: 'ctaActions',\n template: ctx.beat.template,\n handler: 'sendCtaAnalytics',\n })\n }\n}\n\n// First primary click: fires FIRST_TIME_PRIMARY_ACTION_SELECTED and records cta_clicked_at.\nconst markCtaClicked = (ctx: AnalyticsCtx & Pick<CtaContext, 'slot'>): void => {\n const { beat, slot, hostActions, stores } = ctx\n\n if (slot !== 'primary' || beat.cta_clicked_at) return\n\n sendCtaAnalytics(ctx, ANALYTICS_EVENTS_CONFIG.FIRST_TIME_PRIMARY_ACTION_SELECTED)\n\n // Fire-and-forget; a failed write must not fail the user's action, but still report it.\n Promise.resolve()\n .then(() =>\n hostActions.onCtaAction?.({ beatGuid: beat.guid, name: HOST_ACTIONS.markCtaClicked }),\n )\n .catch((error) =>\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n handler: 'markCtaClicked',\n }),\n )\n}\n\n/**\n * Trigger 1 + the first-click bookkeeping together: every CTA press's generic analytics\n * (`Primary/Secondary Action Selected`), plus `FIRST_TIME_PRIMARY_ACTION_SELECTED` /\n * `cta_clicked_at` on the first primary press. The one call site for \"a CTA got pressed\",\n * used by the runner and by the contact-support bypass in `BaseLayout`.\n */\nexport const reportCtaClick = (\n ctx: AnalyticsCtx & Pick<CtaContext, 'slot'>,\n { skipCtaClicked = false }: { skipCtaClicked?: boolean } = {},\n): void => {\n sendCtaAnalytics(\n ctx,\n ctx.slot === 'primary'\n ? ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED\n : ANALYTICS_EVENTS_CONFIG.SECONDARY_ACTION_SELECTED,\n )\n\n if (!skipCtaClicked) markCtaClicked(ctx)\n}\n\n// ─── Shared bookkeeping ─────────────────────────────────────────────────────\n\n/** Runs a named handler, then its `onSuccess` effects. Shared by card CTAs and drawer saves. */\nconst runHandlerWithEffects = async (\n ctx: CtaContext,\n handlerName: CtaHandlerName,\n onSuccess: CtaEffect[],\n): Promise<void> => {\n // Names are typed, but the map is still indexed defensively: config can come from anywhere.\n const handler = (ctaHandlers as Record<string, CtaHandler>)[handlerName]\n\n if (!handler) throw new Error(`Unknown CTA handler \"${handlerName}\"`)\n\n await handler(ctx)\n\n for (const effect of onSuccess) runEffect(effect, ctx)\n}\n\n/** Per-beat status around `work`: `pending` -> `done` | `error` (+ captureException). */\nconst withCtaStatus = async (\n { beat, stores }: Pick<CtaContext, 'beat' | 'stores'>,\n work: () => Promise<void>,\n captureContext: Record<string, string> = {},\n): Promise<boolean> => {\n const { insightsV2Store } = stores\n\n insightsV2Store.setCtaStatus(beat.guid, 'pending')\n\n try {\n await work()\n insightsV2Store.setCtaStatus(beat.guid, 'done')\n\n return true\n } catch (error) {\n insightsV2Store.setCtaStatus(beat.guid, 'error')\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n ...captureContext,\n })\n\n return false\n }\n}\n\n// ─── Entry points ───────────────────────────────────────────────────────────\n\n// Runs the CTA's step: handler, onSuccess effects, post message, then the next target.\nexport const runCtaAction = async (ctx: CtaContext): Promise<void> => {\n const step = resolveStep(ctx)\n const stepParams = typeof step.params === 'function' ? step.params(ctx) : step.params\n const stepCtx: CtaContext = { ...ctx, params: { ...stepParams, ...ctx.params } }\n\n reportCtaClick(stepCtx, { skipCtaClicked: step.skipCtaClicked })\n\n await withCtaStatus(stepCtx, async () => {\n if (step.run) await runHandlerWithEffects(stepCtx, step.run, step.onSuccess ?? [])\n\n // A step's own event, e.g. select_savings_account (Saved) / open_savings_account (Created).\n if (step.analytics) sendCtaAnalytics(stepCtx, step.analytics)\n\n const metadata = resolveCtaMetadata(stepCtx)\n\n if (metadata) postCtaMessage(stepCtx, metadata)\n\n const target = step.next ?? (step.run ? 'none' : 'default')\n\n if (target === 'default') runDefaultTarget(stepCtx)\n else if (target === 'drawer') openDrawerForSlot(stepCtx)\n })\n}\n\n/** Placeholder CTA for handlers run from inside a drawer, where no card slot is involved. */\nconst DIRECT_CTA = { label: '', block: '' }\n\n/** Runs a handler directly (drawer Save buttons). True on success. */\nexport const runCtaHandler = (\n ctx: CtaHandlerContext,\n handlerName: CtaHandlerName,\n { onSuccess = [], analytics }: RunHandlerOptions = {},\n): Promise<boolean> => {\n const fullCtx: CtaContext = { ...ctx, cta: DIRECT_CTA, slot: 'primary' }\n\n return withCtaStatus(\n fullCtx,\n async () => {\n await runHandlerWithEffects(fullCtx, handlerName, onSuccess)\n\n // Success-time analytics for drawer Saves.\n if (analytics) sendCtaAnalytics(fullCtx, analytics)\n },\n { handler: handlerName },\n )\n}\n"],"mappings":";;;;;;;;AAuBA,IAAM,IAAwB,CAAC,GASlB,IAAA,CAAe,EAAE,KAAA,EAAA,MAC3B,EAAI,cAAc,EAAW,EAAI,UAAA,KAAgB,GAE9C,IAAwB;AAAA,EAAE,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ACA,YAAY;AACV,UAAM,EAAsB,GAAS,GAAa,CAAS,GAGvD,KAAW,EAAiB,GAAS,CAAS;AAAA,EACpD,GACA,EAAE,SAAS,EAAY,CACzB;AACF"}
|
|
1
|
+
{"version":3,"file":"runCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/runCtaAction.ts"],"sourcesContent":["import { sendBeatCta } from '../../common/utils/PostMessage'\nimport {\n ANALYTICS_EVENTS_CONFIG,\n type AnalyticsEventConfigEntry,\n} from '../analytics/analyticsEventsConfig'\nimport { resolveAnalyticsEvent } from '../analytics/resolveAnalyticsEvent'\nimport { hasDrawerBlock } from '../mappings/hasDrawerBlock'\nimport { ctaActions } from './ctaConfig'\nimport { resolveCtaMetadata } from './ctaPostMessages'\nimport { ctaHandlers, type CtaHandlerName } from './ctaHandlers'\nimport { HOST_ACTIONS } from './hostActions'\nimport type { CtaPostMessageMetadata } from '../../core'\nimport type {\n CtaContext,\n CtaEffect,\n CtaHandler,\n CtaHandlerContext,\n CtaState,\n CtaStateContext,\n CtaStep,\n RunHandlerOptions,\n} from './types'\n\nconst DEFAULT_STEP: CtaStep = {}\n\n// ─── Resolution ─────────────────────────────────────────────────────────────\n\n/** The beat's own context (input a block collected for it), `{}` until something is written. */\nexport const beatContextOf = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) =>\n stores.insightsV2Store.beatContext[beat.guid] ?? {}\n\n/** The step named by the CTA's `action_key`, or the empty default (no key / unknown key). */\nexport const resolveStep = ({ cta }: Pick<CtaStateContext, 'cta'>): CtaStep =>\n (cta.action_key && ctaActions[cta.action_key]) || DEFAULT_STEP\n\n/** Pending always disables, as may the step's `disabledWhen`; its `presenter` may replace the button. */\nexport const resolveCtaState = (ctx: CtaStateContext): CtaState => {\n const step = resolveStep(ctx)\n const pending = ctx.stores.insightsV2Store.ctaStatus[ctx.beat.guid] === 'pending'\n const presentation = step.presenter?.(ctx)\n\n return {\n disabled: pending || (step.disabledWhen?.(ctx) ?? false),\n ...(presentation && { presentation }),\n }\n}\n\n// ─── Targets and effects ────────────────────────────────────────────────────\n\n/** Opens the beat's drawer for whichever slot triggered the current step. */\nconst openDrawerForSlot = ({\n beat,\n slot,\n stores,\n}: Pick<CtaContext, 'beat' | 'slot' | 'stores'>) => {\n stores.insightsV2Store.openCtaDrawer(\n beat.guid,\n slot === 'primary' ? 'primaryCta' : 'secondaryCta',\n )\n}\n\n/**\n * Posts this CTA's resolved message (event, op and beat-specific payload, from the backend's\n * `cta.metadata` or the template's `ctaPostMessages` entry) to the host.\n */\nconst postCtaMessage = ({ beat, stores }: CtaContext, metadata: CtaPostMessageMetadata) => {\n const { is_mobile_webview, clientConfig } = stores.appDataStore.appConfig\n const { event, action, payload } = metadata\n\n sendBeatCta(beat, {\n event: event ?? undefined,\n op: action ?? undefined,\n extras: payload ?? undefined,\n isMobileWebview: is_mobile_webview,\n webviewScheme: clientConfig?.master?.ui_message_webview_url_scheme,\n userGuid: beat.insights_payload?.user_guid ?? beat.user_guid,\n })\n}\n\n/**\n * Default target: open the drawer for a real block, otherwise nothing. A post message is never\n * implied by a missing block; it is sent only when one resolves (see runCtaAction).\n */\nconst runDefaultTarget = (ctx: CtaContext) => {\n if (hasDrawerBlock(ctx.cta.block)) openDrawerForSlot(ctx)\n}\n\nconst runEffect = (effect: CtaEffect, { beat, stores }: CtaContext) => {\n switch (effect) {\n case 'refreshBeat':\n stores.emitUpdate({ staleBeatGuid: beat.guid })\n break\n }\n}\n\ntype AnalyticsCtx = Pick<CtaContext, 'beat' | 'stores' | 'hostActions'>\n\n/**\n * The one way to fire a catalogued analytics event. Takes the catalogue entry itself (e.g.\n * `ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED`), not a lookup key — the call site already\n * has the entry via property access, so there is no key to look up or mistype. Resolves the\n * payload and hands it to the host directly. Never throws: a failed fire is captured, it\n * cannot fail or disable anything.\n */\nexport const sendCtaAnalytics = (ctx: AnalyticsCtx, event: AnalyticsEventConfigEntry): void => {\n try {\n ctx.hostActions.onAnalyticsEvent?.(resolveAnalyticsEvent(event, ctx.beat))\n } catch (error) {\n ctx.stores.captureException(error, {\n store: 'ctaActions',\n template: ctx.beat.template,\n handler: 'sendCtaAnalytics',\n })\n }\n}\n\n// First primary click: fires FIRST_TIME_PRIMARY_ACTION_SELECTED and records cta_clicked_at.\nconst markCtaClicked = (ctx: AnalyticsCtx & Pick<CtaContext, 'slot'>): void => {\n const { beat, slot, hostActions, stores } = ctx\n\n if (slot !== 'primary' || beat.cta_clicked_at) return\n\n sendCtaAnalytics(ctx, ANALYTICS_EVENTS_CONFIG.FIRST_TIME_PRIMARY_ACTION_SELECTED)\n\n // Fire-and-forget; a failed write must not fail the user's action, but still report it.\n Promise.resolve()\n .then(() =>\n hostActions.onCtaAction?.({ beatGuid: beat.guid, name: HOST_ACTIONS.markCtaClicked }),\n )\n .catch((error) =>\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n handler: 'markCtaClicked',\n }),\n )\n}\n\n/**\n * Trigger 1 + the first-click bookkeeping together: every CTA press's generic analytics\n * (`Primary/Secondary Action Selected`), plus `FIRST_TIME_PRIMARY_ACTION_SELECTED` /\n * `cta_clicked_at` on the first primary press. The one call site for \"a CTA got pressed\",\n * used by the runner and by the contact-support bypass in `BaseLayout`.\n */\nexport const reportCtaClick = (\n ctx: AnalyticsCtx & Pick<CtaContext, 'slot'>,\n { skipCtaClicked = false }: { skipCtaClicked?: boolean } = {},\n): void => {\n sendCtaAnalytics(\n ctx,\n ctx.slot === 'primary'\n ? ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED\n : ANALYTICS_EVENTS_CONFIG.SECONDARY_ACTION_SELECTED,\n )\n\n if (!skipCtaClicked) markCtaClicked(ctx)\n}\n\n// ─── Shared bookkeeping ─────────────────────────────────────────────────────\n\n/** Runs a named handler, then its `onSuccess` effects. Shared by card CTAs and drawer saves. */\nconst runHandlerWithEffects = async (\n ctx: CtaContext,\n handlerName: CtaHandlerName,\n onSuccess: CtaEffect[],\n): Promise<void> => {\n // Names are typed, but the map is still indexed defensively: config can come from anywhere.\n const handler = (ctaHandlers as Record<string, CtaHandler>)[handlerName]\n\n if (!handler) throw new Error(`Unknown CTA handler \"${handlerName}\"`)\n\n await handler(ctx)\n\n for (const effect of onSuccess) runEffect(effect, ctx)\n}\n\n/** Per-beat status around `work`: `pending` -> `done` | `error` (+ captureException). */\nconst withCtaStatus = async (\n { beat, stores }: Pick<CtaContext, 'beat' | 'stores'>,\n work: () => Promise<void>,\n captureContext: Record<string, string> = {},\n): Promise<boolean> => {\n const { insightsV2Store } = stores\n\n insightsV2Store.setCtaStatus(beat.guid, 'pending')\n\n try {\n await work()\n insightsV2Store.setCtaStatus(beat.guid, 'done')\n\n return true\n } catch (error) {\n insightsV2Store.setCtaStatus(beat.guid, 'error')\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n ...captureContext,\n })\n\n return false\n }\n}\n\n// ─── Entry points ───────────────────────────────────────────────────────────\n\n// Runs the CTA's step: handler, onSuccess effects, post message, then the next target.\nexport const runCtaAction = async (ctx: CtaContext): Promise<void> => {\n const step = resolveStep(ctx)\n const stepParams = typeof step.params === 'function' ? step.params(ctx) : step.params\n const stepCtx: CtaContext = { ...ctx, params: { ...stepParams, ...ctx.params } }\n\n reportCtaClick(stepCtx, { skipCtaClicked: step.skipCtaClicked })\n\n await withCtaStatus(stepCtx, async () => {\n if (step.run) await runHandlerWithEffects(stepCtx, step.run, step.onSuccess ?? [])\n\n // A step's own event, e.g. select_savings_account (Saved) / open_savings_account (Created).\n if (step.analytics) sendCtaAnalytics(stepCtx, step.analytics)\n\n const metadata = resolveCtaMetadata(stepCtx)\n\n if (metadata) postCtaMessage(stepCtx, metadata)\n\n const target = step.next ?? (step.run ? 'none' : 'default')\n\n if (target === 'default') runDefaultTarget(stepCtx)\n else if (target === 'drawer') openDrawerForSlot(stepCtx)\n })\n}\n\n/** Placeholder CTA for handlers run from inside a drawer, where no card slot is involved. */\nconst DIRECT_CTA = { label: '', block: '' }\n\n/** Runs a handler directly (drawer Save buttons). True on success. */\nexport const runCtaHandler = (\n ctx: CtaHandlerContext,\n handlerName: CtaHandlerName,\n { onSuccess = [], analytics }: RunHandlerOptions = {},\n): Promise<boolean> => {\n const fullCtx: CtaContext = { ...ctx, cta: DIRECT_CTA, slot: 'primary' }\n\n return withCtaStatus(\n fullCtx,\n async () => {\n await runHandlerWithEffects(fullCtx, handlerName, onSuccess)\n\n // Success-time analytics for drawer Saves.\n if (analytics) sendCtaAnalytics(fullCtx, analytics)\n },\n { handler: handlerName },\n )\n}\n"],"mappings":";;;;;;;;AAuBA,IAAM,IAAwB,CAAC,GASlB,IAAA,CAAe,EAAE,KAAA,EAAA,MAC3B,EAAI,cAAc,EAAW,EAAI,UAAA,KAAgB,GAGvC,IAAA,CAAmB,MAAmC;AACjE,QAAM,IAAO,EAAY,CAAG,GACtB,IAAU,EAAI,OAAO,gBAAgB,UAAU,EAAI,KAAK,IAAA,MAAU,WAClE,IAAe,EAAK,YAAY,CAAG;AAEzC,SAAO;AAAA,IACL,UAAU,MAAY,EAAK,eAAe,CAAG,KAAK;AAAA,IAClD,GAAI,KAAgB,EAAE,cAAA,EAAa;AAAA,EACrC;AACF,GAKM,IAAA,CAAqB,EACzB,MAAA,GACA,MAAA,GACA,QAAA,EAAA,MACkD;AAClD,EAAA,EAAO,gBAAgB,cACrB,EAAK,MACL,MAAS,YAAY,eAAe,cACtC;AACF,GAMM,IAAA,CAAkB,EAAE,MAAA,GAAM,QAAA,EAAA,GAAsB,MAAqC;AACzF,QAAM,EAAE,mBAAA,GAAmB,cAAA,EAAA,IAAiB,EAAO,aAAa,WAC1D,EAAE,OAAA,GAAO,QAAA,GAAQ,SAAA,EAAA,IAAY;AAEnC,EAAA,EAAY,GAAM;AAAA,IAChB,OAAO,KAAS;AAAA,IAChB,IAAI,KAAU;AAAA,IACd,QAAQ,KAAW;AAAA,IACnB,iBAAiB;AAAA,IACjB,eAAe,G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GAGM,IAAa;AAAA,EAAE,OAAO;AAAA,EAAI,OAAO;AAAG,GAG7B,IAAA,CACX,GACA,GACA,EAAE,WAAA,IAAY,CAAC,GAAG,WAAA,EAAA,IAAiC,CAAC,MAC/B;AACrB,QAAM,IAAsB;AAAA,IAAE,GAAG;AAAA,IAAK,KAAK;AAAA,IAAY,MAAM;AAAA,EAAU;AAEvE,SAAO,EACL,GACA,YAAY;AACV,UAAM,EAAsB,GAAS,GAAa,CAAS,GAGvD,KAAW,EAAiB,GAAS,CAAS;AAAA,EACpD,GACA,EAAE,SAAS,EAAY,CACzB;AACF"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { SxProps } from '@mui/system';
|
|
2
|
-
import { CtaStatusVariant } from '../components/CtaStatus';
|
|
3
|
-
import { GlobalCopy } from '../../core/types/GlobalCopy';
|
|
4
1
|
import { InsightsFeedCopy } from '../../core/types/localization/InsightsFeedCopy';
|
|
5
2
|
import { RepeatingTransaction } from '../../core/types/RepeatingTransaction';
|
|
6
3
|
import { BeatActions } from '../beatActions';
|
|
@@ -40,16 +37,10 @@ export interface SubscriptionEntryOptions {
|
|
|
40
37
|
};
|
|
41
38
|
/** Whether the stored answer applies to this beat (default: every answer counts). */
|
|
42
39
|
answerCounts?: (ctx: CtaStateContext, repeating: RepeatingTransaction) => boolean;
|
|
43
|
-
/** Which `CtaStatus` design the answered status uses (default `tinted`). */
|
|
44
|
-
statusVariant?: CtaStatusVariant;
|
|
45
|
-
/** Status bar overrides for this step (e.g. a taller bar). */
|
|
46
|
-
sx?: SxProps;
|
|
47
|
-
/** The card's title once answered, from copy (mini and micro retitle; full keeps its title). */
|
|
48
|
-
answeredTitle?: (copy: GlobalCopy) => string | undefined;
|
|
49
40
|
}
|
|
50
41
|
/**
|
|
51
42
|
* The step a beat's `action_key` names: the button until answered, then the status with Undo. No
|
|
52
43
|
* repeating transaction or transaction: no CTAs, as pulse. A missing word draws nothing.
|
|
53
44
|
*/
|
|
54
|
-
export declare const subscriptionEntryStep: ({ statusLabels,
|
|
45
|
+
export declare const subscriptionEntryStep: ({ statusLabels, answerCounts, }: SubscriptionEntryOptions) => CtaStep;
|
|
55
46
|
export {};
|
|
@@ -10,15 +10,12 @@ export type CtaParams = Record<string, unknown>;
|
|
|
10
10
|
/** Read-only view for state predicates evaluated during render (`hostActions` for a status's analytics). */
|
|
11
11
|
export type CtaStateContext = Pick<CtaContext, 'beat' | 'cta' | 'slot' | 'stores'> & Partial<Pick<CtaContext, 'hostActions'>>;
|
|
12
12
|
/** What a presenter draws instead of the button: a status, or nothing (`hideAll` also hides the secondary). */
|
|
13
|
-
export type CtaPresentation =
|
|
13
|
+
export type CtaPresentation = {
|
|
14
14
|
kind: 'hidden';
|
|
15
15
|
hideAll?: boolean;
|
|
16
16
|
} | ({
|
|
17
17
|
kind: 'status';
|
|
18
|
-
} & CtaStatusProps)
|
|
19
|
-
/** The card's title while this presentation shows (e.g. "Charge Reviewed"); any kind may set it. */
|
|
20
|
-
title?: string;
|
|
21
|
-
};
|
|
18
|
+
} & CtaStatusProps);
|
|
22
19
|
export interface CtaState {
|
|
23
20
|
disabled: boolean;
|
|
24
21
|
/** Set when the step's presenter replaces the button. */
|
|
@@ -6,12 +6,6 @@ export interface BeatCtaActions {
|
|
|
6
6
|
runCta: (slot: CtaSlot, cta: PrimaryCTA | SecondaryCTA, params?: Record<string, unknown>) => Promise<void>;
|
|
7
7
|
primary: CtaState;
|
|
8
8
|
secondary: CtaState;
|
|
9
|
-
/**
|
|
10
|
-
* State of the CTA that drives the card on any widget (`cardActionCta`: primary_cta, else
|
|
11
|
-
* in_description_cta). Mini and micro read their label and title from it; for a full card whose
|
|
12
|
-
* primary_cta names the step it equals `primary`.
|
|
13
|
-
*/
|
|
14
|
-
action: CtaState;
|
|
15
9
|
}
|
|
16
10
|
/**
|
|
17
11
|
* The card's click runner plus per-slot enabled state. Call from an `observer` so `disabledWhen`
|
|
@@ -1,61 +1,56 @@
|
|
|
1
1
|
import { useGlobalStore as p } from "../../common/context/hooks.es.js";
|
|
2
|
-
import {
|
|
3
|
-
import { useEffect as
|
|
2
|
+
import { resolveCtaState as c, resolveStep as C, runCtaAction as d, runCtaHandler as f } from "./runCtaAction.es.js";
|
|
3
|
+
import { useEffect as v } from "react";
|
|
4
4
|
var l = {
|
|
5
5
|
label: "",
|
|
6
6
|
block: ""
|
|
7
|
-
},
|
|
8
|
-
const
|
|
7
|
+
}, S = (t, o = {}, s = l, a = l) => {
|
|
8
|
+
const r = p(), e = C({ cta: s }).prepare, n = {
|
|
9
9
|
beat: t,
|
|
10
|
-
stores:
|
|
11
|
-
hostActions:
|
|
10
|
+
stores: r,
|
|
11
|
+
hostActions: o
|
|
12
12
|
};
|
|
13
|
-
return
|
|
14
|
-
|
|
13
|
+
return v(() => {
|
|
14
|
+
e?.({
|
|
15
15
|
beat: t,
|
|
16
|
-
stores:
|
|
16
|
+
stores: r
|
|
17
17
|
});
|
|
18
18
|
}, [
|
|
19
19
|
t.guid,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
e,
|
|
21
|
+
r
|
|
22
22
|
]), {
|
|
23
|
-
runCta: (u,
|
|
23
|
+
runCta: (u, i, m = {}) => d({
|
|
24
24
|
beat: t,
|
|
25
|
-
cta:
|
|
25
|
+
cta: i,
|
|
26
26
|
slot: u,
|
|
27
|
-
stores:
|
|
28
|
-
hostActions:
|
|
29
|
-
params:
|
|
27
|
+
stores: r,
|
|
28
|
+
hostActions: o,
|
|
29
|
+
params: m
|
|
30
30
|
}),
|
|
31
31
|
primary: c({
|
|
32
32
|
...n,
|
|
33
|
-
cta:
|
|
33
|
+
cta: s,
|
|
34
34
|
slot: "primary"
|
|
35
35
|
}),
|
|
36
36
|
secondary: c({
|
|
37
|
-
...n,
|
|
38
|
-
cta: e,
|
|
39
|
-
slot: "secondary"
|
|
40
|
-
}),
|
|
41
|
-
action: c({
|
|
42
37
|
...n,
|
|
43
38
|
cta: a,
|
|
44
|
-
slot: "
|
|
39
|
+
slot: "secondary"
|
|
45
40
|
})
|
|
46
41
|
};
|
|
47
|
-
},
|
|
48
|
-
const
|
|
49
|
-
return (
|
|
42
|
+
}, x = (t, o = {}) => {
|
|
43
|
+
const s = p();
|
|
44
|
+
return (a, r = {}, e) => f({
|
|
50
45
|
beat: t,
|
|
51
|
-
stores:
|
|
52
|
-
hostActions:
|
|
53
|
-
params:
|
|
54
|
-
},
|
|
46
|
+
stores: s,
|
|
47
|
+
hostActions: o,
|
|
48
|
+
params: r
|
|
49
|
+
}, a, e);
|
|
55
50
|
};
|
|
56
51
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
S as useBeatCtaActions,
|
|
53
|
+
x as useCtaHandler
|
|
59
54
|
};
|
|
60
55
|
|
|
61
56
|
//# sourceMappingURL=useCtaAction.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/useCtaAction.ts"],"sourcesContent":["import { useEffect } from 'react'\n\nimport type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { useGlobalStore } from '../../common'\nimport type { BeatActions } from '../beatActions'\nimport type { CtaHandlerName } from './ctaHandlers'\nimport {
|
|
1
|
+
{"version":3,"file":"useCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/useCtaAction.ts"],"sourcesContent":["import { useEffect } from 'react'\n\nimport type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { useGlobalStore } from '../../common'\nimport type { BeatActions } from '../beatActions'\nimport type { CtaHandlerName } from './ctaHandlers'\nimport { resolveCtaState, resolveStep, runCtaAction, runCtaHandler } from './runCtaAction'\nimport type { CtaSlot, CtaState, RunHandlerOptions } from './types'\n\nconst EMPTY_CTA: PrimaryCTA = { label: '', block: '' }\n\nexport interface BeatCtaActions {\n runCta: (\n slot: CtaSlot,\n cta: PrimaryCTA | SecondaryCTA,\n params?: Record<string, unknown>,\n ) => Promise<void>\n primary: CtaState\n secondary: CtaState\n}\n\n/**\n * The card's click runner plus per-slot enabled state. Call from an `observer` so `disabledWhen`\n * store reads re-render. `beatActions` is a parameter: BaseLayout mounts its provider below this.\n */\nexport const useBeatCtaActions = (\n beat: Beat,\n beatActions: BeatActions = {},\n primaryCta: PrimaryCTA | SecondaryCTA = EMPTY_CTA,\n secondaryCta: PrimaryCTA | SecondaryCTA = EMPTY_CTA,\n): BeatCtaActions => {\n const stores = useGlobalStore()\n const prepare = resolveStep({ cta: primaryCta }).prepare\n const stateCtx = { beat, stores, hostActions: beatActions }\n\n // Once per beat (beat.guid; the beat object can be new each render): load what the step reads.\n useEffect(() => {\n prepare?.({ beat, stores })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [beat.guid, prepare, stores])\n\n return {\n runCta: (slot, cta, params = {}) =>\n runCtaAction({ beat, cta, slot, stores, hostActions: beatActions, params }),\n primary: resolveCtaState({ ...stateCtx, cta: primaryCta, slot: 'primary' }),\n secondary: resolveCtaState({ ...stateCtx, cta: secondaryCta, slot: 'secondary' }),\n }\n}\n\n/**\n * Runs a handler from inside a drawer, e.g. `runHandler('createBudget', { categoryGuid, amount },\n * { onSuccess: ['refreshBeat'] })`. Inside a block, pass `useBeatActions()` as `beatActions`.\n */\nexport const useCtaHandler = (beat: Beat, beatActions: BeatActions = {}) => {\n const stores = useGlobalStore()\n\n return (\n handlerName: CtaHandlerName,\n params: Record<string, unknown> = {},\n options?: RunHandlerOptions,\n ) => runCtaHandler({ beat, stores, hostActions: beatActions, params }, handlerName, options)\n}\n"],"mappings":";;;AASA,IAAM,IAAwB;AAAA,EAAE,OAAO;AAAA,EAAI,OAAO;AAAG,GAgBxC,IAAA,CACX,GACA,IAA2B,CAAC,GAC5B,IAAwC,GACxC,IAA0C,MACvB;AACnB,QAAM,IAAS,EAAe,GACxB,IAAU,EAAY,EAAE,KAAK,EAAW,CAAC,EAAE,SAC3C,IAAW;AAAA,IAAE,MAAA;AAAA,IAAM,QAAA;AAAA,IAAQ,aAAa;AAAA,EAAY;AAG1D,SAAA,EAAA,MAAgB;AACd,IAAA,IAAU;AAAA,MAAE,MAAA;AAAA,MAAM,QAAA;AAAA,IAAO,CAAC;AAAA,EAE5B,GAAG;AAAA,IAAC,EAAK;AAAA,IAAM;AAAA,IAAS;AAAA,EAAM,CAAC,GAExB;AAAA,IACL,QAAA,CAAS,GAAM,GAAK,IAAS,CAAC,MAC5B,EAAa;AAAA,MAAE,MAAA;AAAA,MAAM,KAAA;AAAA,MAAK,MAAA;AAAA,MAAM,QAAA;AAAA,MAAQ,aAAa;AAAA,MAAa,QAAA;AAAA,IAAO,CAAC;AAAA,IAC5E,SAAS,EAAgB;AAAA,MAAE,GAAG;AAAA,MAAU,KAAK;AAAA,MAAY,MAAM;AAAA,IAAU,CAAC;AAAA,IAC1E,WAAW,EAAgB;AAAA,MAAE,GAAG;AAAA,MAAU,KAAK;AAAA,MAAc,MAAM;AAAA,IAAY,CAAC;AAAA,EAClF;AACF,GAMa,IAAA,CAAiB,GAAY,IAA2B,CAAC,MAAM;AAC1E,QAAM,IAAS,EAAe;AAE9B,SAAA,CACE,GACA,IAAkC,CAAC,GACnC,MACG,EAAc;AAAA,IAAE,MAAA;AAAA,IAAM,QAAA;AAAA,IAAQ,aAAa;AAAA,IAAa,QAAA;AAAA,EAAO,GAAG,GAAa,CAAO;AAC7F"}
|
|
@@ -8,7 +8,6 @@ export declare const actionBlocksKey: {
|
|
|
8
8
|
CONNECTION_DETAIL_ACTION_BLOCK: string;
|
|
9
9
|
CONNECT_WIDGET_ACTION_BLOCK: string;
|
|
10
10
|
SURVEY_MODAL_ACTION_BLOCK: string;
|
|
11
|
-
SUBSCRIPTION_STATUS_MODAL_ACTION_BLOCK: string;
|
|
12
11
|
RECURRING_TRANSACTION_ACTION_BLOCK: string;
|
|
13
12
|
TRANSACTION_LIST_ACTION_BLOCK: string;
|
|
14
13
|
REMAINING_CASH_ACTION_BLOCK: string;
|
|
@@ -8,7 +8,6 @@ var _ = {
|
|
|
8
8
|
CONNECTION_DETAIL_ACTION_BLOCK: "connection_detail_block",
|
|
9
9
|
CONNECT_WIDGET_ACTION_BLOCK: "connect_widget_block",
|
|
10
10
|
SURVEY_MODAL_ACTION_BLOCK: "survey_modal_block",
|
|
11
|
-
SUBSCRIPTION_STATUS_MODAL_ACTION_BLOCK: "subscription_status_modal_block",
|
|
12
11
|
RECURRING_TRANSACTION_ACTION_BLOCK: "recurring_transaction_block",
|
|
13
12
|
TRANSACTION_LIST_ACTION_BLOCK: "transaction_list_block",
|
|
14
13
|
REMAINING_CASH_ACTION_BLOCK: "remaining_cash_block",
|