@@ -3,7 +3,12 @@ import React, { useCallback, useEffect, useState } from 'react'
33import { BiBookmarkMinus , BiBookmarkPlus , BiCheckDouble , BiShareAlt } from 'react-icons/bi'
44import { ShareModal } from 'src/features/shareModal'
55import { ShareModalData } from 'src/features/shareModal/types'
6- import { Attributes , trackLinkBookmark , trackLinkUnBookmark } from 'src/lib/analytics'
6+ import {
7+ Attributes ,
8+ trackLinkBookmark ,
9+ trackLinkUnBookmark ,
10+ trackMarkAsRead ,
11+ } from 'src/lib/analytics'
712import { useBookmarks } from 'src/stores/bookmarks'
813import { useReadPosts } from 'src/stores/readPosts'
914import { useShallow } from 'zustand/shallow'
@@ -46,15 +51,25 @@ export const CardItemWithActions = ({
4651 userBookmarks . some ( ( bm ) => bm . source === source && bm . url === item . url )
4752 )
4853
49- const onMarkAsReadClick = useCallback ( ( ) => {
54+ const onMarkAsReadClicked = useCallback ( ( ) => {
5055 if ( isRead ) {
5156 markAsUnread ( item . id )
5257 } else {
5358 markAsRead ( item . id )
5459 }
60+
61+ if ( isRead ) {
62+ const analyticsAttrs = {
63+ [ Attributes . TRIGERED_FROM ] : 'card' ,
64+ [ Attributes . TITLE ] : item . title ,
65+ [ Attributes . LINK ] : item . url ,
66+ [ Attributes . SOURCE ] : source ,
67+ }
68+ trackMarkAsRead ( analyticsAttrs )
69+ }
5570 } , [ isRead , item . id ] )
5671
57- const onBookmarkClick = useCallback ( ( ) => {
72+ const onBookmarkClicked = useCallback ( ( ) => {
5873 const itemToBookmark = {
5974 title : item . title ,
6075 url : item . url ,
@@ -113,15 +128,15 @@ export const CardItemWithActions = ({
113128 { showBookmarkAction && (
114129 < button
115130 className = { `blockActionButton ${ isBookmarked ? 'active' : '' } ` }
116- onClick = { onBookmarkClick }
131+ onClick = { onBookmarkClicked }
117132 aria-label = "Bookmark item" >
118133 { ! isBookmarked ? < BiBookmarkPlus /> : < BiBookmarkMinus /> }
119134 </ button >
120135 ) }
121136
122137 < button
123138 className = { `blockActionButton ${ isRead ? 'active' : '' } ` }
124- onClick = { onMarkAsReadClick }
139+ onClick = { onMarkAsReadClicked }
125140 aria-label = { isRead ? 'Mark as unread' : 'Mark as read' } >
126141 < BiCheckDouble />
127142 </ button >
0 commit comments