@cloudscape-design/components 3.0.610 → 3.0.612
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/alert/index.d.ts.map +1 -1
- package/alert/index.js +5 -1
- package/alert/index.js.map +1 -1
- package/app-layout/index.d.ts.map +1 -1
- package/app-layout/index.js +16 -12
- package/app-layout/index.js.map +1 -1
- package/container/index.d.ts.map +1 -1
- package/container/index.js +1 -1
- package/container/index.js.map +1 -1
- package/container/internal.d.ts.map +1 -1
- package/container/internal.js +12 -10
- package/container/internal.js.map +1 -1
- package/flashbar/flash.d.ts.map +1 -1
- package/flashbar/flash.js +8 -2
- package/flashbar/flash.js.map +1 -1
- package/form/index.js +2 -2
- package/form/index.js.map +1 -1
- package/header/internal.d.ts.map +1 -1
- package/header/internal.js +3 -1
- package/header/internal.js.map +1 -1
- package/internal/analytics/components/analytics-funnel.d.ts +4 -4
- package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
- package/internal/analytics/components/analytics-funnel.js +9 -9
- package/internal/analytics/components/analytics-funnel.js.map +1 -1
- package/internal/analytics/context/analytics-context.d.ts +2 -2
- package/internal/analytics/context/analytics-context.d.ts.map +1 -1
- package/internal/analytics/context/analytics-context.js.map +1 -1
- package/internal/analytics/hooks/use-funnel.d.ts +1 -1
- package/internal/analytics/hooks/use-funnel.js +3 -3
- package/internal/analytics/hooks/use-funnel.js.map +1 -1
- package/internal/analytics/interfaces.d.ts +13 -7
- package/internal/analytics/interfaces.d.ts.map +1 -1
- package/internal/analytics/interfaces.js.map +1 -1
- package/internal/context/container-header.d.ts +6 -0
- package/internal/context/container-header.d.ts.map +1 -0
- package/internal/context/container-header.js +12 -0
- package/internal/context/container-header.js.map +1 -0
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/generated/theming/index.cjs +14 -14
- package/internal/generated/theming/index.js +14 -14
- package/internal/hooks/use-performance-marks.js +2 -2
- package/internal/hooks/use-performance-marks.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/table/body-cell/td-element.js +1 -1
- package/table/body-cell/td-element.js.map +1 -1
- package/table/header-cell/index.d.ts +1 -2
- package/table/header-cell/index.d.ts.map +1 -1
- package/table/header-cell/index.js.map +1 -1
- package/table/header-cell/th-element.js +1 -1
- package/table/header-cell/th-element.js.map +1 -1
- package/table/table-role/grid-navigation.d.ts.map +1 -1
- package/table/table-role/grid-navigation.js +2 -3
- package/table/table-role/grid-navigation.js.map +1 -1
- package/table/table-role/utils.d.ts +1 -0
- package/table/table-role/utils.d.ts.map +1 -1
- package/table/table-role/utils.js +8 -0
- package/table/table-role/utils.js.map +1 -1
- package/wizard/index.js +1 -1
- package/wizard/index.js.map +1 -1
- package/wizard/wizard-form.js +1 -1
- package/wizard/wizard-form.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-funnel.d.ts","sourceRoot":"","sources":["../../../../../src/internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAEvE,OAAO,EAKL,sBAAsB,EAEtB,yBAAyB,EAC1B,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,iBAAiB,EAElB,MAAM,eAAe,CAAC;AAavB,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACxC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACtC,mBAAmB,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAC;IACxD,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAClD,
|
|
1
|
+
{"version":3,"file":"analytics-funnel.d.ts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e,CAAC,YAAY,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,mBAAmB,UAAW,wBAAwB,gBAMlE,CAAC;AA4KF,UAAU,2BAA2B;IACnC,kBAAkB,CAAC,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;IAC7D,YAAY,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,yBAAyB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;CACtF;AAED,eAAO,MAAM,sBAAsB,qCAAsC,2BAA2B,gBAkGnG,CAAC"}
|
|
@@ -91,7 +91,7 @@ const InnerAnalyticsFunnel = (_a) => {
|
|
|
91
91
|
{ number: 1, isOptional: false, name: (_a = getNameFromSelector(funnelNameSelector.current)) !== null && _a !== void 0 ? _a : '' },
|
|
92
92
|
];
|
|
93
93
|
funnelInteractionId = FunnelMetrics.funnelStart({
|
|
94
|
-
|
|
94
|
+
instanceIdentifier: props.instanceIdentifier,
|
|
95
95
|
flowType: props.flowType,
|
|
96
96
|
funnelNameSelector: funnelNameSelector.current,
|
|
97
97
|
optionalStepNumbers: props.optionalStepNumbers,
|
|
@@ -238,7 +238,7 @@ function useStepChangeListener(stepNumber, handler) {
|
|
|
238
238
|
return { onStepChange: stepChangeCallback, subStepConfiguration };
|
|
239
239
|
}
|
|
240
240
|
const InnerAnalyticsFunnelStep = (_a) => {
|
|
241
|
-
var { children, stepNumber,
|
|
241
|
+
var { children, stepNumber, instanceIdentifier } = _a, rest = __rest(_a, ["children", "stepNumber", "instanceIdentifier"]);
|
|
242
242
|
const { funnelInteractionId, funnelNameSelector, funnelState, funnelType } = useFunnel();
|
|
243
243
|
const parentStep = useFunnelStep();
|
|
244
244
|
const parentStepExists = parentStep.isInStep;
|
|
@@ -253,7 +253,7 @@ const InnerAnalyticsFunnelStep = (_a) => {
|
|
|
253
253
|
}
|
|
254
254
|
const stepName = (_a = getNameFromSelector(stepNameSelector)) !== null && _a !== void 0 ? _a : '';
|
|
255
255
|
FunnelMetrics.funnelStepChange({
|
|
256
|
-
|
|
256
|
+
instanceIdentifier,
|
|
257
257
|
funnelInteractionId,
|
|
258
258
|
stepNumber,
|
|
259
259
|
stepName,
|
|
@@ -283,7 +283,7 @@ const InnerAnalyticsFunnelStep = (_a) => {
|
|
|
283
283
|
const stepName = getNameFromSelector(stepNameSelector);
|
|
284
284
|
if (funnelState.current === 'default') {
|
|
285
285
|
FunnelMetrics.funnelStepStart({
|
|
286
|
-
|
|
286
|
+
instanceIdentifier,
|
|
287
287
|
funnelInteractionId,
|
|
288
288
|
stepNumber,
|
|
289
289
|
stepName,
|
|
@@ -297,7 +297,7 @@ const InnerAnalyticsFunnelStep = (_a) => {
|
|
|
297
297
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
298
298
|
if (funnelState.current !== 'cancelled') {
|
|
299
299
|
FunnelMetrics.funnelStepComplete({
|
|
300
|
-
|
|
300
|
+
instanceIdentifier,
|
|
301
301
|
funnelInteractionId,
|
|
302
302
|
stepNumber,
|
|
303
303
|
stepName,
|
|
@@ -309,7 +309,7 @@ const InnerAnalyticsFunnelStep = (_a) => {
|
|
|
309
309
|
}
|
|
310
310
|
};
|
|
311
311
|
}, [
|
|
312
|
-
|
|
312
|
+
instanceIdentifier,
|
|
313
313
|
funnelInteractionId,
|
|
314
314
|
stepNumber,
|
|
315
315
|
stepNameSelector,
|
|
@@ -319,7 +319,7 @@ const InnerAnalyticsFunnelStep = (_a) => {
|
|
|
319
319
|
parentStepFunnelInteractionId,
|
|
320
320
|
]);
|
|
321
321
|
const contextValue = {
|
|
322
|
-
|
|
322
|
+
instanceIdentifier,
|
|
323
323
|
stepNumber,
|
|
324
324
|
stepNameSelector,
|
|
325
325
|
funnelStepProps,
|
|
@@ -337,7 +337,7 @@ const InnerAnalyticsFunnelStep = (_a) => {
|
|
|
337
337
|
const effectiveContextValue = parentStepExists && parentStepFunnelInteractionId ? parentStep : contextValue;
|
|
338
338
|
return (React.createElement(FunnelStepContext.Provider, { value: effectiveContextValue }, typeof children === 'function' ? children(effectiveContextValue) : children));
|
|
339
339
|
};
|
|
340
|
-
export const AnalyticsFunnelSubStep = ({ children,
|
|
340
|
+
export const AnalyticsFunnelSubStep = ({ children, instanceIdentifier }) => {
|
|
341
341
|
const subStepId = useUniqueId('substep');
|
|
342
342
|
const subStepSelector = getSubStepSelector(subStepId);
|
|
343
343
|
const subStepNameSelector = getSubStepNameSelector(subStepId);
|
|
@@ -349,7 +349,7 @@ export const AnalyticsFunnelSubStep = ({ children, instanceId }) => {
|
|
|
349
349
|
const { funnelState, funnelInteractionId } = useFunnel();
|
|
350
350
|
const { stepNumber, stepNameSelector } = useFunnelStep();
|
|
351
351
|
const newContext = {
|
|
352
|
-
|
|
352
|
+
instanceIdentifier,
|
|
353
353
|
subStepSelector,
|
|
354
354
|
subStepNameSelector,
|
|
355
355
|
subStepId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-funnel.js","sourceRoot":"","sources":["../../../../../src/internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,GAKd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASzC,OAAO,EACL,qBAAqB,EACrB,qBAAq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mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,mBAAmB;QACnB,WAAW;QACX,gBAAgB;QAChB,UAAU;QACV,mBAAmB;QACnB,eAAe;QACf,oBAAoB;QACpB,QAAQ;QACR,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAC1C,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAChC,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef, useState } from 'react';\n\nimport {\n FunnelStepContext,\n FunnelSubStepContext,\n FunnelContext,\n FunnelContextValue,\n FunnelStepContextValue,\n FunnelState,\n FunnelSubStepContextValue,\n} from '../context/analytics-context';\nimport { useFunnel, useFunnelStep } from '../hooks/use-funnel';\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\n\nimport { PACKAGE_VERSION } from '../../environment';\n\nimport { FunnelMetrics } from '../index';\nimport {\n AnalyticsMetadata,\n FunnelProps,\n FunnelStepProps,\n StepConfiguration,\n SubStepConfiguration,\n} from '../interfaces';\n\nimport {\n DATA_ATTR_FUNNEL_STEP,\n getFunnelNameSelector,\n getNameFromSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n} from '../selectors';\nimport { useDebounceCallback } from '../../hooks/use-debounce-callback';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\nexport const FUNNEL_VERSION = '1.4';\n\ninterface AnalyticsFunnelProps {\n children?: React.ReactNode;\n stepConfiguration?: StepConfiguration[];\n funnelNameSelectors?: string[];\n funnelType: FunnelProps['funnelType'];\n optionalStepNumbers: FunnelProps['optionalStepNumbers'];\n totalFunnelSteps: FunnelProps['totalFunnelSteps'];\n instanceId?: AnalyticsMetadata['instanceId'];\n flowType?: AnalyticsMetadata['flowType'];\n errorContext?: AnalyticsMetadata['errorContext'];\n}\n\nexport const AnalyticsFunnel = (props: AnalyticsFunnelProps) => {\n const { isInFunnel } = useFunnel();\n /*\n If the current funnel component is a Form (i.e. single-page funnel), it should\n defer its funnel-handling to a parent Form element, if present.\n Wizards (i.e. multi-page funnels) always take highest precedence for handling funnels,\n and do not defer to any other element.\n */\n if (isInFunnel && props.funnelType === 'single-page') {\n return <>{props.children}</>;\n }\n\n return <InnerAnalyticsFunnel {...props} />;\n};\nexport const CREATION_EDIT_FLOW_DONE_EVENT_NAME = 'awsui-creation-edit-flow-done';\nconst dispatchCreateEditFlowDoneEvent = () => {\n try {\n window.top?.document.dispatchEvent(new Event(CREATION_EDIT_FLOW_DONE_EVENT_NAME));\n } catch {\n // probably because of cross-origin error, then do not dispatch the event\n }\n};\n\nconst onFunnelCancelled = ({ funnelInteractionId }: { funnelInteractionId: string }) => {\n FunnelMetrics.funnelCancelled({ funnelInteractionId });\n};\n\nconst onFunnelComplete = ({ funnelInteractionId }: { funnelInteractionId: string }) => {\n FunnelMetrics.funnelComplete({ funnelInteractionId });\n dispatchCreateEditFlowDoneEvent();\n};\n\nfunction evaluateSelectors(selectors: string[], defaultSelector: string) {\n for (const selector of selectors) {\n const element = document.querySelector(selector);\n if (element) {\n return selector;\n }\n }\n\n return defaultSelector;\n}\n\nconst InnerAnalyticsFunnel = ({ children, stepConfiguration, ...props }: AnalyticsFunnelProps) => {\n const [funnelInteractionId, setFunnelInteractionId] = useState<string>('');\n const [submissionAttempt, setSubmissionAttempt] = useState(0);\n const isVisualRefresh = useVisualRefresh();\n const funnelState = useRef<FunnelState>('default');\n const funnelNameSelector = useRef<string>(getFunnelNameSelector());\n const errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\n const wizardCount = useRef<number>(0);\n const latestFocusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n\n // This useEffect hook is run once on component mount to initiate the funnel analytics.\n // It first calls the 'funnelStart' method from FunnelMetrics, providing all necessary details\n // about the funnel, and receives a unique interaction id.\n // This unique interaction id is then stored in the state for further use.\n //\n // On component unmount, it checks whether the funnel was successfully completed.\n // Based on this, it either calls 'funnelComplete' or 'funnelCancelled' method from FunnelMetrics.\n //\n // The eslint-disable is required as we deliberately want this effect to run only once on mount and unmount,\n // hence we do not provide any dependencies.\n useEffect(() => {\n /*\n We run this effect with a delay, in order to detect whether this funnel contains a Wizard.\n If it does contain a Wizard, that Wizard should take precedence for handling the funnel, and\n this current funnel component should do nothing.\n */\n let funnelInteractionId: string;\n const handle = setTimeout(() => {\n funnelNameSelector.current = evaluateSelectors(props.funnelNameSelectors || [], getFunnelNameSelector());\n\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n // Reset the state, in case the component was re-mounted.\n funnelState.current = 'default';\n\n const singleStepFlowStepConfiguration = [\n { number: 1, isOptional: false, name: getNameFromSelector(funnelNameSelector.current) ?? '' },\n ];\n\n funnelInteractionId = FunnelMetrics.funnelStart({\n instanceId: props.instanceId,\n flowType: props.flowType,\n funnelNameSelector: funnelNameSelector.current,\n optionalStepNumbers: props.optionalStepNumbers,\n funnelType: props.funnelType,\n totalFunnelSteps: props.totalFunnelSteps,\n componentVersion: PACKAGE_VERSION,\n theme: isVisualRefresh ? 'vr' : 'classic',\n funnelVersion: FUNNEL_VERSION,\n stepConfiguration: stepConfiguration ?? singleStepFlowStepConfiguration,\n });\n\n setFunnelInteractionId(funnelInteractionId);\n }, 1);\n\n /*\n A funnel counts as \"successful\" if it is unmounted after being \"complete\".\n */\n /* eslint-disable react-hooks/exhaustive-deps */\n return () => {\n clearTimeout(handle);\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n if (funnelState.current === 'validating') {\n // Finish the validation phase early.\n onFunnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId });\n } else {\n onFunnelCancelled({ funnelInteractionId });\n funnelState.current = 'cancelled';\n }\n };\n }, []);\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const funnelSubmit = () => {\n funnelState.current = 'validating';\n\n /*\n When the user attempts to submit the form, we wait for 50 milliseconds before checking\n if any form validation errors are present. This value was chosen to give enough time\n for validation and rerendering to occur, but be low enough that the user will not\n be able to take further action in the meantime.\n */\n const VALIDATION_WAIT_DELAY = 50;\n /*\n Loading is expected to take longer than validation, so we can keep the pressure on the CPU low.\n */\n const LOADING_WAIT_DELAY = 100;\n\n const checkForCompleteness = () => {\n if (funnelState.current === 'complete') {\n return;\n }\n\n if (loadingButtonCount.current > 0) {\n setTimeout(checkForCompleteness, LOADING_WAIT_DELAY);\n return;\n }\n\n if (errorCount.current === 0) {\n /*\n If no validation errors are rendered, we treat the funnel as complete.\n */\n onFunnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n } else {\n funnelState.current = 'default';\n }\n };\n\n setTimeout(checkForCompleteness, VALIDATION_WAIT_DELAY);\n };\n\n const funnelNextOrSubmitAttempt = () => setSubmissionAttempt(i => i + 1);\n\n const funnelCancel = () => {};\n\n const funnelContextValue: FunnelContextValue = {\n funnelInteractionId,\n setFunnelInteractionId,\n funnelType: props.funnelType,\n optionalStepNumbers: props.optionalStepNumbers,\n totalFunnelSteps: props.totalFunnelSteps,\n funnelNameSelector: funnelNameSelector.current,\n funnelSubmit,\n funnelCancel,\n submissionAttempt,\n funnelNextOrSubmitAttempt,\n funnelState,\n errorCount,\n loadingButtonCount,\n latestFocusCleanupFunction,\n isInFunnel: true,\n wizardCount,\n };\n\n return <FunnelContext.Provider value={funnelContextValue}>{children}</FunnelContext.Provider>;\n};\n\ninterface AnalyticsFunnelStepProps {\n instanceId?: AnalyticsMetadata['instanceId'];\n errorContext?: AnalyticsMetadata['errorContext'];\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n stepNameSelector?: FunnelStepProps['stepNameSelector'];\n stepNumber: FunnelStepProps['stepNumber'];\n}\n\nexport const AnalyticsFunnelStep = (props: AnalyticsFunnelStepProps) => {\n /*\n This wrapper is used to apply a `key` property to the actual (inner) AnalyticsFunnelStep\n element. This allows us to keep the state and effects separate per step.\n */\n return <InnerAnalyticsFunnelStep {...props} key={props.stepNumber} />;\n};\n\nfunction getSubStepConfiguration(): SubStepConfiguration[] {\n const subSteps = Array.from(document.querySelectorAll<HTMLElement>(getSubStepAllSelector()));\n\n const subStepConfiguration = subSteps.map((substep, index) => {\n const name = substep.querySelector<HTMLElement>(getSubStepNameSelector())?.innerText?.trim() ?? '';\n return {\n name,\n number: index + 1,\n };\n });\n return subStepConfiguration;\n}\n\nfunction useStepChangeListener(stepNumber: number, handler: (stepConfiguration: SubStepConfiguration[]) => void) {\n const subStepConfiguration = useRef(new Map<number, SubStepConfiguration[] | undefined>());\n /*\n Chosen so that it's hopefully shorter than a user interaction, but gives enough time for the\n amount of containers to stabilise.\n */\n const SUBSTEP_CHANGE_DEBOUNCE = 50;\n\n const listenForSubStepChanges = useRef(false);\n useEffect(() => {\n // We prevent emitting the event on the first render.\n const handle = setTimeout(() => (listenForSubStepChanges.current = true), SUBSTEP_CHANGE_DEBOUNCE);\n\n return () => {\n clearTimeout(handle);\n listenForSubStepChanges.current = false;\n };\n }, []);\n\n useEffect(() => {\n const handle = setTimeout(\n () => subStepConfiguration.current.set(stepNumber, getSubStepConfiguration()),\n SUBSTEP_CHANGE_DEBOUNCE\n );\n return () => {\n clearTimeout(handle);\n };\n }, [stepNumber]);\n\n /* We debounce this handler, so that multiple containers can change at once without causing \n too many events. */\n const stepChangeCallback = useDebounceCallback(() => {\n // We don't want to emit the event after the component has been unmounted.\n if (!listenForSubStepChanges.current) {\n return;\n }\n\n subStepConfiguration.current.set(stepNumber, getSubStepConfiguration());\n handler(subStepConfiguration.current.get(stepNumber)!);\n }, SUBSTEP_CHANGE_DEBOUNCE);\n\n return { onStepChange: stepChangeCallback, subStepConfiguration };\n}\n\nconst InnerAnalyticsFunnelStep = ({ children, stepNumber, instanceId, ...rest }: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, funnelNameSelector, funnelState, funnelType } = useFunnel();\n const parentStep = useFunnelStep();\n const parentStepExists = parentStep.isInStep;\n const parentStepFunnelInteractionId = parentStep.funnelInteractionId;\n\n const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };\n\n const subStepCount = useRef<number>(0);\n\n const stepNameSelector = rest.stepNameSelector || funnelNameSelector;\n const { onStepChange, subStepConfiguration } = useStepChangeListener(stepNumber, subStepConfiguration => {\n if (!funnelInteractionId) {\n return;\n }\n const stepName = getNameFromSelector(stepNameSelector) ?? '';\n\n FunnelMetrics.funnelStepChange({\n instanceId,\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration,\n });\n });\n\n // This useEffect hook is used to track the start and completion of interaction with the step.\n // On mount, if there is a valid funnel interaction id, it calls the 'funnelStepStart' method from FunnelMetrics\n // to record the beginning of the interaction with the current step.\n // On unmount, it does a similar thing but this time calling 'funnelStepComplete' to record the completion of the interaction.\n useEffect(() => {\n if (!funnelInteractionId) {\n // This step is not inside an active funnel.\n return;\n }\n if (parentStepExists && parentStepFunnelInteractionId) {\n /*\n This step is inside another step, which already reports events as\n part of an active funnel (i.e. that step is not a parent of a Wizard).\n Thus, this current step does not need to report any events.\n */\n return;\n }\n\n const stepName = getNameFromSelector(stepNameSelector);\n\n if (funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n instanceId,\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration: getSubStepConfiguration(),\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n instanceId,\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n totalSubSteps: subStepCount.current,\n });\n }\n };\n }, [\n instanceId,\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n funnelState,\n parentStepExists,\n funnelType,\n parentStepFunnelInteractionId,\n ]);\n\n const contextValue: FunnelStepContextValue = {\n instanceId,\n stepNumber,\n stepNameSelector,\n funnelStepProps,\n subStepCount,\n isInStep: true,\n funnelInteractionId,\n onStepChange,\n subStepConfiguration,\n };\n\n /*\n If this step is inside another step which already reports events as part of an active\n funnel (i.e. that step is not a parent of a Wizard), the current step becomes invisible\n in the hierarchy by passing the context of its parent through.\n */\n const effectiveContextValue = parentStepExists && parentStepFunnelInteractionId ? parentStep : contextValue;\n\n return (\n <FunnelStepContext.Provider value={effectiveContextValue}>\n {typeof children === 'function' ? children(effectiveContextValue) : children}\n </FunnelStepContext.Provider>\n );\n};\ninterface AnalyticsFunnelSubStepProps {\n instanceId?: AnalyticsMetadata['instanceId'];\n errorContext?: AnalyticsMetadata['errorContext'];\n children?: React.ReactNode | ((props: FunnelSubStepContextValue) => React.ReactNode);\n}\n\nexport const AnalyticsFunnelSubStep = ({ children, instanceId }: AnalyticsFunnelSubStepProps) => {\n const subStepId = useUniqueId('substep');\n const subStepSelector = getSubStepSelector(subStepId);\n const subStepNameSelector = getSubStepNameSelector(subStepId);\n const subStepRef = useRef<HTMLDivElement | null>(null);\n const { subStepCount, onStepChange } = useFunnelStep();\n const mousePressed = useRef<boolean>(false);\n const isFocusedSubStep = useRef<boolean>(false);\n const focusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n const { funnelState, funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const newContext: FunnelSubStepContextValue = {\n instanceId,\n subStepSelector,\n subStepNameSelector,\n subStepId,\n subStepRef,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n isNestedSubStep: false,\n };\n\n const inheritedContext = { ...useContext(FunnelSubStepContext), isNestedSubStep: true };\n\n const isNested = Boolean(inheritedContext.subStepId);\n\n useEffect(() => {\n if (!isNested) {\n subStepCount.current++;\n onStepChange();\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n subStepCount.current--;\n onStepChange();\n };\n }\n }, [isNested, subStepCount, onStepChange]);\n\n const context = isNested ? inheritedContext : newContext;\n\n useEffect(() => {\n if (isNested || !subStepRef.current) {\n return;\n }\n\n const onMouseDown = () => (mousePressed.current = true);\n\n const onMouseUp = async () => {\n mousePressed.current = false;\n\n if (!isFocusedSubStep.current) {\n return;\n }\n\n /*\n Some mouse events result in an element being focused. However,\n this happens only _after_ the onMouseUp event. We yield the\n event loop here, so that `document.activeElement` has the\n correct new value. \n */\n await new Promise(r => setTimeout(r, 1));\n\n if (!subStepRef.current || !document.activeElement || !nodeBelongs(subStepRef.current, document.activeElement)) {\n isFocusedSubStep.current = false;\n\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n };\n window.addEventListener('mousedown', onMouseDown);\n window.addEventListener('mouseup', onMouseUp);\n return () => {\n window.removeEventListener('mousedown', onMouseDown);\n window.removeEventListener('mouseup', onMouseUp);\n };\n }, [\n funnelInteractionId,\n funnelState,\n stepNameSelector,\n stepNumber,\n subStepNameSelector,\n subStepSelector,\n focusCleanupFunction,\n isNested,\n subStepRef,\n ]);\n\n return (\n <FunnelSubStepContext.Provider value={context}>\n {typeof children === 'function' ? children(context) : children}\n </FunnelSubStepContext.Provider>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"analytics-funnel.js","sourceRoot":"","sources":["../../../../../src/internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,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C,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE;gBAC9G,gBAAgB,CAAC,OAAO,GAAG,KAAK,CAAC;gBAEjC;;;mBAGG;gBACH,MAAA,oBAAoB,CAAC,OAAO,oEAAI,CAAC;aAClC;QACH,CAAC,CAAA,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YACrD,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,mBAAmB;QACnB,WAAW;QACX,gBAAgB;QAChB,UAAU;QACV,mBAAmB;QACnB,eAAe;QACf,oBAAoB;QACpB,QAAQ;QACR,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAC1C,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAChC,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef, useState } from 'react';\n\nimport {\n FunnelStepContext,\n FunnelSubStepContext,\n FunnelContext,\n FunnelContextValue,\n FunnelStepContextValue,\n FunnelState,\n FunnelSubStepContextValue,\n} from '../context/analytics-context';\nimport { useFunnel, useFunnelStep } from '../hooks/use-funnel';\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\n\nimport { PACKAGE_VERSION } from '../../environment';\n\nimport { FunnelMetrics } from '../index';\nimport {\n AnalyticsMetadata,\n FunnelProps,\n FunnelStepProps,\n StepConfiguration,\n SubStepConfiguration,\n} from '../interfaces';\n\nimport {\n DATA_ATTR_FUNNEL_STEP,\n getFunnelNameSelector,\n getNameFromSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n} from '../selectors';\nimport { useDebounceCallback } from '../../hooks/use-debounce-callback';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\nexport const FUNNEL_VERSION = '1.4';\n\ninterface AnalyticsFunnelProps {\n children?: React.ReactNode;\n stepConfiguration?: StepConfiguration[];\n funnelNameSelectors?: string[];\n funnelType: FunnelProps['funnelType'];\n optionalStepNumbers: FunnelProps['optionalStepNumbers'];\n totalFunnelSteps: FunnelProps['totalFunnelSteps'];\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n flowType?: AnalyticsMetadata['flowType'];\n errorContext?: AnalyticsMetadata['errorContext'];\n}\n\nexport const AnalyticsFunnel = (props: AnalyticsFunnelProps) => {\n const { isInFunnel } = useFunnel();\n /*\n If the current funnel component is a Form (i.e. single-page funnel), it should\n defer its funnel-handling to a parent Form element, if present.\n Wizards (i.e. multi-page funnels) always take highest precedence for handling funnels,\n and do not defer to any other element.\n */\n if (isInFunnel && props.funnelType === 'single-page') {\n return <>{props.children}</>;\n }\n\n return <InnerAnalyticsFunnel {...props} />;\n};\nexport const CREATION_EDIT_FLOW_DONE_EVENT_NAME = 'awsui-creation-edit-flow-done';\nconst dispatchCreateEditFlowDoneEvent = () => {\n try {\n window.top?.document.dispatchEvent(new Event(CREATION_EDIT_FLOW_DONE_EVENT_NAME));\n } catch {\n // probably because of cross-origin error, then do not dispatch the event\n }\n};\n\nconst onFunnelCancelled = ({ funnelInteractionId }: { funnelInteractionId: string }) => {\n FunnelMetrics.funnelCancelled({ funnelInteractionId });\n};\n\nconst onFunnelComplete = ({ funnelInteractionId }: { funnelInteractionId: string }) => {\n FunnelMetrics.funnelComplete({ funnelInteractionId });\n dispatchCreateEditFlowDoneEvent();\n};\n\nfunction evaluateSelectors(selectors: string[], defaultSelector: string) {\n for (const selector of selectors) {\n const element = document.querySelector(selector);\n if (element) {\n return selector;\n }\n }\n\n return defaultSelector;\n}\n\nconst InnerAnalyticsFunnel = ({ children, stepConfiguration, ...props }: AnalyticsFunnelProps) => {\n const [funnelInteractionId, setFunnelInteractionId] = useState<string>('');\n const [submissionAttempt, setSubmissionAttempt] = useState(0);\n const isVisualRefresh = useVisualRefresh();\n const funnelState = useRef<FunnelState>('default');\n const funnelNameSelector = useRef<string>(getFunnelNameSelector());\n const errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\n const wizardCount = useRef<number>(0);\n const latestFocusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n\n // This useEffect hook is run once on component mount to initiate the funnel analytics.\n // It first calls the 'funnelStart' method from FunnelMetrics, providing all necessary details\n // about the funnel, and receives a unique interaction id.\n // This unique interaction id is then stored in the state for further use.\n //\n // On component unmount, it checks whether the funnel was successfully completed.\n // Based on this, it either calls 'funnelComplete' or 'funnelCancelled' method from FunnelMetrics.\n //\n // The eslint-disable is required as we deliberately want this effect to run only once on mount and unmount,\n // hence we do not provide any dependencies.\n useEffect(() => {\n /*\n We run this effect with a delay, in order to detect whether this funnel contains a Wizard.\n If it does contain a Wizard, that Wizard should take precedence for handling the funnel, and\n this current funnel component should do nothing.\n */\n let funnelInteractionId: string;\n const handle = setTimeout(() => {\n funnelNameSelector.current = evaluateSelectors(props.funnelNameSelectors || [], getFunnelNameSelector());\n\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n // Reset the state, in case the component was re-mounted.\n funnelState.current = 'default';\n\n const singleStepFlowStepConfiguration = [\n { number: 1, isOptional: false, name: getNameFromSelector(funnelNameSelector.current) ?? '' },\n ];\n\n funnelInteractionId = FunnelMetrics.funnelStart({\n instanceIdentifier: props.instanceIdentifier,\n flowType: props.flowType,\n funnelNameSelector: funnelNameSelector.current,\n optionalStepNumbers: props.optionalStepNumbers,\n funnelType: props.funnelType,\n totalFunnelSteps: props.totalFunnelSteps,\n componentVersion: PACKAGE_VERSION,\n theme: isVisualRefresh ? 'vr' : 'classic',\n funnelVersion: FUNNEL_VERSION,\n stepConfiguration: stepConfiguration ?? singleStepFlowStepConfiguration,\n });\n\n setFunnelInteractionId(funnelInteractionId);\n }, 1);\n\n /*\n A funnel counts as \"successful\" if it is unmounted after being \"complete\".\n */\n /* eslint-disable react-hooks/exhaustive-deps */\n return () => {\n clearTimeout(handle);\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n if (funnelState.current === 'validating') {\n // Finish the validation phase early.\n onFunnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId });\n } else {\n onFunnelCancelled({ funnelInteractionId });\n funnelState.current = 'cancelled';\n }\n };\n }, []);\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const funnelSubmit = () => {\n funnelState.current = 'validating';\n\n /*\n When the user attempts to submit the form, we wait for 50 milliseconds before checking\n if any form validation errors are present. This value was chosen to give enough time\n for validation and rerendering to occur, but be low enough that the user will not\n be able to take further action in the meantime.\n */\n const VALIDATION_WAIT_DELAY = 50;\n /*\n Loading is expected to take longer than validation, so we can keep the pressure on the CPU low.\n */\n const LOADING_WAIT_DELAY = 100;\n\n const checkForCompleteness = () => {\n if (funnelState.current === 'complete') {\n return;\n }\n\n if (loadingButtonCount.current > 0) {\n setTimeout(checkForCompleteness, LOADING_WAIT_DELAY);\n return;\n }\n\n if (errorCount.current === 0) {\n /*\n If no validation errors are rendered, we treat the funnel as complete.\n */\n onFunnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n } else {\n funnelState.current = 'default';\n }\n };\n\n setTimeout(checkForCompleteness, VALIDATION_WAIT_DELAY);\n };\n\n const funnelNextOrSubmitAttempt = () => setSubmissionAttempt(i => i + 1);\n\n const funnelCancel = () => {};\n\n const funnelContextValue: FunnelContextValue = {\n funnelInteractionId,\n setFunnelInteractionId,\n funnelType: props.funnelType,\n optionalStepNumbers: props.optionalStepNumbers,\n totalFunnelSteps: props.totalFunnelSteps,\n funnelNameSelector: funnelNameSelector.current,\n funnelSubmit,\n funnelCancel,\n submissionAttempt,\n funnelNextOrSubmitAttempt,\n funnelState,\n errorCount,\n loadingButtonCount,\n latestFocusCleanupFunction,\n isInFunnel: true,\n wizardCount,\n };\n\n return <FunnelContext.Provider value={funnelContextValue}>{children}</FunnelContext.Provider>;\n};\n\ninterface AnalyticsFunnelStepProps {\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n errorContext?: AnalyticsMetadata['errorContext'];\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n stepNameSelector?: FunnelStepProps['stepNameSelector'];\n stepNumber: FunnelStepProps['stepNumber'];\n}\n\nexport const AnalyticsFunnelStep = (props: AnalyticsFunnelStepProps) => {\n /*\n This wrapper is used to apply a `key` property to the actual (inner) AnalyticsFunnelStep\n element. This allows us to keep the state and effects separate per step.\n */\n return <InnerAnalyticsFunnelStep {...props} key={props.stepNumber} />;\n};\n\nfunction getSubStepConfiguration(): SubStepConfiguration[] {\n const subSteps = Array.from(document.querySelectorAll<HTMLElement>(getSubStepAllSelector()));\n\n const subStepConfiguration = subSteps.map((substep, index) => {\n const name = substep.querySelector<HTMLElement>(getSubStepNameSelector())?.innerText?.trim() ?? '';\n return {\n name,\n number: index + 1,\n };\n });\n return subStepConfiguration;\n}\n\nfunction useStepChangeListener(stepNumber: number, handler: (stepConfiguration: SubStepConfiguration[]) => void) {\n const subStepConfiguration = useRef(new Map<number, SubStepConfiguration[] | undefined>());\n /*\n Chosen so that it's hopefully shorter than a user interaction, but gives enough time for the\n amount of containers to stabilise.\n */\n const SUBSTEP_CHANGE_DEBOUNCE = 50;\n\n const listenForSubStepChanges = useRef(false);\n useEffect(() => {\n // We prevent emitting the event on the first render.\n const handle = setTimeout(() => (listenForSubStepChanges.current = true), SUBSTEP_CHANGE_DEBOUNCE);\n\n return () => {\n clearTimeout(handle);\n listenForSubStepChanges.current = false;\n };\n }, []);\n\n useEffect(() => {\n const handle = setTimeout(\n () => subStepConfiguration.current.set(stepNumber, getSubStepConfiguration()),\n SUBSTEP_CHANGE_DEBOUNCE\n );\n return () => {\n clearTimeout(handle);\n };\n }, [stepNumber]);\n\n /* We debounce this handler, so that multiple containers can change at once without causing \n too many events. */\n const stepChangeCallback = useDebounceCallback(() => {\n // We don't want to emit the event after the component has been unmounted.\n if (!listenForSubStepChanges.current) {\n return;\n }\n\n subStepConfiguration.current.set(stepNumber, getSubStepConfiguration());\n handler(subStepConfiguration.current.get(stepNumber)!);\n }, SUBSTEP_CHANGE_DEBOUNCE);\n\n return { onStepChange: stepChangeCallback, subStepConfiguration };\n}\n\nconst InnerAnalyticsFunnelStep = ({ children, stepNumber, instanceIdentifier, ...rest }: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, funnelNameSelector, funnelState, funnelType } = useFunnel();\n const parentStep = useFunnelStep();\n const parentStepExists = parentStep.isInStep;\n const parentStepFunnelInteractionId = parentStep.funnelInteractionId;\n\n const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };\n\n const subStepCount = useRef<number>(0);\n\n const stepNameSelector = rest.stepNameSelector || funnelNameSelector;\n const { onStepChange, subStepConfiguration } = useStepChangeListener(stepNumber, subStepConfiguration => {\n if (!funnelInteractionId) {\n return;\n }\n const stepName = getNameFromSelector(stepNameSelector) ?? '';\n\n FunnelMetrics.funnelStepChange({\n instanceIdentifier,\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration,\n });\n });\n\n // This useEffect hook is used to track the start and completion of interaction with the step.\n // On mount, if there is a valid funnel interaction id, it calls the 'funnelStepStart' method from FunnelMetrics\n // to record the beginning of the interaction with the current step.\n // On unmount, it does a similar thing but this time calling 'funnelStepComplete' to record the completion of the interaction.\n useEffect(() => {\n if (!funnelInteractionId) {\n // This step is not inside an active funnel.\n return;\n }\n if (parentStepExists && parentStepFunnelInteractionId) {\n /*\n This step is inside another step, which already reports events as\n part of an active funnel (i.e. that step is not a parent of a Wizard).\n Thus, this current step does not need to report any events.\n */\n return;\n }\n\n const stepName = getNameFromSelector(stepNameSelector);\n\n if (funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n instanceIdentifier,\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration: getSubStepConfiguration(),\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n instanceIdentifier,\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n totalSubSteps: subStepCount.current,\n });\n }\n };\n }, [\n instanceIdentifier,\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n funnelState,\n parentStepExists,\n funnelType,\n parentStepFunnelInteractionId,\n ]);\n\n const contextValue: FunnelStepContextValue = {\n instanceIdentifier,\n stepNumber,\n stepNameSelector,\n funnelStepProps,\n subStepCount,\n isInStep: true,\n funnelInteractionId,\n onStepChange,\n subStepConfiguration,\n };\n\n /*\n If this step is inside another step which already reports events as part of an active\n funnel (i.e. that step is not a parent of a Wizard), the current step becomes invisible\n in the hierarchy by passing the context of its parent through.\n */\n const effectiveContextValue = parentStepExists && parentStepFunnelInteractionId ? parentStep : contextValue;\n\n return (\n <FunnelStepContext.Provider value={effectiveContextValue}>\n {typeof children === 'function' ? children(effectiveContextValue) : children}\n </FunnelStepContext.Provider>\n );\n};\ninterface AnalyticsFunnelSubStepProps {\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n errorContext?: AnalyticsMetadata['errorContext'];\n children?: React.ReactNode | ((props: FunnelSubStepContextValue) => React.ReactNode);\n}\n\nexport const AnalyticsFunnelSubStep = ({ children, instanceIdentifier }: AnalyticsFunnelSubStepProps) => {\n const subStepId = useUniqueId('substep');\n const subStepSelector = getSubStepSelector(subStepId);\n const subStepNameSelector = getSubStepNameSelector(subStepId);\n const subStepRef = useRef<HTMLDivElement | null>(null);\n const { subStepCount, onStepChange } = useFunnelStep();\n const mousePressed = useRef<boolean>(false);\n const isFocusedSubStep = useRef<boolean>(false);\n const focusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n const { funnelState, funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const newContext: FunnelSubStepContextValue = {\n instanceIdentifier,\n subStepSelector,\n subStepNameSelector,\n subStepId,\n subStepRef,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n isNestedSubStep: false,\n };\n\n const inheritedContext = { ...useContext(FunnelSubStepContext), isNestedSubStep: true };\n\n const isNested = Boolean(inheritedContext.subStepId);\n\n useEffect(() => {\n if (!isNested) {\n subStepCount.current++;\n onStepChange();\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n subStepCount.current--;\n onStepChange();\n };\n }\n }, [isNested, subStepCount, onStepChange]);\n\n const context = isNested ? inheritedContext : newContext;\n\n useEffect(() => {\n if (isNested || !subStepRef.current) {\n return;\n }\n\n const onMouseDown = () => (mousePressed.current = true);\n\n const onMouseUp = async () => {\n mousePressed.current = false;\n\n if (!isFocusedSubStep.current) {\n return;\n }\n\n /*\n Some mouse events result in an element being focused. However,\n this happens only _after_ the onMouseUp event. We yield the\n event loop here, so that `document.activeElement` has the\n correct new value. \n */\n await new Promise(r => setTimeout(r, 1));\n\n if (!subStepRef.current || !document.activeElement || !nodeBelongs(subStepRef.current, document.activeElement)) {\n isFocusedSubStep.current = false;\n\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n };\n window.addEventListener('mousedown', onMouseDown);\n window.addEventListener('mouseup', onMouseUp);\n return () => {\n window.removeEventListener('mousedown', onMouseDown);\n window.removeEventListener('mouseup', onMouseUp);\n };\n }, [\n funnelInteractionId,\n funnelState,\n stepNameSelector,\n stepNumber,\n subStepNameSelector,\n subStepSelector,\n focusCleanupFunction,\n isNested,\n subStepRef,\n ]);\n\n return (\n <FunnelSubStepContext.Provider value={context}>\n {typeof children === 'function' ? children(context) : children}\n </FunnelSubStepContext.Provider>\n );\n};\n"]}
|
|
@@ -20,7 +20,7 @@ export interface FunnelContextValue {
|
|
|
20
20
|
wizardCount: MutableRefObject<number>;
|
|
21
21
|
}
|
|
22
22
|
export interface FunnelStepContextValue {
|
|
23
|
-
|
|
23
|
+
instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];
|
|
24
24
|
stepNameSelector: string;
|
|
25
25
|
stepNumber: number;
|
|
26
26
|
funnelStepProps?: Record<string, string | number | boolean | undefined>;
|
|
@@ -32,7 +32,7 @@ export interface FunnelStepContextValue {
|
|
|
32
32
|
subStepConfiguration: MutableRefObject<Map<number, SubStepConfiguration[] | undefined> | undefined>;
|
|
33
33
|
}
|
|
34
34
|
export interface FunnelSubStepContextValue {
|
|
35
|
-
|
|
35
|
+
instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];
|
|
36
36
|
subStepId: string;
|
|
37
37
|
subStepSelector: string;
|
|
38
38
|
subStepNameSelector: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-context.d.ts","sourceRoot":"","sources":["../../../../../src/internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGpF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,UAAU,EAAE,UAAU,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,sBAAsB,EAAE,CAAC,mBAAmB,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yBAAyB,EAAE,MAAM,IAAI,CAAC;IACtC,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IACpC,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACrC,kBAAkB,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC7C,0BAA0B,EAAE,gBAAgB,CAAC,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACvE,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,sBAAsB;IACrC,
|
|
1
|
+
{"version":3,"file":"analytics-context.d.ts","sourceRoot":"","sources":["../../../../../src/internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGpF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,EAAE,MAAM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C;CACrG;AAED,MAAM,WAAW,yBAAyB;IACxC,kBAAkB,CAAC,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACpD,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC;;;;;OAKG;IACH,gBAAgB,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,oBAAoB,EAAE,gBAAgB,CAAC,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACjE,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC5E;AAGD,eAAO,MAAM,aAAa,6CAiBxB,CAAC;AAEH,eAAO,MAAM,iBAAiB,iDAQ5B,CAAC;AAEH,eAAO,MAAM,oBAAoB,oDAS/B,CAAC;AAEH,eAAO,MAAM,yBAAyB,6CAA+C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-context.js","sourceRoot":"","sources":["../../../../../src/internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAA+B,aAAa,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AA2DrD,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAqB;IAC7D,mBAAmB,EAAE,SAAS;IAC9B,kBAAkB,EAAE,qBAAqB,EAAE;IAC3C,sBAAsB,EAAE,GAAG,EAAE,GAAE,CAAC;IAChC,UAAU,EAAE,aAAa;IACzB,mBA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B,SAAS,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { MutableRefObject, RefObject, createContext } from 'react';\nimport { AnalyticsMetadata, FunnelType, SubStepConfiguration } from '../interfaces';\nimport { getFunnelNameSelector } from '../selectors';\n\nexport type FunnelState = 'default' | 'validating' | 'complete' | 'cancelled';\n\nexport interface FunnelContextValue {\n funnelInteractionId: string | undefined;\n funnelType: FunnelType;\n funnelNameSelector: string;\n optionalStepNumbers: number[];\n totalFunnelSteps: number;\n funnelSubmit: () => void;\n funnelCancel: () => void;\n setFunnelInteractionId: (funnelInteractionId: string) => void;\n submissionAttempt: number;\n funnelNextOrSubmitAttempt: () => void;\n funnelState: RefObject<FunnelState>;\n errorCount: MutableRefObject<number>;\n loadingButtonCount: MutableRefObject<number>;\n latestFocusCleanupFunction: MutableRefObject<undefined | (() => void)>;\n isInFunnel: boolean;\n wizardCount: MutableRefObject<number>;\n}\n\nexport interface FunnelStepContextValue {\n
|
|
1
|
+
{"version":3,"file":"analytics-context.js","sourceRoot":"","sources":["../../../../../src/internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAA+B,aAAa,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AA2DrD,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAqB;IAC7D,mBAAmB,EAAE,SAAS;IAC9B,kBAAkB,EAAE,qBAAqB,EAAE;IAC3C,sBAAsB,EAAE,GAAG,EAAE,GAAE,CAAC;IAChC,UAAU,EAAE,aAAa;IACzB,mBAAmB,EAAE,EAAE;IACvB,gBAAgB,EAAE,CAAC;IACnB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,iBAAiB,EAAE,CAAC;IACpB,yBAAyB,EAAE,GAAG,EAAE,GAAE,CAAC;IACnC,WAAW,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;IACnC,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IAC1B,kBAAkB,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IAClC,0BAA0B,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;IAClD,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAyB;IACrE,gBAAgB,EAAE,EAAE;IACpB,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IAC5B,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,SAAS;IAC9B,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,oBAAoB,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE;CAC7C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAA4B;IAC3E,SAAS,EAAE,EAAE;IACb,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;IACvB,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAC7B,eAAe,EAAE,KAAK;IACtB,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;IAChC,gBAAgB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;IACpC,oBAAoB,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;CAC7C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,aAAa,CAAqB,SAAS,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { MutableRefObject, RefObject, createContext } from 'react';\nimport { AnalyticsMetadata, FunnelType, SubStepConfiguration } from '../interfaces';\nimport { getFunnelNameSelector } from '../selectors';\n\nexport type FunnelState = 'default' | 'validating' | 'complete' | 'cancelled';\n\nexport interface FunnelContextValue {\n funnelInteractionId: string | undefined;\n funnelType: FunnelType;\n funnelNameSelector: string;\n optionalStepNumbers: number[];\n totalFunnelSteps: number;\n funnelSubmit: () => void;\n funnelCancel: () => void;\n setFunnelInteractionId: (funnelInteractionId: string) => void;\n submissionAttempt: number;\n funnelNextOrSubmitAttempt: () => void;\n funnelState: RefObject<FunnelState>;\n errorCount: MutableRefObject<number>;\n loadingButtonCount: MutableRefObject<number>;\n latestFocusCleanupFunction: MutableRefObject<undefined | (() => void)>;\n isInFunnel: boolean;\n wizardCount: MutableRefObject<number>;\n}\n\nexport interface FunnelStepContextValue {\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n stepNameSelector: string;\n stepNumber: number;\n funnelStepProps?: Record<string, string | number | boolean | undefined>;\n subStepCount: MutableRefObject<number>;\n isInStep: boolean;\n funnelInteractionId: string | undefined;\n /** This function is called when the list of substeps in this step changes. */\n onStepChange: () => void;\n subStepConfiguration: MutableRefObject<Map<number, SubStepConfiguration[] | undefined> | undefined>;\n}\n\nexport interface FunnelSubStepContextValue {\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n subStepId: string;\n subStepSelector: string;\n subStepNameSelector: string;\n subStepRef: MutableRefObject<HTMLDivElement | null>;\n mousePressed: MutableRefObject<boolean>;\n /**\n * `isFocusedSubStep` is almost the same as checking if document.activeElement\n * is a child of the curren substep. However, `isFocusedSubStep` stays true\n * while the mouse button is pressed down, even though some browsers move the focus\n * to the body element during that time.\n */\n isFocusedSubStep: MutableRefObject<boolean>;\n\n /**\n * The focus cleanup function should be run when the user leaves the substep.\n */\n focusCleanupFunction: MutableRefObject<undefined | (() => void)>;\n isNestedSubStep: boolean;\n funnelSubStepProps?: Record<string, string | number | boolean | undefined>;\n}\n\n/* istanbul ignore next */\nexport const FunnelContext = createContext<FunnelContextValue>({\n funnelInteractionId: undefined,\n funnelNameSelector: getFunnelNameSelector(),\n setFunnelInteractionId: () => {},\n funnelType: 'single-page',\n optionalStepNumbers: [],\n totalFunnelSteps: 0,\n funnelSubmit: () => {},\n funnelCancel: () => {},\n submissionAttempt: 0,\n funnelNextOrSubmitAttempt: () => {},\n funnelState: { current: 'default' },\n errorCount: { current: 0 },\n loadingButtonCount: { current: 0 },\n latestFocusCleanupFunction: { current: undefined },\n isInFunnel: false,\n wizardCount: { current: 0 },\n});\n\nexport const FunnelStepContext = createContext<FunnelStepContextValue>({\n stepNameSelector: '',\n stepNumber: 0,\n subStepCount: { current: 0 },\n isInStep: false,\n funnelInteractionId: undefined,\n onStepChange: () => {},\n subStepConfiguration: { current: new Map() },\n});\n\nexport const FunnelSubStepContext = createContext<FunnelSubStepContextValue>({\n subStepId: '',\n subStepSelector: '',\n subStepNameSelector: '',\n subStepRef: { current: null },\n isNestedSubStep: false,\n mousePressed: { current: false },\n isFocusedSubStep: { current: false },\n focusCleanupFunction: { current: undefined },\n});\n\nexport const FunnelNameSelectorContext = createContext<string | undefined>(undefined);\n"]}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* The subStepRef is a reference to the DOM element of the funnel sub-step.
|
|
11
11
|
*/
|
|
12
12
|
export declare const useFunnelSubStep: () => import("../context/analytics-context").FunnelSubStepContextValue | {
|
|
13
|
-
|
|
13
|
+
instanceIdentifier?: string | undefined;
|
|
14
14
|
subStepId: string;
|
|
15
15
|
subStepSelector: string;
|
|
16
16
|
subStepNameSelector: string;
|
|
@@ -20,7 +20,7 @@ export const useFunnelSubStep = () => {
|
|
|
20
20
|
const context = useContext(FunnelSubStepContext);
|
|
21
21
|
const { funnelInteractionId, funnelState, latestFocusCleanupFunction } = useFunnel();
|
|
22
22
|
const { stepNumber, stepNameSelector, subStepConfiguration } = useFunnelStep();
|
|
23
|
-
const {
|
|
23
|
+
const { instanceIdentifier, subStepId, subStepSelector, subStepNameSelector, subStepRef, isNestedSubStep, mousePressed, isFocusedSubStep, focusCleanupFunction, } = context;
|
|
24
24
|
if (isNestedSubStep) {
|
|
25
25
|
return context;
|
|
26
26
|
}
|
|
@@ -46,7 +46,7 @@ export const useFunnelSubStep = () => {
|
|
|
46
46
|
const stepName = getNameFromSelector(stepNameSelector);
|
|
47
47
|
const subStepNumber = (_d = (_c = (_b = subStepConfiguration.current) === null || _b === void 0 ? void 0 : _b.get(stepNumber)) === null || _c === void 0 ? void 0 : _c.find(step => step.name === subStepName)) === null || _d === void 0 ? void 0 : _d.number;
|
|
48
48
|
FunnelMetrics.funnelSubStepStart({
|
|
49
|
-
|
|
49
|
+
instanceIdentifier,
|
|
50
50
|
funnelInteractionId,
|
|
51
51
|
subStepSelector,
|
|
52
52
|
subStepNameSelector,
|
|
@@ -77,7 +77,7 @@ export const useFunnelSubStep = () => {
|
|
|
77
77
|
const subStepNumber = (_c = (_b = (_a = subStepConfiguration.current) === null || _a === void 0 ? void 0 : _a.get(stepNumber)) === null || _b === void 0 ? void 0 : _b.find(s => s.name === subStepName)) === null || _c === void 0 ? void 0 : _c.number;
|
|
78
78
|
if (funnelState.current !== 'cancelled') {
|
|
79
79
|
FunnelMetrics.funnelSubStepComplete({
|
|
80
|
-
|
|
80
|
+
instanceIdentifier,
|
|
81
81
|
funnelInteractionId,
|
|
82
82
|
subStepSelector,
|
|
83
83
|
subStepNameSelector,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-funnel.js","sourceRoot":"","sources":["../../../../../src/internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM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// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport {\n FunnelContext,\n FunnelNameSelectorContext,\n FunnelStepContext,\n FunnelSubStepContext,\n} from '../context/analytics-context';\nimport {\n DATA_ATTR_FUNNEL_INTERACTION_ID,\n DATA_ATTR_FUNNEL_SUBSTEP,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../selectors';\nimport { FunnelMetrics } from '../';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\n/**\n * Custom React Hook to manage and interact with FunnelSubStep.\n * This hook will provide necessary properties and methods required\n * to track and manage interactions with a FunnelSubStep component.\n *\n * The `onFocus` method is used to track the beginning of interaction with the FunnelSubStep.\n * The `onBlur` method is used to track the completion of interaction with the FunnelSubStep.\n * The subStepId is a unique identifier for the funnel sub-step.\n * The subStepRef is a reference to the DOM element of the funnel sub-step.\n */\nexport const useFunnelSubStep = () => {\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, funnelState, latestFocusCleanupFunction } = useFunnel();\n const { stepNumber, stepNameSelector, subStepConfiguration } = useFunnelStep();\n\n const {\n instanceId,\n subStepId,\n subStepSelector,\n subStepNameSelector,\n subStepRef,\n isNestedSubStep,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n } = context;\n\n if (isNestedSubStep) {\n return context;\n }\n\n const onFocus = async (event: React.FocusEvent<HTMLDivElement>) => {\n const element = event.target;\n // Ignore spurious focus events, such as when the browser window is focused again.\n await new Promise(r => setTimeout(r, 1));\n if (document.activeElement !== element) {\n return;\n }\n\n if (isFocusedSubStep.current) {\n return;\n }\n isFocusedSubStep.current = true;\n\n if (funnelInteractionId && subStepId) {\n /*\n If the previously focused substep has provided a cleanup function, we\n call it here on behalf of the previously focused substep.\n */\n latestFocusCleanupFunction.current?.();\n\n const subStepName = getNameFromSelector(subStepNameSelector);\n const stepName = getNameFromSelector(stepNameSelector);\n const subStepNumber = subStepConfiguration.current\n ?.get(stepNumber)\n ?.find(step => step.name === subStepName)?.number;\n FunnelMetrics.funnelSubStepStart({\n instanceId,\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n subStepNumber,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n\n /*\n This cleanup function will be called when the user leaves this substep.\n The function might be called either:\n\n - by the next focused substep as `latestFocusCleanupFunction`\n (through a separate instance of the function we're currently in), or\n\n - by the same substep as `focusCleanupFunction`\n (through the `onMouseUp` handler or the `onBlur` handler).\n */\n let cleanupFunctionHasBeenRun = false;\n focusCleanupFunction.current = () => {\n if (cleanupFunctionHasBeenRun) {\n return;\n }\n cleanupFunctionHasBeenRun = true;\n\n const subStepNumber = subStepConfiguration.current?.get(stepNumber)?.find(s => s.name === subStepName)?.number;\n\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelSubStepComplete({\n instanceId,\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n subStepNumber,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n latestFocusCleanupFunction.current = focusCleanupFunction.current;\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (mousePressed.current) {\n /*\n Ignore blur events that are caused by mouse interaction, because these events don't\n always reflect user intention. For example, clicking the label of an interactive form\n element will briefly blur it.\n The mouse-caused events are handled in the global `onMouseUp` handler of the substep\n context instead.\n */\n return;\n }\n\n if (!subStepRef.current || !event.relatedTarget || !nodeBelongs(subStepRef.current, event.relatedTarget)) {\n isFocusedSubStep.current = false;\n\n if (funnelInteractionId && subStepId && funnelState.current !== 'cancelled') {\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n }\n };\n\n const funnelSubStepProps: Record<string, any> = funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_SUBSTEP]: subStepId,\n onFocus,\n onBlur,\n }\n : {};\n\n return { funnelSubStepProps, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with FunnelStep.\n * This hook will provide necessary properties required to track\n * and manage interactions with a FunnelStep component.\n *\n * The 'data-analytics-funnel-step' property of funnelStepProps is used to track the index of the current step in the funnel.\n * The context contains additional properties of the FunnelStep.\n */\nexport const useFunnelStep = () => {\n const context = useContext(FunnelStepContext);\n return context;\n};\n\n/**\n * Custom React Hook to manage and interact with Funnel.\n * This hook will provide necessary properties required to track\n * and manage interactions with a Funnel component.\n *\n * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.\n */\nexport const useFunnel = () => {\n const context = useContext(FunnelContext);\n const funnelProps: Record<string, string | number | boolean | undefined> = context.funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_INTERACTION_ID]: context.funnelInteractionId,\n }\n : {};\n\n return { funnelProps, ...context };\n};\n\nexport const useFunnelNameSelector = () => {\n const context = useContext(FunnelNameSelectorContext);\n return context;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"use-funnel.js","sourceRoot":"","sources":["../../../../../src/internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,MAAM,E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I,WAAW,CAAC,OAAO,KAAK,WAAW,EAAE;gBAC3E;;;mBAGG;gBACH,MAAA,oBAAoB,CAAC,OAAO,oEAAI,CAAC;aAClC;SACF;IACH,CAAC,CAAC;IAEF,MAAM,kBAAkB,GAAwB,mBAAmB;QACjE,CAAC,CAAC;YACE,CAAC,wBAAwB,CAAC,EAAE,SAAS;YACrC,OAAO;YACP,MAAM;SACP;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,kBAAkB,IAAK,OAAO,EAAG;AAC5C,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,WAAW,GAA0D,OAAO,CAAC,mBAAmB;QACpG,CAAC,CAAC;YACE,CAAC,+BAA+B,CAAC,EAAE,OAAO,CAAC,mBAAmB;SAC/D;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,WAAW,IAAK,OAAO,EAAG;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,MAAM,OAAO,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport {\n FunnelContext,\n FunnelNameSelectorContext,\n FunnelStepContext,\n FunnelSubStepContext,\n} from '../context/analytics-context';\nimport {\n DATA_ATTR_FUNNEL_INTERACTION_ID,\n DATA_ATTR_FUNNEL_SUBSTEP,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../selectors';\nimport { FunnelMetrics } from '../';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\n/**\n * Custom React Hook to manage and interact with FunnelSubStep.\n * This hook will provide necessary properties and methods required\n * to track and manage interactions with a FunnelSubStep component.\n *\n * The `onFocus` method is used to track the beginning of interaction with the FunnelSubStep.\n * The `onBlur` method is used to track the completion of interaction with the FunnelSubStep.\n * The subStepId is a unique identifier for the funnel sub-step.\n * The subStepRef is a reference to the DOM element of the funnel sub-step.\n */\nexport const useFunnelSubStep = () => {\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, funnelState, latestFocusCleanupFunction } = useFunnel();\n const { stepNumber, stepNameSelector, subStepConfiguration } = useFunnelStep();\n\n const {\n instanceIdentifier,\n subStepId,\n subStepSelector,\n subStepNameSelector,\n subStepRef,\n isNestedSubStep,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n } = context;\n\n if (isNestedSubStep) {\n return context;\n }\n\n const onFocus = async (event: React.FocusEvent<HTMLDivElement>) => {\n const element = event.target;\n // Ignore spurious focus events, such as when the browser window is focused again.\n await new Promise(r => setTimeout(r, 1));\n if (document.activeElement !== element) {\n return;\n }\n\n if (isFocusedSubStep.current) {\n return;\n }\n isFocusedSubStep.current = true;\n\n if (funnelInteractionId && subStepId) {\n /*\n If the previously focused substep has provided a cleanup function, we\n call it here on behalf of the previously focused substep.\n */\n latestFocusCleanupFunction.current?.();\n\n const subStepName = getNameFromSelector(subStepNameSelector);\n const stepName = getNameFromSelector(stepNameSelector);\n const subStepNumber = subStepConfiguration.current\n ?.get(stepNumber)\n ?.find(step => step.name === subStepName)?.number;\n FunnelMetrics.funnelSubStepStart({\n instanceIdentifier,\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n subStepNumber,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n\n /*\n This cleanup function will be called when the user leaves this substep.\n The function might be called either:\n\n - by the next focused substep as `latestFocusCleanupFunction`\n (through a separate instance of the function we're currently in), or\n\n - by the same substep as `focusCleanupFunction`\n (through the `onMouseUp` handler or the `onBlur` handler).\n */\n let cleanupFunctionHasBeenRun = false;\n focusCleanupFunction.current = () => {\n if (cleanupFunctionHasBeenRun) {\n return;\n }\n cleanupFunctionHasBeenRun = true;\n\n const subStepNumber = subStepConfiguration.current?.get(stepNumber)?.find(s => s.name === subStepName)?.number;\n\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelSubStepComplete({\n instanceIdentifier,\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n subStepNumber,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n latestFocusCleanupFunction.current = focusCleanupFunction.current;\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (mousePressed.current) {\n /*\n Ignore blur events that are caused by mouse interaction, because these events don't\n always reflect user intention. For example, clicking the label of an interactive form\n element will briefly blur it.\n The mouse-caused events are handled in the global `onMouseUp` handler of the substep\n context instead.\n */\n return;\n }\n\n if (!subStepRef.current || !event.relatedTarget || !nodeBelongs(subStepRef.current, event.relatedTarget)) {\n isFocusedSubStep.current = false;\n\n if (funnelInteractionId && subStepId && funnelState.current !== 'cancelled') {\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n }\n };\n\n const funnelSubStepProps: Record<string, any> = funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_SUBSTEP]: subStepId,\n onFocus,\n onBlur,\n }\n : {};\n\n return { funnelSubStepProps, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with FunnelStep.\n * This hook will provide necessary properties required to track\n * and manage interactions with a FunnelStep component.\n *\n * The 'data-analytics-funnel-step' property of funnelStepProps is used to track the index of the current step in the funnel.\n * The context contains additional properties of the FunnelStep.\n */\nexport const useFunnelStep = () => {\n const context = useContext(FunnelStepContext);\n return context;\n};\n\n/**\n * Custom React Hook to manage and interact with Funnel.\n * This hook will provide necessary properties required to track\n * and manage interactions with a Funnel component.\n *\n * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.\n */\nexport const useFunnel = () => {\n const context = useContext(FunnelContext);\n const funnelProps: Record<string, string | number | boolean | undefined> = context.funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_INTERACTION_ID]: context.funnelInteractionId,\n }\n : {};\n\n return { funnelProps, ...context };\n};\n\nexport const useFunnelNameSelector = () => {\n const context = useContext(FunnelNameSelectorContext);\n return context;\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface AnalyticsMetadata {
|
|
2
|
-
|
|
2
|
+
instanceIdentifier?: string;
|
|
3
3
|
flowType?: 'create' | 'edit';
|
|
4
4
|
errorContext?: string;
|
|
5
5
|
}
|
|
@@ -8,7 +8,7 @@ export interface BaseFunnelProps {
|
|
|
8
8
|
funnelInteractionId: string;
|
|
9
9
|
}
|
|
10
10
|
export interface FunnelProps extends BaseFunnelProps {
|
|
11
|
-
|
|
11
|
+
instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];
|
|
12
12
|
flowType?: AnalyticsMetadata['flowType'];
|
|
13
13
|
totalFunnelSteps: number;
|
|
14
14
|
optionalStepNumbers: number[];
|
|
@@ -16,7 +16,7 @@ export interface FunnelProps extends BaseFunnelProps {
|
|
|
16
16
|
funnelNameSelector?: string;
|
|
17
17
|
}
|
|
18
18
|
export interface FunnelStartProps {
|
|
19
|
-
|
|
19
|
+
instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];
|
|
20
20
|
flowType?: AnalyticsMetadata['flowType'];
|
|
21
21
|
funnelNameSelector: string;
|
|
22
22
|
totalFunnelSteps: number;
|
|
@@ -30,7 +30,7 @@ export interface FunnelStartProps {
|
|
|
30
30
|
export type FunnelMethod<T extends BaseFunnelProps> = (props: T) => void;
|
|
31
31
|
export type FunnelStartMethod = (props: FunnelStartProps) => string;
|
|
32
32
|
export interface FunnelStepProps extends BaseFunnelProps {
|
|
33
|
-
|
|
33
|
+
instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];
|
|
34
34
|
stepNumber: number;
|
|
35
35
|
stepName?: string | undefined;
|
|
36
36
|
stepNameSelector: string;
|
|
@@ -50,9 +50,10 @@ export interface FunnelStepNavigationProps extends FunnelStepProps {
|
|
|
50
50
|
}
|
|
51
51
|
export interface FunnelStepErrorProps extends FunnelStepProps {
|
|
52
52
|
stepErrorSelector: string;
|
|
53
|
+
errorContext?: AnalyticsMetadata['errorContext'];
|
|
53
54
|
}
|
|
54
55
|
export interface FunnelSubStepProps extends FunnelStepProps {
|
|
55
|
-
|
|
56
|
+
instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];
|
|
56
57
|
subStepSelector: string;
|
|
57
58
|
subStepName?: string | undefined;
|
|
58
59
|
subStepNameSelector: string;
|
|
@@ -61,10 +62,12 @@ export interface FunnelSubStepProps extends FunnelStepProps {
|
|
|
61
62
|
export interface FunnelSubStepErrorProps extends FunnelSubStepProps {
|
|
62
63
|
fieldLabelSelector: string;
|
|
63
64
|
fieldErrorSelector: string;
|
|
65
|
+
errorContext?: AnalyticsMetadata['errorContext'];
|
|
64
66
|
}
|
|
65
67
|
export interface OptionalFunnelSubStepErrorProps extends FunnelSubStepProps {
|
|
66
68
|
fieldLabelSelector?: string;
|
|
67
69
|
fieldErrorSelector?: string;
|
|
70
|
+
errorContext?: AnalyticsMetadata['errorContext'];
|
|
68
71
|
}
|
|
69
72
|
export interface FunnelLinkInteractionProps extends FunnelSubStepProps {
|
|
70
73
|
elementSelector: string;
|
|
@@ -73,7 +76,7 @@ export interface FunnelChangeProps extends BaseFunnelProps {
|
|
|
73
76
|
stepConfiguration: StepConfiguration[];
|
|
74
77
|
}
|
|
75
78
|
export interface FunnelStepChangeProps extends BaseFunnelProps {
|
|
76
|
-
|
|
79
|
+
instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];
|
|
77
80
|
stepNumber: number;
|
|
78
81
|
stepName: string;
|
|
79
82
|
stepNameSelector: string;
|
|
@@ -90,9 +93,12 @@ export interface SubStepConfiguration {
|
|
|
90
93
|
number: number;
|
|
91
94
|
name: string;
|
|
92
95
|
}
|
|
96
|
+
export interface FunnelErrorProps extends BaseFunnelProps {
|
|
97
|
+
errorContext?: AnalyticsMetadata['errorContext'];
|
|
98
|
+
}
|
|
93
99
|
export interface IFunnelMetrics {
|
|
94
100
|
funnelStart: FunnelStartMethod;
|
|
95
|
-
funnelError: FunnelMethod<
|
|
101
|
+
funnelError: FunnelMethod<FunnelErrorProps>;
|
|
96
102
|
funnelComplete: FunnelMethod<BaseFunnelProps>;
|
|
97
103
|
funnelSuccessful: FunnelMethod<BaseFunnelProps>;
|
|
98
104
|
funnelCancelled: FunnelMethod<BaseFunnelProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/internal/analytics/interfaces.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/internal/analytics/interfaces.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,YAAY,CAAC;AAGtD,MAAM,WAAW,eAAe;IAC9B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,kBAAkB,CAAC,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;IAC7D,QAAQ,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC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,CAAC,0BAA0B,CAAC,CAAC;CAClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/internal/analytics/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n// TODO: Replace with correct type from component-toolkit\nexport interface AnalyticsMetadata {\n
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/internal/analytics/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n// TODO: Replace with correct type from component-toolkit\nexport interface AnalyticsMetadata {\n instanceIdentifier?: string;\n flowType?: 'create' | 'edit';\n errorContext?: string;\n}\n\nexport type FunnelType = 'single-page' | 'multi-page';\n\n// Common properties for all funnels\nexport interface BaseFunnelProps {\n funnelInteractionId: string;\n}\n\nexport interface FunnelProps extends BaseFunnelProps {\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n flowType?: AnalyticsMetadata['flowType'];\n totalFunnelSteps: number;\n optionalStepNumbers: number[];\n funnelType: FunnelType;\n funnelNameSelector?: string;\n}\n\nexport interface FunnelStartProps {\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n flowType?: AnalyticsMetadata['flowType'];\n funnelNameSelector: string;\n totalFunnelSteps: number;\n optionalStepNumbers: number[];\n stepConfiguration?: StepConfiguration[];\n funnelType: FunnelType;\n funnelVersion: string;\n componentVersion: string;\n theme: string;\n}\n\n// A function type for a generic funnel method\nexport type FunnelMethod<T extends BaseFunnelProps> = (props: T) => void;\n\n// A function type specifically for funnelStart\nexport type FunnelStartMethod = (props: FunnelStartProps) => string;\n\n// Define individual method props by extending the base\nexport interface FunnelStepProps extends BaseFunnelProps {\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n stepNumber: number;\n stepName?: string | undefined;\n stepNameSelector: string;\n subStepAllSelector: string;\n}\n\nexport interface FunnelStepStartProps extends FunnelStepProps {\n totalSubSteps?: number;\n subStepConfiguration?: SubStepConfiguration[];\n}\nexport interface FunnelStepCompleteProps extends FunnelStepProps {\n totalSubSteps?: number;\n}\n\nexport interface FunnelStepNavigationProps extends FunnelStepProps {\n destinationStepNumber: number;\n navigationType: string;\n totalSubSteps?: number;\n}\n\nexport interface FunnelStepErrorProps extends FunnelStepProps {\n stepErrorSelector: string;\n errorContext?: AnalyticsMetadata['errorContext'];\n}\n\nexport interface FunnelSubStepProps extends FunnelStepProps {\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n subStepSelector: string;\n subStepName?: string | undefined;\n subStepNameSelector: string;\n subStepNumber?: number;\n}\n\nexport interface FunnelSubStepErrorProps extends FunnelSubStepProps {\n fieldLabelSelector: string;\n fieldErrorSelector: string;\n errorContext?: AnalyticsMetadata['errorContext'];\n}\n\nexport interface OptionalFunnelSubStepErrorProps extends FunnelSubStepProps {\n fieldLabelSelector?: string;\n fieldErrorSelector?: string;\n errorContext?: AnalyticsMetadata['errorContext'];\n}\n\nexport interface FunnelLinkInteractionProps extends FunnelSubStepProps {\n elementSelector: string;\n}\n\nexport interface FunnelChangeProps extends BaseFunnelProps {\n stepConfiguration: StepConfiguration[];\n}\n\nexport interface FunnelStepChangeProps extends BaseFunnelProps {\n instanceIdentifier?: AnalyticsMetadata['instanceIdentifier'];\n stepNumber: number;\n stepName: string;\n stepNameSelector: string;\n subStepAllSelector: string;\n totalSubSteps: number;\n subStepConfiguration: SubStepConfiguration[];\n}\n\nexport interface StepConfiguration {\n number: number;\n name: string;\n isOptional: boolean;\n}\n\nexport interface SubStepConfiguration {\n number: number;\n name: string;\n}\n\nexport interface FunnelErrorProps extends BaseFunnelProps {\n errorContext?: AnalyticsMetadata['errorContext'];\n}\n\n// Define the interface using the method type\nexport interface IFunnelMetrics {\n funnelStart: FunnelStartMethod;\n funnelError: FunnelMethod<FunnelErrorProps>;\n funnelComplete: FunnelMethod<BaseFunnelProps>;\n funnelSuccessful: FunnelMethod<BaseFunnelProps>;\n funnelCancelled: FunnelMethod<BaseFunnelProps>;\n funnelChange: FunnelMethod<FunnelChangeProps>;\n\n funnelStepStart: FunnelMethod<FunnelStepStartProps>;\n funnelStepComplete: FunnelMethod<FunnelStepCompleteProps>;\n funnelStepNavigation: FunnelMethod<FunnelStepNavigationProps>;\n funnelStepError: FunnelMethod<FunnelStepErrorProps>;\n funnelStepChange: FunnelMethod<FunnelStepChangeProps>;\n\n funnelSubStepStart: FunnelMethod<FunnelSubStepProps>;\n funnelSubStepComplete: FunnelMethod<FunnelSubStepProps>;\n funnelSubStepError: FunnelMethod<OptionalFunnelSubStepErrorProps>;\n\n helpPanelInteracted: FunnelMethod<FunnelLinkInteractionProps>;\n externalLinkInteracted: FunnelMethod<FunnelLinkInteractionProps>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-header.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/container-header.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAOzD,eAAO,MAAM,8BAA8B;eAA+B,MAAM,SAAS;iBAExF,CAAC;AACF,eAAO,MAAM,kBAAkB,eAG9B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React, { createContext, useContext } from 'react';
|
|
4
|
+
const ContainerHeaderContext = createContext({ isInContainer: false });
|
|
5
|
+
export const ContainerHeaderContextProvider = ({ children }) => {
|
|
6
|
+
return React.createElement(ContainerHeaderContext.Provider, { value: { isInContainer: true } }, children);
|
|
7
|
+
};
|
|
8
|
+
export const useContainerHeader = () => {
|
|
9
|
+
const { isInContainer } = useContext(ContainerHeaderContext);
|
|
10
|
+
return isInContainer;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=container-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-header.js","sourceRoot":"","sources":["../../../../src/internal/context/container-header.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAMzD,MAAM,sBAAsB,GAAG,aAAa,CAA8B,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AACpG,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAAE,QAAQ,EAAkC,EAAE,EAAE;IAC7F,OAAO,oBAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,IAAG,QAAQ,CAAmC,CAAC;AACvH,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAC7D,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { createContext, useContext } from 'react';\n\ninterface ContainerHeaderContextProps {\n isInContainer: boolean;\n}\n\nconst ContainerHeaderContext = createContext<ContainerHeaderContextProps>({ isInContainer: false });\nexport const ContainerHeaderContextProvider = ({ children }: { children?: React.ReactNode }) => {\n return <ContainerHeaderContext.Provider value={{ isInContainer: true }}>{children}</ContainerHeaderContext.Provider>;\n};\nexport const useContainerHeader = () => {\n const { isInContainer } = useContext(ContainerHeaderContext);\n return isInContainer;\n};\n"]}
|
package/internal/environment.js
CHANGED