Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1195: Buy with Credit Card Form Event #1033

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import browser from 'webextension-polyfill';
import { object as objectSchema, number as numberSchema, mixed as mixedSchema } from 'yup';

import { useUserIdSelector } from 'app/store/settings/selectors';
import { useFormAnalytics } from 'lib/analytics';
import { AnalyticsEventCategory, useAnalytics, useFormAnalytics } from 'lib/analytics';
import { MOONPAY_ASSETS_BASE_URL } from 'lib/apis/moonpay';
import { createAliceBobOrder, getMoonpaySign } from 'lib/apis/temple';
import { createOrder as createUtorgOrder } from 'lib/apis/utorg';
Expand Down Expand Up @@ -54,6 +54,7 @@ const validationSchema = objectSchema().shape({
});

export const useBuyWithCreditCardForm = () => {
const { trackEvent } = useAnalytics();
const validationResolver = useYupValidationResolver<BuyWithCreditCardFormValues>(validationSchema);

const formAnalytics = useFormAnalytics('BuyWithCreditCardForm');
Expand Down Expand Up @@ -99,6 +100,14 @@ export const useBuyWithCreditCardForm = () => {
async (formValues: BuyWithCreditCardFormValues) => {
const { inputAmount, inputCurrency, outputAmount, outputToken, topUpProvider } = formValues;

trackEvent('BUY_WITH_CREDIT_CARD_FORM_SUBMIT', AnalyticsEventCategory.FormSubmit, {
inputAmount: inputAmount?.toString(),
inputAsset: inputCurrency.code,
outputAmount: outputAmount?.toString(),
outputAsset: outputToken.code,
provider: topUpProvider?.name
});

if (
!isDefined(topUpProvider?.outputAmount) ||
!isDefined(inputAmount) ||
Expand Down
Loading