diff --git a/src/storage/index.ts b/src/storage/index.ts index ad7ceb9189b..f3672850416 100644 --- a/src/storage/index.ts +++ b/src/storage/index.ts @@ -1,6 +1,6 @@ import { MMKV } from 'react-native-mmkv'; -import { Account, Device } from '@/storage/schema'; +import { Account, Device, Review } from '@/storage/schema'; import { EthereumAddress } from '@/entities'; import { Network } from '@/networks/types'; @@ -76,3 +76,5 @@ export const device = new Storage<[], Device>({ id: 'global' }); export const account = new Storage<[EthereumAddress, Network], Account>({ id: 'account', }); + +export const review = new Storage<[], Review>({ id: 'review' }); diff --git a/src/storage/schema.ts b/src/storage/schema.ts index 3d5e2a17d6d..881bcb03fca 100644 --- a/src/storage/schema.ts +++ b/src/storage/schema.ts @@ -34,3 +34,32 @@ export type Legacy = { export type Account = { totalTokens: number; }; + +export const enum ReviewPromptAction { + SuccessfulFiatToCryptoPurchase = 'SuccessfulFiatToCryptoPurchase', + DappConnections = 'DappConnections', + NumberOfSwaps = 'NumberOfSwaps', + BridgeToL2 = 'BridgeToL2', + AddingContact = 'AddingContact', + EnsNameSearch = 'EnsNameSearch', + EnsNameRegistration = 'EnsNameRegistration', + WatchWallet = 'WatchWallet', + NftFloorPriceVisitThrice = 'NftFloorPriceVisitThrice', +} + +export type Action = { + id: ReviewPromptAction; + timeOfLastDispatch: number; + numOfTimesDispatched: number; +}; + +/** + * Actions that the user can take that we want to track for review purposes + * Each action has a specific number of times they must be performed before prompting for review + * + * NOTE: if a user has already reviewed, we don't want to prompt them again + */ +export type Review = { + hasReviewed: boolean; + actions: Action[]; +}; diff --git a/src/utils/reviewAlert.ts b/src/utils/reviewAlert.ts index 8d86693d2b7..59ab962b6ca 100644 --- a/src/utils/reviewAlert.ts +++ b/src/utils/reviewAlert.ts @@ -12,19 +12,10 @@ export const REVIEW_ASKED_KEY = 'AppStoreReviewAsked'; let reviewDisplayedInTheSession = false; const TWO_MONTHS = 2 * 30 * 24 * 60 * 60 * 1000; -export const enum ReviewPromptAction { - FiatToCryptoPurchase = 'FiatToCryptoPurchase', - DappConnections = 'DappConnections', - NumberOfSwaps = 'NumberOfSwaps', - BridgeToL2 = 'BridgeToL2', - AddingContact = 'AddingContact', - EnsNameSearch = 'EnsNameSearch', - EnsNameRegistration = 'EnsNameRegistration', - WatchWallet = 'WatchWallet', - NftFloorPriceVisitThrice = 'NftFloorPriceVisitThrice', -} +export const shouldPromptForReview = async (shouldPrompt = false) => { + // when a user manually prompts for review on their own + if (shouldPrompt) return true; -export const shouldPromptForReview = async () => { const reviewAsked = await AsyncStorage.getItem(REVIEW_ASKED_KEY); if (Number(reviewAsked) > Date.now() - TWO_MONTHS) { return false;