diff --git a/VAMobile/src/constants/analytics.ts b/VAMobile/src/constants/analytics.ts index 9cf22154555..9d6b76bfd86 100644 --- a/VAMobile/src/constants/analytics.ts +++ b/VAMobile/src/constants/analytics.ts @@ -328,6 +328,23 @@ export const Events = { }, } }, + vama_claim_submit_ev: (claim_id: string): Event => { + return { + name: 'vama_claim_submit_ev', + params: { + claim_id, + }, + } + }, + vama_claim_submit_tap: (claim_id: string, claim_type: string): Event => { + return { + name: 'vama_claim_submit_tap', + params: { + claim_id, + claim_type, + }, + } + }, vama_claim_upload_compl: ( claim_id: string, claim_request_id: number | null, diff --git a/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.tsx b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.tsx index c726c8ae53c..2addf59ad21 100644 --- a/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.tsx +++ b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.tsx @@ -78,13 +78,15 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) { const { attributes } = claim || ({} as ClaimData) const { dateFiled } = attributes || ({} as ClaimAttributesData) - const [count, setCount] = useState(0) + const [count, setCount] = useState(-1) const [scrollIsEnabled, setScrollIsEnabled] = useState(true) useFocusEffect( useCallback(() => { - setCount(numberOfItemsNeedingAttentionFromVet(attributes?.eventsTimeline || [])) + if (attributes) { + setCount(numberOfItemsNeedingAttentionFromVet(attributes.eventsTimeline)) + } }, [attributes]), ) //force a rerender due to react query updating data @@ -119,6 +121,18 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) { } }, [claim, loadingClaim, claimError, claimID, attributes]) + useEffect(() => { + if (claimType === ClaimTypeConstants.ACTIVE && claim) { + if (claimPhaseExpansionFlag) { + if (count > 0 && !claim.attributes.waiverSubmitted) { + logAnalyticsEvent(Events.vama_claim_file_request(claimID)) + } else if (submitEvidenceExpansionFlag && claim.attributes.open && count >= 0) { + logAnalyticsEvent(Events.vama_claim_submit_ev(claimID)) + } + } + } + }, [claimType, claimPhaseExpansionFlag, submitEvidenceExpansionFlag, count, claim, claimID]) + // Track how long user maintains focus on this screen useFocusEffect( useCallback(() => { @@ -177,7 +191,7 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) { } const submitEvidencePress = () => { - logAnalyticsEvent(Events.vama_claim_review(claimID, attributes.claimType, count)) + logAnalyticsEvent(Events.vama_claim_submit_tap(claimID, attributes.claimType)) navigateTo('SubmitEvidence', { claimID }) }