@cloudscape-design/components 3.0.189 → 3.0.191
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/app-layout/drawer.d.ts +1 -4
- package/app-layout/drawer.d.ts.map +1 -1
- package/app-layout/drawer.js +4 -13
- package/app-layout/drawer.js.map +1 -1
- package/app-layout/index.d.ts.map +1 -1
- package/app-layout/index.js +4 -15
- package/app-layout/index.js.map +1 -1
- package/app-layout/mobile-toolbar/index.js +3 -3
- package/app-layout/mobile-toolbar/index.js.map +1 -1
- package/app-layout/navigation-panel.d.ts +1 -3
- package/app-layout/navigation-panel.d.ts.map +1 -1
- package/app-layout/navigation-panel.js +2 -2
- package/app-layout/navigation-panel.js.map +1 -1
- package/app-layout/notifications/index.d.ts +0 -4
- package/app-layout/notifications/index.d.ts.map +1 -1
- package/app-layout/notifications/index.js +1 -2
- package/app-layout/notifications/index.js.map +1 -1
- package/app-layout/styles.css.js +26 -38
- package/app-layout/styles.scoped.css +34 -109
- package/app-layout/styles.selectors.js +26 -38
- package/app-layout/tools-and-split-panel.d.ts +1 -8
- package/app-layout/tools-and-split-panel.d.ts.map +1 -1
- package/app-layout/tools-and-split-panel.js +2 -3
- package/app-layout/tools-and-split-panel.js.map +1 -1
- package/flashbar/collapsible-flashbar.d.ts.map +1 -1
- package/flashbar/collapsible-flashbar.js +5 -7
- package/flashbar/collapsible-flashbar.js.map +1 -1
- package/flashbar/internal/analytics.d.ts.map +1 -1
- package/flashbar/internal/analytics.js +5 -3
- package/flashbar/internal/analytics.js.map +1 -1
- package/flashbar/styles.css.js +43 -43
- package/flashbar/styles.scoped.css +146 -139
- package/flashbar/styles.selectors.js +43 -43
- package/internal/base-component/index.d.ts.map +1 -1
- package/internal/base-component/index.js +3 -11
- package/internal/base-component/index.js.map +1 -1
- package/internal/base-component/init-awsui-versions.d.ts +2 -0
- package/internal/base-component/init-awsui-versions.d.ts.map +1 -0
- package/internal/base-component/init-awsui-versions.js +15 -0
- package/internal/base-component/init-awsui-versions.js.map +1 -0
- package/internal/environment.d.ts +1 -0
- package/internal/environment.js +2 -1
- package/internal/hooks/use-base-component/component-metadata.d.ts +3 -0
- package/internal/hooks/use-base-component/component-metadata.d.ts.map +1 -0
- package/internal/hooks/use-base-component/component-metadata.js +21 -0
- package/internal/hooks/use-base-component/component-metadata.js.map +1 -0
- package/internal/hooks/use-base-component/index.d.ts +0 -1
- package/internal/hooks/use-base-component/index.d.ts.map +1 -1
- package/internal/hooks/use-base-component/index.js +3 -28
- package/internal/hooks/use-base-component/index.js.map +1 -1
- package/internal/hooks/use-telemetry/index.d.ts.map +1 -1
- package/internal/hooks/use-telemetry/index.js +4 -15
- package/internal/hooks/use-telemetry/index.js.map +1 -1
- package/internal/hooks/use-telemetry/telemetry.d.ts +8 -0
- package/internal/hooks/use-telemetry/telemetry.d.ts.map +1 -0
- package/internal/hooks/use-telemetry/telemetry.js +20 -0
- package/internal/hooks/use-telemetry/telemetry.js.map +1 -0
- package/internal/manifest.json +1 -1
- package/internal/metrics/index.d.ts +3 -0
- package/internal/metrics/index.d.ts.map +1 -0
- package/internal/metrics/index.js +5 -0
- package/internal/metrics/index.js.map +1 -0
- package/internal/metrics/log-clients.d.ts +39 -0
- package/internal/metrics/log-clients.d.ts.map +1 -0
- package/internal/metrics/log-clients.js +90 -0
- package/internal/metrics/log-clients.js.map +1 -0
- package/internal/metrics/metrics-formatters.d.ts +7 -0
- package/internal/metrics/metrics-formatters.d.ts.map +1 -0
- package/internal/metrics/metrics-formatters.js +36 -0
- package/internal/metrics/metrics-formatters.js.map +1 -0
- package/internal/{metrics.d.ts → metrics/metrics.d.ts} +11 -18
- package/internal/metrics/metrics.d.ts.map +1 -0
- package/internal/metrics/metrics.js +95 -0
- package/internal/metrics/metrics.js.map +1 -0
- package/package.json +1 -1
- package/property-filter/index.d.ts.map +1 -1
- package/property-filter/index.js +1 -1
- package/property-filter/index.js.map +1 -1
- package/wizard/internal/analytics.d.ts.map +1 -1
- package/wizard/internal/analytics.js +5 -3
- package/wizard/internal/analytics.js.map +1 -1
- package/app-layout/toggle-buttons.d.ts +0 -12
- package/app-layout/toggle-buttons.d.ts.map +0 -1
- package/app-layout/toggle-buttons.js +0 -13
- package/app-layout/toggle-buttons.js.map +0 -1
- package/internal/hooks/use-previous-frame/index.d.ts +0 -8
- package/internal/hooks/use-previous-frame/index.d.ts.map +0 -1
- package/internal/hooks/use-previous-frame/index.js +0 -20
- package/internal/hooks/use-previous-frame/index.js.map +0 -1
- package/internal/metrics.d.ts.map +0 -1
- package/internal/metrics.js +0 -177
- package/internal/metrics.js.map +0 -1
|
@@ -2,48 +2,48 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"flash-with-motion": "awsui_flash-with-
|
|
6
|
-
"enter": "
|
|
7
|
-
"flash-body": "awsui_flash-
|
|
8
|
-
"flash-message": "awsui_flash-
|
|
9
|
-
"flash-header": "awsui_flash-
|
|
10
|
-
"flash-content": "awsui_flash-
|
|
11
|
-
"action-button-wrapper": "awsui_action-button-
|
|
12
|
-
"dismiss-button-wrapper": "awsui_dismiss-button-
|
|
13
|
-
"flash-icon": "awsui_flash-
|
|
14
|
-
"entering": "
|
|
15
|
-
"entered": "
|
|
16
|
-
"exiting": "
|
|
17
|
-
"stack": "
|
|
18
|
-
"animation-running": "awsui_animation-
|
|
19
|
-
"item": "
|
|
20
|
-
"flash-list-item": "awsui_flash-list-
|
|
21
|
-
"toggle": "
|
|
22
|
-
"collapsed": "
|
|
23
|
-
"animation-ready": "awsui_animation-
|
|
24
|
-
"expanded-only": "awsui_expanded-
|
|
25
|
-
"expanded": "
|
|
26
|
-
"flash": "
|
|
27
|
-
"status": "
|
|
28
|
-
"header": "
|
|
29
|
-
"item-count": "awsui_item-
|
|
30
|
-
"button": "
|
|
31
|
-
"type-count": "awsui_type-
|
|
32
|
-
"count-number": "awsui_count-
|
|
33
|
-
"visual-refresh": "awsui_visual-
|
|
34
|
-
"icon": "
|
|
35
|
-
"spaced-bottom": "awsui_spaced-
|
|
36
|
-
"flashbar": "
|
|
37
|
-
"flash-refresh": "awsui_flash-
|
|
38
|
-
"flash-list": "awsui_flash-
|
|
39
|
-
"flash-focus-container": "awsui_flash-focus-
|
|
40
|
-
"flash-text": "awsui_flash-
|
|
41
|
-
"dismiss-button": "awsui_dismiss-
|
|
42
|
-
"breakpoint-default": "awsui_breakpoint-
|
|
43
|
-
"action-button": "awsui_action-
|
|
44
|
-
"flash-type-success": "awsui_flash-type-
|
|
45
|
-
"flash-type-error": "awsui_flash-type-
|
|
46
|
-
"flash-type-warning": "awsui_flash-type-
|
|
47
|
-
"flash-type-info": "awsui_flash-type-
|
|
5
|
+
"flash-with-motion": "awsui_flash-with-motion_1q84n_1y0ju_93",
|
|
6
|
+
"enter": "awsui_enter_1q84n_1y0ju_93",
|
|
7
|
+
"flash-body": "awsui_flash-body_1q84n_1y0ju_107",
|
|
8
|
+
"flash-message": "awsui_flash-message_1q84n_1y0ju_107",
|
|
9
|
+
"flash-header": "awsui_flash-header_1q84n_1y0ju_107",
|
|
10
|
+
"flash-content": "awsui_flash-content_1q84n_1y0ju_108",
|
|
11
|
+
"action-button-wrapper": "awsui_action-button-wrapper_1q84n_1y0ju_109",
|
|
12
|
+
"dismiss-button-wrapper": "awsui_dismiss-button-wrapper_1q84n_1y0ju_110",
|
|
13
|
+
"flash-icon": "awsui_flash-icon_1q84n_1y0ju_133",
|
|
14
|
+
"entering": "awsui_entering_1q84n_1y0ju_146",
|
|
15
|
+
"entered": "awsui_entered_1q84n_1y0ju_167",
|
|
16
|
+
"exiting": "awsui_exiting_1q84n_1y0ju_272",
|
|
17
|
+
"stack": "awsui_stack_1q84n_1y0ju_294",
|
|
18
|
+
"animation-running": "awsui_animation-running_1q84n_1y0ju_294",
|
|
19
|
+
"item": "awsui_item_1q84n_1y0ju_294",
|
|
20
|
+
"flash-list-item": "awsui_flash-list-item_1q84n_1y0ju_295",
|
|
21
|
+
"toggle": "awsui_toggle_1q84n_1y0ju_296",
|
|
22
|
+
"collapsed": "awsui_collapsed_1q84n_1y0ju_316",
|
|
23
|
+
"animation-ready": "awsui_animation-ready_1q84n_1y0ju_316",
|
|
24
|
+
"expanded-only": "awsui_expanded-only_1q84n_1y0ju_316",
|
|
25
|
+
"expanded": "awsui_expanded_1q84n_1y0ju_316",
|
|
26
|
+
"flash": "awsui_flash_1q84n_1y0ju_93",
|
|
27
|
+
"status": "awsui_status_1q84n_1y0ju_403",
|
|
28
|
+
"header": "awsui_header_1q84n_1y0ju_403",
|
|
29
|
+
"item-count": "awsui_item-count_1q84n_1y0ju_404",
|
|
30
|
+
"button": "awsui_button_1q84n_1y0ju_405",
|
|
31
|
+
"type-count": "awsui_type-count_1q84n_1y0ju_430",
|
|
32
|
+
"count-number": "awsui_count-number_1q84n_1y0ju_430",
|
|
33
|
+
"visual-refresh": "awsui_visual-refresh_1q84n_1y0ju_443",
|
|
34
|
+
"icon": "awsui_icon_1q84n_1y0ju_493",
|
|
35
|
+
"spaced-bottom": "awsui_spaced-bottom_1q84n_1y0ju_531",
|
|
36
|
+
"flashbar": "awsui_flashbar_1q84n_1y0ju_539",
|
|
37
|
+
"flash-refresh": "awsui_flash-refresh_1q84n_1y0ju_579",
|
|
38
|
+
"flash-list": "awsui_flash-list_1q84n_1y0ju_295",
|
|
39
|
+
"flash-focus-container": "awsui_flash-focus-container_1q84n_1y0ju_611",
|
|
40
|
+
"flash-text": "awsui_flash-text_1q84n_1y0ju_638",
|
|
41
|
+
"dismiss-button": "awsui_dismiss-button_1q84n_1y0ju_110",
|
|
42
|
+
"breakpoint-default": "awsui_breakpoint-default_1q84n_1y0ju_679",
|
|
43
|
+
"action-button": "awsui_action-button_1q84n_1y0ju_109",
|
|
44
|
+
"flash-type-success": "awsui_flash-type-success_1q84n_1y0ju_692",
|
|
45
|
+
"flash-type-error": "awsui_flash-type-error_1q84n_1y0ju_696",
|
|
46
|
+
"flash-type-warning": "awsui_flash-type-warning_1q84n_1y0ju_700",
|
|
47
|
+
"flash-type-info": "awsui_flash-type-info_1q84n_1y0ju_704"
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/internal/base-component/index.ts"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/internal/base-component/index.ts"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,CAAC;AAMzB,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CAIb;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,sBAQrD"}
|
|
@@ -2,17 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// these styles needed to be imported for every public component
|
|
4
4
|
import './styles.css.js';
|
|
5
|
-
import { PACKAGE_VERSION } from '../environment';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (!window.awsuiVersions) {
|
|
9
|
-
window.awsuiVersions = {};
|
|
10
|
-
}
|
|
11
|
-
if (!window.awsuiVersions.components) {
|
|
12
|
-
window.awsuiVersions.components = [];
|
|
13
|
-
}
|
|
14
|
-
window.awsuiVersions.components.push(PACKAGE_VERSION);
|
|
15
|
-
}
|
|
5
|
+
import { PACKAGE_SOURCE, PACKAGE_VERSION } from '../environment';
|
|
6
|
+
import { initAwsUiVersions } from './init-awsui-versions.js';
|
|
7
|
+
initAwsUiVersions(PACKAGE_SOURCE, PACKAGE_VERSION);
|
|
16
8
|
export function getBaseProps(props) {
|
|
17
9
|
var baseProps = {};
|
|
18
10
|
Object.keys(props).forEach(function (prop) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/base-component/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,gEAAgE;AAChE,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/base-component/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,gEAAgE;AAChE,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,iBAAiB,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;AAkBnD,MAAM,UAAU,YAAY,CAAC,KAAyB;IACpD,IAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAA,IAAI;QAC7B,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;YACjE,SAAS,CAAC,IAAI,CAAC,GAAI,KAA6B,CAAC,IAAI,CAAC,CAAC;SACxD;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAA+B,CAAC;AACzC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n// these styles needed to be imported for every public component\nimport './styles.css.js';\nimport { PACKAGE_SOURCE, PACKAGE_VERSION } from '../environment';\nimport { initAwsUiVersions } from './init-awsui-versions.js';\n\ninitAwsUiVersions(PACKAGE_SOURCE, PACKAGE_VERSION);\n\nexport interface BaseComponentProps {\n /**\n * Adds the specified classes to the root element of the component.\n * @deprecated Custom CSS is not supported. For other use cases, use [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes).\n */\n className?: string;\n /**\n * Adds the specified ID to the root element of the component.\n * @deprecated Custom CSS is not supported. For other use cases, use [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes).\n */\n id?: string;\n // we also support data-* attributes, but they are always implicitly allowed by typescript\n // http://www.typescriptlang.org/docs/handbook/jsx.html#attribute-type-checking\n // \"Note: If an attribute name is not a valid JS identifier (like a data-* attribute), it is not considered to be an error\"\n}\n\nexport function getBaseProps(props: BaseComponentProps) {\n const baseProps: Record<string, any> = {};\n Object.keys(props).forEach(prop => {\n if (prop === 'id' || prop === 'className' || prop.match(/^data-/)) {\n baseProps[prop] = (props as Record<string, any>)[prop];\n }\n });\n return baseProps as BaseComponentProps;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-awsui-versions.d.ts","sourceRoot":"","sources":["../../../../src/internal/base-component/init-awsui-versions.ts"],"names":[],"mappings":"AAYA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,QAUvE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// expose version info, so it can be checked using the browser devtools
|
|
4
|
+
export function initAwsUiVersions(source, packageVersion) {
|
|
5
|
+
if (typeof window !== 'undefined') {
|
|
6
|
+
if (!window.awsuiVersions) {
|
|
7
|
+
window.awsuiVersions = {};
|
|
8
|
+
}
|
|
9
|
+
if (!window.awsuiVersions[source]) {
|
|
10
|
+
window.awsuiVersions[source] = [];
|
|
11
|
+
}
|
|
12
|
+
window.awsuiVersions[source].push(packageVersion);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=init-awsui-versions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-awsui-versions.js","sourceRoot":"","sources":["../../../../src/internal/base-component/init-awsui-versions.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAUtC,uEAAuE;AACvE,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,cAAsB;IACtE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE;YACzB,MAAM,CAAC,aAAa,GAAG,EAAE,CAAC;SAC3B;QACD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;YACjC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;SACnC;QACD,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;KACnD;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n// TODO: move to component-toolkit/internal/base-component\n\n// not using `declare global {}` to avoid polluting customers' typings with this info\ninterface CustomWindow extends Window {\n awsuiVersions?: { [source: string]: string[] };\n}\ndeclare const window: CustomWindow | undefined;\n\n// expose version info, so it can be checked using the browser devtools\nexport function initAwsUiVersions(source: string, packageVersion: string) {\n if (typeof window !== 'undefined') {\n if (!window.awsuiVersions) {\n window.awsuiVersions = {};\n }\n if (!window.awsuiVersions[source]) {\n window.awsuiVersions[source] = [];\n }\n window.awsuiVersions[source].push(packageVersion);\n }\n}\n"]}
|
package/internal/environment.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-metadata.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-base-component/component-metadata.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAE1D,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gCA0B1F"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
// TODO: move to component-toolkit/internal/base-component
|
|
5
|
+
export var COMPONENT_METADATA_KEY = '__awsuiMetadata__';
|
|
6
|
+
export function useComponentMetadata(componentName, packageVersion) {
|
|
7
|
+
var elementRef = useRef(null);
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
if (elementRef.current && !Object.prototype.hasOwnProperty.call(elementRef.current, COMPONENT_METADATA_KEY)) {
|
|
10
|
+
var node = elementRef.current;
|
|
11
|
+
var metadata = { name: componentName, version: packageVersion };
|
|
12
|
+
Object.freeze(metadata);
|
|
13
|
+
Object.defineProperty(node, COMPONENT_METADATA_KEY, { value: metadata, writable: false });
|
|
14
|
+
}
|
|
15
|
+
// Some component refs change dynamically. E.g. The Modal component where
|
|
16
|
+
// the content gets rendered conditionally inside a Portal.
|
|
17
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
+
}, [elementRef.current]);
|
|
19
|
+
return elementRef;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=component-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-base-component/component-metadata.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,0DAA0D;AAE1D,MAAM,CAAC,IAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAE1D,MAAM,UAAU,oBAAoB,CAAU,aAAqB,EAAE,cAAsB;IAUzF,IAAM,UAAU,GAAG,MAAM,CAAI,IAAI,CAAC,CAAC;IAEnC,SAAS,CAAC;QACR,IAAI,UAAU,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,sBAAsB,CAAC,EAAE;YAC3G,IAAM,IAAI,GAAG,UAAU,CAAC,OAAyC,CAAC;YAClE,IAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;YAElE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;SAC3F;QACD,yEAAyE;QACzE,2DAA2D;QAC3D,uDAAuD;IACzD,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IAEzB,OAAO,UAAU,CAAC;AACpB,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\n// TODO: move to component-toolkit/internal/base-component\n\nexport const COMPONENT_METADATA_KEY = '__awsuiMetadata__';\n\nexport function useComponentMetadata<T = any>(componentName: string, packageVersion: string) {\n interface AwsUiMetadata {\n name: string;\n version: string;\n }\n\n interface HTMLMetadataElement extends HTMLElement {\n [COMPONENT_METADATA_KEY]: AwsUiMetadata;\n }\n\n const elementRef = useRef<T>(null);\n\n useEffect(() => {\n if (elementRef.current && !Object.prototype.hasOwnProperty.call(elementRef.current, COMPONENT_METADATA_KEY)) {\n const node = elementRef.current as unknown as HTMLMetadataElement;\n const metadata = { name: componentName, version: packageVersion };\n\n Object.freeze(metadata);\n Object.defineProperty(node, COMPONENT_METADATA_KEY, { value: metadata, writable: false });\n }\n // Some component refs change dynamically. E.g. The Modal component where\n // the content gets rendered conditionally inside a Portal.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [elementRef.current]);\n\n return elementRef;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-base-component/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-base-component/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAKzC,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;CAClD;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,CAAC,GAAG,GAAG,EAAE,aAAa,EAAE,MAAM;;EAItE"}
|
|
@@ -1,39 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { useEffect, useRef } from 'react';
|
|
1
|
+
import { useComponentMetadata } from './component-metadata';
|
|
4
2
|
import { useTelemetry } from '../use-telemetry';
|
|
5
3
|
import { PACKAGE_VERSION } from '../../environment';
|
|
6
|
-
export var COMPONENT_METADATA_KEY = '__awsuiMetadata__';
|
|
7
4
|
/**
|
|
8
5
|
* This hook is used for components which are exported to customers. The returned __internalRootRef needs to be
|
|
9
6
|
* attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this
|
|
10
7
|
* root DOM node and emits the telemetry for this component.
|
|
11
8
|
*/
|
|
12
9
|
export default function useBaseComponent(componentName) {
|
|
13
|
-
var elementRef = useRef(null);
|
|
14
10
|
useTelemetry(componentName);
|
|
15
|
-
useComponentMetadata(componentName,
|
|
16
|
-
return {
|
|
17
|
-
__internalRootRef: elementRef
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function useComponentMetadata(componentName, elementRef) {
|
|
21
|
-
useEffect(function () {
|
|
22
|
-
if (elementRef.current && !Object.prototype.hasOwnProperty.call(elementRef.current, COMPONENT_METADATA_KEY)) {
|
|
23
|
-
var node = elementRef.current;
|
|
24
|
-
var metadata = {
|
|
25
|
-
name: componentName,
|
|
26
|
-
version: PACKAGE_VERSION
|
|
27
|
-
};
|
|
28
|
-
Object.freeze(metadata);
|
|
29
|
-
Object.defineProperty(node, COMPONENT_METADATA_KEY, {
|
|
30
|
-
value: metadata,
|
|
31
|
-
writable: false
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
// Some component refs change dynamically. E.g. The Modal component where
|
|
35
|
-
// the content gets rendered conditionally inside a Portal.
|
|
36
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
-
}, [elementRef.current]);
|
|
11
|
+
var elementRef = useComponentMetadata(componentName, PACKAGE_VERSION);
|
|
12
|
+
return { __internalRootRef: elementRef };
|
|
38
13
|
}
|
|
39
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-base-component/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-base-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMpD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAU,aAAqB;IACrE,YAAY,CAAC,aAAa,CAAC,CAAC;IAC5B,IAAM,UAAU,GAAG,oBAAoB,CAAI,aAAa,EAAE,eAAe,CAAC,CAAC;IAC3E,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { MutableRefObject } from 'react';\nimport { useComponentMetadata } from './component-metadata';\nimport { useTelemetry } from '../use-telemetry';\nimport { PACKAGE_VERSION } from '../../environment';\n\nexport interface InternalBaseComponentProps {\n __internalRootRef?: MutableRefObject<any> | null;\n}\n\n/**\n * This hook is used for components which are exported to customers. The returned __internalRootRef needs to be\n * attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this\n * root DOM node and emits the telemetry for this component.\n */\nexport default function useBaseComponent<T = any>(componentName: string) {\n useTelemetry(componentName);\n const elementRef = useComponentMetadata<T>(componentName, PACKAGE_VERSION);\n return { __internalRootRef: elementRef };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/index.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,QAGjD"}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import {
|
|
4
|
-
import { THEME } from '../../environment';
|
|
5
|
-
import { Metrics } from '../../metrics';
|
|
3
|
+
import { PACKAGE_SOURCE, PACKAGE_VERSION, THEME } from '../../environment';
|
|
6
4
|
import { useVisualRefresh } from '../use-visual-mode';
|
|
5
|
+
import * as telemetry from './telemetry';
|
|
7
6
|
export function useTelemetry(componentName) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
Metrics.initMetrics(isVisualRefresh ? 'vr' : THEME);
|
|
11
|
-
if (typeof window !== 'undefined') {
|
|
12
|
-
Metrics.sendMetricOnce('awsui-viewport-width', window.innerWidth || 0);
|
|
13
|
-
Metrics.sendMetricOnce('awsui-viewport-height', window.innerHeight || 0);
|
|
14
|
-
}
|
|
15
|
-
Metrics.logComponentLoaded();
|
|
16
|
-
Metrics.logComponentUsed(componentName.toLowerCase());
|
|
17
|
-
// Components do not change the name dynamically. Explicit empty array to prevent accidential double metrics
|
|
18
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
-
}, []);
|
|
7
|
+
var theme = useVisualRefresh() ? 'vr' : THEME;
|
|
8
|
+
telemetry.useTelemetry(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme: theme });
|
|
20
9
|
}
|
|
21
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,YAAY,CAAC,aAAqB;IAChD,IAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAChD,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;AACnH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PACKAGE_SOURCE, PACKAGE_VERSION, THEME } from '../../environment';\nimport { useVisualRefresh } from '../use-visual-mode';\nimport * as telemetry from './telemetry';\n\nexport function useTelemetry(componentName: string) {\n const theme = useVisualRefresh() ? 'vr' : THEME;\n telemetry.useTelemetry(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme });\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface Settings {
|
|
2
|
+
packageSource: string;
|
|
3
|
+
packageVersion: string;
|
|
4
|
+
theme: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function useTelemetry(componentName: string, { packageSource, packageVersion, theme }: Settings): void;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/telemetry.ts"],"names":[],"mappings":"AAQA,UAAU,QAAQ;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,QAAQ,QAcrG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { Metrics } from '../../metrics/metrics';
|
|
5
|
+
export function useTelemetry(componentName, _a) {
|
|
6
|
+
var packageSource = _a.packageSource, packageVersion = _a.packageVersion, theme = _a.theme;
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
var metrics = new Metrics(packageSource, packageVersion);
|
|
9
|
+
metrics.initMetrics(theme);
|
|
10
|
+
if (typeof window !== 'undefined') {
|
|
11
|
+
metrics.sendMetricOnce('awsui-viewport-width', window.innerWidth || 0);
|
|
12
|
+
metrics.sendMetricOnce('awsui-viewport-height', window.innerHeight || 0);
|
|
13
|
+
}
|
|
14
|
+
metrics.logComponentLoaded();
|
|
15
|
+
metrics.logComponentUsed(componentName.toLowerCase());
|
|
16
|
+
// Components do not change the name dynamically. Explicit empty array to prevent accidental double metrics
|
|
17
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
+
}, []);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/telemetry.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAUhD,MAAM,UAAU,YAAY,CAAC,aAAqB,EAAE,EAAkD;QAAhD,aAAa,mBAAA,EAAE,cAAc,oBAAA,EAAE,KAAK,WAAA;IACxF,SAAS,CAAC;QACR,IAAM,OAAO,GAAG,IAAI,OAAO,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAE3D,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC3B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,OAAO,CAAC,cAAc,CAAC,sBAAsB,EAAE,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;YACvE,OAAO,CAAC,cAAc,CAAC,uBAAuB,EAAE,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;SAC1E;QACD,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC7B,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;QACtD,2GAA2G;QAC3G,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect } from 'react';\nimport { Metrics } from '../../metrics/metrics';\n\n// TODO: move to component-toolkit/internal/base-component\n\ninterface Settings {\n packageSource: string;\n packageVersion: string;\n theme: string;\n}\n\nexport function useTelemetry(componentName: string, { packageSource, packageVersion, theme }: Settings) {\n useEffect(() => {\n const metrics = new Metrics(packageSource, packageVersion);\n\n metrics.initMetrics(theme);\n if (typeof window !== 'undefined') {\n metrics.sendMetricOnce('awsui-viewport-width', window.innerWidth || 0);\n metrics.sendMetricOnce('awsui-viewport-height', window.innerHeight || 0);\n }\n metrics.logComponentLoaded();\n metrics.logComponentUsed(componentName.toLowerCase());\n // Components do not change the name dynamically. Explicit empty array to prevent accidental double metrics\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n}\n"]}
|
package/internal/manifest.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/internal/metrics/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,iCAAiC,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export { Metrics, MetricsTestHelper } from './metrics';
|
|
4
|
+
export { formatMajorVersionForMetricDetail, formatVersionForMetricName } from './metrics-formatters';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/metrics/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,iCAAiC,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { Metrics, MetricsTestHelper } from './metrics';\nexport { formatMajorVersionForMetricDetail, formatVersionForMetricName } from './metrics-formatters';\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface AWSC {
|
|
2
|
+
Clog: any;
|
|
3
|
+
}
|
|
4
|
+
export interface MetricsWindow extends Window {
|
|
5
|
+
AWSC?: AWSC;
|
|
6
|
+
panorama?: any;
|
|
7
|
+
}
|
|
8
|
+
export interface MetricsV2EventItem {
|
|
9
|
+
eventType?: string;
|
|
10
|
+
eventContext?: string;
|
|
11
|
+
eventDetail?: string | Record<string, string | number | boolean>;
|
|
12
|
+
eventValue?: string | Record<string, string | number | boolean>;
|
|
13
|
+
}
|
|
14
|
+
export interface MetricsLogItem {
|
|
15
|
+
source: string;
|
|
16
|
+
action: string;
|
|
17
|
+
version: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Console Platform's client logging JS API client.
|
|
21
|
+
*/
|
|
22
|
+
export declare class CLogClient {
|
|
23
|
+
/**
|
|
24
|
+
* Sends metric but only if Console Platform client logging JS API is present in the page.
|
|
25
|
+
*/
|
|
26
|
+
sendMetric(metricName: string, value: number, detail?: string): void;
|
|
27
|
+
private findAWSC;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Console Platform's client v2 logging JS API client.
|
|
31
|
+
*/
|
|
32
|
+
export declare class PanoramaClient {
|
|
33
|
+
/**
|
|
34
|
+
* Sends metric but only if Console Platform client v2 logging JS API is present in the page.
|
|
35
|
+
*/
|
|
36
|
+
sendMetric(metric: MetricsV2EventItem): void;
|
|
37
|
+
private findPanorama;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=log-clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-clients.d.ts","sourceRoot":"","sources":["../../../../src/internal/metrics/log-clients.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,GAAG,CAAC;CACX;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC3C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACjE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACjE;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB;;OAEG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAepE,OAAO,CAAC,QAAQ;CAiBjB;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;IAiB5C,OAAO,CAAC,YAAY;CAiBrB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __assign } from "tslib";
|
|
4
|
+
/**
|
|
5
|
+
* Console Platform's client logging JS API client.
|
|
6
|
+
*/
|
|
7
|
+
var CLogClient = /** @class */ (function () {
|
|
8
|
+
function CLogClient() {
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Sends metric but only if Console Platform client logging JS API is present in the page.
|
|
12
|
+
*/
|
|
13
|
+
CLogClient.prototype.sendMetric = function (metricName, value, detail) {
|
|
14
|
+
if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {
|
|
15
|
+
console.error("Invalid metric name: ".concat(metricName));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (detail && detail.length > 200) {
|
|
19
|
+
console.error("Detail for metric ".concat(metricName, " is too long: ").concat(detail));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
var AWSC = this.findAWSC(window);
|
|
23
|
+
if (typeof AWSC === 'object' && typeof AWSC.Clog === 'object' && typeof AWSC.Clog.log === 'function') {
|
|
24
|
+
AWSC.Clog.log(metricName, value, detail);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
CLogClient.prototype.findAWSC = function (currentWindow) {
|
|
28
|
+
try {
|
|
29
|
+
if (typeof (currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.AWSC) === 'object') {
|
|
30
|
+
return currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.AWSC;
|
|
31
|
+
}
|
|
32
|
+
if (!currentWindow || currentWindow.parent === currentWindow) {
|
|
33
|
+
// When the window has no more parents, it references itself
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return this.findAWSC(currentWindow.parent);
|
|
37
|
+
}
|
|
38
|
+
catch (ex) {
|
|
39
|
+
// Most likely a cross-origin access error
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return CLogClient;
|
|
44
|
+
}());
|
|
45
|
+
export { CLogClient };
|
|
46
|
+
/**
|
|
47
|
+
* Console Platform's client v2 logging JS API client.
|
|
48
|
+
*/
|
|
49
|
+
var PanoramaClient = /** @class */ (function () {
|
|
50
|
+
function PanoramaClient() {
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sends metric but only if Console Platform client v2 logging JS API is present in the page.
|
|
54
|
+
*/
|
|
55
|
+
PanoramaClient.prototype.sendMetric = function (metric) {
|
|
56
|
+
if (typeof metric.eventDetail === 'object') {
|
|
57
|
+
metric.eventDetail = JSON.stringify(metric.eventDetail);
|
|
58
|
+
}
|
|
59
|
+
if (metric.eventDetail && metric.eventDetail.length > 200) {
|
|
60
|
+
console.error("Detail for metric is too long: ".concat(metric.eventDetail));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (typeof metric.eventValue === 'object') {
|
|
64
|
+
metric.eventValue = JSON.stringify(metric.eventValue);
|
|
65
|
+
}
|
|
66
|
+
var panorama = this.findPanorama(window);
|
|
67
|
+
if (typeof panorama === 'function') {
|
|
68
|
+
panorama('trackCustomEvent', __assign(__assign({}, metric), { timestamp: Date.now() }));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
PanoramaClient.prototype.findPanorama = function (currentWindow) {
|
|
72
|
+
try {
|
|
73
|
+
if (typeof (currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.panorama) === 'function') {
|
|
74
|
+
return currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.panorama;
|
|
75
|
+
}
|
|
76
|
+
if (!currentWindow || currentWindow.parent === currentWindow) {
|
|
77
|
+
// When the window has no more parents, it references itself
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
return this.findPanorama(currentWindow.parent);
|
|
81
|
+
}
|
|
82
|
+
catch (ex) {
|
|
83
|
+
// Most likely a cross-origin access error
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return PanoramaClient;
|
|
88
|
+
}());
|
|
89
|
+
export { PanoramaClient };
|
|
90
|
+
//# sourceMappingURL=log-clients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-clients.js","sourceRoot":"","sources":["../../../../src/internal/metrics/log-clients.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n// TODO: move to component-toolkit/internal/metrics\n\nexport interface AWSC {\n Clog: any;\n}\n\nexport interface MetricsWindow extends Window {\n AWSC?: AWSC;\n panorama?: any;\n}\n\nexport interface MetricsV2EventItem {\n eventType?: string;\n eventContext?: string;\n eventDetail?: string | Record<string, string | number | boolean>;\n eventValue?: string | Record<string, string | number | boolean>;\n}\n\nexport interface MetricsLogItem {\n source: string;\n action: string;\n version: string;\n}\n\n/**\n * Console Platform's client logging JS API client.\n */\nexport class CLogClient {\n /**\n * Sends metric but only if Console Platform client logging JS API is present in the page.\n */\n sendMetric(metricName: string, value: number, detail?: string): void {\n if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {\n console.error(`Invalid metric name: ${metricName}`);\n return;\n }\n if (detail && detail.length > 200) {\n console.error(`Detail for metric ${metricName} is too long: ${detail}`);\n return;\n }\n const AWSC = this.findAWSC(window);\n if (typeof AWSC === 'object' && typeof AWSC.Clog === 'object' && typeof AWSC.Clog.log === 'function') {\n AWSC.Clog.log(metricName, value, detail);\n }\n }\n\n private findAWSC(currentWindow?: MetricsWindow): AWSC | undefined {\n try {\n if (typeof currentWindow?.AWSC === 'object') {\n return currentWindow?.AWSC;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return this.findAWSC(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n }\n}\n\n/**\n * Console Platform's client v2 logging JS API client.\n */\nexport class PanoramaClient {\n /**\n * Sends metric but only if Console Platform client v2 logging JS API is present in the page.\n */\n sendMetric(metric: MetricsV2EventItem): void {\n if (typeof metric.eventDetail === 'object') {\n metric.eventDetail = JSON.stringify(metric.eventDetail);\n }\n if (metric.eventDetail && metric.eventDetail.length > 200) {\n console.error(`Detail for metric is too long: ${metric.eventDetail}`);\n return;\n }\n if (typeof metric.eventValue === 'object') {\n metric.eventValue = JSON.stringify(metric.eventValue);\n }\n const panorama = this.findPanorama(window);\n if (typeof panorama === 'function') {\n panorama('trackCustomEvent', { ...metric, timestamp: Date.now() });\n }\n }\n\n private findPanorama(currentWindow?: MetricsWindow): any | undefined {\n try {\n if (typeof currentWindow?.panorama === 'function') {\n return currentWindow?.panorama;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return this.findPanorama(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MetricsLogItem } from './log-clients';
|
|
2
|
+
export declare function buildMetricHash({ source, action }: MetricsLogItem): string;
|
|
3
|
+
export declare function buildMetricDetail({ source, action, version }: MetricsLogItem, theme: string): string;
|
|
4
|
+
export declare function buildMetricName({ source, version }: MetricsLogItem, theme: string): string;
|
|
5
|
+
export declare function formatMajorVersionForMetricDetail(version: string): string;
|
|
6
|
+
export declare function formatVersionForMetricName(theme: string, version: string): string;
|
|
7
|
+
//# sourceMappingURL=metrics-formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics-formatters.d.ts","sourceRoot":"","sources":["../../../../src/internal/metrics/metrics-formatters.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAS/C,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,cAAc,GAAG,MAAM,CAE1E;AAED,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAWpG;AAED,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1F;AAED,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,MAAM,UAEhE;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAExE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// React is the only framework we're using.
|
|
4
|
+
var framework = 'react';
|
|
5
|
+
export function buildMetricHash(_a) {
|
|
6
|
+
var source = _a.source, action = _a.action;
|
|
7
|
+
return ["src".concat(source), "action".concat(action)].join('_');
|
|
8
|
+
}
|
|
9
|
+
export function buildMetricDetail(_a, theme) {
|
|
10
|
+
var source = _a.source, action = _a.action, version = _a.version;
|
|
11
|
+
var metricOrigin = typeof AWSUI_METRIC_ORIGIN !== 'undefined' ? AWSUI_METRIC_ORIGIN : 'main';
|
|
12
|
+
var detailObject = {
|
|
13
|
+
o: metricOrigin,
|
|
14
|
+
s: source,
|
|
15
|
+
t: theme,
|
|
16
|
+
a: action,
|
|
17
|
+
f: framework,
|
|
18
|
+
v: formatMajorVersionForMetricDetail(version)
|
|
19
|
+
};
|
|
20
|
+
return JSON.stringify(detailObject);
|
|
21
|
+
}
|
|
22
|
+
export function buildMetricName(_a, theme) {
|
|
23
|
+
var source = _a.source, version = _a.version;
|
|
24
|
+
return ['awsui', source, "".concat(formatVersionForMetricName(theme, version))].join('_');
|
|
25
|
+
}
|
|
26
|
+
export function formatMajorVersionForMetricDetail(version) {
|
|
27
|
+
return version.replace(/\s/g, '');
|
|
28
|
+
}
|
|
29
|
+
export function formatVersionForMetricName(theme, version) {
|
|
30
|
+
return "".concat(theme.charAt(0)).concat(getMajorVersion(version).replace('.', ''));
|
|
31
|
+
}
|
|
32
|
+
function getMajorVersion(versionString) {
|
|
33
|
+
var majorVersionMatch = versionString.match(/^(\d+\.\d+)/);
|
|
34
|
+
return majorVersionMatch ? majorVersionMatch[1] : '';
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=metrics-formatters.js.map
|