From f68b15219fd02e23d965015201400138ed69d59d Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 27 Sep 2024 14:01:57 -0700 Subject: [PATCH] Remove Segment (#5518) --- jest/jestSetup.js | 15 - package.json | 4 - src/Navigation.tsx | 3 - src/lib/analytics/analytics.tsx | 158 --- src/lib/analytics/analytics.web.tsx | 80 -- src/lib/analytics/types.ts | 181 --- src/lib/hooks/useAccountSwitcher.ts | 5 +- src/lib/hooks/useNotificationHandler.ts | 24 +- src/screens/Login/ChooseAccountForm.tsx | 8 - src/screens/Login/ForgotPasswordForm.tsx | 8 +- src/screens/Login/LoginForm.tsx | 9 +- src/screens/Login/PasswordUpdatedForm.tsx | 8 +- src/screens/Login/SetNewPasswordForm.tsx | 8 +- src/screens/Login/index.tsx | 3 - src/screens/Moderation/index.tsx | 5 +- src/screens/Onboarding/StepFinished.tsx | 19 +- .../Onboarding/StepInterests/index.tsx | 18 +- src/screens/Onboarding/StepProfile/index.tsx | 9 +- .../Profile/Header/ProfileHeaderLabeler.tsx | 15 +- .../Profile/Header/ProfileHeaderStandard.tsx | 14 +- src/screens/Signup/index.tsx | 6 - src/state/queries/post.ts | 16 +- src/state/queries/preferences/index.ts | 3 - src/state/queries/profile.ts | 5 - src/state/session/index.tsx | 4 - src/state/shell/onboarding.tsx | 4 - src/view/com/auth/LoggedOut.tsx | 5 +- src/view/com/composer/Composer.tsx | 10 +- .../com/composer/photos/OpenCameraBtn.tsx | 4 - .../com/composer/photos/SelectPhotoBtn.tsx | 6 +- .../com/composer/threadgate/ThreadgateBtn.tsx | 3 - src/view/com/feeds/FeedPage.tsx | 14 +- src/view/com/lists/ListMembers.tsx | 31 +- src/view/com/lists/MyLists.tsx | 15 +- src/view/com/lists/ProfileLists.tsx | 9 +- src/view/com/modals/ChangeHandle.tsx | 19 +- src/view/com/modals/CreateOrEditList.tsx | 11 +- src/view/com/modals/EditProfile.tsx | 10 +- .../com/post-thread/PostThreadFollowBtn.tsx | 19 +- src/view/com/posts/Feed.tsx | 7 +- src/view/com/profile/ProfileMenu.tsx | 45 +- src/view/com/util/SimpleViewHeader.tsx | 11 +- src/view/com/util/ViewHeader.tsx | 5 +- src/view/screens/AccessibilitySettings.tsx | 5 +- src/view/screens/AppPasswords.tsx | 7 +- src/view/screens/LanguageSettings.tsx | 8 +- .../screens/ModerationBlockedAccounts.tsx | 15 +- src/view/screens/ModerationMutedAccounts.tsx | 15 +- src/view/screens/Notifications.tsx | 11 +- .../screens/PreferencesExternalEmbeds.tsx | 5 +- src/view/screens/Profile.tsx | 6 +- src/view/screens/ProfileFeed.tsx | 56 +- src/view/screens/ProfileList.tsx | 74 +- src/view/screens/SavedFeeds.tsx | 36 +- src/view/screens/Search/Search.tsx | 5 +- src/view/screens/Settings/index.tsx | 11 +- src/view/shell/Drawer.tsx | 20 +- src/view/shell/bottom-bar/BottomBar.tsx | 5 +- yarn.lock | 1074 +---------------- 59 files changed, 221 insertions(+), 1988 deletions(-) delete mode 100644 src/lib/analytics/analytics.tsx delete mode 100644 src/lib/analytics/analytics.web.tsx delete mode 100644 src/lib/analytics/types.ts diff --git a/jest/jestSetup.js b/jest/jestSetup.js index 50a33589ea..4653490f3c 100644 --- a/jest/jestSetup.js +++ b/jest/jestSetup.js @@ -54,21 +54,6 @@ jest.mock('expo-image-manipulator', () => ({ SaveFormat: jest.requireActual('expo-image-manipulator').SaveFormat, })) -jest.mock('@segment/analytics-react-native', () => ({ - createClient: () => ({ - add: jest.fn(), - }), - useAnalytics: () => ({ - track: jest.fn(), - identify: jest.fn(), - reset: jest.fn(), - group: jest.fn(), - screen: jest.fn(), - alias: jest.fn(), - flush: jest.fn(), - }), -})) - jest.mock('expo-camera', () => ({ Camera: { useCameraPermissions: jest.fn(() => [true]), diff --git a/package.json b/package.json index 5e4d896cce..ae92b96ab3 100644 --- a/package.json +++ b/package.json @@ -81,10 +81,6 @@ "@react-navigation/drawer": "^6.6.15", "@react-navigation/native": "^6.1.17", "@react-navigation/native-stack": "^6.9.26", - "@segment/analytics-next": "^1.51.3", - "@segment/analytics-react": "^1.0.0-rc1", - "@segment/analytics-react-native": "^2.10.1", - "@segment/sovran-react-native": "^0.4.5", "@sentry/react-native": "5.32.0", "@tamagui/focus-scope": "^1.84.1", "@tanstack/query-async-storage-persister": "^5.25.0", diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 2beba4f9dc..53e8274d54 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -15,7 +15,6 @@ import { StackActions, } from '@react-navigation/native' -import {init as initAnalytics} from '#/lib/analytics/analytics' import {timeout} from '#/lib/async/timeout' import {useColorSchemeStyle} from '#/lib/hooks/useColorSchemeStyle' import {usePalette} from '#/lib/hooks/usePalette' @@ -647,8 +646,6 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) { function onReady() { prevLoggedRouteName.current = getCurrentRouteName() - initAnalytics(currentAccount) - if (currentAccount && shouldRequestEmailConfirmation(currentAccount)) { openModal({name: 'verify-email', showReminder: true}) snoozeEmailConfirmationPrompt() diff --git a/src/lib/analytics/analytics.tsx b/src/lib/analytics/analytics.tsx deleted file mode 100644 index 5f93d982fd..0000000000 --- a/src/lib/analytics/analytics.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import React from 'react' -import {AppState, AppStateStatus} from 'react-native' -import AsyncStorage from '@react-native-async-storage/async-storage' -import {createClient, SegmentClient} from '@segment/analytics-react-native' -import * as Sentry from '@sentry/react-native' -import {sha256} from 'js-sha256' - -import {logger} from '#/logger' -import {SessionAccount, useSession} from '#/state/session' -import {ScreenPropertiesMap, TrackPropertiesMap} from './types' - -type AppInfo = { - build?: string | undefined - name?: string | undefined - namespace?: string | undefined - version?: string | undefined -} - -// Delay creating until first actual use. -let segmentClient: SegmentClient | null = null -function getClient(): SegmentClient { - if (!segmentClient) { - segmentClient = createClient({ - writeKey: '8I6DsgfiSLuoONyaunGoiQM7A6y2ybdI', - trackAppLifecycleEvents: false, - proxy: 'https://api.events.bsky.app/v1', - }) - } - return segmentClient -} - -export const track = async ( - event: E, - properties?: TrackPropertiesMap[E], -) => { - await getClient().track(event, properties) -} - -export function useAnalytics() { - const {hasSession} = useSession() - - return React.useMemo(() => { - if (hasSession) { - return { - async screen( - event: E, - properties?: ScreenPropertiesMap[E], - ) { - await getClient().screen(event, properties) - }, - async track( - event: E, - properties?: TrackPropertiesMap[E], - ) { - await getClient().track(event, properties) - }, - } - } - // dont send analytics pings for anonymous users - return { - screen: async () => {}, - track: async () => {}, - } - }, [hasSession]) -} - -export function init(account: SessionAccount | undefined) { - setupListenersOnce() - - if (account) { - const client = getClient() - if (account.did) { - const did_hashed = sha256(account.did) - client.identify(did_hashed, {did_hashed}) - Sentry.setUser({id: did_hashed}) - logger.debug('Ping w/hash') - } else { - logger.debug('Ping w/o hash') - client.identify() - } - } -} - -let didSetupListeners = false -function setupListenersOnce() { - if (didSetupListeners) { - return - } - didSetupListeners = true - // NOTE - // this is a copy of segment's own lifecycle event tracking - // we handle it manually to ensure that it never fires while the app is backgrounded - // -prf - const client = getClient() - client.isReady.onChange(async () => { - if (AppState.currentState !== 'active') { - logger.debug('Prevented a metrics ping while the app was backgrounded') - return - } - const context = client.context.get() - if (typeof context?.app === 'undefined') { - logger.debug('Aborted metrics ping due to unavailable context') - return - } - - const oldAppInfo = await readAppInfo() - const newAppInfo = context.app as AppInfo - writeAppInfo(newAppInfo) - logger.debug('Recording app info', {new: newAppInfo, old: oldAppInfo}) - - if (typeof oldAppInfo === 'undefined') { - client.track('Application Installed', { - version: newAppInfo.version, - build: newAppInfo.build, - }) - } else if (newAppInfo.version !== oldAppInfo.version) { - client.track('Application Updated', { - version: newAppInfo.version, - build: newAppInfo.build, - previous_version: oldAppInfo.version, - previous_build: oldAppInfo.build, - }) - } - client.track('Application Opened', { - from_background: false, - version: newAppInfo.version, - build: newAppInfo.build, - }) - }) - - let lastState: AppStateStatus = AppState.currentState - AppState.addEventListener('change', (state: AppStateStatus) => { - if (state === 'active' && lastState !== 'active') { - const context = client.context.get() - client.track('Application Opened', { - from_background: true, - version: context?.app?.version, - build: context?.app?.build, - }) - } else if (state !== 'active' && lastState === 'active') { - client.track('Application Backgrounded') - } - lastState = state - }) -} - -async function writeAppInfo(value: AppInfo) { - await AsyncStorage.setItem('BSKY_APP_INFO', JSON.stringify(value)) -} - -async function readAppInfo(): Promise { - const rawData = await AsyncStorage.getItem('BSKY_APP_INFO') - const obj = rawData ? JSON.parse(rawData) : undefined - if (!obj || typeof obj !== 'object') { - return undefined - } - return obj -} diff --git a/src/lib/analytics/analytics.web.tsx b/src/lib/analytics/analytics.web.tsx deleted file mode 100644 index c7f0ed3b14..0000000000 --- a/src/lib/analytics/analytics.web.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import React from 'react' -import {createClient} from '@segment/analytics-react' -import * as Sentry from '@sentry/react-native' -import {sha256} from 'js-sha256' - -import {logger} from '#/logger' -import {SessionAccount, useSession} from '#/state/session' -import {ScreenPropertiesMap, TrackPropertiesMap} from './types' - -type SegmentClient = ReturnType - -// Delay creating until first actual use. -let segmentClient: SegmentClient | null = null -function getClient(): SegmentClient { - if (!segmentClient) { - segmentClient = createClient( - { - writeKey: '8I6DsgfiSLuoONyaunGoiQM7A6y2ybdI', - }, - { - integrations: { - 'Segment.io': { - apiHost: 'api.events.bsky.app/v1', - }, - }, - }, - ) - } - return segmentClient -} - -export const track = async ( - event: E, - properties?: TrackPropertiesMap[E], -) => { - await getClient().track(event, properties) -} - -export function useAnalytics() { - const {hasSession} = useSession() - - return React.useMemo(() => { - if (hasSession) { - return { - async screen( - event: E, - properties?: ScreenPropertiesMap[E], - ) { - await getClient().screen(event, properties) - }, - async track( - event: E, - properties?: TrackPropertiesMap[E], - ) { - await getClient().track(event, properties) - }, - } - } - // dont send analytics pings for anonymous users - return { - screen: async () => {}, - track: async () => {}, - } - }, [hasSession]) -} - -export function init(account: SessionAccount | undefined) { - if (account) { - const client = getClient() - if (account.did) { - const did_hashed = sha256(account.did) - client.identify(did_hashed, {did_hashed}) - Sentry.setUser({id: did_hashed}) - logger.debug('Ping w/hash') - } else { - logger.debug('Ping w/o hash') - client.identify() - } - } -} diff --git a/src/lib/analytics/types.ts b/src/lib/analytics/types.ts deleted file mode 100644 index 720495ea1d..0000000000 --- a/src/lib/analytics/types.ts +++ /dev/null @@ -1,181 +0,0 @@ -export type TrackPropertiesMap = { - // LOGIN / SIGN UP events - 'Sign In': {resumedSession: boolean} // CAN BE SERVER - 'Create Account': {} // CAN BE SERVER - 'Try Create Account': {} - 'Signin:PressedForgotPassword': {} - 'Signin:PressedSelectService': {} - // COMPOSER / CREATE POST events - 'Create Post': {imageCount: string | number} // CAN BE SERVER - 'Composer:PastedPhotos': {} - 'Composer:CameraOpened': {} - 'Composer:GalleryOpened': {} - 'Composer:ThreadgateOpened': {} - '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': {} - // POST events - 'Post:Like': {} // CAN BE SERVER - 'Post:Unlike': {} // CAN BE SERVER - 'Post:Repost': {} // CAN BE SERVER - 'Post:Unrepost': {} // CAN BE SERVER - 'Post:Delete': {} // CAN BE SERVER - 'Post:ThreadMute': {} // CAN BE SERVER - 'Post:ThreadUnmute': {} // CAN BE SERVER - 'Post:Reply': {} // CAN BE SERVER - 'Post:EditThreadgateOpened': {} - 'Post:ThreadgateEdited': {} - // PROFILE events - 'Profile:Follow': { - username: string - } - 'Profile:Unfollow': { - username: string - } - // PROFILE HEADER events - 'ProfileHeader:EditProfileButtonClicked': {} - 'ProfileHeader:FollowersButtonClicked': { - handle: string - } - 'ProfileHeader:FollowsButtonClicked': { - handle: string - } - 'ProfileHeader:ShareButtonClicked': {} - 'ProfileHeader:MuteAccountButtonClicked': {} - 'ProfileHeader:UnmuteAccountButtonClicked': {} - 'ProfileHeader:ReportAccountButtonClicked': {} - 'ProfileHeader:AddToListsButtonClicked': {} - 'ProfileHeader:BlockAccountButtonClicked': {} - 'ProfileHeader:UnblockAccountButtonClicked': {} - 'ProfileHeader:FollowButtonClicked': {} - 'ProfileHeader:UnfollowButtonClicked': {} - 'ProfileHeader:SuggestedFollowsOpened': {} - 'ProfileHeader:SuggestedFollowFollowed': {} - 'ViewHeader:MenuButtonClicked': {} - // SETTINGS events - 'Settings:SwitchAccountButtonClicked': {} - 'Settings:AddAccountButtonClicked': {} - 'Settings:ChangeHandleButtonClicked': {} - 'Settings:InvitecodesButtonClicked': {} - 'Settings:SignOutButtonClicked': {} - 'Settings:ContentlanguagesButtonClicked': {} - // MENU events - 'Menu:ItemClicked': {url: string} - 'Menu:FeedbackClicked': {} - 'Menu:HelpClicked': {} - // MOBILE SHELL events - 'MobileShell:MyProfileButtonPressed': {} - 'MobileShell:HomeButtonPressed': {} - 'MobileShell:SearchButtonPressed': {} - 'MobileShell:NotificationsButtonPressed': {} - 'MobileShell:FeedsButtonPressed': {} - 'MobileShell:MessagesButtonPressed': {} - // NOTIFICATIONS events - 'Notificatons:OpenApp': {} - // LISTS events - 'Lists:onRefresh': {} - 'Lists:onEndReached': {} - 'CreateList:AvatarSelected': {} - 'CreateList:SaveCurateList': {} // CAN BE SERVER - 'CreateList:SaveModList': {} // CAN BE SERVER - 'Lists:Mute': {} // CAN BE SERVER - 'Lists:Unmute': {} // CAN BE SERVER - 'Lists:Block': {} // CAN BE SERVER - 'Lists:Unblock': {} // CAN BE SERVER - 'Lists:Delete': {} // CAN BE SERVER - 'Lists:Share': {} // CAN BE SERVER - // CUSTOM FEED events - 'CustomFeed:Save': {} - 'CustomFeed:Unsave': {} - 'CustomFeed:Like': {} - 'CustomFeed:Unlike': {} - 'CustomFeed:Share': {} - 'CustomFeed:Pin': { - uri: string - name?: string - } - 'CustomFeed:Unpin': { - uri: string - name?: string - } - 'CustomFeed:Reorder': { - uri: string - name?: string - index: number - } - 'CustomFeed:LoadMore': {} - 'MultiFeed:onEndReached': {} - 'MultiFeed:onRefresh': {} - // MODERATION events - 'Moderation:ContentfilteringButtonClicked': {} - // ONBOARDING events - 'Onboarding:Begin': {} - 'Onboarding:Complete': {} - 'Onboarding:Skipped': {} - 'Onboarding:Reset': {} - 'Onboarding:SuggestedFollowFollowed': {} - 'Onboarding:CustomFeedAdded': {} - // Onboarding v2 - 'OnboardingV2:Begin': {} - 'OnboardingV2:StepInterests:Start': {} - 'OnboardingV2:StepInterests:End': { - selectedInterests: string[] - selectedInterestsLength: number - } - 'OnboardingV2:StepInterests:Error': {} - 'OnboardingV2:StepSuggestedAccounts:Start': {} - 'OnboardingV2:StepSuggestedAccounts:End': { - selectedAccountsLength: number - } - 'OnboardingV2:StepFollowingFeed:Start': {} - 'OnboardingV2:StepFollowingFeed:End': {} - 'OnboardingV2:StepAlgoFeeds:Start': {} - 'OnboardingV2:StepAlgoFeeds:End': { - selectedPrimaryFeeds: string[] - selectedPrimaryFeedsLength: number - selectedSecondaryFeeds: string[] - selectedSecondaryFeedsLength: number - } - 'OnboardingV2:StepTopicalFeeds:Start': {} - 'OnboardingV2:StepTopicalFeeds:End': { - selectedFeeds: string[] - selectedFeedsLength: number - } - 'OnboardingV2:StepModeration:Start': {} - 'OnboardingV2:StepModeration:End': {} - 'OnboardingV2:StepProfile:Start': {} - 'OnboardingV2:StepProfile:End': {} - 'OnboardingV2:StepFinished:Start': {} - 'OnboardingV2:StepFinished:End': {} - 'OnboardingV2:Complete': {} - 'OnboardingV2:Skip': {} -} - -export type ScreenPropertiesMap = { - Login: {} - CreateAccount: {} - 'Choose Account': {} - 'Signin:ForgotPassword': {} - 'Signin:SetNewPasswordForm': {} - 'Signin:PasswordUpdatedForm': {} - Feed: {} - Notifications: {} - Profile: {} - 'Profile:Preview': {} - Settings: {} - AppPasswords: {} - Moderation: {} - PreferencesExternalEmbeds: {} - BlockedAccounts: {} - MutedAccounts: {} - SavedFeeds: {} -} diff --git a/src/lib/hooks/useAccountSwitcher.ts b/src/lib/hooks/useAccountSwitcher.ts index 09ff30277f..22eb348f2e 100644 --- a/src/lib/hooks/useAccountSwitcher.ts +++ b/src/lib/hooks/useAccountSwitcher.ts @@ -2,7 +2,6 @@ import {useCallback, useState} from 'react' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import {logger} from '#/logger' import {isWeb} from '#/platform/detection' import {SessionAccount, useSessionApi} from '#/state/session' @@ -14,7 +13,6 @@ import {LogEvents} from '../statsig/statsig' export function useAccountSwitcher() { const [pendingDid, setPendingDid] = useState(null) const {_} = useLingui() - const {track} = useAnalytics() const {resumeSession} = useSessionApi() const {requestSwitchToAccount} = useLoggedOutViewControls() @@ -23,7 +21,6 @@ export function useAccountSwitcher() { account: SessionAccount, logContext: LogEvents['account:loggedIn']['logContext'], ) => { - track('Settings:SwitchAccountButtonClicked') if (pendingDid) { // The session API isn't resilient to race conditions so let's just ignore this. return @@ -62,7 +59,7 @@ export function useAccountSwitcher() { setPendingDid(null) } }, - [_, track, resumeSession, requestSwitchToAccount, pendingDid], + [_, resumeSession, requestSwitchToAccount, pendingDid], ) return {onPressSwitchAccount, pendingDid} diff --git a/src/lib/hooks/useNotificationHandler.ts b/src/lib/hooks/useNotificationHandler.ts index e4e7e14744..625ec9e6a9 100644 --- a/src/lib/hooks/useNotificationHandler.ts +++ b/src/lib/hooks/useNotificationHandler.ts @@ -3,19 +3,18 @@ import * as Notifications from 'expo-notifications' import {CommonActions, useNavigation} from '@react-navigation/native' import {useQueryClient} from '@tanstack/react-query' +import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher' +import {NavigationProp} from '#/lib/routes/types' +import {logEvent} from '#/lib/statsig/statsig' import {logger} from '#/logger' -import {track} from 'lib/analytics/analytics' -import {useAccountSwitcher} from 'lib/hooks/useAccountSwitcher' -import {NavigationProp} from 'lib/routes/types' -import {logEvent} from 'lib/statsig/statsig' -import {isAndroid} from 'platform/detection' -import {useCurrentConvoId} from 'state/messages/current-convo-id' -import {RQKEY as RQKEY_NOTIFS} from 'state/queries/notifications/feed' -import {invalidateCachedUnreadPage} from 'state/queries/notifications/unread' -import {truncateAndInvalidate} from 'state/queries/util' -import {useSession} from 'state/session' -import {useLoggedOutViewControls} from 'state/shell/logged-out' -import {useCloseAllActiveElements} from 'state/util' +import {isAndroid} from '#/platform/detection' +import {useCurrentConvoId} from '#/state/messages/current-convo-id' +import {RQKEY as RQKEY_NOTIFS} from '#/state/queries/notifications/feed' +import {invalidateCachedUnreadPage} from '#/state/queries/notifications/unread' +import {truncateAndInvalidate} from '#/state/queries/util' +import {useSession} from '#/state/session' +import {useLoggedOutViewControls} from '#/state/shell/logged-out' +import {useCloseAllActiveElements} from '#/state/util' import {resetToTab} from '#/Navigation' type NotificationReason = @@ -228,7 +227,6 @@ export function useNotificationsHandler() { {}, logger.DebugContext.notifications, ) - track('Notificatons:OpenApp') logEvent('notifications:openApp', {}) invalidateCachedUnreadPage() truncateAndInvalidate(queryClient, RQKEY_NOTIFS()) diff --git a/src/screens/Login/ChooseAccountForm.tsx b/src/screens/Login/ChooseAccountForm.tsx index 678ba51237..9765786ecf 100644 --- a/src/screens/Login/ChooseAccountForm.tsx +++ b/src/screens/Login/ChooseAccountForm.tsx @@ -3,7 +3,6 @@ import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import {logEvent} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {SessionAccount, useSession, useSessionApi} from '#/state/session' @@ -23,16 +22,11 @@ export const ChooseAccountForm = ({ onPressBack: () => void }) => { const [pendingDid, setPendingDid] = React.useState(null) - const {track, screen} = useAnalytics() const {_} = useLingui() const {currentAccount} = useSession() const {resumeSession} = useSessionApi() const {setShowLoggedOut} = useLoggedOutViewControls() - React.useEffect(() => { - screen('Choose Account') - }, [screen]) - const onSelect = React.useCallback( async (account: SessionAccount) => { if (pendingDid) { @@ -56,7 +50,6 @@ export const ChooseAccountForm = ({ logContext: 'ChooseAccountForm', withPassword: false, }) - track('Sign In', {resumedSession: true}) Toast.show(_(msg`Signed in as @${account.handle}`)) } catch (e: any) { logger.error('choose account: initSession failed', { @@ -70,7 +63,6 @@ export const ChooseAccountForm = ({ }, [ currentAccount, - track, resumeSession, pendingDid, onSelectAccount, diff --git a/src/screens/Login/ForgotPasswordForm.tsx b/src/screens/Login/ForgotPasswordForm.tsx index 7acaae5101..e8582f46f5 100644 --- a/src/screens/Login/ForgotPasswordForm.tsx +++ b/src/screens/Login/ForgotPasswordForm.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react' +import React, {useState} from 'react' import {ActivityIndicator, Keyboard, View} from 'react-native' import {ComAtprotoServerDescribeServer} from '@atproto/api' import {BskyAgent} from '@atproto/api' @@ -6,7 +6,6 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import * as EmailValidator from 'email-validator' -import {useAnalytics} from '#/lib/analytics/analytics' import {isNetworkError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors' import {logger} from '#/logger' @@ -41,13 +40,8 @@ export const ForgotPasswordForm = ({ const t = useTheme() const [isProcessing, setIsProcessing] = useState(false) const [email, setEmail] = useState('') - const {screen} = useAnalytics() const {_} = useLingui() - useEffect(() => { - screen('Signin:ForgotPassword') - }, [screen]) - const onPressSelectService = React.useCallback(() => { Keyboard.dismiss() }, []) diff --git a/src/screens/Login/LoginForm.tsx b/src/screens/Login/LoginForm.tsx index c2038b2879..f3661ac92c 100644 --- a/src/screens/Login/LoginForm.tsx +++ b/src/screens/Login/LoginForm.tsx @@ -13,15 +13,14 @@ import { import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' +import {useRequestNotificationsPermission} from '#/lib/notifications/notifications' import {isNetworkError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors' import {createFullHandle} from '#/lib/strings/handles' import {logger} from '#/logger' +import {useSetHasCheckedForStarterPack} from '#/state/preferences/used-starter-packs' import {useSessionApi} from '#/state/session' import {useLoggedOutViewControls} from '#/state/shell/logged-out' -import {useRequestNotificationsPermission} from 'lib/notifications/notifications' -import {useSetHasCheckedForStarterPack} from 'state/preferences/used-starter-packs' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {FormError} from '#/components/forms/FormError' @@ -57,7 +56,6 @@ export const LoginForm = ({ onPressBack: () => void onPressForgotPassword: () => void }) => { - const {track} = useAnalytics() const t = useTheme() const [isProcessing, setIsProcessing] = useState(false) const [isAuthFactorTokenNeeded, setIsAuthFactorTokenNeeded] = @@ -74,8 +72,7 @@ export const LoginForm = ({ const onPressSelectService = React.useCallback(() => { Keyboard.dismiss() - track('Signin:PressedSelectService') - }, [track]) + }, []) const onPressNext = async () => { if (isProcessing) return diff --git a/src/screens/Login/PasswordUpdatedForm.tsx b/src/screens/Login/PasswordUpdatedForm.tsx index 03e7d86696..9c12a47e3f 100644 --- a/src/screens/Login/PasswordUpdatedForm.tsx +++ b/src/screens/Login/PasswordUpdatedForm.tsx @@ -1,9 +1,8 @@ -import React, {useEffect} from 'react' +import React from 'react' import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import {atoms as a, useBreakpoints} from '#/alf' import {Button, ButtonText} from '#/components/Button' import {Text} from '#/components/Typography' @@ -14,14 +13,9 @@ export const PasswordUpdatedForm = ({ }: { onPressNext: () => void }) => { - const {screen} = useAnalytics() const {_} = useLingui() const {gtMobile} = useBreakpoints() - useEffect(() => { - screen('Signin:PasswordUpdatedForm') - }, [screen]) - return ( void onPasswordSet: () => void }) => { - const {screen} = useAnalytics() const {_} = useLingui() const t = useTheme() - useEffect(() => { - screen('Signin:SetNewPasswordForm') - }, [screen]) - const [isProcessing, setIsProcessing] = useState(false) const [resetCode, setResetCode] = useState('') const [password, setPassword] = useState('') diff --git a/src/screens/Login/index.tsx b/src/screens/Login/index.tsx index 1fce63d298..b46f8d26bf 100644 --- a/src/screens/Login/index.tsx +++ b/src/screens/Login/index.tsx @@ -4,7 +4,6 @@ import {LayoutAnimationConfig} from 'react-native-reanimated' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import {DEFAULT_SERVICE} from '#/lib/constants' import {logger} from '#/logger' import {useServiceQuery} from '#/state/queries/service' @@ -31,7 +30,6 @@ export const Login = ({onPressBack}: {onPressBack: () => void}) => { const {_} = useLingui() const {accounts} = useSession() - const {track} = useAnalytics() const {requestedAccountSwitchTo} = useLoggedOutView() const requestedAccount = accounts.find( acc => acc.did === requestedAccountSwitchTo, @@ -87,7 +85,6 @@ export const Login = ({onPressBack}: {onPressBack: () => void}) => { }, [serviceError, serviceUrl, _]) const onPressForgotPassword = () => { - track('Signin:PressedForgotPassword') setCurrentForm(Forms.ForgotPassword) } diff --git a/src/screens/Moderation/index.tsx b/src/screens/Moderation/index.tsx index 9bfe6c3fac..070b879508 100644 --- a/src/screens/Moderation/index.tsx +++ b/src/screens/Moderation/index.tsx @@ -7,7 +7,6 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useFocusEffect} from '@react-navigation/native' -import {useAnalytics} from '#/lib/analytics/analytics' import {getLabelingServiceTitle} from '#/lib/moderation' import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types' import {logger} from '#/logger' @@ -163,7 +162,6 @@ export function ModerationScreenInner({ const {_} = useLingui() const t = useTheme() const setMinimalShellMode = useSetMinimalShellMode() - const {screen} = useAnalytics() const {gtMobile} = useBreakpoints() const {mutedWordsDialogControl} = useGlobalDialogsControlContext() const birthdateDialogControl = Dialog.useDialogControl() @@ -175,9 +173,8 @@ export function ModerationScreenInner({ useFocusEffect( React.useCallback(() => { - screen('Moderation') setMinimalShellMode(false) - }, [screen, setMinimalShellMode]), + }, [setMinimalShellMode]), ) const {mutateAsync: setAdultContentPref, variables: optimisticAdultContent} = diff --git a/src/screens/Onboarding/StepFinished.tsx b/src/screens/Onboarding/StepFinished.tsx index bc765781af..fdc0a3eb72 100644 --- a/src/screens/Onboarding/StepFinished.tsx +++ b/src/screens/Onboarding/StepFinished.tsx @@ -7,27 +7,26 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useQueryClient} from '@tanstack/react-query' -import {useAnalytics} from '#/lib/analytics/analytics' +import {uploadBlob} from '#/lib/api' import { BSKY_APP_ACCOUNT_DID, DISCOVER_SAVED_FEED, TIMELINE_SAVED_FEED, } from '#/lib/constants' +import {useRequestNotificationsPermission} from '#/lib/notifications/notifications' import {logEvent} from '#/lib/statsig/statsig' import {logger} from '#/logger' +import {useSetHasCheckedForStarterPack} from '#/state/preferences/used-starter-packs' +import {getAllListMembers} from '#/state/queries/list-members' import {preferencesQueryKey} from '#/state/queries/preferences' import {RQKEY as profileRQKey} from '#/state/queries/profile' import {useAgent} from '#/state/session' import {useOnboardingDispatch} from '#/state/shell' import {useProgressGuideControls} from '#/state/shell/progress-guide' -import {uploadBlob} from 'lib/api' -import {useRequestNotificationsPermission} from 'lib/notifications/notifications' -import {useSetHasCheckedForStarterPack} from 'state/preferences/used-starter-packs' -import {getAllListMembers} from 'state/queries/list-members' import { useActiveStarterPack, useSetActiveStarterPack, -} from 'state/shell/starter-pack' +} from '#/state/shell/starter-pack' import { DescriptionText, OnboardingControls, @@ -48,7 +47,6 @@ import {Text} from '#/components/Typography' export function StepFinished() { const {_} = useLingui() const t = useTheme() - const {track} = useAnalytics() const {state, dispatch} = React.useContext(Context) const onboardDispatch = useOnboardingDispatch() const [saving, setSaving] = React.useState(false) @@ -190,8 +188,6 @@ export function StepFinished() { startProgressGuide('like-10-and-follow-7') dispatch({type: 'finish'}) onboardDispatch({type: 'finish'}) - track('OnboardingV2:StepFinished:End') - track('OnboardingV2:Complete') logEvent('onboarding:finished:nextPressed', { usedStarterPack: Boolean(starterPack), starterPackName: AppBskyGraphStarterpack.isRecord(starterPack?.record) @@ -214,7 +210,6 @@ export function StepFinished() { agent, dispatch, onboardDispatch, - track, activeStarterPack, state, requestNotificationsPermission, @@ -223,10 +218,6 @@ export function StepFinished() { startProgressGuide, ]) - React.useEffect(() => { - track('OnboardingV2:StepFinished:Start') - }, [track]) - return ( diff --git a/src/screens/Onboarding/StepInterests/index.tsx b/src/screens/Onboarding/StepInterests/index.tsx index ded473ff59..2f41433aa5 100644 --- a/src/screens/Onboarding/StepInterests/index.tsx +++ b/src/screens/Onboarding/StepInterests/index.tsx @@ -4,7 +4,6 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useQuery} from '@tanstack/react-query' -import {useAnalytics} from '#/lib/analytics/analytics' import {logEvent} from '#/lib/statsig/statsig' import {capitalize} from '#/lib/strings/capitalize' import {logger} from '#/logger' @@ -36,7 +35,6 @@ export function StepInterests() { const {_} = useLingui() const t = useTheme() const {gtMobile} = useBreakpoints() - const {track} = useAnalytics() const interestsDisplayNames = useInterestsDisplayNames() const {state, dispatch} = React.useContext(Context) @@ -90,7 +88,6 @@ export function StepInterests() { `onboarding: getTaggedSuggestions fetch or processing failed`, ) logger.error(e) - track('OnboardingV2:StepInterests:Error') throw new Error(`a network error occurred`) } @@ -108,11 +105,6 @@ export function StepInterests() { selectedInterests: interests, }) dispatch({type: 'next'}) - - track('OnboardingV2:StepInterests:End', { - selectedInterests: interests, - selectedInterestsLength: interests.length, - }) logEvent('onboarding:interests:nextPressed', { selectedInterests: interests, selectedInterestsLength: interests.length, @@ -121,18 +113,12 @@ export function StepInterests() { logger.info(`onboading: error saving interests`) logger.error(e) } - }, [interests, data, setSaving, dispatch, track]) + }, [interests, data, setSaving, dispatch]) const skipOnboarding = React.useCallback(() => { onboardDispatch({type: 'finish'}) dispatch({type: 'finish'}) - track('OnboardingV2:Skip') - }, [onboardDispatch, dispatch, track]) - - React.useEffect(() => { - track('OnboardingV2:Begin') - track('OnboardingV2:StepInterests:Start') - }, [track]) + }, [onboardDispatch, dispatch]) const title = isError ? ( Oh no! Something went wrong. diff --git a/src/screens/Onboarding/StepProfile/index.tsx b/src/screens/Onboarding/StepProfile/index.tsx index 79957da31a..663418f220 100644 --- a/src/screens/Onboarding/StepProfile/index.tsx +++ b/src/screens/Onboarding/StepProfile/index.tsx @@ -9,7 +9,6 @@ import { import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import {usePhotoLibraryPermission} from '#/lib/hooks/usePermissions' import {compressIfNeeded} from '#/lib/media/manip' import {openCropper} from '#/lib/media/picker' @@ -68,7 +67,6 @@ export function StepProfile() { const {_} = useLingui() const t = useTheme() const {gtMobile} = useBreakpoints() - const {track} = useAnalytics() const {requestPhotoAccessIfNeeded} = usePhotoLibraryPermission() const gate = useGate() const requestNotificationsPermission = useRequestNotificationsPermission() @@ -87,10 +85,6 @@ export function StepProfile() { const canvasRef = React.useRef(null) - React.useEffect(() => { - track('OnboardingV2:StepProfile:Start') - }, [track]) - React.useEffect(() => { requestNotificationsPermission('StartOnboarding') }, [gate, requestNotificationsPermission]) @@ -155,9 +149,8 @@ export function StepProfile() { } dispatch({type: 'next'}) - track('OnboardingV2:StepProfile:End') logEvent('onboarding:profile:nextPressed', {}) - }, [avatar, dispatch, track]) + }, [avatar, dispatch]) const onDoneCreating = React.useCallback(() => { setAvatar(prev => ({ diff --git a/src/screens/Profile/Header/ProfileHeaderLabeler.tsx b/src/screens/Profile/Header/ProfileHeaderLabeler.tsx index a807c70dd9..7b44e58693 100644 --- a/src/screens/Profile/Header/ProfileHeaderLabeler.tsx +++ b/src/screens/Profile/Header/ProfileHeaderLabeler.tsx @@ -12,18 +12,17 @@ import {useLingui} from '@lingui/react' // eslint-disable-next-line @typescript-eslint/no-unused-vars import {MAX_LABELERS} from '#/lib/constants' +import {useHaptics} from '#/lib/haptics' import {isAppLabeler} from '#/lib/moderation' import {logger} from '#/logger' +import {isIOS} from '#/platform/detection' +import {useProfileShadow} from '#/state/cache/profile-shadow' import {Shadow} from '#/state/cache/types' import {useModalControls} from '#/state/modals' import {useLabelerSubscriptionMutation} from '#/state/queries/labeler' import {useLikeMutation, useUnlikeMutation} from '#/state/queries/like' import {usePreferencesQuery} from '#/state/queries/preferences' import {useRequireAuth, useSession} from '#/state/session' -import {useAnalytics} from 'lib/analytics/analytics' -import {useHaptics} from 'lib/haptics' -import {isIOS} from 'platform/detection' -import {useProfileShadow} from 'state/cache/profile-shadow' import {ProfileMenu} from '#/view/com/profile/ProfileMenu' import * as Toast from '#/view/com/util/Toast' import {atoms as a, tokens, useBreakpoints, useTheme} from '#/alf' @@ -66,7 +65,6 @@ let ProfileHeaderLabeler = ({ const {_} = useLingui() const {currentAccount, hasSession} = useSession() const {openModal} = useModalControls() - const {track} = useAnalytics() const requireAuth = useRequireAuth() const playHaptic = useHaptics() const cantSubscribePrompt = Prompt.usePromptControl() @@ -102,12 +100,10 @@ let ProfileHeaderLabeler = ({ if (likeUri) { await unlikeMod({uri: likeUri}) - track('CustomFeed:Unlike') setLikeCount(c => c - 1) setLikeUri('') } else { const res = await likeMod({uri: labeler.uri, cid: labeler.cid}) - track('CustomFeed:Like') setLikeCount(c => c + 1) setLikeUri(res.uri) } @@ -120,15 +116,14 @@ let ProfileHeaderLabeler = ({ ) logger.error(`Failed to toggle labeler like`, {message: e.message}) } - }, [labeler, playHaptic, likeUri, unlikeMod, track, likeMod, _]) + }, [labeler, playHaptic, likeUri, unlikeMod, likeMod, _]) const onPressEditProfile = React.useCallback(() => { - track('ProfileHeader:EditProfileButtonClicked') openModal({ name: 'edit-profile', profile, }) - }, [track, openModal, profile]) + }, [openModal, profile]) const onPressSubscribe = React.useCallback( () => diff --git a/src/screens/Profile/Header/ProfileHeaderStandard.tsx b/src/screens/Profile/Header/ProfileHeaderStandard.tsx index 846fa4424b..3bfc4bf2f2 100644 --- a/src/screens/Profile/Header/ProfileHeaderStandard.tsx +++ b/src/screens/Profile/Header/ProfileHeaderStandard.tsx @@ -9,8 +9,10 @@ import { import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {sanitizeDisplayName} from '#/lib/strings/display-names' import {logger} from '#/logger' import {isIOS} from '#/platform/detection' +import {useProfileShadow} from '#/state/cache/profile-shadow' import {Shadow} from '#/state/cache/types' import {useModalControls} from '#/state/modals' import { @@ -18,9 +20,6 @@ import { useProfileFollowMutationQueue, } from '#/state/queries/profile' import {useRequireAuth, useSession} from '#/state/session' -import {useAnalytics} from 'lib/analytics/analytics' -import {sanitizeDisplayName} from 'lib/strings/display-names' -import {useProfileShadow} from 'state/cache/profile-shadow' import {ProfileMenu} from '#/view/com/profile/ProfileMenu' import * as Toast from '#/view/com/util/Toast' import {atoms as a} from '#/alf' @@ -59,7 +58,6 @@ let ProfileHeaderStandard = ({ const {currentAccount, hasSession} = useSession() const {_} = useLingui() const {openModal} = useModalControls() - const {track} = useAnalytics() const moderation = useMemo( () => moderateProfile(profile, moderationOpts), [profile, moderationOpts], @@ -77,17 +75,15 @@ let ProfileHeaderStandard = ({ profile.viewer?.blockingByList const onPressEditProfile = React.useCallback(() => { - track('ProfileHeader:EditProfileButtonClicked') openModal({ name: 'edit-profile', profile, }) - }, [track, openModal, profile]) + }, [openModal, profile]) const onPressFollow = () => { requireAuth(async () => { try { - track('ProfileHeader:FollowButtonClicked') await queueFollow() Toast.show( _( @@ -109,7 +105,6 @@ let ProfileHeaderStandard = ({ const onPressUnfollow = () => { requireAuth(async () => { try { - track('ProfileHeader:UnfollowButtonClicked') await queueUnfollow() Toast.show( _( @@ -129,7 +124,6 @@ let ProfileHeaderStandard = ({ } const unblockAccount = React.useCallback(async () => { - track('ProfileHeader:UnblockAccountButtonClicked') try { await queueUnblock() Toast.show(_(msg`Account unblocked`)) @@ -139,7 +133,7 @@ let ProfileHeaderStandard = ({ Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark') } } - }, [_, queueUnblock, track]) + }, [_, queueUnblock]) const isMe = React.useMemo( () => currentAccount?.did === profile.did, diff --git a/src/screens/Signup/index.tsx b/src/screens/Signup/index.tsx index 3209800328..e3da053c09 100644 --- a/src/screens/Signup/index.tsx +++ b/src/screens/Signup/index.tsx @@ -5,7 +5,6 @@ import {AppBskyGraphStarterpack} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import {FEEDBACK_FORM_URL} from '#/lib/constants' import {useServiceQuery} from '#/state/queries/service' import {useStarterPackQuery} from '#/state/queries/starter-packs' @@ -31,7 +30,6 @@ import {Text} from '#/components/Typography' export function Signup({onPressBack}: {onPressBack: () => void}) { const {_} = useLingui() const t = useTheme() - const {screen} = useAnalytics() const [state, dispatch] = React.useReducer(reducer, initialState) const {gtMobile} = useBreakpoints() const submit = useSubmitSignup() @@ -56,10 +54,6 @@ export function Signup({onPressBack}: {onPressBack: () => void}) { refetch, } = useServiceQuery(state.serviceUrl) - React.useEffect(() => { - screen('CreateAccount') - }, [screen]) - React.useEffect(() => { if (isFetching) { dispatch({type: 'setIsLoading', value: true}) diff --git a/src/state/queries/post.ts b/src/state/queries/post.ts index 982d224aee..7023580bbe 100644 --- a/src/state/queries/post.ts +++ b/src/state/queries/post.ts @@ -2,7 +2,6 @@ import {useCallback} from 'react' import {AppBskyActorDefs, AppBskyFeedDefs, AtUri} from '@atproto/api' import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' -import {track} from '#/lib/analytics/analytics' import {useToggleMutationQueue} from '#/lib/hooks/useToggleMutationQueue' import {logEvent, LogEvents, toClout} from '#/lib/statsig/statsig' import {updatePostShadow} from '#/state/cache/post-shadow' @@ -193,9 +192,6 @@ function usePostLikeMutation( }) return agent.like(uri, cid) }, - onSuccess() { - track('Post:Like') - }, }) } @@ -208,9 +204,6 @@ function usePostUnlikeMutation( logEvent('post:unlike:sampled', {logContext}) return agent.deleteLike(likeUri) }, - onSuccess() { - track('Post:Unlike') - }, }) } @@ -285,9 +278,6 @@ function usePostRepostMutation( logEvent('post:repost:sampled', {logContext}) return agent.repost(post.uri, post.cid) }, - onSuccess() { - track('Post:Repost') - }, }) } @@ -300,9 +290,6 @@ function usePostUnrepostMutation( logEvent('post:unrepost:sampled', {logContext}) return agent.deleteRepost(repostUri) }, - onSuccess() { - track('Post:Unrepost') - }, }) } @@ -313,9 +300,8 @@ export function usePostDeleteMutation() { mutationFn: async ({uri}) => { await agent.deletePost(uri) }, - onSuccess(data, variables) { + onSuccess(_, variables) { updatePostShadow(queryClient, variables.uri, {isDeleted: true}) - track('Post:Delete') }, }) } diff --git a/src/state/queries/preferences/index.ts b/src/state/queries/preferences/index.ts index ab866d5e2a..3cb121a470 100644 --- a/src/state/queries/preferences/index.ts +++ b/src/state/queries/preferences/index.ts @@ -5,7 +5,6 @@ import { } from '@atproto/api' import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' -import {track} from '#/lib/analytics/analytics' import {PROD_DEFAULT_FEED} from '#/lib/constants' import {replaceEqualDeep} from '#/lib/functions' import {getAge} from '#/lib/strings/time' @@ -218,7 +217,6 @@ export function useAddSavedFeedsMutation() { >({ mutationFn: async savedFeeds => { await agent.addSavedFeeds(savedFeeds) - track('CustomFeed:Save') // triggers a refetch await queryClient.invalidateQueries({ queryKey: preferencesQueryKey, @@ -234,7 +232,6 @@ export function useRemoveFeedMutation() { return useMutation>({ mutationFn: async savedFeed => { await agent.removeSavedFeeds([savedFeed.id]) - track('CustomFeed:Unsave') // triggers a refetch await queryClient.invalidateQueries({ queryKey: preferencesQueryKey, diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts index 532b005cf4..78a142eead 100644 --- a/src/state/queries/profile.ts +++ b/src/state/queries/profile.ts @@ -16,7 +16,6 @@ import { useQueryClient, } from '@tanstack/react-query' -import {track} from '#/lib/analytics/analytics' import {uploadBlob} from '#/lib/api' import {until} from '#/lib/async/until' import {useToggleMutationQueue} from '#/lib/hooks/useToggleMutationQueue' @@ -316,9 +315,6 @@ function useProfileFollowMutation( }) return await agent.follow(did) }, - onSuccess(data, variables) { - track('Profile:Follow', {username: variables.did}) - }, }) } @@ -329,7 +325,6 @@ function useProfileUnfollowMutation( return useMutation({ mutationFn: async ({followUri}) => { logEvent('profile:unfollow:sampled', {logContext}) - track('Profile:Unfollow', {username: followUri}) return await agent.deleteFollow(followUri) }, }) diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index 21fe7f75b9..ab3352bf3a 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -1,7 +1,6 @@ import React from 'react' import {AtpSessionEvent, BskyAgent} from '@atproto/api' -import {track} from '#/lib/analytics/analytics' import {logEvent} from '#/lib/statsig/statsig' import {isWeb} from '#/platform/detection' import * as persisted from '#/state/persisted' @@ -70,7 +69,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) { async params => { addSessionDebugLog({type: 'method:start', method: 'createAccount'}) const signal = cancelPendingTask() - track('Try Create Account') logEvent('account:create:begin', {}) const {agent, account} = await createAgentAndCreateAccount( params, @@ -85,7 +83,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) { newAgent: agent, newAccount: account, }) - track('Create Account') logEvent('account:create:success', {}) addSessionDebugLog({type: 'method:end', method: 'createAccount', account}) }, @@ -109,7 +106,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) { newAgent: agent, newAccount: account, }) - track('Sign In', {resumedSession: false}) logEvent('account:loggedIn', {logContext, withPassword: true}) addSessionDebugLog({type: 'method:end', method: 'login', account}) }, diff --git a/src/state/shell/onboarding.tsx b/src/state/shell/onboarding.tsx index d3a8fec466..9aad9953d4 100644 --- a/src/state/shell/onboarding.tsx +++ b/src/state/shell/onboarding.tsx @@ -1,6 +1,5 @@ import React from 'react' -import {track} from '#/lib/analytics/analytics' import * as persisted from '#/state/persisted' export const OnboardingScreenSteps = { @@ -55,17 +54,14 @@ function reducer(state: StateContext, action: Action): StateContext { return compute({...state, step: nextStep}) } case 'start': { - track('Onboarding:Begin') persisted.write('onboarding', {step: 'Welcome'}) return compute({...state, step: 'Welcome'}) } case 'finish': { - track('Onboarding:Complete') persisted.write('onboarding', {step: 'Home'}) return compute({...state, step: 'Home'}) } case 'skip': { - track('Onboarding:Skipped') persisted.write('onboarding', {step: 'Home'}) return compute({...state, step: 'Home'}) } diff --git a/src/view/com/auth/LoggedOut.tsx b/src/view/com/auth/LoggedOut.tsx index cc57238053..5b9e3932f9 100644 --- a/src/view/com/auth/LoggedOut.tsx +++ b/src/view/com/auth/LoggedOut.tsx @@ -4,7 +4,6 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import {usePalette} from '#/lib/hooks/usePalette' import {logEvent} from '#/lib/statsig/statsig' import {s} from '#/lib/styles' @@ -32,7 +31,6 @@ export function LoggedOut({onDismiss}: {onDismiss?: () => void}) { const {_} = useLingui() const pal = usePalette('default') const setMinimalShellMode = useSetMinimalShellMode() - const {screen} = useAnalytics() const {requestedAccountSwitchTo} = useLoggedOutView() const [screenState, setScreenState] = React.useState(() => { if (requestedAccountSwitchTo === 'new') { @@ -48,9 +46,8 @@ export function LoggedOut({onDismiss}: {onDismiss?: () => void}) { const {clearRequestedAccount} = useLoggedOutViewControls() React.useEffect(() => { - screen('Login') setMinimalShellMode(true) - }, [screen, setMinimalShellMode]) + }, [setMinimalShellMode]) const onPressDismiss = React.useCallback(() => { if (onDismiss) { diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 49ce0d4428..ade37af1b6 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -45,7 +45,6 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import * as apilib from '#/lib/api/index' import {until} from '#/lib/async/until' import {MAX_GRAPHEME_LENGTH} from '#/lib/constants' @@ -147,7 +146,6 @@ export const ComposePost = ({ const {data: currentProfile} = useProfileQuery({did: currentAccount!.did}) const {isModalActive} = useModals() const {closeComposer} = useComposerControls() - const {track} = useAnalytics() const pal = usePalette('default') const {isMobile} = useWebMediaQueries() const {_} = useLingui() @@ -310,7 +308,6 @@ export const ComposePost = ({ const onPhotoPasted = useCallback( async (uri: string) => { - track('Composer:PastedPhotos') if (uri.startsWith('data:video/')) { selectVideo({uri, type: 'video', height: 0, width: 0}) } else { @@ -318,7 +315,7 @@ export const ComposePost = ({ onImageAdd([res]) } }, - [track, selectVideo, onImageAdd], + [selectVideo, onImageAdd], ) const isAltTextRequiredAndMissing = useMemo(() => { @@ -446,10 +443,6 @@ export const ComposePost = ({ logContext: 'Composer', }) } - track('Create Post', { - imageCount: images.length, - }) - if (replyTo && replyTo.uri) track('Post:Reply') } if (postUri && !replyTo) { emitPostCreated() @@ -499,7 +492,6 @@ export const ComposePost = ({ setExtLink, setLangPrefs, threadgateAllowUISettings, - track, videoAltText, videoUploadState.asset, videoUploadState.pendingPublish, diff --git a/src/view/com/composer/photos/OpenCameraBtn.tsx b/src/view/com/composer/photos/OpenCameraBtn.tsx index 2183ca7902..79d59a92d1 100644 --- a/src/view/com/composer/photos/OpenCameraBtn.tsx +++ b/src/view/com/composer/photos/OpenCameraBtn.tsx @@ -3,7 +3,6 @@ import * as MediaLibrary from 'expo-media-library' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import {POST_IMG_MAX} from '#/lib/constants' import {useCameraPermission} from '#/lib/hooks/usePermissions' import {openCamera} from '#/lib/media/picker' @@ -20,7 +19,6 @@ type Props = { } export function OpenCameraBtn({disabled, onAdd}: Props) { - const {track} = useAnalytics() const {_} = useLingui() const {requestCameraAccessIfNeeded} = useCameraPermission() const [mediaPermissionRes, requestMediaPermission] = @@ -28,7 +26,6 @@ export function OpenCameraBtn({disabled, onAdd}: Props) { const t = useTheme() const onPressTakePicture = useCallback(async () => { - track('Composer:CameraOpened') try { if (!(await requestCameraAccessIfNeeded())) { return @@ -58,7 +55,6 @@ export function OpenCameraBtn({disabled, onAdd}: Props) { } }, [ onAdd, - track, requestCameraAccessIfNeeded, mediaPermissionRes, requestMediaPermission, diff --git a/src/view/com/composer/photos/SelectPhotoBtn.tsx b/src/view/com/composer/photos/SelectPhotoBtn.tsx index 95d2df022c..34ead3d9a9 100644 --- a/src/view/com/composer/photos/SelectPhotoBtn.tsx +++ b/src/view/com/composer/photos/SelectPhotoBtn.tsx @@ -3,7 +3,6 @@ import React, {useCallback} from 'react' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAnalytics} from '#/lib/analytics/analytics' import {usePhotoLibraryPermission} from '#/lib/hooks/usePermissions' import {openPicker} from '#/lib/media/picker' import {isNative} from '#/platform/detection' @@ -19,14 +18,11 @@ type Props = { } export function SelectPhotoBtn({size, disabled, onAdd}: Props) { - const {track} = useAnalytics() const {_} = useLingui() const {requestPhotoAccessIfNeeded} = usePhotoLibraryPermission() const t = useTheme() const onPressSelectPhotos = useCallback(async () => { - track('Composer:GalleryOpened') - if (isNative && !(await requestPhotoAccessIfNeeded())) { return } @@ -41,7 +37,7 @@ export function SelectPhotoBtn({size, disabled, onAdd}: Props) { ) onAdd(results) - }, [track, requestPhotoAccessIfNeeded, size, onAdd]) + }, [requestPhotoAccessIfNeeded, size, onAdd]) return (