@@ -38,6 +38,7 @@ enum Verbs {
3838 FINISH = 'Finish' ,
3939 SKIP = 'Skip' ,
4040 DRAG = 'Drag' ,
41+ Change = 'Change' ,
4142}
4243
4344export enum Attributes {
@@ -60,6 +61,7 @@ export enum Attributes {
6061 SOURCE_TAGS = 'Source Tags' ,
6162 CAMPAIGN_ID = 'Campaign Id' ,
6263 OCCUPATION = 'Occupation' ,
64+ MAX_VISIBLE_CARDS = 'Max Visible Cards' ,
6365}
6466
6567const _SEP_ = ' '
@@ -82,6 +84,7 @@ export const setupIdentification = () => {
8284 listingMode,
8385 openLinksNewTab,
8486 searchEngine,
87+ maxVisibleCards
8588 } = useUserPreferences . getState ( )
8689
8790 identifyUserProperty ( Attributes . RESOLUTION , getScreenResolution ( ) )
@@ -91,6 +94,7 @@ export const setupIdentification = () => {
9194 identifyUserListingMode ( listingMode )
9295 identifyUserSearchEngine ( searchEngine )
9396 identifyUserLinksInNewTab ( openLinksNewTab )
97+ identifyUserMaxVisibleCards ( maxVisibleCards )
9498 if ( onboardingResult ?. title ) {
9599 identifyUserOccupation ( onboardingResult . title )
96100 }
@@ -291,6 +295,14 @@ export const trackPageDrag = () => {
291295 } )
292296}
293297
298+ export const trackMaxVisibleCardsChange = ( maxVisibleCards : number ) => {
299+ trackEvent ( {
300+ object : Objects . CARD ,
301+ verb : Verbs . Change ,
302+ attributes : { [ Attributes . MAX_VISIBLE_CARDS ] : maxVisibleCards }
303+ } )
304+ }
305+
294306// Identification
295307
296308export const identifyUserLanguages = ( languages : string [ ] ) => {
@@ -317,7 +329,9 @@ export const identifyUserLinksInNewTab = (enabled: boolean) => {
317329export const identifyUserOccupation = ( occupation : string ) => {
318330 identifyUserProperty ( Attributes . OCCUPATION , occupation )
319331}
320-
332+ export const identifyUserMaxVisibleCards = ( maxVisibleCards : number ) => {
333+ identifyUserProperty ( Attributes . MAX_VISIBLE_CARDS , maxVisibleCards )
334+ }
321335
322336// Private functions
323337type trackEventProps = {
@@ -365,13 +379,13 @@ const trackEvent = ({ object, verb, attributes }: trackEventProps) => {
365379 }
366380}
367381
368- const identifyUserProperty = ( attributes : Attributes , value : string | string [ ] ) => {
382+ const identifyUserProperty = ( attributes : Attributes , value : string | number | string [ ] ) => {
369383 try {
370384 let formatedValue
371385 if ( Array . isArray ( value ) ) {
372386 formatedValue = value . filter ( Boolean ) . map ( ( item ) => item . toLowerCase ( ) )
373387 } else {
374- formatedValue = value . toLowerCase ( )
388+ formatedValue = typeof value === "string" ? value . toLowerCase ( ) : value . toString ( )
375389 }
376390
377391 if ( isDevelopment ( ) ) {
0 commit comments