diff --git a/src/App.native.tsx b/src/App.native.tsx index afab8236..a02ca62c 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -13,7 +13,7 @@ import * as view from './view/index' import {RootStoreModel, setupState, RootStoreProvider} from './state' import {Shell} from './view/shell' import * as notifee from 'lib/notifee' -import * as analytics from 'lib/analytics' +import * as analytics from 'lib/analytics/analytics' import * as Toast from './view/com/util/Toast' import {handleLink} from './Navigation' diff --git a/src/App.web.tsx b/src/App.web.tsx index 7570db44..b0f949b8 100644 --- a/src/App.web.tsx +++ b/src/App.web.tsx @@ -3,7 +3,7 @@ import 'lib/sentry' // must be relatively on top import {SafeAreaProvider} from 'react-native-safe-area-context' import {RootSiblingParent} from 'react-native-root-siblings' import * as view from './view/index' -import * as analytics from 'lib/analytics' +import * as analytics from 'lib/analytics/analytics' import {RootStoreModel, setupState, RootStoreProvider} from './state' import {Shell} from './view/shell/index' import {ToastContainer} from './view/com/util/Toast.web' diff --git a/src/lib/analytics.tsx b/src/lib/analytics/analytics.tsx similarity index 81% rename from src/lib/analytics.tsx rename to src/lib/analytics/analytics.tsx index d0a8f124..d9d53e6a 100644 --- a/src/lib/analytics.tsx +++ b/src/lib/analytics/analytics.tsx @@ -4,10 +4,12 @@ import { createClient, AnalyticsProvider, useAnalytics as useAnalyticsOrig, + ClientMethods, } from '@segment/analytics-react-native' import {RootStoreModel, AppInfo} from 'state/models/root-store' import {useStores} from 'state/models/root-store' import {sha256} from 'js-sha256' +import {ScreenEvent, TrackEvent} from './types' const segmentClient = createClient({ writeKey: '8I6DsgfiSLuoONyaunGoiQM7A6y2ybdI', @@ -16,20 +18,28 @@ const segmentClient = createClient({ export function useAnalytics() { const store = useStores() - const methods = useAnalyticsOrig() + const methods: ClientMethods = useAnalyticsOrig() return React.useMemo(() => { if (store.session.hasSession) { - return methods + return { + screen: methods.screen as ScreenEvent, // ScreenEvents defines all the possible screen names + track: methods.track as TrackEvent, // TrackEvents defines all the possible track events and their properties + identify: methods.identify, + flush: methods.flush, + group: methods.group, + alias: methods.alias, + reset: methods.reset, + } } // dont send analytics pings for anonymous users return { - screen: () => {}, - track: () => {}, - identify: () => {}, - flush: () => {}, - group: () => {}, - alias: () => {}, - reset: () => {}, + screen: () => Promise, + track: () => Promise, + identify: () => Promise, + flush: () => Promise, + group: () => Promise, + alias: () => Promise, + reset: () => Promise, } }, [store, methods]) } diff --git a/src/lib/analytics.web.tsx b/src/lib/analytics/analytics.web.tsx similarity index 100% rename from src/lib/analytics.web.tsx rename to src/lib/analytics/analytics.web.tsx diff --git a/src/lib/analytics/types.ts b/src/lib/analytics/types.ts new file mode 100644 index 00000000..0638c6b7 --- /dev/null +++ b/src/lib/analytics/types.ts @@ -0,0 +1,98 @@ +export type TrackEvent = ( + event: keyof TrackPropertiesMap, + properties?: TrackPropertiesMap[keyof TrackPropertiesMap], +) => Promise + +export type ScreenEvent = ( + name: keyof ScreenPropertiesMap, + properties?: ScreenPropertiesMap[keyof ScreenPropertiesMap], +) => Promise +interface TrackPropertiesMap { + // LOGIN / SIGN UP events + 'Sign In': {resumedSession: boolean} // CAN BE SERVER + 'Create Account': {} // CAN BE SERVER + 'Signin:PressedForgotPassword': {} + 'Signin:PressedSelectService': {} + // COMPOSER / CREATE POST events + 'Create Post': {imageCount: string} // CAN BE SERVER + 'Composer:PastedPhotos': {} + 'Composer:CameraOpened': {} + 'Composer:GalleryOpened': {} + 'HomeScreen:PressCompose': {} + 'ProfileScreen:PressCompose': {} + // EDIT PROFILE events + 'EditHandle:ViewCustomForm': {} + 'EditHandle:ViewProvidedForm': {} + 'EditHandle:SetNewHandle': {} + 'EditProfile:AvatarSelected': {} + 'EditProfile:BannerSelected': {} + 'EditProfile:Save': {} // CAN BE SERVER + // FEED events + 'Feed:onRefresh': {} + 'Feed:onEndReached': {} + // FEED ITEM events + 'FeedItem:PostReply': {} // CAN BE SERVER + 'FeedItem:PostRepost': {} // CAN BE SERVER + 'FeedItem:PostLike': {} // CAN BE SERVER + 'FeedItem:PostDelete': {} // CAN BE SERVER + 'FeedItem:ThreadMute': {} // CAN BE SERVER + // PROFILE HEADER events + 'ProfileHeader:EditProfileButtonClicked': {} + 'ProfileHeader:FollowersButtonClicked': {} + 'ProfileHeader:FollowsButtonClicked': {} + 'ProfileHeader:ShareButtonClicked': {} + 'ProfileHeader:MuteAccountButtonClicked': {} + 'ProfileHeader:UnmuteAccountButtonClicked': {} + 'ProfileHeader:ReportAccountButtonClicked': {} + 'ProfileHeader:AddToListsButtonClicked': {} + 'ProfileHeader:BlockAccountButtonClicked': {} + 'ProfileHeader:UnblockAccountButtonClicked': {} + 'ProfileHeader:FollowButtonClicked': {} + 'ProfileHeader:UnfollowButtonClicked': {} + 'ViewHeader:MenuButtonClicked': {} + // SETTINGS events + 'Settings:SwitchAccountButtonClicked': {} + 'Settings:AddAccountButtonClicked': {} + 'Settings:ChangeHandleButtonClicked': {} + 'Settings:InvitecodesButtonClicked': {} + 'Settings:ContentfilteringButtonClicked': {} + 'Settings:SignOutButtonClicked': {} + 'Settings:ContentlanguagesButtonClicked': {} + // MENU events + 'Menu:ItemClicked': {url: string} + 'Menu:FeedbackClicked': {} + // MOBILE SHELL events + 'MobileShell:MyProfileButtonPressed': {} + 'MobileShell:HomeButtonPressed': {} + 'MobileShell:SearchButtonPressed': {} + 'MobileShell:NotificationsButtonPressed': {} + 'MobileShell:FeedsButtonPressed': {} + // LISTS events + 'Lists:onRefresh': {} + 'Lists:onEndReached': {} + 'CreateMuteList:AvatarSelected': {} + 'CreateMuteList:Save': {} // CAN BE SERVER + // CUSTOM FEED events + 'MultiFeed:onEndReached': {} + 'MultiFeed:onRefresh': {} + // MODERATION events + 'Moderation:ContentfilteringButtonClicked': {} +} + +interface ScreenPropertiesMap { + Login: {} + CreateAccount: {} + 'Choose Account': {} + 'Signin:ForgotPassword': {} + 'Signin:SetNewPasswordForm': {} + 'Signin:PasswordUpdatedForm': {} + Feed: {} + Notifications: {} + Profile: {} + Settings: {} + AppPasswords: {} + Moderation: {} + BlockedAccounts: {} + MutedAccounts: {} + SavedFeeds: {} +} diff --git a/src/view/com/auth/LoggedOut.tsx b/src/view/com/auth/LoggedOut.tsx index 5d4b9451..e3570646 100644 --- a/src/view/com/auth/LoggedOut.tsx +++ b/src/view/com/auth/LoggedOut.tsx @@ -7,7 +7,7 @@ import {ErrorBoundary} from 'view/com/util/ErrorBoundary' import {s} from 'lib/styles' import {usePalette} from 'lib/hooks/usePalette' import {useStores} from 'state/index' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {SplashScreen} from './SplashScreen' import {CenteredView} from '../util/Views' diff --git a/src/view/com/auth/create/CreateAccount.tsx b/src/view/com/auth/create/CreateAccount.tsx index ed2c379b..97200709 100644 --- a/src/view/com/auth/create/CreateAccount.tsx +++ b/src/view/com/auth/create/CreateAccount.tsx @@ -8,7 +8,7 @@ import { View, } from 'react-native' import {observer} from 'mobx-react-lite' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {Text} from '../../util/text/Text' import {s} from 'lib/styles' import {useStores} from 'state/index' diff --git a/src/view/com/auth/login/Login.tsx b/src/view/com/auth/login/Login.tsx index c5ccd7c1..af4f0187 100644 --- a/src/view/com/auth/login/Login.tsx +++ b/src/view/com/auth/login/Login.tsx @@ -14,7 +14,7 @@ import { } from '@fortawesome/react-native-fontawesome' import * as EmailValidator from 'email-validator' import {BskyAgent} from '@atproto/api' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {Text} from '../../util/text/Text' import {UserAvatar} from '../../util/UserAvatar' import {s, colors} from 'lib/styles' diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index d7a4a42d..37569fbe 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -13,7 +13,7 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context' import LinearGradient from 'react-native-linear-gradient' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {RichText} from '@atproto/api' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {UserAutocompleteModel} from 'state/models/discovery/user-autocomplete' import {ExternalEmbed} from './ExternalEmbed' import {Text} from '../util/text/Text' diff --git a/src/view/com/composer/photos/OpenCameraBtn.tsx b/src/view/com/composer/photos/OpenCameraBtn.tsx index bfcfa6b7..0f955984 100644 --- a/src/view/com/composer/photos/OpenCameraBtn.tsx +++ b/src/view/com/composer/photos/OpenCameraBtn.tsx @@ -5,7 +5,7 @@ import { FontAwesomeIconStyle, } from '@fortawesome/react-native-fontawesome' import {usePalette} from 'lib/hooks/usePalette' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {useStores} from 'state/index' import {isDesktopWeb} from 'platform/detection' import {openCamera} from 'lib/media/picker' diff --git a/src/view/com/composer/photos/SelectPhotoBtn.tsx b/src/view/com/composer/photos/SelectPhotoBtn.tsx index 0b8046a4..aaf0477c 100644 --- a/src/view/com/composer/photos/SelectPhotoBtn.tsx +++ b/src/view/com/composer/photos/SelectPhotoBtn.tsx @@ -5,7 +5,7 @@ import { FontAwesomeIconStyle, } from '@fortawesome/react-native-fontawesome' import {usePalette} from 'lib/hooks/usePalette' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {isDesktopWeb} from 'platform/detection' import {usePhotoLibraryPermission} from 'lib/hooks/usePermissions' import {GalleryModel} from 'state/models/media/gallery' diff --git a/src/view/com/lists/ListItems.tsx b/src/view/com/lists/ListItems.tsx index 914f446a..42965981 100644 --- a/src/view/com/lists/ListItems.tsx +++ b/src/view/com/lists/ListItems.tsx @@ -20,7 +20,7 @@ import {RichText as RichTextCom} from '../util/text/RichText' import {UserAvatar} from '../util/UserAvatar' import {TextLink} from '../util/Link' import {ListModel} from 'state/models/content/list' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {usePalette} from 'lib/hooks/usePalette' import {useStores} from 'state/index' import {s} from 'lib/styles' diff --git a/src/view/com/lists/ListsList.tsx b/src/view/com/lists/ListsList.tsx index 88b71acc..09e3a501 100644 --- a/src/view/com/lists/ListsList.tsx +++ b/src/view/com/lists/ListsList.tsx @@ -21,7 +21,7 @@ import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn' import {Button} from '../util/forms/Button' import {Text} from '../util/text/Text' import {ListsListModel} from 'state/models/lists/lists-list' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {usePalette} from 'lib/hooks/usePalette' import {s} from 'lib/styles' diff --git a/src/view/com/modals/ChangeHandle.tsx b/src/view/com/modals/ChangeHandle.tsx index 57f922f8..961efc08 100644 --- a/src/view/com/modals/ChangeHandle.tsx +++ b/src/view/com/modals/ChangeHandle.tsx @@ -18,7 +18,7 @@ import {s} from 'lib/styles' import {makeValidHandle, createFullHandle} from 'lib/strings/handles' import {usePalette} from 'lib/hooks/usePalette' import {useTheme} from 'lib/ThemeContext' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {cleanError} from 'lib/strings/errors' export const snapPoints = ['100%'] diff --git a/src/view/com/modals/CreateOrEditMuteList.tsx b/src/view/com/modals/CreateOrEditMuteList.tsx index 7984ea64..09048b5d 100644 --- a/src/view/com/modals/CreateOrEditMuteList.tsx +++ b/src/view/com/modals/CreateOrEditMuteList.tsx @@ -21,7 +21,7 @@ import {compressIfNeeded} from 'lib/media/manip' import {UserAvatar} from '../util/UserAvatar' import {usePalette} from 'lib/hooks/usePalette' import {useTheme} from 'lib/ThemeContext' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {cleanError, isNetworkError} from 'lib/strings/errors' import {isDesktopWeb} from 'platform/detection' diff --git a/src/view/com/modals/EditProfile.tsx b/src/view/com/modals/EditProfile.tsx index f37a0f71..3db8d82d 100644 --- a/src/view/com/modals/EditProfile.tsx +++ b/src/view/com/modals/EditProfile.tsx @@ -23,7 +23,7 @@ import {UserBanner} from '../util/UserBanner' import {UserAvatar} from '../util/UserAvatar' import {usePalette} from 'lib/hooks/usePalette' import {useTheme} from 'lib/ThemeContext' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {cleanError, isNetworkError} from 'lib/strings/errors' export const snapPoints = ['fullscreen'] diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx index 8206ca50..921f2319 100644 --- a/src/view/com/posts/Feed.tsx +++ b/src/view/com/posts/Feed.tsx @@ -16,7 +16,7 @@ import {FeedSlice} from './FeedSlice' import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn' import {OnScrollCb} from 'lib/hooks/useOnMainScroll' import {s} from 'lib/styles' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {usePalette} from 'lib/hooks/usePalette' import {useTheme} from 'lib/ThemeContext' diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 7854035f..18c32b89 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -25,7 +25,7 @@ import {UserAvatar} from '../util/UserAvatar' import {s} from 'lib/styles' import {useStores} from 'state/index' import {usePalette} from 'lib/hooks/usePalette' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {sanitizeDisplayName} from 'lib/strings/display-names' export const FeedItem = observer(function ({ diff --git a/src/view/com/posts/MultiFeed.tsx b/src/view/com/posts/MultiFeed.tsx index db353909..dc28d2d8 100644 --- a/src/view/com/posts/MultiFeed.tsx +++ b/src/view/com/posts/MultiFeed.tsx @@ -19,7 +19,7 @@ import {Link} from '../util/Link' import {UserAvatar} from '../util/UserAvatar' import {OnScrollCb} from 'lib/hooks/useOnMainScroll' import {s} from 'lib/styles' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {usePalette} from 'lib/hooks/usePalette' import {useTheme} from 'lib/ThemeContext' import {isDesktopWeb} from 'platform/detection' diff --git a/src/view/com/profile/ProfileHeader.tsx b/src/view/com/profile/ProfileHeader.tsx index 46a6bb23..0ad6b2eb 100644 --- a/src/view/com/profile/ProfileHeader.tsx +++ b/src/view/com/profile/ProfileHeader.tsx @@ -29,7 +29,7 @@ import {UserAvatar} from '../util/UserAvatar' import {UserBanner} from '../util/UserBanner' import {ProfileHeaderWarnings} from '../util/moderation/ProfileHeaderWarnings' import {usePalette} from 'lib/hooks/usePalette' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {NavigationProp} from 'lib/routes/types' import {listUriToHref} from 'lib/strings/url-helpers' import {isDesktopWeb, isNative} from 'platform/detection' @@ -117,6 +117,11 @@ const ProfileHeaderLoaded = observer( }, [store, view]) const onPressToggleFollow = React.useCallback(() => { + track( + view.viewer.following + ? 'ProfileHeader:FollowButtonClicked' + : 'ProfileHeader:UnfollowButtonClicked', + ) view?.toggleFollowing().then( () => { Toast.show( @@ -127,7 +132,7 @@ const ProfileHeaderLoaded = observer( }, err => store.log.error('Failed to toggle follow', err), ) - }, [view, store]) + }, [track, view, store.log]) const onPressEditProfile = React.useCallback(() => { track('ProfileHeader:EditProfileButtonClicked') diff --git a/src/view/com/search/HeaderWithInput.tsx b/src/view/com/search/HeaderWithInput.tsx index d4467371..c51d4f70 100644 --- a/src/view/com/search/HeaderWithInput.tsx +++ b/src/view/com/search/HeaderWithInput.tsx @@ -9,7 +9,7 @@ import {MagnifyingGlassIcon} from 'lib/icons' import {useTheme} from 'lib/ThemeContext' import {usePalette} from 'lib/hooks/usePalette' import {useStores} from 'state/index' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' const MENU_HITSLOP = {left: 10, top: 10, right: 30, bottom: 10} diff --git a/src/view/com/util/ViewHeader.tsx b/src/view/com/util/ViewHeader.tsx index 732a46d0..f5a921ac 100644 --- a/src/view/com/util/ViewHeader.tsx +++ b/src/view/com/util/ViewHeader.tsx @@ -8,7 +8,7 @@ import {Text} from './text/Text' import {useStores} from 'state/index' import {usePalette} from 'lib/hooks/usePalette' import {useAnimatedValue} from 'lib/hooks/useAnimatedValue' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {NavigationProp} from 'lib/routes/types' import {isDesktopWeb} from 'platform/detection' diff --git a/src/view/screens/AppPasswords.tsx b/src/view/screens/AppPasswords.tsx index ca60787d..582bc0f9 100644 --- a/src/view/screens/AppPasswords.tsx +++ b/src/view/screens/AppPasswords.tsx @@ -12,7 +12,7 @@ import {withAuthRequired} from 'view/com/auth/withAuthRequired' import {observer} from 'mobx-react-lite' import {NativeStackScreenProps} from '@react-navigation/native-stack' import {CommonNavigatorParams} from 'lib/routes/types' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {useFocusEffect} from '@react-navigation/native' import {ViewHeader} from '../com/util/ViewHeader' import {CenteredView} from 'view/com/util/Views' diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index 4b90c214..95fb6940 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -19,7 +19,7 @@ import {FAB} from '../com/util/fab/FAB' import {useStores} from 'state/index' import {s} from 'lib/styles' import {useOnMainScroll} from 'lib/hooks/useOnMainScroll' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {ComposeIcon2} from 'lib/icons' import {isDesktopWeb, isMobileWebMediaQuery, isWeb} from 'platform/detection' diff --git a/src/view/screens/Moderation.tsx b/src/view/screens/Moderation.tsx index 4c52301c..41df1244 100644 --- a/src/view/screens/Moderation.tsx +++ b/src/view/screens/Moderation.tsx @@ -15,7 +15,7 @@ import {ViewHeader} from '../com/util/ViewHeader' import {Link} from '../com/util/Link' import {Text} from '../com/util/text/Text' import {usePalette} from 'lib/hooks/usePalette' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {isDesktopWeb} from 'platform/detection' type Props = NativeStackScreenProps diff --git a/src/view/screens/ModerationBlockedAccounts.tsx b/src/view/screens/ModerationBlockedAccounts.tsx index cd506d63..794195e5 100644 --- a/src/view/screens/ModerationBlockedAccounts.tsx +++ b/src/view/screens/ModerationBlockedAccounts.tsx @@ -16,7 +16,7 @@ import {observer} from 'mobx-react-lite' import {NativeStackScreenProps} from '@react-navigation/native-stack' import {CommonNavigatorParams} from 'lib/routes/types' import {BlockedAccountsModel} from 'state/models/lists/blocked-accounts' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {useFocusEffect} from '@react-navigation/native' import {ViewHeader} from '../com/util/ViewHeader' import {CenteredView} from 'view/com/util/Views' diff --git a/src/view/screens/ModerationMutedAccounts.tsx b/src/view/screens/ModerationMutedAccounts.tsx index 22b8c0d3..995223c1 100644 --- a/src/view/screens/ModerationMutedAccounts.tsx +++ b/src/view/screens/ModerationMutedAccounts.tsx @@ -16,7 +16,7 @@ import {observer} from 'mobx-react-lite' import {NativeStackScreenProps} from '@react-navigation/native-stack' import {CommonNavigatorParams} from 'lib/routes/types' import {MutedAccountsModel} from 'state/models/lists/muted-accounts' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {useFocusEffect} from '@react-navigation/native' import {ViewHeader} from '../com/util/ViewHeader' import {CenteredView} from 'view/com/util/Views' diff --git a/src/view/screens/Notifications.tsx b/src/view/screens/Notifications.tsx index 4db1d14a..15bbf4fd 100644 --- a/src/view/screens/Notifications.tsx +++ b/src/view/screens/Notifications.tsx @@ -15,7 +15,7 @@ import {useStores} from 'state/index' import {useOnMainScroll} from 'lib/hooks/useOnMainScroll' import {useTabFocusEffect} from 'lib/hooks/useTabFocusEffect' import {s} from 'lib/styles' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {isWeb} from 'platform/detection' type Props = NativeStackScreenProps< diff --git a/src/view/screens/Profile.tsx b/src/view/screens/Profile.tsx index c5ad286c..f50a2c45 100644 --- a/src/view/screens/Profile.tsx +++ b/src/view/screens/Profile.tsx @@ -23,7 +23,7 @@ import {EmptyState} from '../com/util/EmptyState' import {Text} from '../com/util/text/Text' import {FAB} from '../com/util/fab/FAB' import {s, colors} from 'lib/styles' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {ComposeIcon2} from 'lib/icons' import {CustomFeed} from 'view/com/feeds/CustomFeed' import {CustomFeedModel} from 'state/models/feeds/custom-feed' diff --git a/src/view/screens/SavedFeeds.tsx b/src/view/screens/SavedFeeds.tsx index 103b18c7..ac38a760 100644 --- a/src/view/screens/SavedFeeds.tsx +++ b/src/view/screens/SavedFeeds.tsx @@ -9,7 +9,7 @@ import { } from 'react-native' import {useFocusEffect} from '@react-navigation/native' import {NativeStackScreenProps} from '@react-navigation/native-stack' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {usePalette} from 'lib/hooks/usePalette' import {CommonNavigatorParams} from 'lib/routes/types' import {observer} from 'mobx-react-lite' diff --git a/src/view/screens/Settings.tsx b/src/view/screens/Settings.tsx index ac072c47..3d057451 100644 --- a/src/view/screens/Settings.tsx +++ b/src/view/screens/Settings.tsx @@ -35,7 +35,7 @@ import {ToggleButton} from 'view/com/util/forms/ToggleButton' import {usePalette} from 'lib/hooks/usePalette' import {useCustomPalette} from 'lib/hooks/useCustomPalette' import {AccountData} from 'state/models/session' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {NavigationProp} from 'lib/routes/types' import {isDesktopWeb} from 'platform/detection' import {pluralize} from 'lib/strings/helpers' diff --git a/src/view/shell/Drawer.tsx b/src/view/shell/Drawer.tsx index cf863933..c02478f9 100644 --- a/src/view/shell/Drawer.tsx +++ b/src/view/shell/Drawer.tsx @@ -36,7 +36,7 @@ import {UserAvatar} from 'view/com/util/UserAvatar' import {Text} from 'view/com/util/text/Text' import {useTheme} from 'lib/ThemeContext' import {usePalette} from 'lib/hooks/usePalette' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {pluralize} from 'lib/strings/helpers' import {getTabState, TabState} from 'lib/routes/helpers' import {NavigationProp} from 'lib/routes/types' diff --git a/src/view/shell/bottom-bar/BottomBar.tsx b/src/view/shell/bottom-bar/BottomBar.tsx index e8cba904..09b6f9f6 100644 --- a/src/view/shell/bottom-bar/BottomBar.tsx +++ b/src/view/shell/bottom-bar/BottomBar.tsx @@ -11,7 +11,7 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context' import {observer} from 'mobx-react-lite' import {Text} from 'view/com/util/text/Text' import {useStores} from 'state/index' -import {useAnalytics} from 'lib/analytics' +import {useAnalytics} from 'lib/analytics/analytics' import {clamp} from 'lib/numbers' import { HomeIcon, @@ -30,6 +30,8 @@ import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode' import {useNavigationTabState} from 'lib/hooks/useNavigationTabState' import {UserAvatar} from 'view/com/util/UserAvatar' +type TabOptions = 'Home' | 'Search' | 'Notifications' | 'MyProfile' | 'Feeds' + export const BottomBar = observer(({navigation}: BottomTabBarProps) => { const store = useStores() const pal = usePalette('default') @@ -42,7 +44,7 @@ export const BottomBar = observer(({navigation}: BottomTabBarProps) => { const {notifications} = store.me const onPressTab = React.useCallback( - (tab: string) => { + (tab: TabOptions) => { track(`MobileShell:${tab}ButtonPressed`) const state = navigation.getState() const tabState = getTabState(state, tab)