diff --git a/src/copy-to-clipboard/internal.tsx b/src/copy-to-clipboard/internal.tsx index 097f68eb8c..a4904a6d4e 100644 --- a/src/copy-to-clipboard/internal.tsx +++ b/src/copy-to-clipboard/internal.tsx @@ -52,6 +52,14 @@ export default function InternalCopyToClipboard({ }, [copyErrorText]); const baseProps = getBaseProps(restProps); + + // Extract data-* attributes to forward to the inner button for analytics support. + const dataAttributes: Record = {}; + Object.keys(restProps).forEach(key => { + if (key.match(/^data-/)) { + dataAttributes[key] = (restProps as Record)[key]; + } + }); const onClick = () => { if (!navigator.clipboard) { // The clipboard API is not available in insecure contexts. @@ -87,6 +95,7 @@ export default function InternalCopyToClipboard({ const button = (