export async function copyToClipboardWithMeta(value: string, event?: Event) { navigator.clipboard.writeText(value) if (event) { trackEvent(event) }}
I think ‘withMeta’ in the function name copyToClipboardWithMeta refers to the analytics recorded in the trackEvent function.
import va from "@vercel/analytics"export function trackEvent(input: Event): void { const event = eventSchema.parse(input) if (event) { va.track(event.name, event.properties) }}
If I were to implement a copyToClipboard functionality, I would also add a fallback in case the navigator.clipboard is not available in a given browser like in Codehike and if you also use Vercel analytics in your application, you might as well record your analytics like in shadcn-ui/ui.
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.