Skip to content

Commit

Permalink
chore: Add props telemetry reporting to board item component
Browse files Browse the repository at this point in the history
  • Loading branch information
just-boris committed Mar 5, 2024
1 parent d5dd6dc commit 212b6e0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/board-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { InternalBoardItem } from "./internal";
export { BoardItemProps };

export default function BoardItem(props: BoardItemProps) {
const baseComponentProps = useBaseComponent("BoardItem");
const baseComponentProps = useBaseComponent("BoardItem", {

Check warning on line 11 in src/board-item/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/board-item/index.tsx#L11

Added line #L11 was not covered by tests
props: { disableContentPaddings: props.disableContentPaddings },
});
return <InternalBoardItem {...props} {...baseComponentProps} />;
}

Expand Down
10 changes: 7 additions & 3 deletions src/internal/base-component/use-base-component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { initAwsUiVersions, useComponentMetadata } from "@cloudscape-design/component-toolkit/internal";
import {
ComponentConfiguration,
initAwsUiVersions,
useComponentMetadata,
} from "@cloudscape-design/component-toolkit/internal";
import { MutableRefObject } from "react";
import { PACKAGE_SOURCE, PACKAGE_VERSION } from "../environment";
import { useTelemetry } from "./use-telemetry";
Expand All @@ -17,8 +21,8 @@ export interface InternalBaseComponentProps {
* attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this
* root DOM node and emits the telemetry for this component.
*/
export default function useBaseComponent<T = any>(componentName: string) {
useTelemetry(componentName);
export default function useBaseComponent<T = any>(componentName: string, config?: ComponentConfiguration) {
useTelemetry(componentName, config);

Check warning on line 25 in src/internal/base-component/use-base-component.ts

View check run for this annotation

Codecov / codecov/patch

src/internal/base-component/use-base-component.ts#L24-L25

Added lines #L24 - L25 were not covered by tests
const elementRef = useComponentMetadata<T>(componentName, PACKAGE_VERSION);
return { __internalRootRef: elementRef };
}
6 changes: 3 additions & 3 deletions src/internal/base-component/use-telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

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

export function useTelemetry(componentName: string) {
export function useTelemetry(componentName: string, config?: ComponentConfiguration) {

Check warning on line 8 in src/internal/base-component/use-telemetry.ts

View check run for this annotation

Codecov / codecov/patch

src/internal/base-component/use-telemetry.ts#L8

Added line #L8 was not covered by tests
const theme = useVisualRefresh() ? "vr" : THEME;
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme });
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme }, config);

Check warning on line 10 in src/internal/base-component/use-telemetry.ts

View check run for this annotation

Codecov / codecov/patch

src/internal/base-component/use-telemetry.ts#L10

Added line #L10 was not covered by tests
}

0 comments on commit 212b6e0

Please sign in to comment.