Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/10030+10028 create analytics and trigger #10279

Merged
merged 19 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions VAMobile/e2e/tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ export const CommonE2eIdConstants = {
}

/** Logs into demo mode.
* @param skipOnboarding: Boolean value that defaults to true. Set this to false if you want the detox test to view the onboarding carasoul on login
* @param pushNotifications: Boolean value that tells the detox tests whether to turn on/off push notifications
* */
* @param skipOnboarding: Boolean value that defaults to true. Set this to false if you want the detox test to view the onboarding carasoul on login
* @param pushNotifications: Boolean value that tells the detox tests whether to turn on/off push notifications
* */
export async function loginToDemoMode(skipOnboarding = true, pushNotifications?: boolean) {
try {
await waitFor(element(by.id(CommonE2eIdConstants.VA_LOGO_ICON_ID)))
Expand Down Expand Up @@ -460,10 +460,10 @@ export async function backButton(backButtonName: string) {
}

/** Enables the availibility banner.
* @param AFFeature: Name of the AF waygate.
* @param AFUseCase: Name of the AF type.
* @param AFAppUpdate: Boolean value that tells the script whether to enable the update now button or not
* */
* @param AFFeature: Name of the AF waygate.
* @param AFUseCase: Name of the AF type.
* @param AFAppUpdate: Boolean value that tells the script whether to enable the update now button or not
* */
export async function enableAF(AFFeature, AFUseCase, AFAppUpdate = false) {
await device.launchApp({ newInstance: true, permissions: { notifications: 'YES' } })
await loginToDemoMode()
Expand Down Expand Up @@ -543,11 +543,11 @@ export async function enableAF(AFFeature, AFUseCase, AFAppUpdate = false) {
}

/** Disables the availibility banner.
* @param featureNavigationArray: Array that tells the AF script how to navigate to the feature
* @param AFFeature: Name of the AF waygate.
* @param AFUseCaseName: Name of the AF type.
* @param AFAppUpdate: Boolean value that tells the script whether to enable the update now button or not
* */
* @param featureNavigationArray: Array that tells the AF script how to navigate to the feature
* @param AFFeature: Name of the AF waygate.
* @param AFUseCaseName: Name of the AF type.
* @param AFAppUpdate: Boolean value that tells the script whether to enable the update now button or not
* */
export async function disableAF(featureNavigationArray, AFFeature, AFFeatureName, AFUseCaseName) {
if (AFUseCaseName === 'AllowFunction') {
await element(by.id(CommonE2eIdConstants.HOME_TAB_BUTTON_ID)).tap()
Expand Down Expand Up @@ -583,7 +583,7 @@ export async function disableAF(featureNavigationArray, AFFeature, AFFeatureName
}

/** Function that allows the AF script to navigate to a certain feature
* */
* */
const navigateToFeature = async (featureNavigationArray) => {
for (let j = 2; j < featureNavigationArray.length; j++) {
if (featureNavigationArray[j] === 'Talk to the Veterans Crisis Line now') {
Expand Down Expand Up @@ -652,10 +652,10 @@ const navigateToFeature = async (featureNavigationArray) => {
}

/** Verifies that the availibility banner is the correct type and is populated with the correct information.
* @param featureNavigationArray: Array that tells the AF script how to navigate to the feature
* @param AFUseCaseName: Name of the AF type.
* @param AFUseCaseUpgrade: Boolean value that tells the script whether to enable the update now button or not
* */
* @param featureNavigationArray: Array that tells the AF script how to navigate to the feature
* @param AFUseCaseName: Name of the AF type.
* @param AFUseCaseUpgrade: Boolean value that tells the script whether to enable the update now button or not
* */
export async function verifyAF(featureNavigationArray, AFUseCase, AFUseCaseUpgrade = false) {
let featureName
if (AFUseCase !== 'AllowFunction') {
Expand Down Expand Up @@ -718,7 +718,7 @@ export async function verifyAF(featureNavigationArray, AFUseCase, AFUseCaseUpgra

/** Toggle the specified remote config feature flag
* @param flagName - name of flag to toggle
* */
* */
export async function toggleRemoteConfigFlag(flagName: string) {
await loginToDemoMode()
await openProfile()
Expand Down
2 changes: 1 addition & 1 deletion VAMobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export type RootNavStackParamList = WebviewStackParams & {
SubmitEvidenceSubtask: {
claimID: string
}
InAppFeedback: { task: string }
InAppFeedback: { screen: string }
Tabs: undefined
}

Expand Down
4 changes: 2 additions & 2 deletions VAMobile/src/api/appointments/cancelAppointment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DEFAULT_UPCOMING_DAYS_LIMIT, TimeFrameTypeConstants } from 'constants/a
import { put } from 'store/api'
import { logNonFatalErrorToFirebase } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { appointmentsKeys } from './queryKeys'

Expand All @@ -30,7 +30,7 @@ const cancelAppointment = (cancelID: string) => {
*/
export const useCancelAppointment = () => {
const queryClient = useQueryClient()

const registerReviewEvent = useReviewEvent()
return useMutation({
mutationFn: cancelAppointment,
onSuccess(_, variables) {
Expand Down
13 changes: 9 additions & 4 deletions VAMobile/src/api/claimsAndAppeals/downloadEFolderDocument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import store from 'store'
import { DEMO_MODE_LETTER_ENDPOINT } from 'store/api/demo/letters'
import getEnv from 'utils/env'
import { downloadDemoFile, downloadFile } from 'utils/filesystem'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { claimsAndAppealsKeys } from './queryKeys'

Expand All @@ -15,14 +15,18 @@ const { API_ROOT } = getEnv()
/**
* Fetch user E Folder Document
*/
const downloadEFolderDocument = async (id: string, fileName: string): Promise<boolean | undefined> => {
const downloadEFolderDocument = async (
id: string,
fileName: string,
func: () => Promise<void>,
): Promise<boolean | undefined> => {
const eFolderDocumentAPI = `${API_ROOT}/v0/efolder/documents/${id}/download?file_name=${fileName}}`

const filePath = store.getState().demo.demoMode
? await downloadDemoFile(DEMO_MODE_LETTER_ENDPOINT, fileName)
: await downloadFile('POST', eFolderDocumentAPI, fileName, undefined, 1)
if (filePath) {
await FileViewer.open(filePath, { onDismiss: () => registerReviewEvent() })
await FileViewer.open(filePath, { onDismiss: () => func() })
return true
}
}
Expand All @@ -31,10 +35,11 @@ const downloadEFolderDocument = async (id: string, fileName: string): Promise<bo
* Returns a query for a user E Folder Document
*/
export const useDownloadEFolderDocument = (id: string, fileName: string) => {
const registerReviewEvent = useReviewEvent(false)
return useQuery({
enabled: false,
queryKey: [claimsAndAppealsKeys.eFolderDownloadDoc, id, fileName],
queryFn: () => downloadEFolderDocument(id, fileName),
queryFn: () => downloadEFolderDocument(id, fileName, registerReviewEvent),
meta: {
errorName: 'downloadEFolderDocument: Service error',
},
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/contactInformation/deleteEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Events, UserAnalytics } from 'constants/analytics'
import { Params as APIParams, EditResponseData, del } from 'store/api'
import { logAnalyticsEvent, logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { contactInformationKeys } from './queryKeys'

Expand All @@ -20,6 +20,7 @@ const deleteEmail = (emailData: EmailData) => {
* Returns a mutation for deleting an email
*/
export const useDeleteEmail = () => {
const registerReviewEvent = useReviewEvent()
const queryClient = useQueryClient()

return useMutation({
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/contactInformation/saveAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Events, UserAnalytics } from 'constants/analytics'
import { Params as APIParams, EditResponseData, post, put } from 'store/api'
import { logAnalyticsEvent, logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { contactInformationKeys } from './queryKeys'
import { validateAddress } from './validateAddress'
Expand All @@ -32,6 +32,7 @@ export const saveAddress = async ({ addressData, revalidate }: SaveAddressParame
* Returns a mutation for saving an address
*/
export const useSaveAddress = () => {
const registerReviewEvent = useReviewEvent()
const queryClient = useQueryClient()

return useMutation({
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/contactInformation/saveEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Events, UserAnalytics } from 'constants/analytics'
import { Params as APIParams, EditResponseData, post, put } from 'store/api'
import { logAnalyticsEvent, logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { contactInformationKeys } from './queryKeys'

Expand All @@ -26,6 +26,7 @@ const saveEmail = (emailData: SaveEmailData) => {
* Returns a mutation for saving an email
*/
export const useSaveEmail = () => {
const registerReviewEvent = useReviewEvent()
const queryClient = useQueryClient()

return useMutation({
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/contactInformation/savePhoneNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Events, UserAnalytics } from 'constants/analytics'
import { Params as APIParams, EditResponseData, post, put } from 'store/api'
import { logAnalyticsEvent, logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { contactInformationKeys } from './queryKeys'

Expand All @@ -26,6 +26,7 @@ const savePhoneNumber = (phoneData: PhoneData) => {
* Returns a mutation for saving a phone number
*/
export const useSavePhoneNumber = () => {
const registerReviewEvent = useReviewEvent()
const queryClient = useQueryClient()

return useMutation({
Expand Down
9 changes: 5 additions & 4 deletions VAMobile/src/api/decisionLetters/downloadDecisionLetter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import store from 'store'
import { DEMO_MODE_LETTER_ENDPOINT, DEMO_MODE_LETTER_NAME } from 'store/api/demo/letters'
import getEnv from 'utils/env'
import { downloadDemoFile, downloadFile } from 'utils/filesystem'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { decisionLettersKeys } from './queryKeys'

Expand All @@ -15,14 +15,14 @@ const { API_ROOT } = getEnv()
/**
* Fetch user decision letter
*/
const downloadDecisionLetter = async (id: string): Promise<boolean | undefined> => {
const downloadDecisionLetter = async (id: string, func: () => Promise<void>): Promise<boolean | undefined> => {
const escapedId = encodeURI(id) // escape chars like {} in document ID
const decisionLettersEndpoint = `${API_ROOT}/v0/claims/decision-letters/${escapedId}/download`
const filePath = store.getState().demo.demoMode
? await downloadDemoFile(DEMO_MODE_LETTER_ENDPOINT, DEMO_MODE_LETTER_NAME)
: await downloadFile('GET', decisionLettersEndpoint, 'decision_letter.pdf', undefined, 3)
if (filePath) {
await FileViewer.open(filePath, { onDismiss: () => registerReviewEvent() })
await FileViewer.open(filePath, { onDismiss: () => func() })
return true
}
}
Expand All @@ -31,10 +31,11 @@ const downloadDecisionLetter = async (id: string): Promise<boolean | undefined>
* Returns a query for a user decision letter
*/
export const useDownloadDecisionLetter = (id: string, options?: { enabled?: boolean }) => {
const registerReviewEvent = useReviewEvent(false)
return useQuery({
...options,
queryKey: [decisionLettersKeys.downloadLetter, id],
queryFn: () => downloadDecisionLetter(id),
queryFn: () => downloadDecisionLetter(id, registerReviewEvent),
meta: {
errorName: 'downloadDecisionLetter: Service error',
},
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/demographics/updateGenderIdentity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Events, UserAnalytics } from 'constants/analytics'
import { put } from 'store/api'
import { logAnalyticsEvent, logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { demographicsKeys } from './queryKeys'

Expand All @@ -19,6 +19,7 @@ const updateGenderIdentity = (genderIdentity: string) => {
* Returns a mutation for updating gender identity
*/
export const useUpdateGenderIdentity = () => {
const registerReviewEvent = useReviewEvent()
const queryClient = useQueryClient()

return useMutation({
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/demographics/updatePreferredName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Events, UserAnalytics } from 'constants/analytics'
import { put } from 'store/api'
import { logAnalyticsEvent, logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { demographicsKeys } from './queryKeys'

Expand All @@ -22,6 +22,7 @@ const updatePreferredName = (preferredName: string) => {
* Returns a mutation for updating preferred name
*/
export const useUpdatePreferredName = () => {
const registerReviewEvent = useReviewEvent()
const queryClient = useQueryClient()

return useMutation({
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/directDeposit/updateBankInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DemoState } from 'store/slices/demoSlice'
import { logAnalyticsEvent, logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { getErrorKeys } from 'utils/errors'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { directDepositKeys } from './queryKeys'

Expand All @@ -28,6 +28,7 @@ const updateBankInfo = (paymentAccountData: PaymentAccountData) => {
* Returns a mutation for updating direct deposit information
*/
export const useUpdateBankInfo = () => {
const registerReviewEvent = useReviewEvent()
const queryClient = useQueryClient()
const { demoMode } = useSelector<RootState, DemoState>((state) => state.demo)

Expand Down
8 changes: 5 additions & 3 deletions VAMobile/src/api/letters/downloadLetter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DEMO_MODE_LETTER_ENDPOINT, DEMO_MODE_LETTER_NAME } from 'store/api/demo
import { logAnalyticsEvent, setAnalyticsUserProperty } from 'utils/analytics'
import getEnv from 'utils/env'
import { downloadDemoFile, downloadFile } from 'utils/filesystem'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { lettersKeys } from './queryKeys'

Expand All @@ -22,6 +22,7 @@ const { API_ROOT } = getEnv()
const downloadLetter = async (
letterType: LetterTypes,
lettersOption: LettersDownloadParams,
func: () => Promise<void>,
): Promise<boolean | undefined> => {
const lettersAPI = `${API_ROOT}/v0/letters/${letterType}/download`
const filePath = store.getState().demo.demoMode
Expand All @@ -30,7 +31,7 @@ const downloadLetter = async (
if (filePath) {
logAnalyticsEvent(Events.vama_letter_download(letterType))
setAnalyticsUserProperty(UserAnalytics.vama_uses_letters())
await FileViewer.open(filePath, { onDismiss: () => registerReviewEvent() })
await FileViewer.open(filePath, { onDismiss: () => func() })
return true
}
}
Expand All @@ -39,10 +40,11 @@ const downloadLetter = async (
* Returns a query for a user letter
*/
export const useDownloadLetter = (letterType: LetterTypes, lettersOption: LettersDownloadParams) => {
const registerReviewEvent = useReviewEvent(false)
return useQuery({
enabled: false,
queryKey: [lettersKeys.downloadLetter, letterType, lettersOption],
queryFn: () => downloadLetter(letterType, lettersOption),
queryFn: () => downloadLetter(letterType, lettersOption, registerReviewEvent),
meta: {
errorName: 'downloadLetter: Service error',
},
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/prescriptions/requestRefills.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Events, UserAnalytics } from 'constants/analytics'
import { put } from 'store/api'
import { logAnalyticsEvent, logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { prescriptionKeys } from './queryKeys'

Expand All @@ -30,6 +30,7 @@ const requestRefills = async (prescriptions: PrescriptionsList): Promise<RefillR
* Returns a mutation for requesting refills for a users prescriptions
*/
export const useRequestRefills = () => {
const registerReviewEvent = useReviewEvent(false, 'refillRequest')
const queryClient = useQueryClient()
return useMutation({
mutationFn: requestRefills,
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/secureMessaging/saveDraft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { UserAnalytics } from 'constants/analytics'
import { Params, post, put } from 'store/api'
import { logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { secureMessagingKeys } from './queryKeys'

Expand All @@ -28,6 +28,7 @@ const saveDraft = ({ messageID, replyID, messageData }: SaveDraftParameters) =>
* Returns a mutation for saving a draft message
*/
export const useSaveDraft = () => {
const registerReviewEvent = useReviewEvent()
const queryClient = useQueryClient()
return useMutation({
mutationFn: saveDraft,
Expand Down
3 changes: 2 additions & 1 deletion VAMobile/src/api/secureMessaging/sendMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { UserAnalytics } from 'constants/analytics'
import { Params, contentTypes, post } from 'store/api'
import { logNonFatalErrorToFirebase, setAnalyticsUserProperty } from 'utils/analytics'
import { isErrorObject } from 'utils/common'
import { registerReviewEvent } from 'utils/inAppReviews'
import { useReviewEvent } from 'utils/inAppReviews'

import { secureMessagingKeys } from './queryKeys'

Expand Down Expand Up @@ -58,6 +58,7 @@ const sendMessage = ({ messageData, replyToID, uploads }: SendMessageParameters)
* Returns a mutation for sending a message
*/
export const useSendMessage = () => {
const registerReviewEvent = useReviewEvent()
const queryClient = useQueryClient()
return useMutation({
mutationFn: sendMessage,
Expand Down
Loading
Loading