@cloudscape-design/components 3.0.807 → 3.0.808
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/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/hooks/use-table-interaction-metrics/index.d.ts.map +1 -1
- package/internal/hooks/use-table-interaction-metrics/index.js +15 -8
- package/internal/hooks/use-table-interaction-metrics/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
package/internal/environment.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAWxD,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACzC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACjD,yBAAyB,EAAE,MAAM,UAAU,CAAC;IAC5C,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AAED,wBAAgB,0BAA0B,CAAC,EACzC,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,OAAe,EACf,mBAAmB,GACpB,EAAE,+BAA+B;;;;8BAkEJ,MAAM;EAEnC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
4
|
import { ComponentMetrics, PerformanceMetrics } from '../../analytics';
|
|
5
|
+
import { useFunnel } from '../../analytics/hooks/use-funnel';
|
|
5
6
|
import { useDOMAttribute } from '../use-dom-attribute';
|
|
6
7
|
import { useEffectOnUpdate } from '../use-effect-on-update';
|
|
7
8
|
import { useRandomId } from '../use-unique-id';
|
|
@@ -13,18 +14,22 @@ const USER_ACTION_TIME_LIMIT = 1000;
|
|
|
13
14
|
export function useTableInteractionMetrics({ elementRef, itemCount, instanceIdentifier, getComponentIdentifier, getComponentConfiguration, loading = false, interactionMetadata, }) {
|
|
14
15
|
const taskInteractionId = useRandomId();
|
|
15
16
|
const tableInteractionAttributes = useDOMAttribute(elementRef, 'data-analytics-task-interaction-id', taskInteractionId);
|
|
17
|
+
const { isInFunnel } = useFunnel();
|
|
16
18
|
const lastUserAction = useRef(null);
|
|
17
19
|
const capturedUserAction = useRef(null);
|
|
18
20
|
const loadingStartTime = useRef(null);
|
|
19
21
|
const metadata = useRef({ itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata });
|
|
20
22
|
metadata.current = { itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata };
|
|
21
23
|
useEffect(() => {
|
|
24
|
+
if (isInFunnel) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
22
27
|
ComponentMetrics.componentMounted({
|
|
23
28
|
taskInteractionId,
|
|
24
29
|
componentName: 'table',
|
|
25
30
|
componentConfiguration: metadata.current.getComponentConfiguration(),
|
|
26
31
|
});
|
|
27
|
-
}, [taskInteractionId]);
|
|
32
|
+
}, [taskInteractionId, isInFunnel]);
|
|
28
33
|
useEffect(() => {
|
|
29
34
|
if (loading) {
|
|
30
35
|
loadingStartTime.current = performance.now();
|
|
@@ -49,14 +54,16 @@ export function useTableInteractionMetrics({ elementRef, itemCount, instanceIden
|
|
|
49
54
|
instanceIdentifier,
|
|
50
55
|
noOfResourcesInTable: metadata.current.itemCount,
|
|
51
56
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
if (!isInFunnel) {
|
|
58
|
+
ComponentMetrics.componentUpdated({
|
|
59
|
+
taskInteractionId,
|
|
60
|
+
componentName: 'table',
|
|
61
|
+
actionType: (_b = capturedUserAction.current) !== null && _b !== void 0 ? _b : '',
|
|
62
|
+
componentConfiguration: metadata.current.getComponentConfiguration(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
58
65
|
}
|
|
59
|
-
}, [instanceIdentifier, loading, taskInteractionId]);
|
|
66
|
+
}, [instanceIdentifier, loading, taskInteractionId, isInFunnel]);
|
|
60
67
|
return {
|
|
61
68
|
tableInteractionAttributes,
|
|
62
69
|
setLastUserAction: (name) => void (lastUserAction.current = { name, time: performance.now() }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;EAGE;AACF,MAAM,sB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CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC;KACvG,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useRef } from 'react';\n\nimport { ComponentMetrics, PerformanceMetrics } from '../../analytics';\nimport { useFunnel } from '../../analytics/hooks/use-funnel';\nimport { JSONObject } from '../../analytics/interfaces';\nimport { useDOMAttribute } from '../use-dom-attribute';\nimport { useEffectOnUpdate } from '../use-effect-on-update';\nimport { useRandomId } from '../use-unique-id';\n\n/*\nIf the last user interaction is more than this time ago, it is not considered\nto be the cause of the current loading state.\n*/\nconst USER_ACTION_TIME_LIMIT = 1_000;\n\nexport interface UseTableInteractionMetricsProps {\n elementRef: React.RefObject<HTMLElement>;\n instanceIdentifier: string | undefined;\n loading: boolean | undefined;\n itemCount: number;\n getComponentIdentifier: () => string | undefined;\n getComponentConfiguration: () => JSONObject;\n interactionMetadata: () => string;\n}\n\nexport function useTableInteractionMetrics({\n elementRef,\n itemCount,\n instanceIdentifier,\n getComponentIdentifier,\n getComponentConfiguration,\n loading = false,\n interactionMetadata,\n}: UseTableInteractionMetricsProps) {\n const taskInteractionId = useRandomId();\n const tableInteractionAttributes = useDOMAttribute(\n elementRef,\n 'data-analytics-task-interaction-id',\n taskInteractionId\n );\n const { isInFunnel } = useFunnel();\n const lastUserAction = useRef<{ name: string; time: number } | null>(null);\n const capturedUserAction = useRef<string | null>(null);\n const loadingStartTime = useRef<number | null>(null);\n\n const metadata = useRef({ itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata });\n metadata.current = { itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata };\n\n useEffect(() => {\n if (isInFunnel) {\n return;\n }\n\n ComponentMetrics.componentMounted({\n taskInteractionId,\n componentName: 'table',\n componentConfiguration: metadata.current.getComponentConfiguration(),\n });\n }, [taskInteractionId, isInFunnel]);\n\n useEffect(() => {\n if (loading) {\n loadingStartTime.current = performance.now();\n\n if (lastUserAction.current && lastUserAction.current.time > performance.now() - USER_ACTION_TIME_LIMIT) {\n capturedUserAction.current = lastUserAction.current.name;\n } else {\n capturedUserAction.current = null;\n }\n }\n }, [loading]);\n\n useEffectOnUpdate(() => {\n if (!loading && loadingStartTime.current !== null) {\n const loadingDuration = performance.now() - loadingStartTime.current;\n loadingStartTime.current = null;\n\n PerformanceMetrics.tableInteraction({\n userAction: capturedUserAction.current ?? '',\n interactionTime: Math.round(loadingDuration),\n interactionMetadata: metadata.current.interactionMetadata(),\n componentIdentifier: metadata.current.getComponentIdentifier(),\n instanceIdentifier,\n noOfResourcesInTable: metadata.current.itemCount,\n });\n\n if (!isInFunnel) {\n ComponentMetrics.componentUpdated({\n taskInteractionId,\n componentName: 'table',\n actionType: capturedUserAction.current ?? '',\n componentConfiguration: metadata.current.getComponentConfiguration(),\n });\n }\n }\n }, [instanceIdentifier, loading, taskInteractionId, isInFunnel]);\n\n return {\n tableInteractionAttributes,\n setLastUserAction: (name: string) => void (lastUserAction.current = { name, time: performance.now() }),\n };\n}\n"]}
|
package/internal/manifest.json
CHANGED
package/package.json
CHANGED