diff --git a/src/components/DataAnalysis/Disclaimer.tsx b/src/components/DataAnalysis/Disclaimer.tsx index 3bb21348..fa38adbf 100644 --- a/src/components/DataAnalysis/Disclaimer.tsx +++ b/src/components/DataAnalysis/Disclaimer.tsx @@ -1,3 +1,4 @@ +import { useTracking } from '@/contexts/TrackingContext'; import { httpPut } from '@/helpers/http'; import { Box, Button, Dialog, DialogActions, DialogTitle, Typography } from '@mui/material'; import { useSession } from 'next-auth/react'; @@ -13,6 +14,8 @@ type Org = { export const Disclaimer = ({ open, setIsOpen }: { open: boolean; setIsOpen: any }) => { const { data: session } = useSession(); + const trackAmplitudeEvent: any = useTracking(); + const handleOkayButton = async () => { try { const response = await httpPut(session, 'v1/organizations/user_self', { @@ -59,7 +62,15 @@ export const Disclaimer = ({ open, setIsOpen }: { open: boolean; setIsOpen: any p: 0, }} > - diff --git a/src/components/DataAnalysis/LLMSummary.tsx b/src/components/DataAnalysis/LLMSummary.tsx index 70f68099..9a61b7e5 100644 --- a/src/components/DataAnalysis/LLMSummary.tsx +++ b/src/components/DataAnalysis/LLMSummary.tsx @@ -10,6 +10,7 @@ import Markdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import { ContentCopy, ThumbDownAltOutlined } from '@mui/icons-material'; import { MODALS } from '@/pages/analysis/data-analysis'; +import { useTracking } from '@/contexts/TrackingContext'; export const LLMSummary = ({ resetState, @@ -30,10 +31,12 @@ export const LLMSummary = ({ handleNewSession: (x: any) => void; }) => { const globalContext = useContext(GlobalContext); + const trackAmplitudeEvent: any = useTracking(); // Function to handle copying text -> const handleCopyClick = async () => { const copyRes: boolean = await copyToClipboard(llmSummary); + trackAmplitudeEvent(`[Copy-LLMSummary] Button Clicked`); if (copyRes) { successToast('Successfully copied to clipboard', [], globalContext); } else { @@ -126,6 +129,7 @@ export const LLMSummary = ({ { + trackAmplitudeEvent(`[Dislike-LLMSummary] Button Clicked`); setModalName(MODALS.FEEDBACK_FORM); setIsBoxOpen(true); }} @@ -142,6 +146,7 @@ export const LLMSummary = ({ variant="outlined" disabled={!newSessionId} onClick={() => { + trackAmplitudeEvent(`[Save-as-LLMSummary] Button Clicked`); setModalName(oldSessionMetaInfo.oldSessionId ? MODALS.OVERWRITE : MODALS.SAVE); setIsBoxOpen(true); }} @@ -158,7 +163,10 @@ export const LLMSummary = ({ variant="contained" sx={{ width: '6.75rem', padding: '8px 0', borderRadius: '6px' }} disabled={!llmSummary} - onClick={downloadCSV} + onClick={() => { + downloadCSV(); + trackAmplitudeEvent(`[Download-aisummary-LLMSummary] Button Clicked`); + }} > Download diff --git a/src/components/DataAnalysis/OverwriteBox.tsx b/src/components/DataAnalysis/OverwriteBox.tsx index 9e72b15c..d62c91c7 100644 --- a/src/components/DataAnalysis/OverwriteBox.tsx +++ b/src/components/DataAnalysis/OverwriteBox.tsx @@ -89,7 +89,10 @@ export const OverWriteDialog = ({ padding: '8px 0', borderRadius: '5px', }, - onClick: handleClose, + onClick: () => { + trackAmplitudeEvent(`[Cancel-Save-Op-LLMSummary] Button Clicked`); + handleClose(); + }, }, ], }, @@ -120,6 +123,7 @@ export const OverWriteDialog = ({ borderRadius: '5px', }, onClick: () => { + trackAmplitudeEvent(`[Save-as-new-LLMSummary] Button Clicked`); reset({ sessionName: '', feedback: '', @@ -135,7 +139,10 @@ export const OverWriteDialog = ({ padding: '8px 0', borderRadius: '5px', }, - onClick: handleClose, + onClick: () => { + trackAmplitudeEvent(`[Cancel-Save-Op-LLMSummary] Button Clicked`); + handleClose(); + }, }, ], }, @@ -165,7 +172,10 @@ export const OverWriteDialog = ({ padding: '8px 0', borderRadius: '5px', }, - onClick: handleClose, + onClick: () => { + trackAmplitudeEvent(`[Cancel-Save-Op-LLMSummary] Button Clicked`); + handleClose(); + }, }, ], }, @@ -183,7 +193,10 @@ export const OverWriteDialog = ({ padding: '8px 0', borderRadius: '5px', }, - onClick: handleSubmit((data) => submitFeedback(data.feedback)), + onClick: () => { + trackAmplitudeEvent(`[Submit-Feedback-LLMSummary] Button Clicked`); + handleSubmit((data) => submitFeedback(data.feedback)); + }, }, ], }, @@ -203,6 +216,7 @@ export const OverWriteDialog = ({ borderRadius: '5px', }, onClick: () => { + trackAmplitudeEvent(`[Save-Changes-LLMSummary] Button Clicked`); setModalName(oldSessionName ? MODALS.OVERWRITE : MODALS.SAVE); }, }, @@ -215,6 +229,7 @@ export const OverWriteDialog = ({ borderRadius: '5px', }, onClick: () => { + trackAmplitudeEvent(`[Leave-anyway-LLMSummary] Button Clicked`); onConfirmNavigation(); }, }, @@ -235,6 +250,7 @@ export const OverWriteDialog = ({ borderRadius: '5px', }, onClick: () => { + trackAmplitudeEvent(`[Save-Changes-LLMSummary] Button Clicked`); setModalName(oldSessionName ? MODALS.OVERWRITE : MODALS.SAVE); }, }, @@ -247,6 +263,7 @@ export const OverWriteDialog = ({ borderRadius: '5px', }, onClick: () => { + trackAmplitudeEvent(`[Reset-LLMSummary] Button Clicked`); handleNewSession(true); setIsBoxOpen(false); }, @@ -268,6 +285,7 @@ export const OverWriteDialog = ({ borderRadius: '5px', }, onClick: () => { + trackAmplitudeEvent(`[Save-Changes-LLMSummary] Button Clicked`); setModalName(oldSessionName ? MODALS.OVERWRITE : MODALS.SAVE); }, }, @@ -281,6 +299,7 @@ export const OverWriteDialog = ({ }, onClick: () => { setIsBoxOpen(false); + trackAmplitudeEvent(`[Leave-anyway-LLMSummary] Button Clicked`); handleEditSession(selectedSession, true); }, }, diff --git a/src/components/DataAnalysis/SavedSession.tsx b/src/components/DataAnalysis/SavedSession.tsx index 671c982d..2746226d 100644 --- a/src/components/DataAnalysis/SavedSession.tsx +++ b/src/components/DataAnalysis/SavedSession.tsx @@ -23,6 +23,7 @@ import moment from 'moment'; import { errorToast } from '../ToastMessage/ToastHelper'; import { GlobalContext } from '@/contexts/ContextProvider'; import InfoTooltip from '../UI/Tooltip/Tooltip'; +import { useTracking } from '@/contexts/TrackingContext'; interface QueryResponse { prompt: string; response: string; @@ -65,7 +66,7 @@ export const SavedSession = memo( const [currentPageIndex, setCurrentPageIndex] = useState(0); // Page index starts from 0 const [savedSessions, setSavedSession] = useState([]); const [loading, setLoading] = useState(false); - + const trackAmplitudeEvent: any = useTracking(); const getSavedSessions = async (pageIndex: number, rowsPerPage: number) => { setLoading(true); try { @@ -274,6 +275,7 @@ export const SavedSession = memo( savedSessions.map((row: any, idx) => ( { + trackAmplitudeEvent(`[View-a-saved-session-LLMSummary] Button Clicked`); handleEditSession({ prompt: row.response[0].prompt, summary: row.response[0].response, diff --git a/src/components/DataAnalysis/TopBar.tsx b/src/components/DataAnalysis/TopBar.tsx index 4807a0d6..e1a9de31 100644 --- a/src/components/DataAnalysis/TopBar.tsx +++ b/src/components/DataAnalysis/TopBar.tsx @@ -1,7 +1,10 @@ import { Box, Button, Typography } from '@mui/material'; import InfoTooltip from '../UI/Tooltip/Tooltip'; import Folder from '@mui/icons-material/Folder'; +import { useTracking } from '@/contexts/TrackingContext'; export const TopBar = ({ handleOpenSavedSession, handleNewSession }: any) => { + const trackAmplitudeEvent: any = useTracking(); + return ( <> { color: '#FFFFFF', }, }} - onClick={handleOpenSavedSession} + onClick={() => { + handleOpenSavedSession(); + trackAmplitudeEvent(`[Saved-sessions-LLMSummary] Button Clicked`); + }} > Saved Sessions @@ -78,6 +84,7 @@ export const TopBar = ({ handleOpenSavedSession, handleNewSession }: any) => { id="create-new-button" sx={{ width: '100%', height: '2rem' }} onClick={() => { + trackAmplitudeEvent(`[+New-LLMSummary] Button Clicked`); handleNewSession(); }} >