Skip to content

Commit d5616bc

Browse files
committed
feat: implement feed scroll tracking in analytics and improve layout class handling
1 parent ef1c658 commit d5616bc

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ export const App = () => {
8484

8585
<div
8686
className={clsx(
87-
'layoutLayers',
88-
layout === 'cards' ? 'cardsLayout hideScrollBar' : 'gridLayout'
87+
'layoutLayers hideScrollBar',
88+
layout === 'cards' ? 'cardsLayout' : 'gridLayout'
8989
)}>
9090
{isDNDModeActive() && <DNDLayout />}
9191
<AppContentLayout />

src/features/feed/components/Feed.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import useInfiniteScroll from 'react-infinite-scroll-hook'
22
import { PropagateLoader } from 'react-spinners'
33
import { useGetFeed } from 'src/features/cards'
4+
import { trackFeedScroll } from 'src/lib/analytics'
45
import { useUserPreferences } from 'src/stores/preferences'
56
import './feed.css'
67
import { AdvFeedItem } from './feedItems/AdvFeedItem'
@@ -24,7 +25,10 @@ export const Feed = () => {
2425
const [infiniteRef, {rootRef}] = useInfiniteScroll({
2526
loading: isLoading,
2627
hasNextPage: Boolean(hasNextPage),
27-
onLoadMore: fetchNextPage,
28+
onLoadMore: () => {
29+
fetchNextPage()
30+
trackFeedScroll()
31+
},
2832
disabled: Boolean(error),
2933
rootMargin: '0px 0px 100% 0px',
3034
})
@@ -46,7 +50,7 @@ export const Feed = () => {
4650
}
4751

4852
return (
49-
<div ref={rootRef} className="feed scrollable" style={{ overflow: 'auto', maxHeight: '100vh' }}>
53+
<div ref={rootRef} className="feed scrollable" style={{ overflow: 'auto', maxHeight: '100%' }}>
5054

5155
<div key={`adv`} className="feedItem">
5256
<AdvFeedItem />

src/lib/analytics.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ enum Objects {
2222
RSS = 'Rss',
2323
DO_NOT_DISTURB = 'DND',
2424
DISPLAY_LAYOUT = 'Display Layout',
25+
FEED = 'Feed',
2526
}
2627

2728
enum Verbs {
@@ -417,6 +418,12 @@ export const trackDisplayTypeChange = (value: "grid" | "cards") => {
417418
})
418419
}
419420

421+
export const trackFeedScroll = () => {
422+
trackEvent({
423+
object: Objects.FEED,
424+
verb: Verbs.SCROLL
425+
})
426+
}
420427
// Identification
421428

422429
export const identifyUserLanguages = (languages: string[]) => {

0 commit comments

Comments
 (0)