Skip to content

chore: Provide additinal component metadata #3483

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

Merged
merged 1 commit into from
May 12, 2025
Merged

Conversation

just-boris
Copy link
Member

Description

Consume changes added in this PR: cloudscape-design/component-toolkit#132

Related links, issue #, if available: n/a

How has this been tested?

PR build

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

useTelemetry('AnnotationContext');
useBaseComponent('AnnotationContext');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched all non-UI components to useBaseComponent for consistency.

The only difference, there is __internalRootRef which is left unused in these components, but the ref handling code checks its presence anyway, so this ref is effectively a no-op

Comment on lines +33 to +37
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme }, config);
useFocusVisible();
const elementRef = useComponentMetadata<T>(componentName, PACKAGE_VERSION, { ...analyticsMetadata });
const elementRef = useComponentMetadata<T>(
componentName,
{ packageName: PACKAGE_SOURCE, version: PACKAGE_VERSION, theme },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an annoying structure difference between useComponentMetrics and useComponentMetadata. They receive same data, but in different shape. Still some refactoring needed.

const elementRef = useComponentMetadata<T>(
componentName,
{ packageName: PACKAGE_SOURCE, version: PACKAGE_VERSION, theme },
analyticsMetadata as any
Copy link
Member Author

@just-boris just-boris May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value is typed differently in the toolkit and this package

// this package
export interface AnalyticsMetadata {
  instanceIdentifier?: string;
  flowType?: FlowType;
  errorContext?: string;
  resourceType?: string;
}

// toolkit
export type AnalyticsMetadata = JSONObject;

This component's more strict type is not assignable to the toolkit. Before my change we used to fool typescript with runtime code { ...analyticsMetadata }. I do not like it. If we mess with types anyway, let's do it more clearly at least

Copy link

codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.49%. Comparing base (5024307) to head (d7b29a7).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3483      +/-   ##
==========================================
- Coverage   96.49%   96.49%   -0.01%     
==========================================
  Files         804      803       -1     
  Lines       23090    23088       -2     
  Branches     7587     8001     +414     
==========================================
- Hits        22281    22279       -2     
+ Misses        802      755      -47     
- Partials        7       54      +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@just-boris just-boris marked this pull request as ready for review May 7, 2025 18:37
@just-boris just-boris requested a review from a team as a code owner May 7, 2025 18:38
@just-boris just-boris requested review from YueyingLu, a team, gethinwebster and cansuaa and removed request for a team, YueyingLu and gethinwebster May 7, 2025 18:38
@just-boris just-boris added this pull request to the merge queue May 12, 2025
Merged via the queue into main with commit 39fe90f May 12, 2025
38 checks passed
@just-boris just-boris deleted the base-component-metadata branch May 12, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants