Skip to content

Commit

Permalink
feat(Bonus Pagamenti Digitali): [#175883232] Send BPay actions to mix…
Browse files Browse the repository at this point in the history
…panel (#2678)

* [#175889351] wip

* [#175889351] add missing navigation

* [#175889351] fix compile

* [#175889351] renaming

* [#175889351] remove navigation bar

* [#175889351] fix and link with data

* [#175889351] remove unused import

* [#175889351] remove all the bancomat reference

* [#175889351] fix add bpay

* [#175889351] fix ts

* Update ts/features/wallet/onboarding/bancomatPay/screens/add-account/AddBPayScreen.tsx

Co-authored-by: Matteo Boschi <[email protected]>

* [#175889351] simplify code

* [#175889351] add sectionstatus

* [#175889351] simplify code

* [#175883232] add mixpanel

* [#175883232] remove eslint complexity

* [#175883232] fix action tap

* [#175883232] restore eslint

Co-authored-by: Matteo Boschi <[email protected]>
  • Loading branch information
fabriziofff and Undermaken authored Jan 8, 2021
1 parent 3f9bb70 commit 44f2978
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ts/features/bonus/bpd/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const trackAction = (mp: NonNullable<typeof mixpanel>) => (
case getType(bpdAllData.failure):
return mp.track(action.type, { reason: action.payload.message });

// iban
// IBAN
case getType(bpdIbanInsertionStart):
case getType(bpdIbanInsertionContinue):
case getType(bpdIbanInsertionCancel):
Expand Down
1 change: 0 additions & 1 deletion ts/features/wallet/onboarding/bancomat/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from "../store/actions";
import { isTimeoutError } from "../../../../../utils/errors";

// eslint-disable-next-line complexity
const trackAction = (mp: NonNullable<typeof mixpanel>) => (
action: Action
): Promise<any> => {
Expand Down
46 changes: 46 additions & 0 deletions ts/features/wallet/onboarding/bancomatPay/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { getType } from "typesafe-actions";
import { mixpanel } from "../../../../../mixpanel";
import { Action } from "../../../../../store/actions/types";
import { isTimeoutError } from "../../../../../utils/errors";
import {
addBPayToWallet,
searchUserBPay,
walletAddBPayBack,
walletAddBPayCancel,
walletAddBPayCompleted,
walletAddBPayStart
} from "../store/actions";

export const trackBPayAction = (mp: NonNullable<typeof mixpanel>) => (
action: Action
): Promise<any> => {
switch (action.type) {
case getType(walletAddBPayStart):
case getType(walletAddBPayCompleted):
case getType(walletAddBPayCancel):
case getType(walletAddBPayBack):
case getType(addBPayToWallet.request):
case getType(addBPayToWallet.success):
return mp.track(action.type);
case getType(searchUserBPay.request):
return mp.track(action.type, { abi: action.payload ?? "all" });
case getType(searchUserBPay.success):
return mp.track(action.type, {
count: action.payload.length,
serviceStateList: action.payload.map(bPay =>
bPay.serviceState?.toString()
)
});

case getType(addBPayToWallet.failure):
return mp.track(action.type, { reason: action.payload.message });

case getType(searchUserBPay.failure):
return mp.track(action.type, {
reason: isTimeoutError(action.payload)
? action.payload.kind
: action.payload.value.message
});
}
return Promise.resolve();
};
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const BPaySearchStartScreen = (props: Props): React.ReactElement => (
<SafeAreaView style={IOStyles.flex}>
<Content style={IOStyles.flex} />
<SectionStatusComponent sectionKey={"bancomatpay"} />
{renderFooterButtons(props.onCancel, props.searchBPay)}
{renderFooterButtons(props.onCancel, () => props.searchBPay())}
</SafeAreaView>
</BaseScreenComponent>
);
Expand Down
10 changes: 6 additions & 4 deletions ts/store/middlewares/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
isActivationResponseTrackable,
isEligibilityResponseTrackable
} from "../../features/bonus/bonusVacanze/utils/bonus";
import { trackBPayAction } from "../../features/wallet/onboarding/bancomatPay/analytics";
import { mixpanel } from "../../mixpanel";
import { getCurrentRouteName } from "../../utils/navigation";
import {
Expand Down Expand Up @@ -441,10 +442,11 @@ export const actionTracking = (_: MiddlewareAPI) => (next: Dispatch) => (
if (mixpanel !== undefined) {
// call mixpanel tracking only after we have initialized mixpanel with the
// API token
trackAction(mixpanel)(action).then(constNull, constNull);
trackBpdAction(mixpanel)(action).then(constNull, constNull);
trackBancomatAction(mixpanel)(action).then(constNull, constNull);
trackSatispayAction(mixpanel)(action).then(constNull, constNull);
void trackAction(mixpanel)(action);
void trackBpdAction(mixpanel)(action);
void trackBancomatAction(mixpanel)(action);
void trackSatispayAction(mixpanel)(action);
void trackBPayAction(mixpanel)(action);
}
return next(action);
};
Expand Down

0 comments on commit 44f2978

Please sign in to comment.