Skip to content

Commit 8dd9444

Browse files
authored
Track Insights link clicks on the file block Download button (#4632)
1 parent bdc2497 commit 8dd9444

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Track Insights link clicks on the Download button of file blocks.

‎packages/gitbook/src/components/primitives/DownloadButton.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use client';
2+
import { useTrackEvent } from '../Insights';
23
import { Button, type ButtonProps } from './Button';
34

45
/**
@@ -7,13 +8,17 @@ import { Button, type ButtonProps } from './Button';
78
export function DownloadButton(
89
props: Omit<ButtonProps, 'onClick' | 'href'> & { downloadUrl: string; filename: string }
910
) {
10-
const { downloadUrl, filename, ...buttonProps } = props;
11+
const { downloadUrl, filename, insights, ...buttonProps } = props;
12+
const trackEvent = useTrackEvent();
1113

1214
return (
1315
<Button
1416
{...buttonProps}
1517
onClick={(e) => {
1618
e.preventDefault();
19+
if (insights) {
20+
trackEvent(insights);
21+
}
1722
void forceDownload(downloadUrl, filename);
1823
}}
1924
/>

0 commit comments

Comments
 (0)