Skip to content

Commit

Permalink
fix: remove mixpanel event's tracking from PA
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrogelmi committed Mar 29, 2024
1 parent 306458f commit 97554a0
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 440 deletions.
8 changes: 4 additions & 4 deletions packages/pn-commons/src/components/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand All @@ -33,7 +33,7 @@ const Prompt: React.FC<Props> = ({

useEffect(() => {
if (showPrompt) {
eventTrackingCallbackPromptOpened();
eventTrackingCallbackPromptOpened?.();
}
});

Expand Down
8 changes: 4 additions & 4 deletions packages/pn-commons/src/hooks/usePrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -37,7 +37,7 @@ export function usePrompt(
const confirmNavigation = useCallback(() => {
setShowPrompt(false);
setConfirmedNavigation(true);
callbackConfirm();
callbackConfirm?.();
}, []);

useEffect(() => {
Expand Down
36 changes: 2 additions & 34 deletions packages/pn-pa-webapp/src/App.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -21,7 +21,6 @@ import {
initLocalization,
useMultiEvent,
useTracking,
useUnload,
} from '@pagopa-pn/pn-commons';
import { LinkType, ProductEntity } from '@pagopa/mui-italia';

Expand All @@ -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';

Expand All @@ -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
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -238,20 +216,10 @@ const ActualApp = () => {
showHeader={!isPrivacyPage}
showFooter={!isPrivacyPage}
onExitAction={handleLogout}
eventTrackingCallbackAppCrash={handleEventTrackingCallbackAppCrash}
eventTrackingCallbackProductSwitch={(target: string) =>
handleEventTrackingCallbackProductSwitch(target)
}
sideMenu={
role &&
menuItems && (
<SideMenu
menuItems={menuItems.menuItems}
selfCareItems={menuItems.selfCareItems}
eventTrackingCallback={(target: string) =>
trackEventByType(TrackEventType.USER_NAV_ITEM, { target })
}
/>
<SideMenu menuItems={menuItems.menuItems} selfCareItems={menuItems.selfCareItems} />
)
}
showSideMenu={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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(() => {
Expand Down
15 changes: 0 additions & 15 deletions packages/pn-pa-webapp/src/components/NewNotification/Recipient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -250,13 +248,6 @@ const Recipient: React.FC<Props> = ({
) => {
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(
Expand Down Expand Up @@ -297,9 +288,6 @@ const Recipient: React.FC<Props> = ({
...values.recipients,
{ ...singleRecipient, idx: lastRecipientIdx + 1, id: `recipient.${lastRecipientIdx + 1}` },
]);
trackEventByType(TrackEventType.NOTIFICATION_SEND_MULTIPLE_RECIPIENTS, {
recipients: lastRecipientIdx + 1,
});
};

const handleSubmit = (values: FormRecipients) => {
Expand Down Expand Up @@ -361,9 +349,6 @@ const Recipient: React.FC<Props> = ({
// 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, () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -160,8 +158,6 @@ const DesktopNotifications = ({
// Navigation handlers
const handleRowClick = (row: Row<Notification>) => {
navigate(routes.GET_DETTAGLIO_NOTIFICA_PATH(row.iun));
// log event
trackEventByType(TrackEventType.NOTIFICATION_TABLE_ROW_INTERACTION);
};

const filtersApplied: boolean = filterNotificationsRef.current.filtersApplied;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -105,15 +103,13 @@ const FilterNotifications = forwardRef(({ showFilters }: Props, ref) => {
if (_.isEqual(prevFilters, currentFilters)) {
return;
}
trackEventByType(TrackEventType.NOTIFICATION_FILTER_SEARCH);
dispatch(setNotificationFilters(currentFilters));
setPrevFilters(currentFilters);
dialogRef.current?.toggleOpen();
},
});

const cancelSearch = () => {
trackEventByType(TrackEventType.NOTIFICATION_FILTER_REMOVE);
dispatch(setNotificationFilters(emptyValues));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {
Expand All @@ -90,7 +86,6 @@ const FilterNotificationsFormBody = ({
(e.target as HTMLSelectElement).value,
false
);
trackEventByType(TrackEventType.NOTIFICATION_FILTER_NOTIFICATION_STATE);
};

return (
Expand Down Expand Up @@ -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={{
Expand Down Expand Up @@ -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);
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -146,8 +144,6 @@ const MobileNotifications = ({
// Navigation handlers
const handleRowClick = (row: Row<Notification>) => {
navigate(routes.GET_DETTAGLIO_NOTIFICA_PATH(row.iun));
// log event
trackEventByType(TrackEventType.NOTIFICATION_TABLE_ROW_INTERACTION);
};

const cardData: Array<Row<Notification>> = notifications.map((n) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -42,7 +40,6 @@ const NotificationDetailTableSender: React.FC<Props> = ({ 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);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,7 +24,6 @@ const NotificationPaymentPagoPa: React.FC<Props> = ({ iun, payment }) => {

const dowloadHandler = () => {
if (!_.isNil(payment.recIndex) && payment.attachment) {
trackEventByType(TrackEventType.NOTIFICATION_DETAIL_PAYMENT_PAGOPA_FILE);
dispatch(
getPaymentAttachment({
iun,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Notification> }> = ({ data }) => {
const handleEventTrackingTooltip = () => {
trackEventByType(TrackEventType.NOTIFICATION_TABLE_ROW_TOOLTIP);
};
const { label, tooltip, color } = getNotificationStatusInfos(data.notificationStatus, {
recipients: data.recipients,
});
return (
<StatusTooltip
label={label}
tooltip={tooltip}
color={color}
eventTrackingCallback={handleEventTrackingTooltip}
></StatusTooltip>
);
return <StatusTooltip label={label} tooltip={tooltip} color={color}></StatusTooltip>;
};

const NotificationsDataSwitch: React.FC<{ data: Row<Notification>; type: keyof Notification }> = ({
Expand Down
8 changes: 0 additions & 8 deletions packages/pn-pa-webapp/src/pages/ApiKeys.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 (
<Box p={3}>
<TitleBox
Expand Down Expand Up @@ -218,7 +211,6 @@ const ApiKeys = () => {
totalElements,
}}
onPageRequest={handleChangePage}
eventTrackingCallbackPageSize={handleEventTrackingCallbackPageSize}
pagesToShow={pagesToShow}
/>
)}
Expand Down
Loading

0 comments on commit 97554a0

Please sign in to comment.