Skip to content

Commit a19ae16

Browse files
fix(landing): restore homepage view tracking (#6260)
1 parent c14818b commit a19ae16

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @vitest-environment node
3+
*/
4+
import { renderToStaticMarkup } from 'react-dom/server'
5+
import { describe, expect, it, vi } from 'vitest'
6+
7+
vi.mock('@sim/emcn', () => ({
8+
cn: (...values: Array<string | false | null | undefined>) => values.filter(Boolean).join(' '),
9+
}))
10+
11+
vi.mock('@/app/(landing)/components', () => ({
12+
Cta: () => null,
13+
Features: () => null,
14+
Hero: () => null,
15+
HomeStructuredData: () => null,
16+
Mothership: () => null,
17+
ProductDemo: () => null,
18+
}))
19+
20+
vi.mock('@/app/(landing)/components/landing-layout', () => ({
21+
LANDING_SECTION_RHYTHM: 'gap-test',
22+
}))
23+
24+
vi.mock('@/app/(landing)/landing-analytics', () => ({
25+
LandingAnalytics: () => <span>landing-analytics-marker</span>,
26+
}))
27+
28+
import Landing from '@/app/(landing)/landing'
29+
30+
describe('Landing', () => {
31+
it('mounts the landing page analytics tracker exactly once', () => {
32+
const markup = renderToStaticMarkup(<Landing />)
33+
34+
expect(markup.match(/landing-analytics-marker/g)).toHaveLength(1)
35+
})
36+
})

apps/sim/app/(landing)/landing.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ProductDemo,
99
} from '@/app/(landing)/components'
1010
import { LANDING_SECTION_RHYTHM } from '@/app/(landing)/components/landing-layout'
11+
import { LandingAnalytics } from '@/app/(landing)/landing-analytics'
1112

1213
/**
1314
* Landing page root - owns the section order and the `<main>` content region.
@@ -26,6 +27,7 @@ import { LANDING_SECTION_RHYTHM } from '@/app/(landing)/components/landing-layou
2627
export default function Landing() {
2728
return (
2829
<main id='main-content' className={cn('flex flex-col', LANDING_SECTION_RHYTHM)}>
30+
<LandingAnalytics />
2931
<HomeStructuredData />
3032
<Hero />
3133
<ProductDemo />

0 commit comments

Comments
 (0)