From c9acb4ca9b178bf6a776076adec3991827d9c183 Mon Sep 17 00:00:00 2001 From: Luke Watts Date: Fri, 14 Jan 2022 08:16:56 +0100 Subject: [PATCH] feat: track interaction with comment events --- src/components/Comment/Comment.tsx | 36 ++++++++++++++++++- .../Howto/HowToComments/HowToComments.tsx | 28 +++++++++++++-- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/components/Comment/Comment.tsx b/src/components/Comment/Comment.tsx index c575138d34..e03cf74d97 100644 --- a/src/components/Comment/Comment.tsx +++ b/src/components/Comment/Comment.tsx @@ -1,4 +1,5 @@ import React, { useState } from 'react' +import ReactGA from 'react-ga' import { FaTrash, FaRegEdit } from 'react-icons/fa' import { Flex } from 'rebass/styled-components' import { useCommonStores } from 'src/index' @@ -45,7 +46,14 @@ export const Comment: React.FC = ({ }} mr={2} fontSize="12px" - onClick={async () => setShowEditModal(true)} + onClick={async () => { + ReactGA.event({ + category: 'Comments', + action: 'Edit existing comment', + label: stores.howtoStore.activeHowto?.title, + }) + return setShowEditModal(true) + }} > edit @@ -61,6 +69,19 @@ export const Comment: React.FC = ({ ) if (confirmation) { await stores.howtoStore.deleteComment(_id) + ReactGA.event({ + category: 'Comments', + action: 'Deleted', + label: stores.howtoStore.activeHowto?.title, + }) + logger.debug( + { + category: 'Comments', + action: 'Deleted', + label: stores.howtoStore.activeHowto?.title, + }, + 'comment deleted', + ) } }} > @@ -106,6 +127,19 @@ export const Comment: React.FC = ({