Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplitude tracking llm summary #1295

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/components/DataAnalysis/Disclaimer.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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', {
Expand Down Expand Up @@ -59,7 +62,15 @@ export const Disclaimer = ({ open, setIsOpen }: { open: boolean; setIsOpen: any
p: 0,
}}
>
<Button onClick={handleOkayButton} variant="contained" sx={{ width: '5rem' }}>
<Button
onClick={() => {
trackAmplitudeEvent(`[Accept-llmDisclaimer-LLMSummary] Button Clicked`);

handleOkayButton();
}}
variant="contained"
sx={{ width: '5rem' }}
>
Okay
</Button>
</DialogActions>
Expand Down
10 changes: 9 additions & 1 deletion src/components/DataAnalysis/LLMSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import remarkGfm from 'remark-gfm';
import { ContentCopy, ThumbDownAltOutlined } from '@mui/icons-material';
import { MODALS } from '@/pages/analysis/data-analysis';
import { useTracking } from '@/contexts/TrackingContext';

Check warning on line 13 in src/components/DataAnalysis/LLMSummary.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/LLMSummary.tsx#L13

Added line #L13 was not covered by tests

export const LLMSummary = ({
resetState,
Expand All @@ -30,10 +31,12 @@
handleNewSession: (x: any) => void;
}) => {
const globalContext = useContext(GlobalContext);
const trackAmplitudeEvent: any = useTracking();

Check warning on line 34 in src/components/DataAnalysis/LLMSummary.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/LLMSummary.tsx#L34

Added line #L34 was not covered by tests

// Function to handle copying text ->
const handleCopyClick = async () => {
const copyRes: boolean = await copyToClipboard(llmSummary);
trackAmplitudeEvent(`[Copy-LLMSummary] Button Clicked`);

Check warning on line 39 in src/components/DataAnalysis/LLMSummary.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/LLMSummary.tsx#L39

Added line #L39 was not covered by tests
if (copyRes) {
successToast('Successfully copied to clipboard', [], globalContext);
} else {
Expand Down Expand Up @@ -126,6 +129,7 @@
</IconButton>
<IconButton
onClick={() => {
trackAmplitudeEvent(`[Dislike-LLMSummary] Button Clicked`);

Check warning on line 132 in src/components/DataAnalysis/LLMSummary.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/LLMSummary.tsx#L132

Added line #L132 was not covered by tests
setModalName(MODALS.FEEDBACK_FORM);
setIsBoxOpen(true);
}}
Expand All @@ -142,6 +146,7 @@
variant="outlined"
disabled={!newSessionId}
onClick={() => {
trackAmplitudeEvent(`[Save-as-LLMSummary] Button Clicked`);

Check warning on line 149 in src/components/DataAnalysis/LLMSummary.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/LLMSummary.tsx#L149

Added line #L149 was not covered by tests
setModalName(oldSessionMetaInfo.oldSessionId ? MODALS.OVERWRITE : MODALS.SAVE);
setIsBoxOpen(true);
}}
Expand All @@ -158,7 +163,10 @@
variant="contained"
sx={{ width: '6.75rem', padding: '8px 0', borderRadius: '6px' }}
disabled={!llmSummary}
onClick={downloadCSV}
onClick={() => {
downloadCSV();
trackAmplitudeEvent(`[Download-aisummary-LLMSummary] Button Clicked`);

Check warning on line 168 in src/components/DataAnalysis/LLMSummary.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/LLMSummary.tsx#L166-L168

Added lines #L166 - L168 were not covered by tests
}}
>
Download
</Button>
Expand Down
27 changes: 23 additions & 4 deletions src/components/DataAnalysis/OverwriteBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@
padding: '8px 0',
borderRadius: '5px',
},
onClick: handleClose,
onClick: () => {
trackAmplitudeEvent(`[Cancel-Save-Op-LLMSummary] Button Clicked`);
handleClose();

Check warning on line 94 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L92-L94

Added lines #L92 - L94 were not covered by tests
},
},
],
},
Expand Down Expand Up @@ -120,6 +123,7 @@
borderRadius: '5px',
},
onClick: () => {
trackAmplitudeEvent(`[Save-as-new-LLMSummary] Button Clicked`);

Check warning on line 126 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L126

Added line #L126 was not covered by tests
reset({
sessionName: '',
feedback: '',
Expand All @@ -135,7 +139,10 @@
padding: '8px 0',
borderRadius: '5px',
},
onClick: handleClose,
onClick: () => {
trackAmplitudeEvent(`[Cancel-Save-Op-LLMSummary] Button Clicked`);
handleClose();

Check warning on line 144 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L142-L144

Added lines #L142 - L144 were not covered by tests
},
},
],
},
Expand Down Expand Up @@ -165,7 +172,10 @@
padding: '8px 0',
borderRadius: '5px',
},
onClick: handleClose,
onClick: () => {
trackAmplitudeEvent(`[Cancel-Save-Op-LLMSummary] Button Clicked`);
handleClose();

Check warning on line 177 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L175-L177

Added lines #L175 - L177 were not covered by tests
},
},
],
},
Expand All @@ -183,7 +193,10 @@
padding: '8px 0',
borderRadius: '5px',
},
onClick: handleSubmit((data) => submitFeedback(data.feedback)),
onClick: () => {
trackAmplitudeEvent(`[Submit-Feedback-LLMSummary] Button Clicked`);
handleSubmit((data) => submitFeedback(data.feedback));

Check warning on line 198 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L196-L198

Added lines #L196 - L198 were not covered by tests
},
},
],
},
Expand All @@ -203,6 +216,7 @@
borderRadius: '5px',
},
onClick: () => {
trackAmplitudeEvent(`[Save-Changes-LLMSummary] Button Clicked`);

Check warning on line 219 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L219

Added line #L219 was not covered by tests
setModalName(oldSessionName ? MODALS.OVERWRITE : MODALS.SAVE);
},
},
Expand All @@ -215,6 +229,7 @@
borderRadius: '5px',
},
onClick: () => {
trackAmplitudeEvent(`[Leave-anyway-LLMSummary] Button Clicked`);

Check warning on line 232 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L232

Added line #L232 was not covered by tests
onConfirmNavigation();
},
},
Expand All @@ -235,6 +250,7 @@
borderRadius: '5px',
},
onClick: () => {
trackAmplitudeEvent(`[Save-Changes-LLMSummary] Button Clicked`);

Check warning on line 253 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L253

Added line #L253 was not covered by tests
setModalName(oldSessionName ? MODALS.OVERWRITE : MODALS.SAVE);
},
},
Expand All @@ -247,6 +263,7 @@
borderRadius: '5px',
},
onClick: () => {
trackAmplitudeEvent(`[Reset-LLMSummary] Button Clicked`);

Check warning on line 266 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L266

Added line #L266 was not covered by tests
handleNewSession(true);
setIsBoxOpen(false);
},
Expand All @@ -268,6 +285,7 @@
borderRadius: '5px',
},
onClick: () => {
trackAmplitudeEvent(`[Save-Changes-LLMSummary] Button Clicked`);

Check warning on line 288 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L288

Added line #L288 was not covered by tests
setModalName(oldSessionName ? MODALS.OVERWRITE : MODALS.SAVE);
},
},
Expand All @@ -281,6 +299,7 @@
},
onClick: () => {
setIsBoxOpen(false);
trackAmplitudeEvent(`[Leave-anyway-LLMSummary] Button Clicked`);

Check warning on line 302 in src/components/DataAnalysis/OverwriteBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DataAnalysis/OverwriteBox.tsx#L302

Added line #L302 was not covered by tests
handleEditSession(selectedSession, true);
},
},
Expand Down
4 changes: 3 additions & 1 deletion src/components/DataAnalysis/SavedSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,7 +66,7 @@ export const SavedSession = memo(
const [currentPageIndex, setCurrentPageIndex] = useState(0); // Page index starts from 0
const [savedSessions, setSavedSession] = useState<Session[]>([]);
const [loading, setLoading] = useState(false);

const trackAmplitudeEvent: any = useTracking();
const getSavedSessions = async (pageIndex: number, rowsPerPage: number) => {
setLoading(true);
try {
Expand Down Expand Up @@ -274,6 +275,7 @@ export const SavedSession = memo(
savedSessions.map((row: any, idx) => (
<TableRow
onClick={() => {
trackAmplitudeEvent(`[View-a-saved-session-LLMSummary] Button Clicked`);
handleEditSession({
prompt: row.response[0].prompt,
summary: row.response[0].response,
Expand Down
9 changes: 8 additions & 1 deletion src/components/DataAnalysis/TopBar.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Box
Expand Down Expand Up @@ -66,7 +69,10 @@ export const TopBar = ({ handleOpenSavedSession, handleNewSession }: any) => {
color: '#FFFFFF',
},
}}
onClick={handleOpenSavedSession}
onClick={() => {
handleOpenSavedSession();
trackAmplitudeEvent(`[Saved-sessions-LLMSummary] Button Clicked`);
}}
>
<Folder />
<Typography sx={{ fontWeight: 700, fontSize: '16px' }}>Saved Sessions</Typography>
Expand All @@ -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();
}}
>
Expand Down