Skip to content

Commit

Permalink
Add tracking for selecting topic, live toggle and pill
Browse files Browse the repository at this point in the history
  • Loading branch information
jahooma committed Apr 13, 2023
1 parent 4cdacfe commit dc97959
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
18 changes: 14 additions & 4 deletions web/components/activity-log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { Content } from './widgets/editor'
import { LoadingIndicator } from './widgets/loading-indicator'
import { UserLink } from './widgets/user-link'
import { db } from 'web/lib/supabase/db'
import { track } from 'web/lib/service/analytics'

const EXTRA_USERNAMES_TO_EXCLUDE = ['Charlie', 'GamblingGandalf']

Expand Down Expand Up @@ -203,28 +204,37 @@ export const LivePillOptions = (props: {
}) => {
const { pill, setPill } = props

const selectPill = (pill: pill_options) => {
setPill(pill)
track('select live feed pill', { pill })
}

return (
<Row className="mx-2 gap-2 sm:mx-0">
<PillButton selected={pill === 'all'} onSelect={() => setPill('all')} xs>
<PillButton
selected={pill === 'all'}
onSelect={() => selectPill('all')}
xs
>
All
</PillButton>
<PillButton
selected={pill === 'markets'}
onSelect={() => setPill('markets')}
onSelect={() => selectPill('markets')}
xs
>
Markets
</PillButton>
<PillButton
selected={pill === 'comments'}
onSelect={() => setPill('comments')}
onSelect={() => selectPill('comments')}
xs
>
Comments
</PillButton>
<PillButton
selected={pill === 'trades'}
onSelect={() => setPill('trades')}
onSelect={() => selectPill('trades')}
xs
>
Trades
Expand Down
8 changes: 7 additions & 1 deletion web/components/topic-selector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { uniq } from 'lodash'
import { cleanTopic, TOPICS_TO_SUBTOPICS } from 'common/topics'
import { Select } from './widgets/select'
import { track } from 'web/lib/service/analytics'

export function TopicSelector(props: {
topic: string | undefined
Expand All @@ -9,11 +10,16 @@ export function TopicSelector(props: {
const { topic, onSetTopic } = props
const subtopics = uniq(Object.values(TOPICS_TO_SUBTOPICS).flat())

const selectTopic = (topic: string) => {
onSetTopic(topic)
track('select topic', { topic })
}

return (
<Select
className="!border-ink-200"
value={topic}
onChange={(e) => onSetTopic(e.target.value)}
onChange={(e) => selectTopic(e.target.value)}
>
<option value="">🖤 For you</option>
{subtopics.map((subtopic) => (
Expand Down
7 changes: 6 additions & 1 deletion web/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ const MainContent = () => {
'live-pill'
)

const selectLive = (on: boolean) => {
setIsLive(on)
track('select live', { on })
}

return (
<Col>
<Row className="h-[48px] items-center justify-between">
Expand All @@ -249,7 +254,7 @@ const MainContent = () => {
)}
<Row className="items-center gap-3">
Live
<ShortToggle on={isLive} setOn={setIsLive} />
<ShortToggle on={isLive} setOn={selectLive} />
</Row>
</Row>
<YourFeedSection topic={topic} className={clsx(isLive ? 'hidden' : '')} />
Expand Down

0 comments on commit dc97959

Please sign in to comment.