The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update convert-currency.ts
Kiran K52120a833756
diff --git a/apps/web/lib/analytics/convert-currency.ts b/apps/web/lib/analytics/convert-currency.tsindex c338f8f81e..48797fdbd3 100644--- a/apps/web/lib/analytics/convert-currency.ts+++ b/apps/web/lib/analytics/convert-currency.ts@@ -28,10 +28,15 @@ export const convertCurrency = async ({amount: number;fxRates?: Record<string, string>;}) => {+ let fxRate: string | null = null;const currencyCode = currency.toUpperCase();const isZeroDecimalCurrency = ZERO_DECIMAL_CURRENCIES.includes(currencyCode);- const fxRate =- fxRates?.[currencyCode] ?? (await redis.hget("fxRates:usd", currencyCode)); // e.g. for MYR it'll be around 4.4++ if (fxRates) {+ fxRate = fxRates[currencyCode] ?? null;+ } else {+ fxRate = await redis.hget("fxRates:usd", currencyCode); // e.g. for MYR it'll be around 4.4+ }if (fxRate) {// convert amount to USD based on the current FX rate