Skip to content

Commit

Permalink
Merge pull request #185 from gruz0/refactor/reorganize-plausible-goals
Browse files Browse the repository at this point in the history
Reorganize Plausible goals
  • Loading branch information
gruz0 authored Nov 24, 2024
2 parents 7d241b8 + f99cbd3 commit 80ddda3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/app/concepts/[id]/ProblemRequiresChanges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
},
})
Expand Down
4 changes: 3 additions & 1 deletion src/app/concepts/[id]/WellDefinedProblem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,8 +42,9 @@ const WellDefinedProblem = ({ conceptId, evaluation }: Props) => {
setStatus('loading')
setErrorMessage(null)

plausible('analysis', {
plausible(Goals.Analysis, {
props: {
page: 'WellDefinedProblem',
buttonId: 'well_defined',
},
})
Expand Down
19 changes: 16 additions & 3 deletions src/app/ideas/[id]/IdeaAnalysisReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -243,7 +244,13 @@ export const IdeaAnalysisReport = ({ data }: Props) => {
{readyForReport ? (
<Link
href={`/api/ideas/${data.id}/pdf`}
onClick={() => 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"
>
Expand Down Expand Up @@ -345,7 +352,13 @@ export const IdeaAnalysisReport = ({ data }: Props) => {
{readyForReport ? (
<Link
href={`/api/ideas/${data.id}/pdf`}
onClick={() => 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"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions src/lib/goals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum Goals {
Analysis = 'analysis',
DownloadPDF = 'download_pdf',
ArchiveReport = 'archive_report',
RequestSocialMediaCampaigns = 'request_social_media_campaigns',
}

0 comments on commit 80ddda3

Please sign in to comment.