Skip to content

Commit

Permalink
Add space suggested events
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Mar 7, 2024
1 parent 3b1407a commit b0a8317
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/onboarding/RecommendedSpacesOnboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect, useMemo, useState } from 'react'
import { useMyAddress } from 'src/components/auth/MyAccountsContext'
import config from 'src/config'
import { useBooleanExternalStorage } from 'src/hooks/useExternalStorage'
import { useSendEvent } from 'src/providers/AnalyticContext'
import { useMyAccount } from 'src/stores/my-account'
import { useIsMobileWidthOrDevice } from '../responsive'
import SpacesSuggestedForOnBoarding from '../spaces/SpacesSuggestedForOnBoarding'
Expand All @@ -19,6 +20,7 @@ const shuffledRecommendedSpaceIds = recommendedSpaceIds.sort(() => Math.random()
export default function RecommendedSpacesOnboarding() {
const myAddress = useMyAddress()
const isMobile = useIsMobileWidthOrDevice()
const sendEvent = useSendEvent()
const isInitializedProxy = useMyAccount(state => state.isInitializedProxy)
const { data: isFinishedOnBoarding, setData: setIsFinishedOnBoarding } =
useBooleanExternalStorage(ON_BOARDING_MODAL_KEY, {
Expand All @@ -40,6 +42,7 @@ export default function RecommendedSpacesOnboarding() {
}, [myAddress, isInitializedProxy, isFinishedOnBoarding])

const closeModal = () => {
sendEvent('login_space_suggestion_skipped')
setIsOpen(false)
setIsFinishedOnBoarding(true)
setIsOnBoardingSkipped(true)
Expand Down Expand Up @@ -75,6 +78,7 @@ export default function RecommendedSpacesOnboarding() {
onClick: (space, type) => {
const currentSpaces = new Set(spacesSet)
if (type === 'follow') {
sendEvent('login_space_suggestion_followed', { value: space.id })
currentSpaces.add(space.id)
} else {
currentSpaces.delete(space.id)
Expand All @@ -95,7 +99,10 @@ export default function RecommendedSpacesOnboarding() {
type='primary'
params={() => [selectedSpaces.map(id => api.tx.spaceFollows.followSpace(id))]}
disabled={selectedSpaces.length === 0}
onSend={() => closeModal()}
onSend={() => {
sendEvent('login_space_suggestion_finished')
closeModal()
}}
>
Finish
</ResolvedTxButton>
Expand Down

0 comments on commit b0a8317

Please sign in to comment.