mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-25 11:52:10 +00:00
Track Insights link clicks on the file block Download button (#4632)
This commit is contained in:
@@ -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);
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user