Skip to content

Commit d50fa11

Browse files
authored
feat: add homepage click events (supabase#33005)
* feat: add homepage click events * fix codeowners telemetry filepath
1 parent 439f039 commit d50fa11

File tree

8 files changed

+135
-6
lines changed

8 files changed

+135
-6
lines changed

.github/CODEOWNERS

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/packages/shared-data/pricing.ts @roryw10 @kevcodez
22
/packages/shared-data/plans.ts @roryw10 @kevcodez
3+
/packages/common/telemetry-constants.ts @4L3k51 @loong @pamelachia
34

45
/apps/studio/ @supabase/Dashboard
56

@@ -17,5 +18,3 @@
1718
/apps/studio/components/interfaces/Organization/BillingSettings/ @supabase/security
1819
/apps/studio/components/interfaces/Organization/Documents/ @supabase/security
1920
/apps/studio/pages/new/index.tsx @supabase/security
20-
21-
/apps/studio/common/telemetry-constants.ts @4L3k51 @loong @pamelachia

apps/www/components/BuiltWithSupabase/ExamplesMobile.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const ExamplesMobile: FC<Props> = ({ examples, className }: any) => {
4242
>
4343
{examples.map((example: Example, i: number) => (
4444
<SwiperSlide key={`${content}-${i}`}>
45-
<ExampleCard {...example} showProducts />
45+
<ExampleCard {...example} showProducts inHomepage />
4646
</SwiperSlide>
4747
))}
4848
</Swiper>

apps/www/components/BuiltWithSupabase/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const BuiltWithSupabase = () => {
4545
)}
4646
key={i}
4747
>
48-
<ExampleCard {...example} showProducts />
48+
<ExampleCard {...example} showProducts inHomepage />
4949
</div>
5050
)
5151
})}

apps/www/components/CustomerStories/index.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import Panel from '~/components/Panel'
1212

1313
import customerStories from '~/data/CustomerStories'
1414
import type { CustomerStoryType } from '~/data/CustomerStories'
15+
import { useSendTelemetryEvent } from '~/lib/telemetry'
16+
import { TelemetryActions } from 'common/telemetry-constants'
1517

1618
const CustomersSliderMobile = dynamic(() => import('./CustomersSliderMobile'))
1719
const CutomsersSliderDesktop = dynamic(() => import('./CutomsersSliderDesktop'))
@@ -99,6 +101,7 @@ const compositionCols: CompositionColType[] = [
99101
]
100102

101103
export const CompositionCol: React.FC<CompositionColProps> = ({ column, className }) => {
104+
const sendTelemetryEvent = useSendTelemetryEvent()
102105
return (
103106
<div className={className}>
104107
{column.cards.map((customer) =>
@@ -107,6 +110,12 @@ export const CompositionCol: React.FC<CompositionColProps> = ({ column, classNam
107110
href={customer.url!}
108111
key={customer.organization}
109112
className="col-span-12 md:col-span-4 w-full md:w-[450px] h-full"
113+
onClick={() =>
114+
sendTelemetryEvent({
115+
action: TelemetryActions.HOMEPAGE_CUSTOMER_STORY_CARD_CLICKED,
116+
properties: { customer: customer.organization, cardType: 'expanded' },
117+
})
118+
}
110119
>
111120
<CustomerCard size="expanded" customer={customer} />
112121
</Link>
@@ -115,6 +124,12 @@ export const CompositionCol: React.FC<CompositionColProps> = ({ column, classNam
115124
href={customer.url!}
116125
key={customer.organization}
117126
className="col-span-12 md:col-span-4 w-full h-full flex-grow"
127+
onClick={() =>
128+
sendTelemetryEvent({
129+
action: TelemetryActions.HOMEPAGE_CUSTOMER_STORY_CARD_CLICKED,
130+
properties: { customer: customer.organization, cardType: 'narrow' },
131+
})
132+
}
118133
>
119134
<CustomerCard size="narrow" customer={customer} />
120135
</Link>

apps/www/components/ExampleCard.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import { useBreakpoint } from 'common'
55

66
import { Button } from 'ui'
77
import Panel from './Panel'
8+
import { useSendTelemetryEvent } from '~/lib/telemetry'
9+
import { TelemetryActions } from 'common/telemetry-constants'
810

911
function ExampleCard(props: any) {
1012
const isXs = useBreakpoint()
1113
const [mounted, setMounted] = useState(false)
14+
const sendTelemetryEvent = useSendTelemetryEvent()
1215

1316
useEffect(() => {
1417
setMounted(true)
@@ -17,7 +20,18 @@ function ExampleCard(props: any) {
1720
if (!mounted) return null
1821

1922
return (
20-
<Link href={props.repo_url} className="w-full h-full" target="_blank">
23+
<Link
24+
href={props.repo_url}
25+
className="w-full h-full"
26+
target="_blank"
27+
onClick={() => {
28+
if (props.inHomepage)
29+
sendTelemetryEvent({
30+
action: TelemetryActions.HOMEPAGE_PROJECT_TEMPLATE_CARD_CLICKED,
31+
properties: { templateTitle: props.title },
32+
})
33+
}}
34+
>
2135
<Panel outerClassName="h-full" innerClassName="bg-surface-75 group/panel" hasActiveOnHover>
2236
<div className="flex flex-col justify-between">
2337
{props.tags && (

apps/www/components/Nav/GitHubButton.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react'
22
import { Button } from 'ui'
33
import { githubStars } from '~/.contentlayer/generated/staticContent/_index.json' with { type: 'json' }
4+
import { useSendTelemetryEvent } from '~/lib/telemetry'
5+
import { TelemetryActions } from 'common/telemetry-constants'
46

57
const GitHubButton = () => {
68
const kFormatter = (num: number) => {
@@ -19,12 +21,16 @@ const GitHubButton = () => {
1921
? `${kFormat}.${decimalPart >= 8 ? hundreds + 1 : hundreds}K`
2022
: `${isAlmostNextThousand ? kFormat + 1 : kFormat}K`
2123
}
24+
const sendTelemetryEvent = useSendTelemetryEvent()
2225

2326
return (
2427
<Button
2528
className="hidden group lg:flex text-foreground-light hover:text-foreground"
2629
type="text"
2730
asChild
31+
onClick={() =>
32+
sendTelemetryEvent({ action: TelemetryActions.HOMEPAGE_GITHUB_BUTTON_CLICKED })
33+
}
2834
>
2935
<a type={undefined} href="https://github.com/supabase/supabase" target="_blank">
3036
<span className="flex items-center gap-1">

apps/www/components/TwitterSocialSection.tsx

+18-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import TwitterSocialProof from './Sections/TwitterSocialProof'
66
import TwitterSocialProofMobile from './Sections/TwitterSocialProofMobile'
77

88
import Tweets from '~/data/tweets/Tweets.json'
9+
import { useSendTelemetryEvent } from '~/lib/telemetry'
10+
import { TelemetryActions } from 'common/telemetry-constants'
911

1012
const TwitterSocialSection = () => {
1113
const tweets = Tweets.slice(0, 18)
14+
const sendTelemetryEvent = useSendTelemetryEvent()
1215

1316
return (
1417
<>
@@ -23,12 +26,26 @@ const TwitterSocialSection = () => {
2326
href={'https://github.com/supabase/supabase/discussions'}
2427
target="_blank"
2528
tabIndex={-1}
29+
onClick={() =>
30+
sendTelemetryEvent({
31+
action: TelemetryActions.HOMEPAGE_GITHUB_DISCUSSIONS_BUTTON_CLICKED,
32+
})
33+
}
2634
>
2735
GitHub discussions
2836
</Link>
2937
</Button>
3038
<Button asChild type="default" size="small" iconRight={<MessageCircle size={14} />}>
31-
<Link href={'https://discord.supabase.com/'} target="_blank" tabIndex={-1}>
39+
<Link
40+
href={'https://discord.supabase.com/'}
41+
target="_blank"
42+
tabIndex={-1}
43+
onClick={() =>
44+
sendTelemetryEvent({
45+
action: TelemetryActions.HOMEPAGE_DISCORD_BUTTON_CLICKED,
46+
})
47+
}
48+
>
3249
Discord
3350
</Link>
3451
</Button>

packages/common/telemetry-constants.ts

+78
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export enum TelemetryActions {
5151
PRICING_PLAN_CTA_CLICKED = 'pricing_plan_cta_clicked',
5252
PRICING_COMPARISON_PLAN_CLICKED = 'pricing_comparison_plan_clicked',
5353
EVENT_PAGE_CTA_CLICKED = 'event_page_cta_clicked',
54+
HOMEPAGE_GITHUB_BUTTON_CLICKED = 'homepage_github_button_clicked',
55+
HOMEPAGE_GITHUB_DISCUSSIONS_BUTTON_CLICKED = 'homepage_github_discussions_button_clicked',
56+
HOMEPAGE_DISCORD_BUTTON_CLICKED = 'homepage_discord_button_clicked',
57+
HOMEPAGE_CUSTOMER_STORY_CARD_CLICKED = 'homepage_customer_story_card_clicked',
58+
HOMEPAGE_PROJECT_TEMPLATE_CARD_CLICKED = 'homepage_project_template_card_clicked',
5459
}
5560

5661
/**
@@ -754,6 +759,74 @@ export interface EventPageCtaClickedEvent {
754759
}
755760
}
756761

762+
/**
763+
* User clicked on the GitHub button in the homepage header section. Is hidden when in mobile view.
764+
*
765+
* @group Events
766+
* @source www
767+
* @page /
768+
*/
769+
export interface HomepageGitHubButtonClickedEvent {
770+
action: TelemetryActions.HOMEPAGE_GITHUB_BUTTON_CLICKED
771+
}
772+
773+
/**
774+
* User clicked on the GitHub Discussions button in the homepage community section.
775+
*
776+
* @group Events
777+
* @source www
778+
* @page /
779+
*/
780+
export interface HomepageGitHubDiscussionsButtonClickedEvent {
781+
action: TelemetryActions.HOMEPAGE_GITHUB_DISCUSSIONS_BUTTON_CLICKED
782+
}
783+
784+
/**
785+
* User clicked on the Discord button in the homepage community section.
786+
*
787+
* @group Events
788+
* @source www
789+
* @page /
790+
*/
791+
export interface HomepageDiscordButtonClickedEvent {
792+
action: TelemetryActions.HOMEPAGE_DISCORD_BUTTON_CLICKED
793+
}
794+
795+
/**
796+
* User clicked on a customer story in the homepage.
797+
*
798+
* @group Events
799+
* @source www
800+
* @page /
801+
*/
802+
export interface HomepageCustomerStoryCardClickedEvent {
803+
action: TelemetryActions.HOMEPAGE_CUSTOMER_STORY_CARD_CLICKED
804+
properties: {
805+
customer?: string
806+
/**
807+
* The size of the card clicked.
808+
*/
809+
cardType: 'expanded' | 'narrow'
810+
}
811+
}
812+
813+
/**
814+
* User clicked on a project template card in the homepage.
815+
*
816+
* @group Events
817+
* @source www
818+
* @page /
819+
*/
820+
export interface HomepageProjectTemplateCardClickedEvent {
821+
action: TelemetryActions.HOMEPAGE_PROJECT_TEMPLATE_CARD_CLICKED
822+
properties: {
823+
/**
824+
* The title of the project template card clicked.
825+
*/
826+
templateTitle: string
827+
}
828+
}
829+
757830
export type TelemetryEvent =
758831
| SignUpEvent
759832
| SignInEvent
@@ -796,3 +869,8 @@ export type TelemetryEvent =
796869
| PricingPlanCtaClickedEvent
797870
| PricingComparisonPlanClickedEvent
798871
| EventPageCtaClickedEvent
872+
| HomepageGitHubButtonClickedEvent
873+
| HomepageGitHubDiscussionsButtonClickedEvent
874+
| HomepageDiscordButtonClickedEvent
875+
| HomepageCustomerStoryCardClickedEvent
876+
| HomepageProjectTemplateCardClickedEvent

0 commit comments

Comments
 (0)