Wire up action captures
This commit is contained in:
@@ -4,7 +4,6 @@ import {msg, Trans} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
|
||||
import {
|
||||
ProgressGuideAction,
|
||||
ProgressGuideName,
|
||||
useProgressGuide,
|
||||
useProgressGuideControls,
|
||||
@@ -19,12 +18,7 @@ export function ProgressGuideList({style}: {style: StyleProp<ViewStyle>}) {
|
||||
const t = useTheme()
|
||||
const {_} = useLingui()
|
||||
const guide = useProgressGuide(ProgressGuideName.Like10AndFollow7)
|
||||
const {captureAction, endProgressGuide} = useProgressGuideControls()
|
||||
|
||||
React.useEffect(() => {
|
||||
const i = setInterval(() => captureAction(ProgressGuideAction.Like), 2e3)
|
||||
return () => clearInterval(i)
|
||||
}, [captureAction])
|
||||
const {endProgressGuide} = useProgressGuideControls()
|
||||
|
||||
if (guide?.guide === ProgressGuideName.Like10AndFollow7) {
|
||||
return (
|
||||
|
||||
@@ -23,6 +23,10 @@ import {
|
||||
import {cleanError} from '#/lib/strings/errors'
|
||||
import {logger} from '#/logger'
|
||||
import {useDeleteStarterPackMutation} from '#/state/queries/starter-packs'
|
||||
import {
|
||||
ProgressGuideAction,
|
||||
useProgressGuideControls,
|
||||
} from '#/state/shell/progress-guide'
|
||||
import {batchedUpdates} from 'lib/batchedUpdates'
|
||||
import {HITSLOP_20} from 'lib/constants'
|
||||
import {isBlockedOrBlocking, isMuted} from 'lib/moderation/blocked-and-muted'
|
||||
@@ -305,6 +309,7 @@ function Header({
|
||||
const queryClient = useQueryClient()
|
||||
const setActiveStarterPack = useSetActiveStarterPack()
|
||||
const {requestSwitchToAccount} = useLoggedOutViewControls()
|
||||
const {captureAction} = useProgressGuideControls()
|
||||
|
||||
const [isProcessing, setIsProcessing] = React.useState(false)
|
||||
|
||||
@@ -369,6 +374,7 @@ function Header({
|
||||
starterPack: starterPack.uri,
|
||||
count: dids.length,
|
||||
})
|
||||
captureAction(ProgressGuideAction.Follow, dids.length)
|
||||
Toast.show(_(msg`All accounts have been followed!`))
|
||||
} catch (e) {
|
||||
Toast.show(_(msg`An error occurred while trying to follow all`))
|
||||
|
||||
@@ -25,6 +25,10 @@ import {STALE} from '#/state/queries'
|
||||
import {resetProfilePostsQueries} from '#/state/queries/post-feed'
|
||||
import {updateProfileShadow} from '../cache/profile-shadow'
|
||||
import {useAgent, useSession} from '../session'
|
||||
import {
|
||||
ProgressGuideAction,
|
||||
useProgressGuideControls,
|
||||
} from '../shell/progress-guide'
|
||||
import {RQKEY as RQKEY_LIST_CONVOS} from './messages/list-converations'
|
||||
import {RQKEY as RQKEY_MY_BLOCKED} from './my-blocked-accounts'
|
||||
import {RQKEY as RQKEY_MY_MUTED} from './my-muted-accounts'
|
||||
@@ -274,12 +278,15 @@ function useProfileFollowMutation(
|
||||
const {currentAccount} = useSession()
|
||||
const agent = useAgent()
|
||||
const queryClient = useQueryClient()
|
||||
const {captureAction} = useProgressGuideControls()
|
||||
|
||||
return useMutation<{uri: string; cid: string}, Error, {did: string}>({
|
||||
mutationFn: async ({did}) => {
|
||||
let ownProfile: AppBskyActorDefs.ProfileViewDetailed | undefined
|
||||
if (currentAccount) {
|
||||
ownProfile = findProfileQueryData(queryClient, currentAccount.did)
|
||||
}
|
||||
captureAction(ProgressGuideAction.Follow)
|
||||
logEvent('profile:follow', {
|
||||
logContext,
|
||||
didBecomeMutual: profile.viewer
|
||||
|
||||
@@ -34,11 +34,11 @@ const ProgressGuideContext = React.createContext<ProgressGuide>(undefined)
|
||||
const ProgressGuideControlContext = React.createContext<{
|
||||
startProgressGuide(guide: ProgressGuideName): void
|
||||
endProgressGuide(): void
|
||||
captureAction(action: ProgressGuideAction): void
|
||||
captureAction(action: ProgressGuideAction, count?: number): void
|
||||
}>({
|
||||
startProgressGuide: (_guide: ProgressGuideName) => {},
|
||||
endProgressGuide: () => {},
|
||||
captureAction: (_action: ProgressGuideAction) => {},
|
||||
captureAction: (_action: ProgressGuideAction, _count = 1) => {},
|
||||
})
|
||||
|
||||
export function useProgressGuide(guide: ProgressGuideName) {
|
||||
@@ -85,7 +85,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
setActiveProgressGuide(undefined)
|
||||
},
|
||||
|
||||
captureAction(action: ProgressGuideAction) {
|
||||
captureAction(action: ProgressGuideAction, count = 1) {
|
||||
let guide = activeProgressGuide
|
||||
if (guide?.isComplete) {
|
||||
return
|
||||
@@ -94,7 +94,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
if (action === ProgressGuideAction.Like) {
|
||||
guide = {
|
||||
...guide,
|
||||
numLikes: (guide.numLikes || 0) + 1,
|
||||
numLikes: (guide.numLikes || 0) + count,
|
||||
}
|
||||
if (guide.numLikes === 1) {
|
||||
firstLikeToastRef.current?.open()
|
||||
@@ -109,7 +109,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
if (action === ProgressGuideAction.Follow) {
|
||||
guide = {
|
||||
...guide,
|
||||
numFollows: (guide.numFollows || 0) + 1,
|
||||
numFollows: (guide.numFollows || 0) + count,
|
||||
}
|
||||
}
|
||||
if (guide.numLikes >= 10 && guide.numFollows >= 7) {
|
||||
|
||||
@@ -6,10 +6,6 @@ import {useLingui} from '@lingui/react'
|
||||
|
||||
import {useSession} from '#/state/session'
|
||||
import {useSetDrawerOpen} from '#/state/shell/drawer-open'
|
||||
import {
|
||||
ProgressGuideAction,
|
||||
useProgressGuideControls,
|
||||
} from '#/state/shell/progress-guide'
|
||||
import {useShellLayout} from '#/state/shell/shell-layout'
|
||||
import {HITSLOP_10} from 'lib/constants'
|
||||
import {useMinimalShellHeaderTransform} from 'lib/hooks/useMinimalShellTransform'
|
||||
@@ -38,19 +34,11 @@ export function HomeHeaderLayoutMobile({
|
||||
const {headerHeight} = useShellLayout()
|
||||
const headerMinimalShellTransform = useMinimalShellHeaderTransform()
|
||||
const {hasSession} = useSession()
|
||||
const {captureAction} = useProgressGuideControls()
|
||||
|
||||
const onPressAvi = React.useCallback(() => {
|
||||
setDrawerOpen(true)
|
||||
}, [setDrawerOpen])
|
||||
|
||||
React.useEffect(() => {
|
||||
const i = setInterval(() => captureAction(ProgressGuideAction.Like), 1000)
|
||||
return () => {
|
||||
clearInterval(i)
|
||||
}
|
||||
}, [captureAction])
|
||||
|
||||
return (
|
||||
<Animated.View
|
||||
style={[pal.view, pal.border, styles.tabBar, headerMinimalShellTransform]}
|
||||
|
||||
@@ -31,6 +31,10 @@ import {
|
||||
} from '#/state/queries/post'
|
||||
import {useRequireAuth, useSession} from '#/state/session'
|
||||
import {useComposerControls} from '#/state/shell/composer'
|
||||
import {
|
||||
ProgressGuideAction,
|
||||
useProgressGuideControls,
|
||||
} from '#/state/shell/progress-guide'
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import {useDialogControl} from '#/components/Dialog'
|
||||
import {ArrowOutOfBox_Stroke2_Corner0_Rounded as ArrowOutOfBox} from '#/components/icons/ArrowOutOfBox'
|
||||
@@ -77,6 +81,7 @@ let PostCtrls = ({
|
||||
const requireAuth = useRequireAuth()
|
||||
const loggedOutWarningPromptControl = useDialogControl()
|
||||
const {sendInteraction} = useFeedFeedbackContext()
|
||||
const {captureAction} = useProgressGuideControls()
|
||||
const playHaptic = useHaptics()
|
||||
const gate = useGate()
|
||||
|
||||
@@ -103,6 +108,7 @@ let PostCtrls = ({
|
||||
event: 'app.bsky.feed.defs#interactionLike',
|
||||
feedContext,
|
||||
})
|
||||
captureAction(ProgressGuideAction.Like)
|
||||
await queueLike()
|
||||
} else {
|
||||
await queueUnlike()
|
||||
@@ -119,6 +125,7 @@ let PostCtrls = ({
|
||||
queueLike,
|
||||
queueUnlike,
|
||||
sendInteraction,
|
||||
captureAction,
|
||||
feedContext,
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user