Skip to content

Commit 577297e

Browse files
authored
chore: Add props telemerty reporting for code-view component (#21)
1 parent f2a97aa commit 577297e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/code-view/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { InternalCodeView } from "./internal";
88
export type { CodeViewProps };
99

1010
export default function CodeView(props: CodeViewProps) {
11-
const baseComponentProps = useBaseComponent("CodeView");
11+
const baseComponentProps = useBaseComponent("CodeView", {
12+
props: { lineNumbers: props.lineNumbers },
13+
});
1214
return <InternalCodeView {...props} {...baseComponentProps} />;
1315
}
1416

src/internal/base-component/use-base-component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { initAwsUiVersions, useComponentMetadata } from "@cloudscape-design/component-toolkit/internal";
4+
import {
5+
ComponentConfiguration,
6+
initAwsUiVersions,
7+
useComponentMetadata,
8+
} from "@cloudscape-design/component-toolkit/internal";
59
import { MutableRefObject } from "react";
610
import { PACKAGE_SOURCE, PACKAGE_VERSION } from "../environment";
711
import { useTelemetry } from "./use-telemetry";
@@ -17,8 +21,8 @@ export interface InternalBaseComponentProps {
1721
* attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this
1822
* root DOM node and emits the telemetry for this component.
1923
*/
20-
export default function useBaseComponent<T = any>(componentName: string) {
21-
useTelemetry(componentName);
24+
export default function useBaseComponent<T = any>(componentName: string, config?: ComponentConfiguration) {
25+
useTelemetry(componentName, config);
2226
const elementRef = useComponentMetadata<T>(componentName, PACKAGE_VERSION);
2327
return { __internalRootRef: elementRef };
2428
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { useComponentMetrics } from "@cloudscape-design/component-toolkit/internal";
4+
import { ComponentConfiguration, useComponentMetrics } from "@cloudscape-design/component-toolkit/internal";
55
import { PACKAGE_SOURCE, PACKAGE_VERSION, THEME } from "../environment";
66
import { useVisualRefresh } from "./use-visual-refresh";
77

8-
export function useTelemetry(componentName: string) {
8+
export function useTelemetry(componentName: string, config?: ComponentConfiguration) {
99
const theme = useVisualRefresh() ? "vr" : THEME;
10-
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme });
10+
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme }, config);
1111
}

0 commit comments

Comments
 (0)