Skip to content

Commit

Permalink
feat: [IOCOM-548] Tracking properties on PN_UX_SUCCESS event to track…
Browse files Browse the repository at this point in the history
… cancelled PN notification (#5016)

## Short description
This PR adds properties to PN_UX_SUCCESS event to better track cancelled
PN notifications.

## List of changes proposed in this pull request
- notification_status: active/cancelled
- contains_multipayment: no
- count_payment: 0/1
- contains_f24: no

## How to test
Run the application with an io-dev-api-server configuration that
generates PN messages that are-cancelled/are-not-cancelled and that
have/do-not-have a payment. Select such messages and check that the
PN_UX_SUCCESS event is triggered with proper values.

Co-authored-by: Alessandro Dell'Oste <[email protected]>
  • Loading branch information
Vangaorth and adelloste authored Sep 26, 2023
1 parent 1896cde commit 8b3aa60
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
9 changes: 7 additions & 2 deletions ts/features/pn/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,18 @@ export function trackPNShowTimeline() {

export function trackPNUxSuccess(
containsPayment: boolean,
firstTimeOpening: boolean
firstTimeOpening: boolean,
isCancelled: boolean
) {
void mixpanelTrack(
"PN_UX_SUCCESS",
buildEventProperties("UX", "screen_view", {
contains_payment: booleanToYesNo(containsPayment),
first_time_opening: booleanToYesNo(firstTimeOpening)
first_time_opening: booleanToYesNo(firstTimeOpening),
notification_status: isCancelled ? "cancelled" : "active",
contains_multipayment: "no",
count_payment: containsPayment ? 1 : 0,
contains_f24: "no"
})
);
}
5 changes: 3 additions & 2 deletions ts/features/pn/screens/LegacyPnMessageDetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { pnMessageFromIdSelector } from "../store/reducers";
import { NotificationPaymentInfo, PNMessage } from "../store/types/types";
import { cancelPreviousAttachmentDownload } from "../../../store/actions/messages";
import { profileFiscalCodeSelector } from "../../../store/reducers/profile";
import { paymentFromPNMessagePot } from "../utils";
import { isCancelledFromPNMessagePot, paymentFromPNMessagePot } from "../utils";
import { trackPNUxSuccess } from "../analytics";
import { getRptIdFromPayment } from "../utils/rptId";
import { isStrictSome } from "../../../utils/pot";
Expand Down Expand Up @@ -104,7 +104,8 @@ export const LegacyPnMessageDetailsScreen = (
if (!uxEventTracked.current && isStrictSome(message)) {
// eslint-disable-next-line functional/immutable-data
uxEventTracked.current = true;
trackPNUxSuccess(!!rptId, firstTimeOpening);
const isCancelled = isCancelledFromPNMessagePot(message);
trackPNUxSuccess(!!rptId, firstTimeOpening, isCancelled);
}

return (
Expand Down
5 changes: 3 additions & 2 deletions ts/features/pn/screens/PnMessageDetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { pnMessageFromIdSelector } from "../store/reducers";
import { NotificationPaymentInfo, PNMessage } from "../store/types/types";
import { cancelPreviousAttachmentDownload } from "../../../store/actions/messages";
import { profileFiscalCodeSelector } from "../../../store/reducers/profile";
import { paymentFromPNMessagePot } from "../utils";
import { isCancelledFromPNMessagePot, paymentFromPNMessagePot } from "../utils";
import { getRptIdFromPayment } from "../utils/rptId";
import { trackPNUxSuccess } from "../analytics";
import { isStrictSome } from "../../../utils/pot";
Expand Down Expand Up @@ -104,7 +104,8 @@ export const PnMessageDetailsScreen = (
if (!uxEventTracked.current && isStrictSome(message)) {
// eslint-disable-next-line functional/immutable-data
uxEventTracked.current = true;
trackPNUxSuccess(!!rptId, firstTimeOpening);
const isCancelled = isCancelledFromPNMessagePot(message);
trackPNUxSuccess(!!rptId, firstTimeOpening, isCancelled);
}

return (
Expand Down
9 changes: 9 additions & 0 deletions ts/features/pn/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,12 @@ export const paymentFromPNMessagePot = (
O.chainNullableK(recipient => recipient.payment),
O.toUndefined
);

export const isCancelledFromPNMessagePot = (
potMessage: pot.Pot<O.Option<PNMessage>, Error>
) =>
pipe(
pot.getOrElse(potMessage, O.none),
O.chainNullableK(message => message.isCancelled),
O.getOrElse(() => false)
);

0 comments on commit 8b3aa60

Please sign in to comment.