From a509336bef437422d40a1f544b9db2d0c4673e09 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 21 Mar 2024 13:33:48 -0700 Subject: [PATCH] Fixed UTM display. --- src/app/(main)/profile/LanguageSetting.tsx | 2 +- src/queries/analytics/reports/getUTM.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app/(main)/profile/LanguageSetting.tsx b/src/app/(main)/profile/LanguageSetting.tsx index 3004af1e..41ff3dde 100644 --- a/src/app/(main)/profile/LanguageSetting.tsx +++ b/src/app/(main)/profile/LanguageSetting.tsx @@ -20,7 +20,7 @@ export function LanguageSetting() { const handleReset = () => saveLocale(DEFAULT_LOCALE); - const renderValue = (value: string | number) => languages[value].label; + const renderValue = (value: string | number) => languages?.[value]?.label; return ( diff --git a/src/queries/analytics/reports/getUTM.ts b/src/queries/analytics/reports/getUTM.ts index 01269926..c7d39352 100644 --- a/src/queries/analytics/reports/getUTM.ts +++ b/src/queries/analytics/reports/getUTM.ts @@ -99,12 +99,13 @@ function parseParameters(data: any[]) { for (const [key, value] of searchParams) { if (key.match(/^utm_(\w+)$/)) { + const name = decodeURIComponent(value); if (!obj[key]) { - obj[key] = { [value]: +num }; - } else if (!obj[key][value]) { - obj[key][value] = +num; + obj[key] = { [name]: +num }; + } else if (!obj[key][name]) { + obj[key][name] = +num; } else { - obj[key][value] += +num; + obj[key][name] += +num; } } }