Skip to content

Commit

Permalink
fix(Bonus Pagamenti Digitali): [#176551362] Not all the getWalletV2 c…
Browse files Browse the repository at this point in the history
…all are tracked (#2815)

* [#176551362] remove old analytics

* [#176551362] track wallet in saga

Co-authored-by: Matteo Boschi <[email protected]>
  • Loading branch information
fabriziofff and Undermaken authored Feb 12, 2021
1 parent 5aca618 commit a286f21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 12 additions & 2 deletions ts/sagas/wallet/pagopaApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ActionType } from "typesafe-actions";
import { Either, left, right } from "fp-ts/lib/Either";
import { BackendClient } from "../../api/backend";
import { PaymentManagerClient } from "../../api/pagopa";
import { mixpanelTrack } from "../../mixpanel";
import {
paymentAttiva,
paymentCheck,
Expand Down Expand Up @@ -72,13 +73,17 @@ export function* getWalletsV2(
pmSessionManager: SessionManager<PaymentManagerToken>
): Generator<Effect, Either<Error, ReadonlyArray<Wallet>>, any> {
try {
void mixpanelTrack("WALLETS_LOAD_REQUEST");
const request = pmSessionManager.withRefresh(pagoPaClient.getWalletsV2);
const getResponse: SagaCallReturnType<typeof request> = yield call(request);
if (getResponse.isRight()) {
if (getResponse.value.status === 200) {
const wallets = (getResponse.value.value.data ?? []).map(
convertWalletV2toWalletV1
);
void mixpanelTrack("WALLETS_LOAD_SUCCESS", {
count: wallets.length
});
yield put(fetchWalletsSuccess(wallets));
return right<Error, ReadonlyArray<Wallet>>(wallets);
} else {
Expand All @@ -91,6 +96,11 @@ export function* getWalletsV2(
// this is required to handle 401 response from PM
// On 401 response sessionManager retries for X attempts to get a valid session
// If it exceeds a fixed threshold of attempts a max retries error will be dispatched

void mixpanelTrack("WALLETS_LOAD_FAILURE", {
reason: error.message
});

if (isTimeoutError(getNetworkError(error))) {
// check if also the IO session is expired
yield put(checkCurrentSession.request());
Expand Down Expand Up @@ -676,9 +686,9 @@ export function* paymentAttivaRequestHandler(
paymentActivationsPostRequest: {
rptId: RptIdFromString.encode(action.payload.rptId),
codiceContestoPagamento:
action.payload.verifica.codiceContestoPagamento,
action.payload.verifica.codiceContestoPagamento,
importoSingoloVersamento:
action.payload.verifica.importoSingoloVersamento
action.payload.verifica.importoSingoloVersamento
},
test: isPagoPATestEnabled
}
Expand Down
6 changes: 0 additions & 6 deletions ts/store/middlewares/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ import {
deleteWalletFailure,
deleteWalletRequest,
deleteWalletSuccess,
fetchWalletsFailure,
fetchWalletsRequest,
fetchWalletsSuccess,
payCreditCardVerificationFailure,
payCreditCardVerificationRequest,
payCreditCardVerificationSuccess,
Expand Down Expand Up @@ -194,7 +191,6 @@ const trackAction = (mp: NonNullable<typeof mixpanel>) => (
// wallets success / services load requests
//
case getType(loadServicesDetail):
case getType(fetchWalletsSuccess):
return mp.track(action.type, {
count: action.payload.length
});
Expand Down Expand Up @@ -294,7 +290,6 @@ const trackAction = (mp: NonNullable<typeof mixpanel>) => (
case getType(loginFailure):
case getType(loadMessages.failure):
case getType(loadVisibleServices.failure):
case getType(fetchWalletsFailure):
case getType(payCreditCardVerificationFailure):
case getType(deleteWalletFailure):
case getType(setFavouriteWalletFailure):
Expand Down Expand Up @@ -365,7 +360,6 @@ const trackAction = (mp: NonNullable<typeof mixpanel>) => (
case getType(loadServiceMetadata.request):
case getType(loadServiceMetadata.success):
// wallet
case getType(fetchWalletsRequest):
case getType(addWalletCreditCardInit):
case getType(addWalletCreditCardRequest):
case getType(addWalletNewCreditCardSuccess):
Expand Down

0 comments on commit a286f21

Please sign in to comment.