From 9954b37b015eee01b23022bdd2c9d84db2244500 Mon Sep 17 00:00:00 2001 From: MananTank Date: Fri, 13 Dec 2024 21:10:48 +0000 Subject: [PATCH] [DASH-624] Add tracking in insight playground (#5737) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved DASH-624 --- ## PR-Codex overview This PR focuses on enhancing the `CodeBlockContainer` and related components to support an `onCopy` callback, allowing for custom actions when code is copied. It also introduces tracking for user interactions within the `BlueprintPlayground` component. ### Detailed summary - Added `onCopy` prop to `CodeBlockContainer`, `RenderCode`, `PlainTextCodeBlock`, and `CodeClient`. - Updated button click handler in `CodeBlockContainer` to call `onCopy` and pass the copied code. - Integrated `useTrack` for tracking user events in `BlueprintPlayground`. - Added tracking for "run", "copy-url", and "copy-response" actions in relevant components. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../components/ui/code/CodeBlockContainer.tsx | 6 +++- .../src/@/components/ui/code/RenderCode.tsx | 2 ++ .../src/@/components/ui/code/code.client.tsx | 4 +++ .../@/components/ui/code/plaintext-code.tsx | 2 ++ .../blueprint-playground.client.tsx | 28 +++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/src/@/components/ui/code/CodeBlockContainer.tsx b/apps/dashboard/src/@/components/ui/code/CodeBlockContainer.tsx index d927a06cf90..bfc697747f6 100644 --- a/apps/dashboard/src/@/components/ui/code/CodeBlockContainer.tsx +++ b/apps/dashboard/src/@/components/ui/code/CodeBlockContainer.tsx @@ -14,6 +14,7 @@ export function CodeBlockContainer(props: { scrollableContainerClassName?: string; copyButtonClassName?: string; shadowColor?: string; + onCopy?: (code: string) => void; }) { const { hasCopied, onCopy } = useClipboard(props.codeToCopy); @@ -38,7 +39,10 @@ export function CodeBlockContainer(props: {