11'use client' ;
22
3+ import { useAnalytics } from '@prezly/analytics-nextjs' ;
34import type { Story } from '@prezly/sdk' ;
45import { translations , useIntl } from '@prezly/theme-kit-nextjs/index' ;
56import classNames from 'classnames' ;
@@ -39,6 +40,7 @@ export function Share({
3940 url,
4041 uuid,
4142} : Props ) {
43+ const { track } = useAnalytics ( ) ;
4244 const { formatMessage } = useIntl ( ) ;
4345 const socialNetworks = sharingOptions . sharing_actions ;
4446 const socialShareButtonsCount = socialNetworks . length ;
@@ -53,15 +55,18 @@ export function Share({
5355 : undefined ;
5456
5557 function handleCopyLink ( ) {
58+ track ( `Newsroom - Story Page - Story link copy` , { id : uuid } ) ;
5659 window . navigator . clipboard . writeText ( url ) ;
5760 }
5861
5962 async function handleCopyText ( ) {
63+ track ( `Newsroom - Story Page - Story text copy` , { id : uuid } ) ;
6064 const { copyStoryText } = await import ( './utils/copyStoryText' ) ;
6165 copyStoryText ( ) ;
6266 }
6367
6468 async function handlePdfDownload ( ) {
69+ track ( `Newsroom - Story Page - Story PDF download` , { id : uuid } ) ;
6570 const pdfUrl = await getStoryPdfUrl ( uuid ) ;
6671 const link = document . createElement ( 'a' ) ;
6772 link . setAttribute ( 'href' , pdfUrl ) ;
@@ -121,6 +126,11 @@ export function Share({
121126 className = { styles . action }
122127 icon = { IconFolderDown }
123128 variation = "secondary"
129+ onClick = { ( ) => {
130+ track ( `Newsroom - Story Page - Story assets download` , {
131+ id : uuid ,
132+ } ) ;
133+ } }
124134 >
125135 Download assets
126136 </ ButtonLink >
0 commit comments