From ce934f7e57df4f647ae556c05a94c87f1a882155 Mon Sep 17 00:00:00 2001 From: Bahugunajii Date: Fri, 5 Jan 2024 15:27:12 +0530 Subject: [PATCH] added more events --- app/library/show/page.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/library/show/page.tsx b/app/library/show/page.tsx index 83e3b1e..c06d607 100644 --- a/app/library/show/page.tsx +++ b/app/library/show/page.tsx @@ -95,27 +95,27 @@ const ContentLibrary = () => { }, [selectedGrade, page, selectedChapter]); - const handleChapterClick = async (chapterId: number) => { + const handleChapterClick = async (chapterId: number, chapterName: string) => { try { const topicData = await getTopics([chapterId]); setTopics(topicData); const topicIds = topicData.map((topic) => topic.id); const resourceData = await getResourcesWithSource(topicIds); setResources(resourceData); - MixpanelTracking.getInstance().trackEvent('Selected chapter: ' + chapterId); + MixpanelTracking.getInstance().trackEvent('Selected chapter: ' + chapterName); } catch (error) { console.error('Error fetching chapter data:', error); } }; - const toggleChapterExpansion = async (chapterId: number) => { + const toggleChapterExpansion = async (chapterId: number, chapterName: string) => { setExpandedChapters((prevExpanded) => ({ ...prevExpanded, [chapterId]: !prevExpanded[chapterId], })); if (!expandedChapters[chapterId]) { - await handleChapterClick(chapterId); + await handleChapterClick(chapterId, chapterName); } }; @@ -134,6 +134,10 @@ const ContentLibrary = () => { setChapterList(chapterData); }; + const handleResourceTracking = (resourceName: any) => { + MixpanelTracking.getInstance().trackEvent('Selected resource: '+ resourceName) + } + const generateSubjectButton = (subject: string, label: string) => ( {
toggleChapterExpansion(chapter.id)} + onClick={() => toggleChapterExpansion(chapter.id, chapter.name)} >
{chapter.name}
@@ -214,7 +218,7 @@ const ContentLibrary = () => { {resources .filter((resource) => resource.topic_id === topic.id) .map((resource) => ( -
  • +
  • handleResourceTracking(resource.name)} className="py-2"> Play {resource.name}