From f7fef63b90d2863824846f1f6122ab26c985aeb5 Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:34:52 +0100 Subject: [PATCH 1/8] fix: add missing mix panel event ref to IOBP-1104 task --- ts/features/payments/home/analytics/index.ts | 16 ++++++++++++++++ .../components/PaymentsHomeUserMethodsList.tsx | 12 ++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ts/features/payments/home/analytics/index.ts b/ts/features/payments/home/analytics/index.ts index bc18fc04e39..b3c938be157 100644 --- a/ts/features/payments/home/analytics/index.ts +++ b/ts/features/payments/home/analytics/index.ts @@ -12,6 +12,11 @@ export type PaymentHomeAnalyticsProps = { add_entry_point: PaymentsAnalyticsHomeAddWalletEntryPoint; }; +type PaymentMethodAnalyticsProps = { + payment_method_selected: string; + payment_method_status: "valid" | "invalid"; +}; + export const trackPaymentsHome = ( props: Partial ) => { @@ -60,3 +65,14 @@ export const trackPaymentWalletAddStart = ( }) ); }; + +export const trackPaymentWalletMethodDetail = ( + props: Partial +) => { + void mixpanelTrack( + "WALLET_PAYMENT_METHOD_DETAIL", + buildEventProperties("UX", "action", { + ...props + }) + ); +}; diff --git a/ts/features/payments/home/components/PaymentsHomeUserMethodsList.tsx b/ts/features/payments/home/components/PaymentsHomeUserMethodsList.tsx index 45a276bb801..c544d1f7227 100644 --- a/ts/features/payments/home/components/PaymentsHomeUserMethodsList.tsx +++ b/ts/features/payments/home/components/PaymentsHomeUserMethodsList.tsx @@ -73,7 +73,12 @@ const PaymentsHomeUserMethodsList = ({ enforcedLoadingState }: Props) => { } }, [dispatch, paymentMethodsPot]); - const handleOnMethodPress = (walletId: string) => () => { + const handleOnMethodPress = (walletId: string, isExpired: boolean) => () => { + analytics.trackPaymentWalletMethodDetail({ + payment_method_selected: paymentAnalyticsData?.selectedPaymentMethod, + payment_method_status: isExpired ? "invalid" : "valid" + }); + navigation.navigate( PaymentsMethodDetailsRoutes.PAYMENT_METHOD_DETAILS_NAVIGATOR, { @@ -107,7 +112,10 @@ const PaymentsHomeUserMethodsList = ({ enforcedLoadingState }: Props) => { const userMethods = paymentMethods.map( (method: WalletInfo): PaymentCardSmallProps => ({ ...getPaymentCardPropsFromWalletInfo(method), - onPress: handleOnMethodPress(method.walletId) + onPress: handleOnMethodPress( + method.walletId, + getPaymentCardPropsFromWalletInfo(method)?.isExpired ?? false + ) }) ); From 60bca13932cf44bc63520df2243634c762815f99 Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:44:33 +0100 Subject: [PATCH 2/8] fix: add missing receipt filter analytics ref to IOBP-1105 task --- ts/features/payments/receipts/analytics/index.ts | 10 ++++++++++ .../payments/receipts/screens/ReceiptListScreen.tsx | 1 + 2 files changed, 11 insertions(+) diff --git a/ts/features/payments/receipts/analytics/index.ts b/ts/features/payments/receipts/analytics/index.ts index 168cdb1f8d9..b4925625e5e 100644 --- a/ts/features/payments/receipts/analytics/index.ts +++ b/ts/features/payments/receipts/analytics/index.ts @@ -1,6 +1,7 @@ import { mixpanelTrack } from "../../../../mixpanel"; import { buildEventProperties } from "../../../../utils/analytics"; import { PaymentsAnalyticsReceiptUser } from "../../common/types/PaymentAnalytics"; +import { ReceiptsCategoryFilter } from "../types"; export type PaymentReceiptAnalyticsProps = { organization_name: string; @@ -111,3 +112,12 @@ export const trackHideReceiptFailure = ( buildEventProperties("KO", undefined, props) ); }; + +export const trackReceiptFilterUsage = ( + filter: Partial +) => { + void mixpanelTrack( + "PAYMENTS_RECEIPT_LISTING_FILTER", + buildEventProperties("UX", "action", { filter }) + ); +}; diff --git a/ts/features/payments/receipts/screens/ReceiptListScreen.tsx b/ts/features/payments/receipts/screens/ReceiptListScreen.tsx index 789b1386e7c..087f4d577f3 100644 --- a/ts/features/payments/receipts/screens/ReceiptListScreen.tsx +++ b/ts/features/payments/receipts/screens/ReceiptListScreen.tsx @@ -124,6 +124,7 @@ const ReceiptListScreen = () => { const handleCategorySelected = React.useCallback( (category: ReceiptsCategoryFilter) => { setNoticeCategory(category); + analytics.trackReceiptFilterUsage(category); dispatch( getPaymentsReceiptAction.request({ firstLoad: true, From 3db647f465d257039d31b77ba18e95fc5c977d72 Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:26:24 +0100 Subject: [PATCH 3/8] fix: add missing props to `trackPaymentsSaveAndShareReceipt` ref to IOBP-1110 task --- ts/features/payments/receipts/analytics/index.ts | 5 ++++- .../payments/receipts/screens/ReceiptPreviewScreen.tsx | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ts/features/payments/receipts/analytics/index.ts b/ts/features/payments/receipts/analytics/index.ts index b4925625e5e..5b51e14c442 100644 --- a/ts/features/payments/receipts/analytics/index.ts +++ b/ts/features/payments/receipts/analytics/index.ts @@ -57,10 +57,13 @@ export const trackPaymentsOpenSubReceipt = () => { ); }; -export const trackPaymentsSaveAndShareReceipt = () => { +export const trackPaymentsSaveAndShareReceipt = ( + props: Partial +) => { void mixpanelTrack( "SAVE_AND_SHARE_RECEIPT", buildEventProperties("UX", "action", { + ...props, receipt_entry_point: "payments_receipt_listing" }) ); diff --git a/ts/features/payments/receipts/screens/ReceiptPreviewScreen.tsx b/ts/features/payments/receipts/screens/ReceiptPreviewScreen.tsx index 451d2c6e8b5..0c1a54465ba 100644 --- a/ts/features/payments/receipts/screens/ReceiptPreviewScreen.tsx +++ b/ts/features/payments/receipts/screens/ReceiptPreviewScreen.tsx @@ -18,6 +18,7 @@ import { FooterActionsMeasurements } from "../../../../components/ui/FooterActions"; import * as analytics from "../analytics"; +import { paymentAnalyticsDataSelector } from "../../history/store/selectors"; export type ReceiptPreviewScreenProps = RouteProp< PaymentsReceiptParamsList, @@ -32,6 +33,7 @@ const ReceiptPreviewScreen = () => { }); const transactionReceiptPot = useIOSelector(walletReceiptPotSelector); + const paymentAnalyticsData = useIOSelector(paymentAnalyticsDataSelector); useHeaderSecondLevel({ title: "", @@ -43,7 +45,12 @@ const ReceiptPreviewScreen = () => { if (!transactionReceiptFileInfo) { return; } - analytics.trackPaymentsSaveAndShareReceipt(); + analytics.trackPaymentsSaveAndShareReceipt({ + payment_status: "paid", + organization_name: paymentAnalyticsData?.receiptOrganizationName, + first_time_opening: paymentAnalyticsData?.receiptFirstTimeOpening, + user: paymentAnalyticsData?.receiptUser + }); // The file name is normalized to remove the .pdf extension on Android devices since it's added by default to the Share module const normalizedFilename = Platform.OS === "ios" From 64496571ef50cdf55cb395d0abecfdd2b5d7efa3 Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:37:30 +0100 Subject: [PATCH 4/8] fix: add missing prop to `trackHideReceiptConfirm` ref to IOBP-1109 task --- .../payments/receipts/components/HideReceiptButton.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ts/features/payments/receipts/components/HideReceiptButton.tsx b/ts/features/payments/receipts/components/HideReceiptButton.tsx index 5a614f2062c..e99b23b2dd3 100644 --- a/ts/features/payments/receipts/components/HideReceiptButton.tsx +++ b/ts/features/payments/receipts/components/HideReceiptButton.tsx @@ -4,10 +4,10 @@ import { Alert, View } from "react-native"; import { useDispatch } from "react-redux"; import I18n from "../../../../i18n"; import { useIONavigation } from "../../../../navigation/params/AppParamsList"; -import * as analytics from "../analytics"; -import { hidePaymentsReceiptAction } from "../store/actions"; import { useIOSelector } from "../../../../store/hooks"; import { paymentAnalyticsDataSelector } from "../../history/store/selectors"; +import * as analytics from "../analytics"; +import { hidePaymentsReceiptAction } from "../store/actions"; type Props = { transactionId: string; @@ -31,7 +31,10 @@ const HideReceiptButton = (props: Props) => { analytics.trackHideReceiptConfirm({ organization_name: paymentAnalyticsData?.receiptOrganizationName, first_time_opening: paymentAnalyticsData?.receiptFirstTimeOpening, - user: paymentAnalyticsData?.receiptUser + user: paymentAnalyticsData?.receiptUser, + organization_fiscal_code: + paymentAnalyticsData?.verifiedData?.paFiscalCode, + payment_status: paymentAnalyticsData?.paymentsHomeStatus }); }; From 2fe9029708092733abf53b39e730023d3650399f Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:43:30 +0100 Subject: [PATCH 5/8] fix: add missing prop to `trackPaymentsDownloadReceiptAction` ref to IOBP-1108 task --- .../payments/receipts/components/HideReceiptButton.tsx | 2 +- .../payments/receipts/screens/ReceiptDetailsScreen.tsx | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ts/features/payments/receipts/components/HideReceiptButton.tsx b/ts/features/payments/receipts/components/HideReceiptButton.tsx index e99b23b2dd3..56bfb517b6a 100644 --- a/ts/features/payments/receipts/components/HideReceiptButton.tsx +++ b/ts/features/payments/receipts/components/HideReceiptButton.tsx @@ -34,7 +34,7 @@ const HideReceiptButton = (props: Props) => { user: paymentAnalyticsData?.receiptUser, organization_fiscal_code: paymentAnalyticsData?.verifiedData?.paFiscalCode, - payment_status: paymentAnalyticsData?.paymentsHomeStatus + payment_status: "paid" }); }; diff --git a/ts/features/payments/receipts/screens/ReceiptDetailsScreen.tsx b/ts/features/payments/receipts/screens/ReceiptDetailsScreen.tsx index 1412ba39196..904f150b2b5 100644 --- a/ts/features/payments/receipts/screens/ReceiptDetailsScreen.tsx +++ b/ts/features/payments/receipts/screens/ReceiptDetailsScreen.tsx @@ -108,8 +108,11 @@ const ReceiptDetailsScreen = () => { const handleDownloadPdfReceipt = () => { analytics.trackPaymentsDownloadReceiptAction({ organization_name: paymentAnalyticsData?.receiptOrganizationName, + organization_fiscal_code: + paymentAnalyticsData?.verifiedData?.paFiscalCode, first_time_opening: paymentAnalyticsData?.receiptFirstTimeOpening, - user: paymentAnalyticsData?.receiptUser + user: paymentAnalyticsData?.receiptUser, + payment_status: "paid" }); dispatch( getPaymentsReceiptDownloadAction.request({ From 5d1a43d3d17fea48e371a739307f49c46dd4c2c3 Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:45:28 +0100 Subject: [PATCH 6/8] fix: add missing prop to `analyticsHideReceiptAction` ref to IOBP-1107 task --- .../payments/receipts/components/HideReceiptButton.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ts/features/payments/receipts/components/HideReceiptButton.tsx b/ts/features/payments/receipts/components/HideReceiptButton.tsx index 56bfb517b6a..8f122b4a83c 100644 --- a/ts/features/payments/receipts/components/HideReceiptButton.tsx +++ b/ts/features/payments/receipts/components/HideReceiptButton.tsx @@ -23,7 +23,10 @@ const HideReceiptButton = (props: Props) => { analytics.trackHideReceipt({ organization_name: paymentAnalyticsData?.receiptOrganizationName, first_time_opening: paymentAnalyticsData?.receiptFirstTimeOpening, - user: paymentAnalyticsData?.receiptUser + user: paymentAnalyticsData?.receiptUser, + organization_fiscal_code: + paymentAnalyticsData?.verifiedData?.paFiscalCode, + payment_status: "paid" }); }; From 88b70015545bbb4c05dfbe42909d2d1e126e165c Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:49:05 +0100 Subject: [PATCH 7/8] refactor: update types --- ts/features/payments/receipts/analytics/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ts/features/payments/receipts/analytics/index.ts b/ts/features/payments/receipts/analytics/index.ts index 5b51e14c442..21bd1539759 100644 --- a/ts/features/payments/receipts/analytics/index.ts +++ b/ts/features/payments/receipts/analytics/index.ts @@ -8,6 +8,7 @@ export type PaymentReceiptAnalyticsProps = { payment_status: string; first_time_opening: boolean; user: PaymentsAnalyticsReceiptUser; + organization_fiscal_code: string; }; export const trackPaymentsReceiptListing = () => { From 21fa86ab79d8fa6a2482b669f999240408446a1c Mon Sep 17 00:00:00 2001 From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:54:50 +0100 Subject: [PATCH 8/8] fix: add missing prop to `OPEN_RECEIPT` event ref to IOBP-1106 task --- ts/features/payments/history/store/reducers/index.ts | 3 +++ ts/features/payments/receipts/analytics/index.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ts/features/payments/history/store/reducers/index.ts b/ts/features/payments/history/store/reducers/index.ts index 9046209baed..1a1d167250b 100644 --- a/ts/features/payments/history/store/reducers/index.ts +++ b/ts/features/payments/history/store/reducers/index.ts @@ -218,6 +218,9 @@ const reducer = ( case getType(getPaymentsReceiptDetailsAction.success): receiptsAnalytics.trackPaymentsOpenReceipt({ organization_name: action.payload.carts?.[0]?.payee?.name, + organization_fiscal_code: + state.analyticsData?.verifiedData?.paFiscalCode, + payment_status: "paid", first_time_opening: state.analyticsData?.receiptFirstTimeOpening, user: state.analyticsData?.receiptUser }); diff --git a/ts/features/payments/receipts/analytics/index.ts b/ts/features/payments/receipts/analytics/index.ts index 21bd1539759..e2123c2ad8b 100644 --- a/ts/features/payments/receipts/analytics/index.ts +++ b/ts/features/payments/receipts/analytics/index.ts @@ -35,7 +35,8 @@ export const trackPaymentsOpenReceipt = ( void mixpanelTrack( "OPEN_RECEIPT", buildEventProperties("UX", "screen_view", { - ...props + ...props, + receipt_entry_point: "payments_receipt_listing" }) ); };