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