Skip to content

Commit

Permalink
Send tracking on view achievements
Browse files Browse the repository at this point in the history
  • Loading branch information
mleduc-pass committed Nov 30, 2024
1 parent a11292a commit 5d1908a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/features/navigation/RootNavigator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export type RootStackParamList = {
ThematicHeaders: undefined
MarketingBlocks: undefined
MovieCalendar: undefined
Achievements: undefined
Achievements: { from: 'profile' | 'success' }
} & AccessibilityRootStackParamList &
CulturalSurveyRootStackParamList &
TutorialRootStackParamList &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const BadgeBanner: React.FC = () => {
<InternalTouchableLink
navigateTo={{
screen: 'Achievements',
params: { from: 'profile' },
}}>
<GenericBanner LeftIcon={<BicolorTrophy size={theme.icons.sizes.standard} />}>
<Typo.ButtonText>Mes badges</Typo.ButtonText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const AchievementSuccessModal = ({ visible, hideModal, ids }: Props) => {
<InternalTouchableLink
as={ButtonPrimary}
wording="Accéder à mes succès"
navigateTo={{ screen: 'Achievements' }}
navigateTo={{ screen: 'Achievements', params: { from: 'success' } }}
onBeforeNavigate={() => {
hideModal()
}}
Expand Down
13 changes: 11 additions & 2 deletions src/features/profile/pages/Achievements/Achievements.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { FC } from 'react'
import { useRoute } from '@react-navigation/native'
import React, { FC, useEffect } from 'react'
import { View } from 'react-native'
import { FlatList } from 'react-native-gesture-handler'
import { useTheme } from 'styled-components'
import styled from 'styled-components/native'

import { UseRouteType } from 'features/navigation/RootNavigator/types'
import { Badge } from 'features/profile/components/Achievements/Badge'
import {
achievementCategoryDisplayNames,
Expand All @@ -28,12 +30,19 @@ const emptyBadge = {
}

export const Achievements = () => {
const {
params: { from },
} = useRoute<UseRouteType<'Achievements'>>()
const { uniqueColors } = useTheme()
const { categories } = useAchievements({
const { categories, track } = useAchievements({
achievements: mockAchievements,
completedAchievements: mockCompletedAchievements,
})

useEffect(() => {
track(from)
}, [from, track])

return (
<SecondaryPageWithBlurHeader title="">
<ViewGap gap={4}>
Expand Down
4 changes: 2 additions & 2 deletions src/features/profile/pages/Achievements/useAchievements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Categories = {
}[]
}[]

type UseAchivements = {
type UseAchievements = {
categories: Categories
track: (from: 'profile' | 'success') => void
}
Expand All @@ -33,7 +33,7 @@ export type UseAchivementsProps = {
export const useAchievements = ({
achievements,
completedAchievements,
}: UseAchivementsProps): UseAchivements => {
}: UseAchivementsProps): UseAchievements => {
const categories = getAchievementsCategories(achievements).map(
createCategory(achievements, completedAchievements)
)
Expand Down
2 changes: 1 addition & 1 deletion src/features/profile/pages/Profile.native.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('Profile component', () => {

fireEvent.press(badgeBanner)

expect(navigate).toHaveBeenCalledWith('Achievements', undefined)
expect(navigate).toHaveBeenCalledWith('Achievements', { from: 'profile' })
})
})

Expand Down
2 changes: 2 additions & 0 deletions src/libs/analytics/logEventAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ export const logEventAnalytics = {
analytics.logEvent({ firebase: AnalyticsEvent.DISMISS_NOTIFICATIONS }),
logDismissShareApp: (type: ShareAppModalType) =>
analytics.logEvent({ firebase: AnalyticsEvent.DISMISS_SHARE_APP }, { type }),
logDisplayAchievements: (params: { from: 'profile' | 'success'; numberUnlocked: number }) =>
analytics.logEvent({ firebase: AnalyticsEvent.DISPLAY_ACHIEVEMENTS }, params),
logDisplayForcedLoginHelpMessage: () =>
analytics.logEvent({ firebase: AnalyticsEvent.DISPLAY_FORCED_LOGIN_HELP_MESSAGE }),
logEduconnectExplanationClicked: () =>
Expand Down

0 comments on commit 5d1908a

Please sign in to comment.