Skip to content

Commit

Permalink
feat(analytics/posthog): capture events
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun969 committed Nov 2, 2023
1 parent 9f1b085 commit 0502e9d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"githubPullRequests.ignoredPullRequestBranches": ["dev"]
"githubPullRequests.ignoredPullRequestBranches": ["dev"],
"i18n-ally.localesPaths": ["messages"]
}
9 changes: 8 additions & 1 deletion app/[locale]/careers/Careers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { cva } from 'class-variance-authority'
import { AnimatePresence, motion } from 'framer-motion'
import { Link, useTranslations } from 'next-intl'
import Image from 'next/image'
import { usePostHog } from 'posthog-js/react'
import React from 'react'
import { useForm } from 'react-hook-form'
import { BsFileEarmarkPdf } from 'react-icons/bs'
Expand All @@ -36,6 +37,7 @@ function makeJobLink(job: Job) {
}

export function Careers({ jobs }: { jobs: Job[] }) {
const posthog = usePostHog()
const t = useTranslations('Careers')

// extract mapper with squad.slug as keys and squad.title as values
Expand Down Expand Up @@ -76,7 +78,12 @@ export function Careers({ jobs }: { jobs: Job[] }) {
<h1>{t.rich('Heading')}</h1>
<p>{t.rich('Intro')}</p>

<ButtonLink href="#positions">
<ButtonLink
href="#positions"
onClick={() => {
posthog?.capture('click_see_all_cta')
}}
>
{t('SeeAllCTA')}&nbsp;
<TbArrowRight />
</ButtonLink>
Expand Down
24 changes: 21 additions & 3 deletions components/members/OurMembers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { atom, useAtom } from 'jotai'
import { useFormatter, useTranslations } from 'next-intl'
import Image from 'next/image'
import Link from 'next/link'
import { usePostHog } from 'posthog-js/react'
import React from 'react'
import { CgWebsite } from 'react-icons/cg'
import {
Expand Down Expand Up @@ -65,11 +66,17 @@ const SocialIconMap: Record<Unarray<Member['social']>['platform'], Component> =
xiaohongshu: CgWebsite,
website: CgWebsite,
}
function SocialLink({ social }: { social: Unarray<Member['social']> }) {
function SocialLink({
social,
onClick,
}: {
social: Unarray<Member['social']>
onClick?: () => void
}) {
const Icon = SocialIconMap[social.platform]

return (
<li className="flex items-center">
<li className="flex items-center" onClick={onClick}>
<Link
href={social.url}
target="_blank"
Expand All @@ -82,6 +89,8 @@ function SocialLink({ social }: { social: Unarray<Member['social']> }) {
}

function MemberCard({ member }: { member: Member }) {
const posthog = usePostHog()

const { dateTime: formatDateTime } = useFormatter()
const joined = React.useMemo(
() =>
Expand Down Expand Up @@ -158,7 +167,16 @@ function MemberCard({ member }: { member: Member }) {
{member.social && member.social.length > 0 && (
<ul className="mb-3 flex w-full items-center justify-center gap-1.5">
{member.social.map((social) => (
<SocialLink social={social} key={social._key} />
<SocialLink
social={social}
key={social._key}
onClick={() => {
posthog?.capture('click_social', {
name: member.name,
platform: social.platform,
})
}}
/>
))}
</ul>
)}
Expand Down

0 comments on commit 0502e9d

Please sign in to comment.