diff --git a/__mocks__/Analytics.ts b/__mocks__/Analytics.ts new file mode 100644 index 00000000..4d41f932 --- /dev/null +++ b/__mocks__/Analytics.ts @@ -0,0 +1 @@ +export const logEvent = jest.fn(); diff --git a/redux/GamesSlice.ts b/redux/GamesSlice.ts index 4cc348bc..0e4c4c42 100644 --- a/redux/GamesSlice.ts +++ b/redux/GamesSlice.ts @@ -1,8 +1,8 @@ -import analytics from '@react-native-firebase/analytics'; import { PayloadAction, createAsyncThunk, createEntityAdapter, createSelector, createSlice } from '@reduxjs/toolkit'; import { getContrastRatio } from 'colorsheet'; import * as Crypto from 'expo-crypto'; +import { logEvent } from '../src/Analytics'; import { getPalette } from '../src/ColorPalette'; import { SortDirectionKey, SortSelectorKey } from '../src/components/ScoreLog/SortHelper'; import logger from '../src/Logger'; @@ -153,7 +153,7 @@ export const asyncRematchGame = createAsyncThunk( dispatch(setCurrentGameId(newGameId)); - await analytics().logEvent('rematch_game', { + await logEvent('rematch_game', { gameId: game.id, }); @@ -226,7 +226,7 @@ export const asyncCreateGame = createAsyncThunk( dispatch(setCurrentGameId(newGameId)); - await analytics().logEvent('new_game', { + await logEvent('new_game', { index: gameCount, }); diff --git a/src/Analytics.ts b/src/Analytics.ts new file mode 100644 index 00000000..4c4675bd --- /dev/null +++ b/src/Analytics.ts @@ -0,0 +1,17 @@ +import analytics from '@react-native-firebase/analytics'; + +import logger from './Logger'; + +/** + * Logs an event to Firebase Analytics with additional logging. + * @param eventName The name of the event to log. + * @param params The parameters of the event. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const logEvent = async (eventName: string, params?: Record) => { + // Additional logging logic here (e.g., console.log for debugging) + logger.log(`Logging event: ${eventName}`, params); + + // Log the event to Firebase Analytics + await analytics().logEvent(eventName, params); +}; diff --git a/src/components/AppInfo/RotatingIcon.tsx b/src/components/AppInfo/RotatingIcon.tsx index 615bbbfa..cebcf03d 100644 --- a/src/components/AppInfo/RotatingIcon.tsx +++ b/src/components/AppInfo/RotatingIcon.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import analytics from '@react-native-firebase/analytics'; import * as Haptics from 'expo-haptics'; import { Image } from 'expo-image'; import { TouchableWithoutFeedback } from 'react-native'; @@ -13,6 +12,7 @@ import Animated, { import { useAppDispatch } from '../../../redux/hooks'; import { toggleDevMenuEnabled } from '../../../redux/SettingsSlice'; +import { logEvent } from '../../Analytics'; const RotatingIcon: React.FunctionComponent = ({ }) => { const dispatch = useAppDispatch(); @@ -48,7 +48,7 @@ const RotatingIcon: React.FunctionComponent = ({ }) => { rotationCount.value = rotationCount.value + 1; rotation.value = withTiming((rotationCount.value * 90), { duration: 1000, easing: Easing.elastic(1) }); - await analytics().logEvent('app_icon'); + await logEvent('app_icon'); }}> { const navigation = useNavigationMock(); @@ -22,7 +24,7 @@ describe('AppInfoButton', () => { fireEvent.press(button); await waitFor(() => { - expect(analytics().logEvent).toHaveBeenCalledWith('app_info'); + expect(logEvent).toHaveBeenCalledWith('app_info'); }); }); }); diff --git a/src/components/Buttons/AppInfoButton.tsx b/src/components/Buttons/AppInfoButton.tsx index e9c1cb72..5e30a326 100644 --- a/src/components/Buttons/AppInfoButton.tsx +++ b/src/components/Buttons/AppInfoButton.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { Icon } from 'react-native-elements/dist/icons/Icon'; +import { logEvent } from '../../Analytics'; import { systemBlue } from '../../constants'; import HeaderButton from './HeaderButton'; @@ -17,7 +17,7 @@ const AppInfoButton: React.FunctionComponent = ({ navigation }) => { return ( { navigation.navigate('AppInfo'); - await analytics().logEvent('app_info'); + await logEvent('app_info'); }}> = ({ navigation }) => { return ( { navigation.goBack(); - await analytics().logEvent('menu'); + await logEvent('menu'); }}> { const navigation = useNavigationMock(); @@ -33,7 +35,7 @@ describe('CheckButton', () => { fireEvent.press(button); await waitFor(() => { - expect(analytics().logEvent).toHaveBeenCalledWith('save_game'); + expect(logEvent).toHaveBeenCalledWith('save_game'); }); }); }); diff --git a/src/components/Buttons/CheckButton.tsx b/src/components/Buttons/CheckButton.tsx index 1dc66100..a37acd32 100644 --- a/src/components/Buttons/CheckButton.tsx +++ b/src/components/Buttons/CheckButton.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase, RouteProp } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { Text } from 'react-native'; +import { logEvent } from '../../Analytics'; import { systemBlue } from '../../constants'; import HeaderButton from './HeaderButton'; @@ -23,7 +23,7 @@ const CheckButton: React.FunctionComponent = ({ navigation, route }) => { return ( { - await analytics().logEvent('save_game'); + await logEvent('save_game'); if (route?.params?.source === 'list_screen') { navigation.navigate('List'); } else { diff --git a/src/components/Buttons/FullscreenButton.tsx b/src/components/Buttons/FullscreenButton.tsx index 6c483f4b..18bc4948 100644 --- a/src/components/Buttons/FullscreenButton.tsx +++ b/src/components/Buttons/FullscreenButton.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import analytics from '@react-native-firebase/analytics'; import { Icon } from 'react-native-elements/dist/icons/Icon'; import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; import { toggleHomeFullscreen } from '../../../redux/SettingsSlice'; +import { logEvent } from '../../Analytics'; import { systemBlue } from '../../constants'; import HeaderButton from './HeaderButton'; @@ -15,7 +15,7 @@ const FullscreenButton: React.FunctionComponent = ({ }) => { const expandHandler = async () => { dispatch(toggleHomeFullscreen()); - await analytics().logEvent('fullscreen'); + await logEvent('fullscreen'); }; return ( diff --git a/src/components/Buttons/HomeButton.tsx b/src/components/Buttons/HomeButton.tsx index b40a8430..42b2954f 100644 --- a/src/components/Buttons/HomeButton.tsx +++ b/src/components/Buttons/HomeButton.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import * as StoreReview from 'expo-store-review'; @@ -10,6 +9,7 @@ import { Icon } from 'react-native-elements/dist/icons/Icon'; import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; import { selectLastStoreReviewPrompt } from '../../../redux/selectors'; import { setLastStoreReviewPrompt } from '../../../redux/SettingsSlice'; +import { logEvent } from '../../Analytics'; import { systemBlue } from '../../constants'; import HeaderButton from './HeaderButton'; @@ -30,7 +30,7 @@ const HomeButton: React.FunctionComponent = ({ navigation }) => { if (gameCount < 3) { return; } if (daysSinceLastPrompt < 90) { return; } - await analytics().logEvent('review_prompt'); + await logEvent('review_prompt'); dispatch(setLastStoreReviewPrompt(Date.now())); @@ -49,7 +49,7 @@ const HomeButton: React.FunctionComponent = ({ navigation }) => { return ( { navigation.navigate('List'); - await analytics().logEvent('menu'); + await logEvent('menu'); storePrompt(); }}> diff --git a/src/components/GameListItem.tsx b/src/components/GameListItem.tsx index 0ee85626..d1d3b53b 100644 --- a/src/components/GameListItem.tsx +++ b/src/components/GameListItem.tsx @@ -1,6 +1,5 @@ import React, { useCallback } from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import * as Haptics from 'expo-haptics'; @@ -12,6 +11,7 @@ import Animated, { FadeInUp, SlideOutLeft } from 'react-native-reanimated'; import { selectGameById } from '../../redux/GamesSlice'; import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { setCurrentGameId } from '../../redux/SettingsSlice'; +import { logEvent } from '../Analytics'; import GameListItemPlayerName from './GameListItemPlayerName'; import AbstractPopupMenu from './PopupMenu/AbstractPopupMenu'; @@ -45,7 +45,7 @@ const GameListItem: React.FunctionComponent = ({ navigation, gameId, inde setCurrentGameCallback(); navigation.navigate('Game'); - await analytics().logEvent('select_game', { + await logEvent('select_game', { index: index, game_id: gameId, player_count: playerIds.length, diff --git a/src/components/Headers/EditPlayerHeader.tsx b/src/components/Headers/EditPlayerHeader.tsx index 45dc738f..eb3f6cab 100644 --- a/src/components/Headers/EditPlayerHeader.tsx +++ b/src/components/Headers/EditPlayerHeader.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import { getAnalytics } from '@react-native-firebase/analytics'; import { ParamListBase, RouteProp } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { StyleSheet, Text } from 'react-native'; +import { logEvent } from '../../Analytics'; import { systemBlue } from '../../constants'; import HeaderButton from '../Buttons/HeaderButton'; @@ -28,7 +28,7 @@ const EditPlayerHeader: React.FunctionComponent = ({ navi headerLeft={ { navigation.goBack(); - await getAnalytics().logEvent('edit_player_back'); + await logEvent('edit_player_back'); }}> Back diff --git a/src/components/Headers/GameHeader.tsx b/src/components/Headers/GameHeader.tsx index 7b141908..4dec4d66 100644 --- a/src/components/Headers/GameHeader.tsx +++ b/src/components/Headers/GameHeader.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import * as Haptics from 'expo-haptics'; @@ -10,6 +9,7 @@ import { Icon } from 'react-native-elements/dist/icons/Icon'; import { roundNext, roundPrevious, selectGameById } from '../../../redux/GamesSlice'; import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; +import { logEvent } from '../../Analytics'; import { systemBlue } from '../../constants'; import AddendButton from '../Buttons/AddendButton'; import FullscreenButton from '../Buttons/FullscreenButton'; @@ -92,7 +92,7 @@ const GameHeader: React.FunctionComponent = ({ navigation }) => { } dispatch(roundNext(currentGame.id)); - analytics().logEvent('round_change', { + logEvent('round_change', { game_id: currentGameId, source: 'next button', round: roundCurrent, @@ -105,7 +105,7 @@ const GameHeader: React.FunctionComponent = ({ navigation }) => { Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium); dispatch(roundPrevious(currentGame.id)); - analytics().logEvent('round_change', { + logEvent('round_change', { game_id: currentGameId, source: 'previous button', round: roundCurrent, diff --git a/src/components/Interactions/HalfTap/HalfTileTouchSurface.tsx b/src/components/Interactions/HalfTap/HalfTileTouchSurface.tsx index 9a232a77..2317b908 100644 --- a/src/components/Interactions/HalfTap/HalfTileTouchSurface.tsx +++ b/src/components/Interactions/HalfTap/HalfTileTouchSurface.tsx @@ -1,12 +1,12 @@ import React, { useState } from 'react'; -import analytics from '@react-native-firebase/analytics'; import * as Haptics from 'expo-haptics'; import { StyleSheet, TouchableHighlight, View } from 'react-native'; import { useAppDispatch, useAppSelector } from '../../../../redux/hooks'; import { playerRoundScoreIncrement } from '../../../../redux/PlayersSlice'; import { selectCurrentGame } from '../../../../redux/selectors'; +import { logEvent } from '../../../Analytics'; import { ScoreParticle } from '../../PlayerTiles/AdditionTile/ScoreParticle'; type ScoreParticleProps = { @@ -55,7 +55,7 @@ export const HalfTileTouchSurface: React.FunctionComponent = ( addParticle(addend); } Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); - analytics().logEvent('score_change', { + logEvent('score_change', { player_index: playerIndex, game_id: currentGameId, addend: addend, diff --git a/src/components/PlayerListItem.tsx b/src/components/PlayerListItem.tsx index 931fab8e..97b8b3ce 100644 --- a/src/components/PlayerListItem.tsx +++ b/src/components/PlayerListItem.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { Alert, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; @@ -10,6 +9,7 @@ import { makeSelectPlayerColors, selectGameById, updateGame } from '../../redux/ import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { removePlayer, selectPlayerById } from '../../redux/PlayersSlice'; import { selectCurrentGame } from '../../redux/selectors'; +import { logEvent } from '../Analytics'; interface Props { playerId: string; @@ -62,7 +62,7 @@ const PlayerListItem: React.FunctionComponent = ({ const deleteHandler = async () => { removePlayerHandler(); - await analytics().logEvent('remove_player', { + await logEvent('remove_player', { game_id: currentGameId, player_index: index, }); diff --git a/src/components/PopupMenu/AbstractPopupMenu.tsx b/src/components/PopupMenu/AbstractPopupMenu.tsx index 7d7279cb..766a17a8 100644 --- a/src/components/PopupMenu/AbstractPopupMenu.tsx +++ b/src/components/PopupMenu/AbstractPopupMenu.tsx @@ -1,12 +1,12 @@ import React from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { Alert, Platform } from 'react-native'; import { asyncRematchGame, gameDelete, selectGameById } from '../../../redux/GamesSlice'; import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; +import { logEvent } from '../../Analytics'; import AndroidPopupMenu from './AndroidPopupMenu'; import IOSPopupMenu from './IOSPopupMenu'; @@ -36,7 +36,7 @@ const AbstractPopupMenu: React.FC = (props) => { props.setCurrentGameCallback(); props.navigation.navigate('Share'); - await analytics().logEvent('menu_share', { + await logEvent('menu_share', { round_count: roundTotal, player_count: playerIds.length, }); @@ -49,7 +49,7 @@ const AbstractPopupMenu: React.FC = (props) => { props.setCurrentGameCallback(); props.navigation.navigate('Settings', { source: 'list_screen' }); - await analytics().logEvent('menu_edit', { + await logEvent('menu_edit', { round_count: roundTotal, player_count: playerIds.length, }); @@ -91,7 +91,7 @@ const AbstractPopupMenu: React.FC = (props) => { { cancelable: false }, ); - await analytics().logEvent('delete_game', { + await logEvent('delete_game', { index: props.index, round_count: roundTotal, player_count: playerIds.length, diff --git a/src/components/ScoreLog/RoundScoreColumn.tsx b/src/components/ScoreLog/RoundScoreColumn.tsx index 2a696e34..19312705 100644 --- a/src/components/ScoreLog/RoundScoreColumn.tsx +++ b/src/components/ScoreLog/RoundScoreColumn.tsx @@ -1,11 +1,11 @@ import React, { memo, useCallback } from 'react'; -import analytics from '@react-native-firebase/analytics'; import { LayoutChangeEvent, Text, TouchableWithoutFeedback, View } from 'react-native'; import { updateGame } from '../../../redux/GamesSlice'; import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; import { selectCurrentGame } from '../../../redux/selectors'; +import { logEvent } from '../../Analytics'; import RoundScoreCell from './RoundScoreCell'; import { SortSelectorKey, sortSelectors } from './SortHelper'; @@ -39,7 +39,7 @@ const RoundScoreColumn: React.FunctionComponent = ({ roundCurrent: round, } })); - await analytics().logEvent('round_change', { + await logEvent('round_change', { game_id: currentGameId, source: 'direct select', }); diff --git a/src/components/Sheets/AddendModal.tsx b/src/components/Sheets/AddendModal.tsx index 143be820..4d9ad950 100644 --- a/src/components/Sheets/AddendModal.tsx +++ b/src/components/Sheets/AddendModal.tsx @@ -1,7 +1,6 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { BottomSheetBackdrop, BottomSheetBackdropProps, BottomSheetModal, BottomSheetScrollView } from '@gorhom/bottom-sheet'; -import analytics from '@react-native-firebase/analytics'; import { Picker } from '@react-native-picker/picker'; import * as ScreenOrientation from 'expo-screen-orientation'; import { debounce } from 'lodash'; @@ -9,6 +8,7 @@ import { Platform, StyleSheet, Text, View } from 'react-native'; import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; import { setAddendOne, setAddendTwo, setMultiplier } from '../../../redux/SettingsSlice'; +import { logEvent } from '../../Analytics'; import InteractionSelector from '../Interactions/InteractionSelector'; import { InteractionType } from '../Interactions/InteractionType'; @@ -58,7 +58,7 @@ const AddendModal: React.FunctionComponent = ({ }) => { const onTapValueChange = useCallback((itemValue: number, itemIndex: number) => { dispatch(setMultiplier(addendOptions[itemIndex])); dispatch(setAddendOne(addendOptions[itemIndex])); - analytics().logEvent('addend_two_change', { + logEvent('addend_two_change', { addendOne: itemValue, }); }, [addendOne]); @@ -67,7 +67,7 @@ const AddendModal: React.FunctionComponent = ({ }) => { const onLongTapValueChange = useCallback((itemValue: number) => { dispatch(setAddendTwo(itemValue)); - analytics().logEvent('addend_two_change', { + logEvent('addend_two_change', { addendTwo: itemValue, }); }, [addendTwo]); diff --git a/src/screens/AppInfoScreen.tsx b/src/screens/AppInfoScreen.tsx index 59d9b0ce..fde24fc8 100644 --- a/src/screens/AppInfoScreen.tsx +++ b/src/screens/AppInfoScreen.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import analytics from '@react-native-firebase/analytics'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { ParamListBase } from '@react-navigation/routers'; import * as Application from 'expo-application'; @@ -9,6 +8,7 @@ import { Button } from 'react-native-elements'; import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { toggleShowColorPalettes, toggleShowPlayerIndex, toggleShowPointParticles } from '../../redux/SettingsSlice'; +import { logEvent } from '../Analytics'; import RotatingIcon from '../components/AppInfo/RotatingIcon'; interface Props { @@ -55,7 +55,7 @@ const AppInfoScreen: React.FunctionComponent = ({ navigation }) => { `${Platform.OS} ${Platform.Version}\n` + (process.env.EXPO_PUBLIC_FIREBASE_ANALYTICS) ); - await analytics().logEvent('view_version'); + await logEvent('view_version'); }; return ( diff --git a/src/screens/EditPlayerScreen.tsx b/src/screens/EditPlayerScreen.tsx index 91d3cfa2..cacb4461 100644 --- a/src/screens/EditPlayerScreen.tsx +++ b/src/screens/EditPlayerScreen.tsx @@ -1,6 +1,5 @@ import React, { useState } from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase, RouteProp } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { NativeSyntheticEvent, ScrollView, StyleSheet, TextInput, TextInputEndEditingEventData, View } from 'react-native'; @@ -9,6 +8,7 @@ import { Input } from 'react-native-elements'; import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { updatePlayer } from '../../redux/PlayersSlice'; import { selectCurrentGame } from '../../redux/selectors'; +import { logEvent } from '../Analytics'; import ColorSelector from '../components/ColorPalettes/ColorSelector'; type RouteParams = { @@ -74,7 +74,7 @@ const EditPlayerScreen: React.FC = ({ } })); - analytics().logEvent('update_player', { + logEvent('update_player', { game_id: currentGame.id, player_index: index, }); diff --git a/src/screens/ListScreen.tsx b/src/screens/ListScreen.tsx index cfc9ba50..01c846d2 100644 --- a/src/screens/ListScreen.tsx +++ b/src/screens/ListScreen.tsx @@ -1,6 +1,5 @@ import React, { memo, useEffect } from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import * as Application from 'expo-application'; @@ -9,11 +8,12 @@ import * as Crypto from 'expo-crypto'; import { StyleSheet, Text, View } from 'react-native'; import Animated, { Easing, LinearTransition } from 'react-native-reanimated'; import { SafeAreaView } from 'react-native-safe-area-context'; -import { parse, SemVer } from 'semver'; +import { SemVer, parse } from 'semver'; import { selectGameIds } from '../../redux/GamesSlice'; import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { increaseAppOpens, setInstallId, setOnboardedVersion } from '../../redux/SettingsSlice'; +import { logEvent } from '../Analytics'; import GameListItem from '../components/GameListItem'; import { getPendingOnboardingSemVer } from '../components/Onboarding/Onboarding'; import logger from '../Logger'; @@ -49,7 +49,7 @@ const ListScreen: React.FunctionComponent = ({ navigation }) => { dispatch(setInstallId(installId)); } - analytics().logEvent('game_list', { + logEvent('game_list', { gameCount: gameIds.length, appOpens: appOpens, appVersion: appVersion.version, diff --git a/src/screens/SettingsScreen.tsx b/src/screens/SettingsScreen.tsx index 25473ff4..2408c023 100644 --- a/src/screens/SettingsScreen.tsx +++ b/src/screens/SettingsScreen.tsx @@ -1,6 +1,5 @@ import React, { useEffect } from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase, RouteProp } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; @@ -10,6 +9,7 @@ import { Button, Icon } from 'react-native-elements'; import { addPlayer, reorderPlayers } from '../../redux/GamesSlice'; import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { selectCurrentGame } from '../../redux/selectors'; +import { logEvent } from '../Analytics'; import EditGame from '../components/EditGame'; import PlayerListItem from '../components/PlayerListItem'; import { MAX_PLAYERS, systemBlue } from '../constants'; @@ -45,7 +45,7 @@ const SettingsScreen: React.FunctionComponent = ({ navigation }) => { playerName: `Player ${playerIds.length + 1}`, })); - await analytics().logEvent('add_player', { + await logEvent('add_player', { game_id: currentGameId, player_count: playerIds.length + 1, }); diff --git a/src/screens/ShareScreen.tsx b/src/screens/ShareScreen.tsx index 82e0757c..3d6cbbcc 100644 --- a/src/screens/ShareScreen.tsx +++ b/src/screens/ShareScreen.tsx @@ -1,6 +1,5 @@ import React, { useRef } from 'react'; -import analytics from '@react-native-firebase/analytics'; import { ParamListBase } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import * as Sharing from 'expo-sharing'; @@ -12,6 +11,7 @@ import { captureRef } from 'react-native-view-shot'; import { selectGameById } from '../../redux/GamesSlice'; import { useAppSelector } from '../../redux/hooks'; import { selectCurrentGame } from '../../redux/selectors'; +import { logEvent } from '../Analytics'; import PlayerNameColumn from '../components/ScoreLog/PlayerNameColumn'; import RoundScoreColumn from '../components/ScoreLog/RoundScoreColumn'; import TotalScoreColumn from '../components/ScoreLog/TotalScoreColumn'; @@ -50,7 +50,7 @@ const ShareScreen: React.FunctionComponent = ({ navigation }) => { }); }); - await analytics().logEvent('share_image'); + await logEvent('share_image'); }; return (