({
post,
shouldTrack = true,
}: UseTrackPostViewProps)
| 9 | } |
| 10 | |
| 11 | export const useTrackPostView = ({ |
| 12 | post, |
| 13 | shouldTrack = true, |
| 14 | }: UseTrackPostViewProps): void => { |
| 15 | const { user } = useAuthContext(); |
| 16 | const onSendViewPost = useViewPost(); |
| 17 | |
| 18 | useEffect(() => { |
| 19 | if (!shouldTrack || !post?.id || !user?.id) { |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | onSendViewPost(post.id); |
| 24 | }, [onSendViewPost, post?.id, shouldTrack, user?.id]); |
| 25 | }; |
no test coverage detected