Skip to content

Commit

Permalink
fix(analytic-util): convert the brands and billingAddressRequiredFiel…
Browse files Browse the repository at this point in the history
…ds to string when exists (#2798)
  • Loading branch information
longyulongyu authored Aug 19, 2024
1 parent e75df95 commit 2e682c4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/lib/src/core/Analytics/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import CardInputDefaultProps from '../../components/Card/components/CardInput/de
import { DEFAULT_CARD_GROUP_TYPES } from '../../components/internal/SecuredFields/lib/constants';
import { notFalsy } from '../../utils/commonUtils';

const MAX_LENGTH = 128;
export const getUTCTimestamp = () => Date.now();

/**
Expand Down Expand Up @@ -139,19 +140,17 @@ export const getCardConfigData = (cardProps: CardConfiguration): CardConfigData
showKCPType = countryCode?.toLowerCase() === 'kr' ? 'atStart' : 'auto';
}

// Probably just for development - in real life we wouldn't expect the number of supported brands to push the endpoint limit on 128 chars
let brandsStr = brands.toString();
if (brandsStr.length > 128) {
brandsStr = brandsStr.substring(0, 124);
}
// @ts-ignore commenting out props until endpoint is ready
const configData: CardConfigData = {
autoFocus,
...(billingAddressAllowedCountries?.length > 0 && { billingAddressAllowedCountries: billingAddressAllowedCountries.toString() }),
...(billingAddressAllowedCountries?.length > 0 && {
billingAddressAllowedCountries: billingAddressAllowedCountries.toString().substring(0, MAX_LENGTH)
}),
billingAddressMode: billingAddressModeValue,
billingAddressRequired,
billingAddressRequiredFields: billingAddressRequiredFields.toString(),
brands: brandsStr,
billingAddressRequiredFields: billingAddressRequiredFields?.toString()?.substring(0, MAX_LENGTH),
// Probably just for development - in real life we wouldn't expect the number of supported brands to push the endpoint limit on 128 chars
brands: brands?.toString()?.substring(0, MAX_LENGTH),
challengeWindowSize,
disableIOSArrowKeys,
doBinLookup,
Expand Down

0 comments on commit 2e682c4

Please sign in to comment.