Skip to content

Commit ef1c658

Browse files
committed
feat: integrate display layout tracking and identification in analytics
1 parent 18c43e3 commit ef1c658

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/features/settings/components/GeneralSettings/LayoutSettings.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Select, {
77
SingleValueProps,
88
components,
99
} from 'react-select'
10+
import { identifyDisplayLayout, trackDisplayTypeChange } from 'src/lib/analytics'
1011
import { useUserPreferences } from 'src/stores/preferences'
1112
import { Layout } from 'src/types'
1213

@@ -50,6 +51,8 @@ export const LayoutSettings = () => {
5051
}
5152

5253
setLayout(selectedOption.value)
54+
identifyDisplayLayout(selectedOption.value)
55+
trackDisplayTypeChange(selectedOption.value)
5356
}
5457

5558
const getDefaultValue = (): LayoutOption | undefined => {

src/lib/analytics.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ enum Objects {
2121
ONBOARDING = 'Onboarding',
2222
RSS = 'Rss',
2323
DO_NOT_DISTURB = 'DND',
24+
DISPLAY_LAYOUT = 'Display Layout',
2425
}
2526

2627
enum Verbs {
@@ -74,6 +75,7 @@ export enum Attributes {
7475
PROVIDER = 'Provider',
7576
ADV = 'ADV',
7677
STREAK = 'Streak',
78+
DISPLAY_LAYOUT = 'Display Layout',
7779
}
7880

7981
const _SEP_ = ' '
@@ -102,6 +104,7 @@ export const setupIdentification = () => {
102104
openLinksNewTab,
103105
promptEngine,
104106
maxVisibleCards,
107+
layout,
105108
} = useUserPreferences.getState()
106109

107110
identifyUserProperty(Attributes.RESOLUTION, getScreenResolution())
@@ -112,6 +115,7 @@ export const setupIdentification = () => {
112115
identifyUserSearchEngine(promptEngine)
113116
identifyUserLinksInNewTab(openLinksNewTab)
114117
identifyUserMaxVisibleCards(maxVisibleCards)
118+
identifyDisplayLayout(layout)
115119
if (onboardingResult?.title) {
116120
identifyUserOccupation(onboardingResult.title)
117121
}
@@ -403,6 +407,16 @@ export const trackUserDelete = () => {
403407
})
404408
}
405409

410+
export const trackDisplayTypeChange = (value: "grid" | "cards") => {
411+
trackEvent({
412+
object: Objects.DISPLAY_LAYOUT,
413+
verb: Verbs.CHANGE,
414+
attributes: {
415+
[Attributes.DISPLAY_LAYOUT]: value,
416+
},
417+
})
418+
}
419+
406420
// Identification
407421

408422
export const identifyUserLanguages = (languages: string[]) => {
@@ -438,6 +452,9 @@ export const identifyAdvBlocked = (blocked: boolean) => {
438452
export const identifyUserStreak = (value: number) => {
439453
identifyUserProperty(Attributes.STREAK, value)
440454
}
455+
export const identifyDisplayLayout = (value: "grid" | "cards") => {
456+
identifyUserProperty(Attributes.DISPLAY_LAYOUT, value)
457+
}
441458
// Private functions
442459
type trackEventProps = {
443460
object: Exclude<Objects, null | undefined>

0 commit comments

Comments
 (0)