Skip to content

Commit

Permalink
Merge branch 'master' into IOCOM-555
Browse files Browse the repository at this point in the history
  • Loading branch information
Vangaorth authored Sep 26, 2023
2 parents f20731b + 8b3aa60 commit 6ccda71
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 @@ -206,13 +206,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 @@ -26,7 +26,7 @@ import { PNMessage } from "../store/types/types";
import { NotificationPaymentInfo } from "../../../../definitions/pn/NotificationPaymentInfo";
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 @@ -105,7 +105,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 @@ -26,7 +26,7 @@ import { PNMessage } from "../store/types/types";
import { NotificationPaymentInfo } from "../../../../definitions/pn/NotificationPaymentInfo";
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 @@ -105,7 +105,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 @@ -87,3 +87,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 6ccda71

Please sign in to comment.