Track Insights link clicks on the file block Download button (#4632)

This commit is contained in:
Nolann B.
2026-09-23 17:16:06 +02:00
committed by GitHub
parent bdc2497771
commit 8dd9444596
2 changed files with 11 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Track Insights link clicks on the Download button of file blocks.
@@ -1,4 +1,5 @@
'use client';
import { useTrackEvent } from '../Insights';
import { Button, type ButtonProps } from './Button';
/**
@@ -7,13 +8,17 @@ import { Button, type ButtonProps } from './Button';
export function DownloadButton(
props: Omit<ButtonProps, 'onClick' | 'href'> & { downloadUrl: string; filename: string }
) {
const { downloadUrl, filename, ...buttonProps } = props;
const { downloadUrl, filename, insights, ...buttonProps } = props;
const trackEvent = useTrackEvent();
return (
<Button
{...buttonProps}
onClick={(e) => {
e.preventDefault();
if (insights) {
trackEvent(insights);
}
void forceDownload(downloadUrl, filename);
}}
/>