From 97554a0aeeb7f0400c5dec39a59560c5ea682a89 Mon Sep 17 00:00:00 2001 From: alessandrogelmi Date: Fri, 29 Mar 2024 11:59:55 +0100 Subject: [PATCH] fix: remove mixpanel event's tracking from PA --- packages/pn-commons/src/components/Prompt.tsx | 8 +- packages/pn-commons/src/hooks/usePrompt.ts | 8 +- packages/pn-pa-webapp/src/App.tsx | 36 +-- .../PreliminaryInformations.tsx | 4 - .../components/NewNotification/Recipient.tsx | 15 -- .../Notifications/DesktopNotifications.tsx | 4 - .../Notifications/FilterNotifications.tsx | 4 - .../FilterNotificationsFormBody.tsx | 7 - .../Notifications/MobileNotifications.tsx | 4 - .../NotificationDetailTableSender.tsx | 3 - .../NotificationPaymentPagoPa.tsx | 3 - .../Notifications/NotificationsDataSwitch.tsx | 15 +- .../pn-pa-webapp/src/pages/ApiKeys.page.tsx | 8 - .../pn-pa-webapp/src/pages/Dashboard.page.tsx | 60 +++-- .../src/pages/NewNotification.page.tsx | 33 --- .../src/pages/NotificationDetail.page.tsx | 5 - packages/pn-pa-webapp/src/redux/store.ts | 3 +- packages/pn-pa-webapp/src/utility/events.ts | 237 ------------------ packages/pn-pa-webapp/src/utility/mixpanel.ts | 23 -- 19 files changed, 40 insertions(+), 440 deletions(-) delete mode 100644 packages/pn-pa-webapp/src/utility/events.ts delete mode 100644 packages/pn-pa-webapp/src/utility/mixpanel.ts diff --git a/packages/pn-commons/src/components/Prompt.tsx b/packages/pn-commons/src/components/Prompt.tsx index 869f619b05..c0fd686d9b 100644 --- a/packages/pn-commons/src/components/Prompt.tsx +++ b/packages/pn-commons/src/components/Prompt.tsx @@ -11,9 +11,9 @@ import PnDialogContent from './PnDialog/PnDialogContent'; type Props = { title: string; message: string; - eventTrackingCallbackPromptOpened: () => void; - eventTrackingCallbackCancel: () => void; - eventTrackingCallbackConfirm: () => void; + eventTrackingCallbackPromptOpened?: () => void; + eventTrackingCallbackCancel?: () => void; + eventTrackingCallbackConfirm?: () => void; children?: React.ReactNode; }; @@ -33,7 +33,7 @@ const Prompt: React.FC = ({ useEffect(() => { if (showPrompt) { - eventTrackingCallbackPromptOpened(); + eventTrackingCallbackPromptOpened?.(); } }); diff --git a/packages/pn-commons/src/hooks/usePrompt.ts b/packages/pn-commons/src/hooks/usePrompt.ts index cfc53b80d3..f0a4aefb51 100644 --- a/packages/pn-commons/src/hooks/usePrompt.ts +++ b/packages/pn-commons/src/hooks/usePrompt.ts @@ -6,8 +6,8 @@ import { useBlocker } from './useBlocker'; export function usePrompt( when: boolean, - callbackCancel: () => void, - callbackConfirm: () => void + callbackCancel?: () => void, + callbackConfirm?: () => void ): [boolean, () => void, () => void] { const location = useLocation(); const navigate = useNavigate(); @@ -17,7 +17,7 @@ export function usePrompt( const cancelNavigation = useCallback(() => { setShowPrompt(false); - callbackCancel(); + callbackCancel?.(); }, []); // handle blocking when user click on another route prompt will be shown @@ -37,7 +37,7 @@ export function usePrompt( const confirmNavigation = useCallback(() => { setShowPrompt(false); setConfirmedNavigation(true); - callbackConfirm(); + callbackConfirm?.(); }, []); useEffect(() => { diff --git a/packages/pn-pa-webapp/src/App.tsx b/packages/pn-pa-webapp/src/App.tsx index d216ece221..5740af4e1a 100644 --- a/packages/pn-pa-webapp/src/App.tsx +++ b/packages/pn-pa-webapp/src/App.tsx @@ -1,4 +1,4 @@ -import { ErrorInfo, useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useLocation } from 'react-router-dom'; @@ -21,7 +21,6 @@ import { initLocalization, useMultiEvent, useTracking, - useUnload, } from '@pagopa-pn/pn-commons'; import { LinkType, ProductEntity } from '@pagopa/mui-italia'; @@ -33,8 +32,6 @@ import { useAppDispatch, useAppSelector } from './redux/hooks'; import { RootState } from './redux/store'; import { getConfiguration } from './services/configuration.service'; import { PAAppErrorFactory } from './utility/AppError/PAAppErrorFactory'; -import { TrackEventType } from './utility/events'; -import { trackEventByType } from './utility/mixpanel'; import './utility/onetrust'; import { getMenuItems } from './utility/role.utility'; @@ -61,10 +58,6 @@ const App = () => { }; const ActualApp = () => { - useUnload(() => { - trackEventByType(TrackEventType.APP_UNLOAD); - }); - const loggedUser = useAppSelector((state: RootState) => state.userState.user); const loggedUserOrganizationParty = loggedUser.organization; // TODO check if it can exist more than one role on user @@ -189,28 +182,13 @@ const ActualApp = () => { const { pathname } = useLocation(); const path = pathname.split('/'); - const source = path[path.length - 1]; const isPrivacyPage = path[1] === 'privacy-tos'; - const handleEventTrackingCallbackAppCrash = (e: Error, eInfo: ErrorInfo) => { - trackEventByType(TrackEventType.APP_CRASH, { - route: source, - stacktrace: { error: e, errorInfo: eInfo }, - }); - }; - - const handleEventTrackingCallbackProductSwitch = (target: string) => { - trackEventByType(TrackEventType.USER_PRODUCT_SWITCH, { target }); - }; - const handleLogout = () => { void dispatch(logout()); }; const handleAssistanceClick = () => { - trackEventByType(TrackEventType.CUSTOMER_CARE_MAILTO, { - source: sessionToken ? 'postlogin' : 'prelogin', - }); /* eslint-disable-next-line functional/immutable-data */ window.location.href = sessionToken ? `${SELFCARE_BASE_URL}/assistenza` @@ -238,20 +216,10 @@ const ActualApp = () => { showHeader={!isPrivacyPage} showFooter={!isPrivacyPage} onExitAction={handleLogout} - eventTrackingCallbackAppCrash={handleEventTrackingCallbackAppCrash} - eventTrackingCallbackProductSwitch={(target: string) => - handleEventTrackingCallbackProductSwitch(target) - } sideMenu={ role && menuItems && ( - - trackEventByType(TrackEventType.USER_NAV_ITEM, { target }) - } - /> + ) } showSideMenu={ diff --git a/packages/pn-pa-webapp/src/components/NewNotification/PreliminaryInformations.tsx b/packages/pn-pa-webapp/src/components/NewNotification/PreliminaryInformations.tsx index df99ae5e53..8420e946d6 100644 --- a/packages/pn-pa-webapp/src/components/NewNotification/PreliminaryInformations.tsx +++ b/packages/pn-pa-webapp/src/components/NewNotification/PreliminaryInformations.tsx @@ -31,8 +31,6 @@ import { setPreliminaryInformations } from '../../redux/newNotification/reducers import { PreliminaryInformationsPayload } from '../../redux/newNotification/types'; import { RootState } from '../../redux/store'; import { getConfiguration } from '../../services/configuration.service'; -import { TrackEventType } from '../../utility/events'; -import { trackEventByType } from '../../utility/mixpanel'; import { requiredStringFieldValidation } from '../../utility/validation.utility'; import NewNotificationCard from './NewNotificationCard'; @@ -113,12 +111,10 @@ const PreliminaryInformations = ({ notification, onConfirm }: Props) => { const handleChangeDeliveryMode = (e: ChangeEvent & { target: { value: any } }) => { formik.handleChange(e); - trackEventByType(TrackEventType.NOTIFICATION_SEND_DELIVERY_MODE, { type: e.target.value }); }; const handleChangePaymentMode = (e: ChangeEvent & { target: { value: any } }) => { formik.handleChange(e); - trackEventByType(TrackEventType.NOTIFICATION_SEND_PAYMENT_MODE, { target: e.target.value }); }; const fetchGroups = useCallback(() => { diff --git a/packages/pn-pa-webapp/src/components/NewNotification/Recipient.tsx b/packages/pn-pa-webapp/src/components/NewNotification/Recipient.tsx index 267a881bcf..f12df6eeb3 100644 --- a/packages/pn-pa-webapp/src/components/NewNotification/Recipient.tsx +++ b/packages/pn-pa-webapp/src/components/NewNotification/Recipient.tsx @@ -28,8 +28,6 @@ import { ButtonNaked } from '@pagopa/mui-italia'; import { NewNotificationRecipient, PaymentModel } from '../../models/NewNotification'; import { useAppDispatch } from '../../redux/hooks'; import { saveRecipients } from '../../redux/newNotification/reducers'; -import { TrackEventType } from '../../utility/events'; -import { trackEventByType } from '../../utility/mixpanel'; import { denominationLengthAndCharacters, identicalIUV, @@ -250,13 +248,6 @@ const Recipient: React.FC = ({ ) => { const checked = (event.target as any).checked; const name = (event.target as any).name; - if (checked) { - trackEventByType( - name.endsWith('showPhysicalAddress') - ? TrackEventType.NOTIFICATION_SEND_PHYSICAL_ADDRESS - : TrackEventType.NOTIFICATION_SEND_DIGITAL_DOMICILE - ); - } if (!checked && name.endsWith('showPhysicalAddress')) { // reset physical address setFieldValue( @@ -297,9 +288,6 @@ const Recipient: React.FC = ({ ...values.recipients, { ...singleRecipient, idx: lastRecipientIdx + 1, id: `recipient.${lastRecipientIdx + 1}` }, ]); - trackEventByType(TrackEventType.NOTIFICATION_SEND_MULTIPLE_RECIPIENTS, { - recipients: lastRecipientIdx + 1, - }); }; const handleSubmit = (values: FormRecipients) => { @@ -361,9 +349,6 @@ const Recipient: React.FC = ({ // In fact, I would have liked to specify the change through a function, i.e. // setFieldValue(`recipients[${index}]`, (currentValue: any) => ({...currentValue, ...valuesToUpdate})); // but unfortunately Formik' setFieldValue is not capable of handling such kind of updates. - trackEventByType(TrackEventType.NOTIFICATION_SEND_RECIPIENT_TYPE, { - type: event.currentTarget.value, - }); }; useImperativeHandle(forwardedRef, () => ({ diff --git a/packages/pn-pa-webapp/src/components/Notifications/DesktopNotifications.tsx b/packages/pn-pa-webapp/src/components/Notifications/DesktopNotifications.tsx index 559b9077b3..67b0ce1948 100644 --- a/packages/pn-pa-webapp/src/components/Notifications/DesktopNotifications.tsx +++ b/packages/pn-pa-webapp/src/components/Notifications/DesktopNotifications.tsx @@ -19,8 +19,6 @@ import { } from '@pagopa-pn/pn-commons'; import * as routes from '../../navigation/routes.const'; -import { TrackEventType } from '../../utility/events'; -import { trackEventByType } from '../../utility/mixpanel'; import FilterNotifications from './FilterNotifications'; import NotificationsDataSwitch from './NotificationsDataSwitch'; @@ -160,8 +158,6 @@ const DesktopNotifications = ({ // Navigation handlers const handleRowClick = (row: Row) => { navigate(routes.GET_DETTAGLIO_NOTIFICA_PATH(row.iun)); - // log event - trackEventByType(TrackEventType.NOTIFICATION_TABLE_ROW_INTERACTION); }; const filtersApplied: boolean = filterNotificationsRef.current.filtersApplied; diff --git a/packages/pn-pa-webapp/src/components/Notifications/FilterNotifications.tsx b/packages/pn-pa-webapp/src/components/Notifications/FilterNotifications.tsx index b9f49d4f6c..6d02725c79 100644 --- a/packages/pn-pa-webapp/src/components/Notifications/FilterNotifications.tsx +++ b/packages/pn-pa-webapp/src/components/Notifications/FilterNotifications.tsx @@ -24,8 +24,6 @@ import { import { setNotificationFilters } from '../../redux/dashboard/reducers'; import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { RootState } from '../../redux/store'; -import { TrackEventType } from '../../utility/events'; -import { trackEventByType } from '../../utility/mixpanel'; import FilterNotificationsFormActions from './FilterNotificationsFormActions'; import FilterNotificationsFormBody from './FilterNotificationsFormBody'; @@ -105,7 +103,6 @@ const FilterNotifications = forwardRef(({ showFilters }: Props, ref) => { if (_.isEqual(prevFilters, currentFilters)) { return; } - trackEventByType(TrackEventType.NOTIFICATION_FILTER_SEARCH); dispatch(setNotificationFilters(currentFilters)); setPrevFilters(currentFilters); dialogRef.current?.toggleOpen(); @@ -113,7 +110,6 @@ const FilterNotifications = forwardRef(({ showFilters }: Props, ref) => { }); const cancelSearch = () => { - trackEventByType(TrackEventType.NOTIFICATION_FILTER_REMOVE); dispatch(setNotificationFilters(emptyValues)); }; diff --git a/packages/pn-pa-webapp/src/components/Notifications/FilterNotificationsFormBody.tsx b/packages/pn-pa-webapp/src/components/Notifications/FilterNotificationsFormBody.tsx index db7edfcc89..2072d387e7 100644 --- a/packages/pn-pa-webapp/src/components/Notifications/FilterNotificationsFormBody.tsx +++ b/packages/pn-pa-webapp/src/components/Notifications/FilterNotificationsFormBody.tsx @@ -14,9 +14,6 @@ import { useIsMobile, } from '@pagopa-pn/pn-commons'; -import { TrackEventType } from '../../utility/events'; -import { trackEventByType } from '../../utility/mixpanel'; - type Props = { formikInstance: { values: FormikValues; @@ -81,7 +78,6 @@ const FilterNotificationsFormBody = ({ } else { await formikInstance.setFieldValue(e.target.id, (e.target as HTMLInputElement).value, false); } - trackEventByType(TrackEventType.NOTIFICATION_FILTER_TYPE, { target: e.target.id }); }; const handleChangeNotificationStatus = async (e: ChangeEvent) => { @@ -90,7 +86,6 @@ const FilterNotificationsFormBody = ({ (e.target as HTMLSelectElement).value, false ); - trackEventByType(TrackEventType.NOTIFICATION_FILTER_NOTIFICATION_STATE); }; return ( @@ -139,7 +134,6 @@ const FilterNotificationsFormBody = ({ onChange={(value: DatePickerTypes) => { void formikInstance.setFieldValue('startDate', value || tenYearsAgo).then(() => { setStartDate(value); - trackEventByType(TrackEventType.NOTIFICATION_FILTER_DATE, { source: 'from date' }); }); }} slotProps={{ @@ -169,7 +163,6 @@ const FilterNotificationsFormBody = ({ value={endDate} onChange={(value: DatePickerTypes) => { void formikInstance.setFieldValue('endDate', value || today).then(() => { - trackEventByType(TrackEventType.NOTIFICATION_FILTER_DATE, { source: 'to date' }); setEndDate(value); }); }} diff --git a/packages/pn-pa-webapp/src/components/Notifications/MobileNotifications.tsx b/packages/pn-pa-webapp/src/components/Notifications/MobileNotifications.tsx index 40c8fde913..74d8f581b9 100644 --- a/packages/pn-pa-webapp/src/components/Notifications/MobileNotifications.tsx +++ b/packages/pn-pa-webapp/src/components/Notifications/MobileNotifications.tsx @@ -25,8 +25,6 @@ import { import { ButtonNaked } from '@pagopa/mui-italia'; import * as routes from '../../navigation/routes.const'; -import { TrackEventType } from '../../utility/events'; -import { trackEventByType } from '../../utility/mixpanel'; import FilterNotifications from './FilterNotifications'; import NotificationsDataSwitch from './NotificationsDataSwitch'; @@ -146,8 +144,6 @@ const MobileNotifications = ({ // Navigation handlers const handleRowClick = (row: Row) => { navigate(routes.GET_DETTAGLIO_NOTIFICA_PATH(row.iun)); - // log event - trackEventByType(TrackEventType.NOTIFICATION_TABLE_ROW_INTERACTION); }; const cardData: Array> = notifications.map((n) => ({ diff --git a/packages/pn-pa-webapp/src/components/Notifications/NotificationDetailTableSender.tsx b/packages/pn-pa-webapp/src/components/Notifications/NotificationDetailTableSender.tsx index 399de67693..61d21b8647 100644 --- a/packages/pn-pa-webapp/src/components/Notifications/NotificationDetailTableSender.tsx +++ b/packages/pn-pa-webapp/src/components/Notifications/NotificationDetailTableSender.tsx @@ -19,8 +19,6 @@ import { Tag, TagGroup } from '@pagopa/mui-italia'; import { PNRole } from '../../models/user'; import { useAppSelector } from '../../redux/hooks'; import { RootState } from '../../redux/store'; -import { TrackEventType } from '../../utility/events'; -import { trackEventByType } from '../../utility/mixpanel'; import ConfirmCancellationDialog from './ConfirmCancellationDialog'; import NotificationRecipientsDetail from './NotificationRecipientsDetail'; @@ -42,7 +40,6 @@ const NotificationDetailTableSender: React.FC = ({ notification, onCancel const role = currentUser.organization?.roles ? currentUser.organization?.roles[0] : null; const userHasAdminPermissions = useHasPermissions(role ? [role.role] : [], [PNRole.ADMIN]); const openModal = () => { - trackEventByType(TrackEventType.NOTIFICATION_DETAIL_CANCEL_NOTIFICATION); setShowModal(true); }; diff --git a/packages/pn-pa-webapp/src/components/Notifications/NotificationPaymentPagoPa.tsx b/packages/pn-pa-webapp/src/components/Notifications/NotificationPaymentPagoPa.tsx index f7851baacf..e34bac6030 100644 --- a/packages/pn-pa-webapp/src/components/Notifications/NotificationPaymentPagoPa.tsx +++ b/packages/pn-pa-webapp/src/components/Notifications/NotificationPaymentPagoPa.tsx @@ -12,8 +12,6 @@ import { ButtonNaked } from '@pagopa/mui-italia'; import { useAppDispatch } from '../../redux/hooks'; import { getPaymentAttachment } from '../../redux/notification/actions'; -import { TrackEventType } from '../../utility/events'; -import { trackEventByType } from '../../utility/mixpanel'; type Props = { iun: string; @@ -26,7 +24,6 @@ const NotificationPaymentPagoPa: React.FC = ({ iun, payment }) => { const dowloadHandler = () => { if (!_.isNil(payment.recIndex) && payment.attachment) { - trackEventByType(TrackEventType.NOTIFICATION_DETAIL_PAYMENT_PAGOPA_FILE); dispatch( getPaymentAttachment({ iun, diff --git a/packages/pn-pa-webapp/src/components/Notifications/NotificationsDataSwitch.tsx b/packages/pn-pa-webapp/src/components/Notifications/NotificationsDataSwitch.tsx index 786d6dd370..575f79fc1e 100644 --- a/packages/pn-pa-webapp/src/components/Notifications/NotificationsDataSwitch.tsx +++ b/packages/pn-pa-webapp/src/components/Notifications/NotificationsDataSwitch.tsx @@ -10,24 +10,11 @@ import { } from '@pagopa-pn/pn-commons'; import { Tag, TagGroup } from '@pagopa/mui-italia'; -import { TrackEventType } from '../../utility/events'; -import { trackEventByType } from '../../utility/mixpanel'; - const NotificationStatusChip: React.FC<{ data: Row }> = ({ data }) => { - const handleEventTrackingTooltip = () => { - trackEventByType(TrackEventType.NOTIFICATION_TABLE_ROW_TOOLTIP); - }; const { label, tooltip, color } = getNotificationStatusInfos(data.notificationStatus, { recipients: data.recipients, }); - return ( - - ); + return ; }; const NotificationsDataSwitch: React.FC<{ data: Row; type: keyof Notification }> = ({ diff --git a/packages/pn-pa-webapp/src/pages/ApiKeys.page.tsx b/packages/pn-pa-webapp/src/pages/ApiKeys.page.tsx index 0e63cb9b2b..14f6e45693 100644 --- a/packages/pn-pa-webapp/src/pages/ApiKeys.page.tsx +++ b/packages/pn-pa-webapp/src/pages/ApiKeys.page.tsx @@ -29,8 +29,6 @@ import { setPagination } from '../redux/apiKeys/reducers'; import { useAppDispatch, useAppSelector } from '../redux/hooks'; import { RootState } from '../redux/store'; import { getConfiguration } from '../services/configuration.service'; -import { TrackEventType } from '../utility/events'; -import { trackEventByType } from '../utility/mixpanel'; const LinkApiB2b: React.FC<{ children?: React.ReactNode }> = ({ children }) => { const { API_B2B_LINK } = getConfiguration(); @@ -154,14 +152,9 @@ const ApiKeys = () => { // Pagination handlers const handleChangePage = (paginationData: PaginationData) => { - trackEventByType(TrackEventType.APIKEYS_TABLE_PAGINATION); dispatch(setPagination({ size: paginationData.size, page: paginationData.page })); }; - const handleEventTrackingCallbackPageSize = (pageSize: number) => { - trackEventByType(TrackEventType.APIKEYS_TABLE_SIZE, { pageSize }); - }; - return ( { totalElements, }} onPageRequest={handleChangePage} - eventTrackingCallbackPageSize={handleEventTrackingCallbackPageSize} pagesToShow={pagesToShow} /> )} diff --git a/packages/pn-pa-webapp/src/pages/Dashboard.page.tsx b/packages/pn-pa-webapp/src/pages/Dashboard.page.tsx index 29489dc658..5ee3facdae 100644 --- a/packages/pn-pa-webapp/src/pages/Dashboard.page.tsx +++ b/packages/pn-pa-webapp/src/pages/Dashboard.page.tsx @@ -1,7 +1,6 @@ import { useCallback, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; -import { ButtonNaked } from '@pagopa/mui-italia'; import { Alert, Box, Button, Typography } from '@mui/material'; import { @@ -12,19 +11,15 @@ import { calculatePages, useIsMobile, } from '@pagopa-pn/pn-commons'; +import { ButtonNaked } from '@pagopa/mui-italia'; import DesktopNotifications from '../components/Notifications/DesktopNotifications'; import MobileNotifications from '../components/Notifications/MobileNotifications'; import * as routes from '../navigation/routes.const'; -import { - DASHBOARD_ACTIONS, - getSentNotifications, -} from '../redux/dashboard/actions'; +import { DASHBOARD_ACTIONS, getSentNotifications } from '../redux/dashboard/actions'; import { setPagination } from '../redux/dashboard/reducers'; import { useAppDispatch, useAppSelector } from '../redux/hooks'; import { RootState } from '../redux/store'; -import { TrackEventType } from '../utility/events'; -import { trackEventByType } from '../utility/mixpanel'; import { getConfiguration } from '../services/configuration.service'; const Dashboard = () => { @@ -53,14 +48,11 @@ const Dashboard = () => { // Pagination handlers const handleChangePage = (paginationData: PaginationData) => { - trackEventByType(TrackEventType.NOTIFICATION_TABLE_PAGINATION); dispatch(setPagination({ size: paginationData.size, page: paginationData.page })); }; - // route to Manual Send const handleRouteManualSend = () => { - trackEventByType(TrackEventType.NOTIFICATION_SEND); navigate(routes.NUOVA_NOTIFICA); }; @@ -84,10 +76,6 @@ const Dashboard = () => { fetchNotifications(); }, [fetchNotifications]); - const handleEventTrackingCallbackPageSize = (pageSize: number) => { - trackEventByType(TrackEventType.NOTIFICATION_TABLE_SIZE, { pageSize }); - }; - return ( { {t('subtitle')} - {getConfiguration().IS_MANUAL_SEND_ENABLED ? : - navigate(routes.APP_STATUS)}> - {t('manual-send-disabled-action')} - - }> + {getConfiguration().IS_MANUAL_SEND_ENABLED ? ( + + ) : ( + navigate(routes.APP_STATUS)} + > + {t('manual-send-disabled-action')} + + } + > {t('manual-send-disabled-message')} - } - + + )} } /> @@ -152,7 +149,6 @@ const Dashboard = () => { totalElements, }} onPageRequest={handleChangePage} - eventTrackingCallbackPageSize={handleEventTrackingCallbackPageSize} pagesToShow={pagesToShow} /> )} diff --git a/packages/pn-pa-webapp/src/pages/NewNotification.page.tsx b/packages/pn-pa-webapp/src/pages/NewNotification.page.tsx index a933c33400..475fb0debc 100644 --- a/packages/pn-pa-webapp/src/pages/NewNotification.page.tsx +++ b/packages/pn-pa-webapp/src/pages/NewNotification.page.tsx @@ -15,8 +15,6 @@ import { createNewNotification } from '../redux/newNotification/actions'; import { resetState, setSenderInfos } from '../redux/newNotification/reducers'; import { RootState } from '../redux/store'; import { getConfiguration } from '../services/configuration.service'; -import { TrackEventType } from '../utility/events'; -import { trackEventByType } from '../utility/mixpanel'; const SubTitle = () => { const { t } = useTranslation(['common', 'notifiche']); @@ -47,40 +45,12 @@ const NewNotification = () => { const childRef = useRef<{ confirm: () => void }>(); - const eventStep = [ - TrackEventType.NOTIFICATION_SEND_PRELIMINARY_INFO, - TrackEventType.NOTIFICATION_SEND_RECIPIENT_INFO, - TrackEventType.NOTIFICATION_SEND_ATTACHMENTS, - ]; - if (IS_PAYMENT_ENABLED) { - // eslint-disable-next-line functional/immutable-data - eventStep.push(TrackEventType.NOTIFICATION_SEND_PAYMENT_MODES); // eslint-disable-next-line functional/immutable-data steps.push(t('new-notification.steps.payment-methods.title', { ns: 'notifiche' })); } - const stepType = ['preliminary info', 'recipient', 'attachments', 'payment modes']; - - const handleEventTrackingCallbackPromptOpened = () => { - trackEventByType(TrackEventType.NOTIFICATION_SEND_EXIT_WARNING, { - source: stepType[activeStep], - }); - }; - - const handleEventTrackingCallbackCancel = () => { - trackEventByType(TrackEventType.NOTIFICATION_SEND_EXIT_CANCEL, { - source: stepType[activeStep], - }); - }; - - const handleEventTrackingCallbackConfirm = () => { - trackEventByType(TrackEventType.NOTIFICATION_SEND_EXIT_FLOW, { source: stepType[activeStep] }); - }; - const goToNextStep = () => { - trackEventByType(eventStep[activeStep]); - setActiveStep((previousStep) => previousStep + 1); }; @@ -139,9 +109,6 @@ const NewNotification = () => { diff --git a/packages/pn-pa-webapp/src/pages/NotificationDetail.page.tsx b/packages/pn-pa-webapp/src/pages/NotificationDetail.page.tsx index c1ca2d2c10..0a1aeb4221 100644 --- a/packages/pn-pa-webapp/src/pages/NotificationDetail.page.tsx +++ b/packages/pn-pa-webapp/src/pages/NotificationDetail.page.tsx @@ -46,8 +46,6 @@ import { } from '../redux/notification/reducers'; import { RootState } from '../redux/store'; import { ServerResponseErrorCode } from '../utility/AppError/types'; -import { TrackEventType } from '../utility/events'; -import { trackEventByType } from '../utility/mixpanel'; type Props = { notification: NotificationDetailType; @@ -258,8 +256,6 @@ const NotificationDetail: React.FC = () => { [] ); - const viewMoreTimeline = () => trackEventByType(TrackEventType.NOTIFICATION_TIMELINE_VIEW_MORE); - useDownloadDocument({ url: legalFactDownloadUrl }); useDownloadDocument({ url: documentDownloadUrl }); useDownloadDocument({ url: otherDocumentDownloadUrl }); @@ -375,7 +371,6 @@ const NotificationDetail: React.FC = () => { historyButtonLabel={t('detail.show-history', { ns: 'notifiche' })} showMoreButtonLabel={t('detail.show-more', { ns: 'notifiche' })} showLessButtonLabel={t('detail.show-less', { ns: 'notifiche' })} - eventTrackingCallbackShowMore={viewMoreTimeline} /> diff --git a/packages/pn-pa-webapp/src/redux/store.ts b/packages/pn-pa-webapp/src/redux/store.ts index d73c7b291e..80beddcf9b 100644 --- a/packages/pn-pa-webapp/src/redux/store.ts +++ b/packages/pn-pa-webapp/src/redux/store.ts @@ -4,7 +4,6 @@ import { appStateReducer } from '@pagopa-pn/pn-commons'; import { Middleware, MiddlewareArray, configureStore } from '@reduxjs/toolkit'; import { getConfiguration } from '../services/configuration.service'; -import { trackingMiddleware } from '../utility/mixpanel'; import newApiKeySlice from './NewApiKey/reducers'; import apiKeysSlice from './apiKeys/reducers'; import appStatusSlice from './appStatus/reducers'; @@ -28,7 +27,7 @@ export const appReducers = { const createStore = (logReduxActions?: boolean) => { const mustLogActions = logReduxActions ?? getConfiguration().LOG_REDUX_ACTIONS; - const additionalMiddlewares = [mustLogActions ? logger : undefined, trackingMiddleware]; + const additionalMiddlewares = [mustLogActions ? logger : undefined]; return configureStore({ reducer: appReducers, middleware: (getDefaultMiddleware) => diff --git a/packages/pn-pa-webapp/src/utility/events.ts b/packages/pn-pa-webapp/src/utility/events.ts deleted file mode 100644 index 4e886f0fd6..0000000000 --- a/packages/pn-pa-webapp/src/utility/events.ts +++ /dev/null @@ -1,237 +0,0 @@ -import { EventsType } from '@pagopa-pn/pn-commons'; - -export enum TrackEventType { - NOTIFICATIONS_CHANGE_PAGE = 'setPagination', - NOTIFICATION_FILTER_TYPE = 'NOTIFICATION_FILTER_TYPE', - NOTIFICATION_FILTER_DATE = 'NOTIFICATION_FILTER_DATE', - NOTIFICATION_FILTER_NOTIFICATION_STATE = 'NOTIFICATION_FILTER_NOTIFICATION_STATE', - NOTIFICATION_FILTER_CODE_VALIDATION_RATE = 'NOTIFICATION_FILTER_CODE_VALIDATION_RATE', - NOTIFICATION_FILTER_SEARCH = 'NOTIFICATION_FILTER_SEARCH', - NOTIFICATION_FILTER_REMOVE = 'NOTIFICATION_FILTER_REMOVE', - NOTIFICATION_DETAIL_CANCEL_NOTIFICATION = 'NOTIFICATION_DETAIL_CANCEL_NOTIFICATION', - NOTIFICATION_DETAIL_CONFIRM_CANCEL_NOTIFICATION = 'setCancelledIun/fulfilled', - NOTIFICATION_DETAIL_ALL_ATTACHMENTS = 'NOTIFICATION_DETAIL_ALL_ATTACHMENTS', - NOTIFICATION_DETAIL_SINGLE_ATTACHMENT = 'getSentNotificationDocument/fulfilled', - NOTIFICATION_DETAIL_PAYMENT_PAGOPA_FILE = 'NOTIFICATION_DETAIL_PAYMENT_PAGOPA_FILE', - NOTIFICATION_SEND = 'NOTIFICATION_SEND', - NOTIFICATION_SEND_DELIVERY_MODE = 'NOTIFICATION_SEND_DELIVERY_MODE', - NOTIFICATION_SEND_PAYMENT_MODE = 'NOTIFICATION_SEND_PAYMENT_MODE', - NOTIFICATION_SEND_PRELIMINARY_INFO = 'NOTIFICATION_SEND_PRELIMINARY_INFO', - NOTIFICATION_SEND_RECIPIENT_TYPE = 'NOTIFICATION_SEND_RECIPIENT_TYPE', - NOTIFICATION_SEND_PHYSICAL_ADDRESS = 'NOTIFICATION_SEND_PHYSICAL_ADDRESS', - NOTIFICATION_SEND_DIGITAL_DOMICILE = 'NOTIFICATION_SEND_DIGITAL_DOMICILE', - NOTIFICATION_SEND_MULTIPLE_RECIPIENTS = 'NOTIFICATION_SEND_MULTIPLE_RECIPIENTS', - NOTIFICATION_SEND_RECIPIENT_INFO = 'NOTIFICATION_SEND_RECIPIENT_INFO', - NOTIFICATION_SEND_ATTACHMENTS = 'NOTIFICATION_SEND_ATTACHMENTS', - NOTIFICATION_SEND_PAYMENT_MODES = 'NOTIFICATION_SEND_PAYMENT_MODES', - NOTIFICATION_SEND_EXIT_WARNING = 'NOTIFICATION_SEND_EXIT_WARNING', - NOTIFICATION_SEND_EXIT_FLOW = 'NOTIFICATION_SEND_EXIT_FLOW', - NOTIFICATION_SEND_EXIT_CANCEL = 'NOTIFICATION_SEND_EXIT_CANCEL', - NOTIFICATION_TABLE_SORT = 'NOTIFICATION_TABLE_SORT', - NOTIFICATION_TABLE_ROW_INTERACTION = 'NOTIFICATION_TABLE_ROW_INTERACTION', - NOTIFICATION_TABLE_ROW_TOOLTIP = 'NOTIFICATION_TABLE_ROW_TOOLTIP', - NOTIFICATION_TABLE_SIZE = 'NOTIFICATION_TABLE_SIZE', - NOTIFICATION_TABLE_PAGINATION = 'NOTIFICATION_TABLE_PAGINATION', - NOTIFICATION_TIMELINE_ALL_ATTACHMENTS = 'NOTIFICATION_TIMELINE_ALL_ATTACHMENTS', - NOTIFICATION_TIMELINE_SINGLE_ATTACHMENT = 'getSentNotificationLegalfact/fulfilled', - NOTIFICATION_TIMELINE_VIEW_MORE = 'NOTIFICATION_TIMELINE_VIEW_MORE', - CUSTOMER_CARE_MAILTO = 'CUSTOMER_CARE_MAILTO', - CUSTOMER_CARE_CONTACT = 'CUSTOMER_CARE_CONTACT', - CUSTOMER_CARE_CONTACT_SUCCESS = 'CUSTOMER_CARE_CONTACT_SUCCESS', - CUSTOMER_CARE_CONTACT_FAILURE = 'CUSTOMER_CARE_CONTACT_FAILURE', - APP_CRASH = 'APP_CRASH', - APP_UNLOAD = 'APP_UNLOAD', - USER_PRODUCT_SWITCH = 'USER_PRODUCT_SWITCH', - USER_PARTY_SWITCH = 'USER_PARTY_SWITCH', - USER_LOGOUT = 'logout/fulfilled', - USER_NAV_ITEM = 'USER_NAV_ITEM', - APIKEYS_TABLE_PAGINATION = 'APIKEYS_TABLE_PAGINATION', - APIKEYS_TABLE_SIZE = 'APIKEYS_TABLE_SIZE' -} - -export const events: EventsType = { - [TrackEventType.NOTIFICATIONS_CHANGE_PAGE]: { - event_category: 'notifications', - event_type: 'change page', - }, - [TrackEventType.NOTIFICATION_FILTER_TYPE]: { - event_category: 'notifications', - event_type: 'filter by type', - }, - [TrackEventType.NOTIFICATION_FILTER_DATE]: { - event_category: 'notifications', - event_type: 'filter by date', - }, - [TrackEventType.NOTIFICATION_FILTER_NOTIFICATION_STATE]: { - event_category: 'notifications', - event_type: 'filter by notification status', - }, - [TrackEventType.NOTIFICATION_FILTER_CODE_VALIDATION_RATE]: { - event_category: 'notifications', - event_type: 'filter validation code', - }, - [TrackEventType.NOTIFICATION_FILTER_SEARCH]: { - event_category: 'notifications', - event_type: 'click on filter search', - }, - [TrackEventType.NOTIFICATION_FILTER_REMOVE]: { - event_category: 'notifications', - event_type: 'click on remove filters', - }, - [TrackEventType.NOTIFICATION_DETAIL_CANCEL_NOTIFICATION]: { - event_category: 'notifications', - event_type: 'cancel notification', - }, - [TrackEventType.NOTIFICATION_DETAIL_CONFIRM_CANCEL_NOTIFICATION]: { - event_category: 'notifications', - event_type: 'confirm cancel notification', - }, - [TrackEventType.NOTIFICATION_DETAIL_ALL_ATTACHMENTS]: { - event_category: 'notifications', - event_type: 'detail all attachments', - }, - [TrackEventType.NOTIFICATION_DETAIL_SINGLE_ATTACHMENT]: { - event_category: 'notifications', - event_type: 'detail single attachment', - }, - [TrackEventType.NOTIFICATION_DETAIL_PAYMENT_PAGOPA_FILE]: { - event_category: 'notification', - event_type: 'download the PagoPA file', - }, - [TrackEventType.NOTIFICATION_SEND]: { - event_category: 'notifications', - event_type: 'send notification', - }, - [TrackEventType.NOTIFICATION_SEND_DELIVERY_MODE]: { - event_category: 'notifications', - event_type: 'delivery mode', - }, - [TrackEventType.NOTIFICATION_SEND_PAYMENT_MODE]: { - event_category: 'notifications', - event_type: 'payment mode', - }, - [TrackEventType.NOTIFICATION_SEND_PRELIMINARY_INFO]: { - event_category: 'notifications', - event_type: 'preliminary info', - }, - [TrackEventType.NOTIFICATION_SEND_RECIPIENT_TYPE]: { - event_category: 'notifications', - event_type: 'recipient type', - }, - [TrackEventType.NOTIFICATION_SEND_PHYSICAL_ADDRESS]: { - event_category: 'notifications', - event_type: 'phsycal address', - }, - [TrackEventType.NOTIFICATION_SEND_DIGITAL_DOMICILE]: { - event_category: 'notifications', - event_type: 'digital domicile', - }, - [TrackEventType.NOTIFICATION_SEND_MULTIPLE_RECIPIENTS]: { - event_category: 'notifications', - event_type: 'multiple recipients', - }, - [TrackEventType.NOTIFICATION_SEND_RECIPIENT_INFO]: { - event_category: 'notifications', - event_type: 'recipient info', - }, - [TrackEventType.NOTIFICATION_SEND_ATTACHMENTS]: { - event_category: 'notifications', - event_type: 'attachments', - }, - [TrackEventType.NOTIFICATION_SEND_PAYMENT_MODES]: { - event_category: 'notifications', - event_type: 'payments mode', - }, - [TrackEventType.NOTIFICATION_SEND_EXIT_WARNING]: { - event_category: 'notifications', - event_type: 'confirm cancel send notification', - }, - [TrackEventType.NOTIFICATION_SEND_EXIT_FLOW]: { - event_category: 'notifications', - event_type: 'cancel send notification', - }, - [TrackEventType.NOTIFICATION_SEND_EXIT_CANCEL]: { - event_category: 'notifications', - event_type: 'abort cancel notification', - }, - [TrackEventType.NOTIFICATION_TABLE_SORT]: { - event_category: 'notifications', - event_type: 'sorting table', - }, - [TrackEventType.NOTIFICATION_TABLE_ROW_INTERACTION]: { - event_category: 'notifications', - event_type: 'click on row table', - }, - [TrackEventType.NOTIFICATION_TABLE_ROW_TOOLTIP]: { - event_category: 'notifications', - event_type: 'open table row tooltip', - }, - [TrackEventType.NOTIFICATION_TABLE_SIZE]: { - event_category: 'notifications', - event_type: 'table rows per page', - }, - [TrackEventType.NOTIFICATION_TABLE_PAGINATION]: { - event_category: 'notifications', - event_type: 'table pagination', - }, - [TrackEventType.NOTIFICATION_TIMELINE_ALL_ATTACHMENTS]: { - event_category: 'notifications', - event_type: 'timeline all attachments', - }, - [TrackEventType.NOTIFICATION_TIMELINE_SINGLE_ATTACHMENT]: { - event_category: 'notifications', - event_type: 'single single attachment', - }, - [TrackEventType.NOTIFICATION_TIMELINE_VIEW_MORE]: { - event_category: 'notifications', - event_type: 'timeline view mode', - }, - [TrackEventType.CUSTOMER_CARE_MAILTO]: { - event_category: 'customer care', - event_type: 'click on customer care email', - }, - [TrackEventType.CUSTOMER_CARE_CONTACT]: { - event_category: 'customer care', - event_type: 'click on customer care form', - }, - [TrackEventType.CUSTOMER_CARE_CONTACT_SUCCESS]: { - event_category: 'customer care', - event_type: 'send customer care form success', - }, - [TrackEventType.CUSTOMER_CARE_CONTACT_FAILURE]: { - event_category: 'customer care', - event_type: 'send customer care form failed', - }, - [TrackEventType.APP_CRASH]: { - event_category: 'app', - event_type: 'app crashed', - }, - [TrackEventType.APP_UNLOAD]: { - event_category: 'app', - event_type: 'app unloaded', - }, - [TrackEventType.USER_PRODUCT_SWITCH]: { - event_category: 'user', - event_type: 'switch product', - }, - [TrackEventType.USER_PARTY_SWITCH]: { - event_category: 'user', - event_type: 'switch ente', - }, - [TrackEventType.USER_LOGOUT]: { - event_category: 'user', - event_type: 'user logout', - }, - [TrackEventType.USER_NAV_ITEM]: { - event_category: 'user', - event_type: 'user menu navigation', - }, - [TrackEventType.APIKEYS_TABLE_PAGINATION]: { - event_category: 'apikeys', - event_type: 'table pagination', - }, - [TrackEventType.APIKEYS_TABLE_SIZE]: { - event_category: 'apikeys', - event_type: 'table rows per page', - }, -}; diff --git a/packages/pn-pa-webapp/src/utility/mixpanel.ts b/packages/pn-pa-webapp/src/utility/mixpanel.ts deleted file mode 100644 index 1dd011587f..0000000000 --- a/packages/pn-pa-webapp/src/utility/mixpanel.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { interceptDispatch, trackEvent } from '@pagopa-pn/pn-commons'; -import { AnyAction, Dispatch, Middleware } from '@reduxjs/toolkit'; -import { events, TrackEventType } from './events'; - -/** - * Redux middleware to track events - */ -export const trackingMiddleware: Middleware = - () => (next: Dispatch) => - interceptDispatch(next, events, {}, process.env.NODE_ENV); - -/** - * Function to track events outside redux - * @param trackEventType event name - * @param attributes optional additional attributes - */ -export const trackEventByType = (trackEventType: TrackEventType, attributes?: object) => { - const eventParameters = attributes - ? { ...events[trackEventType], attributes: { ...attributes } } - : events[trackEventType]; - - trackEvent(trackEventType, process.env.NODE_ENV, eventParameters); -};