Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add props telemetry reporting to board item component #294

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", {
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);
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) {
const theme = useVisualRefresh() ? "vr" : THEME;
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme });
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme }, config);
}
Loading