From f99cbd3b7399cb6d49765083cd929999f133b6cf Mon Sep 17 00:00:00 2001 From: Alexander Kadyrov Date: Sun, 24 Nov 2024 13:34:13 +0400 Subject: [PATCH] Reorganize Plausible goals --- .../concepts/[id]/ProblemRequiresChanges.tsx | 4 +++- src/app/concepts/[id]/WellDefinedProblem.tsx | 4 +++- src/app/ideas/[id]/IdeaAnalysisReport.tsx | 19 ++++++++++++++++--- .../SocialMediaCampaigns.tsx | 3 ++- src/lib/goals.ts | 6 ++++++ 5 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 src/lib/goals.ts diff --git a/src/app/concepts/[id]/ProblemRequiresChanges.tsx b/src/app/concepts/[id]/ProblemRequiresChanges.tsx index 27042a3..05c3ceb 100644 --- a/src/app/concepts/[id]/ProblemRequiresChanges.tsx +++ b/src/app/concepts/[id]/ProblemRequiresChanges.tsx @@ -6,6 +6,7 @@ import React, { useState } from 'react' import ConceptForm from '@/components/ConceptForm' import Paragraph from '@/components/Paragraph' import Section from '@/components/Section' +import { Goals } from '@/lib/goals' interface TargetAudience { segment: string @@ -43,8 +44,9 @@ const ProblemRequiresChanges = ({ conceptId, problem, evaluation }: Props) => { setStatus('loading') setErrorMessage(null) - plausible('analysis', { + plausible(Goals.Analysis, { props: { + page: 'ProblemRequiresChanges', buttonId: 'requires_changes', }, }) diff --git a/src/app/concepts/[id]/WellDefinedProblem.tsx b/src/app/concepts/[id]/WellDefinedProblem.tsx index 1c5c5b6..4e63bea 100644 --- a/src/app/concepts/[id]/WellDefinedProblem.tsx +++ b/src/app/concepts/[id]/WellDefinedProblem.tsx @@ -5,6 +5,7 @@ import React, { useState } from 'react' import Paragraph from '@/components/Paragraph' import Section from '@/components/Section' import SimpleUnorderedList from '@/components/SimpleUnorderedList' +import { Goals } from '@/lib/goals' interface TargetAudience { segment: string @@ -41,8 +42,9 @@ const WellDefinedProblem = ({ conceptId, evaluation }: Props) => { setStatus('loading') setErrorMessage(null) - plausible('analysis', { + plausible(Goals.Analysis, { props: { + page: 'WellDefinedProblem', buttonId: 'well_defined', }, }) diff --git a/src/app/ideas/[id]/IdeaAnalysisReport.tsx b/src/app/ideas/[id]/IdeaAnalysisReport.tsx index e536f87..b38fe10 100644 --- a/src/app/ideas/[id]/IdeaAnalysisReport.tsx +++ b/src/app/ideas/[id]/IdeaAnalysisReport.tsx @@ -8,6 +8,7 @@ import BackToTopButton from '@/components/BackToTopButton' import FeedbackForm from '@/components/FeedbackForm' import HorizontalLine from '@/components/HorizontalLine' import MessageBox from '@/components/MessageBox' +import { Goals } from '@/lib/goals' import { NavBar } from './components/NavBar' import SectionActionableNextSteps from './components/SectionActionableNextSteps' import SectionCompetitors from './components/SectionCompetitors' @@ -159,7 +160,7 @@ export const IdeaAnalysisReport = ({ data }: Props) => { } try { - plausible('archive_report') + plausible(Goals.ArchiveReport) const res = await fetch(`/api/ideas/${data.id}`, { method: 'DELETE', @@ -243,7 +244,13 @@ export const IdeaAnalysisReport = ({ data }: Props) => { {readyForReport ? ( plausible('download_pdf')} + onClick={() => + plausible(Goals.DownloadPDF, { + props: { + buttonId: 'top_button', + }, + }) + } target="_blank" className="rounded bg-blue-600 px-4 py-2 font-semibold text-white hover:bg-blue-700" > @@ -345,7 +352,13 @@ export const IdeaAnalysisReport = ({ data }: Props) => { {readyForReport ? ( plausible('download_pdf')} + onClick={() => + plausible(Goals.DownloadPDF, { + props: { + buttonId: 'bottom_button', + }, + }) + } target="_blank" className="rounded bg-blue-600 px-4 py-2 font-semibold text-white hover:bg-blue-700" > diff --git a/src/app/ideas/[id]/social_media_campaigns/SocialMediaCampaigns.tsx b/src/app/ideas/[id]/social_media_campaigns/SocialMediaCampaigns.tsx index 7f47ec1..05a1318 100644 --- a/src/app/ideas/[id]/social_media_campaigns/SocialMediaCampaigns.tsx +++ b/src/app/ideas/[id]/social_media_campaigns/SocialMediaCampaigns.tsx @@ -7,6 +7,7 @@ import BackToTopButton from '@/components/BackToTopButton' import FeedbackForm from '@/components/FeedbackForm' import FetchingDataMessage from '@/components/FetchingDataMessage' import HorizontalLine from '@/components/HorizontalLine' +import { Goals } from '@/lib/goals' import { NavBar } from './components/NavBar' import SectionLongFormContent from './components/SectionLongFormContent' import SectionShortFormContent from './components/SectionShortFormContent' @@ -105,7 +106,7 @@ export const SocialMediaCampaigns = ({ data }: Props) => { setStatus('loading') try { - plausible('request_social_media_campaigns') + plausible(Goals.RequestSocialMediaCampaigns) const res = await fetch(`/api/ideas/${data.id}/social_media_campaigns`, { method: 'POST', diff --git a/src/lib/goals.ts b/src/lib/goals.ts new file mode 100644 index 0000000..b2cc5f0 --- /dev/null +++ b/src/lib/goals.ts @@ -0,0 +1,6 @@ +export enum Goals { + Analysis = 'analysis', + DownloadPDF = 'download_pdf', + ArchiveReport = 'archive_report', + RequestSocialMediaCampaigns = 'request_social_media_campaigns', +}