Skip to content

Commit

Permalink
feat(frontend): add tracking for BTC -> ckBTC conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysKarmazynDFINITY committed Jan 24, 2025
1 parent 89f2124 commit c65c41f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import { btcAddressStore } from '$icp/stores/btc.store';
import ButtonBack from '$lib/components/ui/ButtonBack.svelte';
import ButtonCancel from '$lib/components/ui/ButtonCancel.svelte';
import {
TRACK_COUNT_CONVERT_BTC_TO_CKBTC_ERROR,
TRACK_COUNT_CONVERT_BTC_TO_CKBTC_SUCCESS
} from '$lib/constants/analytics.contants';
import {
btcAddressMainnet,
btcAddressRegtest,
Expand All @@ -20,6 +24,7 @@
import { authIdentity } from '$lib/derived/auth.derived';
import { ProgressStepsConvert } from '$lib/enums/progress-steps';
import { WizardStepsConvert } from '$lib/enums/wizard-steps';
import { trackEvent } from '$lib/services/analytics.services';
import { nullishSignOut } from '$lib/services/auth.services';
import { CONVERT_CONTEXT_KEY, type ConvertContext } from '$lib/stores/convert.store';
import { i18n } from '$lib/stores/i18n.store';
Expand Down Expand Up @@ -98,7 +103,6 @@
dispatch('icNext');
try {
// TODO: add tracking
await sendBtc({
destination: destinationAddress,
amount: sendAmount,
Expand All @@ -117,13 +121,21 @@
progress(ProgressStepsConvert.DONE);
await trackEvent({
name: TRACK_COUNT_CONVERT_BTC_TO_CKBTC_SUCCESS
});
setTimeout(() => close(), 750);
} catch (err: unknown) {
toastsError({
msg: { text: $i18n.convert.error.unexpected },
err
});
await trackEvent({
name: TRACK_COUNT_CONVERT_BTC_TO_CKBTC_ERROR
});
back();
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/lib/constants/analytics.contants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const TRACK_COUNT_WC_ETH_SEND_ERROR = 'wc_eth_send_error_count';
// Internet Computer
export const TRACK_COUNT_CONVERT_CKBTC_TO_BTC_SUCCESS = 'ic_ckbtc_to_btc_success_count';
export const TRACK_COUNT_CONVERT_CKBTC_TO_BTC_ERROR = 'ic_ckbtc_to_btc_error_count';
export const TRACK_COUNT_CONVERT_BTC_TO_CKBTC_SUCCESS = 'ic_btc_to_ckbtc_success_count';
export const TRACK_COUNT_CONVERT_BTC_TO_CKBTC_ERROR = 'ic_btc_to_ckbtc_error_count';
export const TRACK_COUNT_CONVERT_CKETH_TO_ETH_SUCCESS = 'ic_cketh_to_eth_success_count';
export const TRACK_COUNT_CONVERT_CKETH_TO_ETH_ERROR = 'ic_cketh_to_eth_error_count';
export const TRACK_COUNT_CONVERT_CKERC20_TO_ERC20_SUCCESS = 'ic_ckerc20_to_erc20_success_count';
Expand Down

0 comments on commit c65c41f

Please sign in to comment.