From 77f037a3c445417671484b8aa635091ca8ed6f9e Mon Sep 17 00:00:00 2001 From: lyf <1910527151@qq.com> Date: Wed, 25 Sep 2024 13:08:03 +0800 Subject: [PATCH] add maidian --- app/components/auth.tsx | 16 +++++++++++++--- app/components/markdown.tsx | 11 +++++++++-- app/components/settings.tsx | 3 ++- app/utils/auth-settings-events.ts | 19 +++++++++++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 app/utils/auth-settings-events.ts diff --git a/app/components/auth.tsx b/app/components/auth.tsx index 39af25661..e19512d87 100644 --- a/app/components/auth.tsx +++ b/app/components/auth.tsx @@ -13,7 +13,10 @@ import BotIcon from "../icons/bot.svg"; import { getClientConfig } from "../config/client"; import LeftIcon from "@/app/icons/left.svg"; import { safeLocalStorage } from "@/app/utils"; - +import { + trackSettingsPageGuideToCPaymentClick, + trackAuthorizationPageButtonToCPaymentClick, +} from "../utils/auth-settings-events"; const storage = safeLocalStorage(); export function AuthPage() { @@ -22,6 +25,7 @@ export function AuthPage() { const goHome = () => navigate(Path.Home); const goChat = () => navigate(Path.Chat); const goSaas = () => { + trackAuthorizationPageButtonToCPaymentClick(); window.location.href = SAAS_CHAT_URL; }; @@ -151,11 +155,17 @@ function TopBanner() { onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} > -
+
{Locale.Auth.TopTips} - + { + trackSettingsPageGuideToCPaymentClick(); + }} + > {Locale.Settings.Access.SaasStart.ChatNow} diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index b57fd7490..86adb4928 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -21,7 +21,8 @@ import { } from "./artifacts"; import { useChatStore } from "../store"; import { IconButton } from "./button"; - +import { SAAS_CHAT_URL } from "@/app/constant"; +import { trackConversationGuideToCPaymentClick } from "../utils/auth-settings-events"; export function Mermaid(props: { code: string }) { const ref = useRef(null); const [hasError, setHasError] = useState(false); @@ -280,7 +281,13 @@ function _MarkDownContent(props: { content: string }) { const href = aProps.href || ""; const isInternal = /^\/#/i.test(href); const target = isInternal ? "_self" : aProps.target ?? "_blank"; - return ; + const handleClick = () => { + if (href === SAAS_CHAT_URL) { + trackConversationGuideToCPaymentClick(); + } + }; + + return ; }, }} > diff --git a/app/components/settings.tsx b/app/components/settings.tsx index dfc4e92e7..0e6cfadd9 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -19,7 +19,7 @@ import ConfirmIcon from "../icons/confirm.svg"; import ConnectionIcon from "../icons/connection.svg"; import CloudSuccessIcon from "../icons/cloud-success.svg"; import CloudFailIcon from "../icons/cloud-fail.svg"; - +import { trackSettingsPageGuideToCPaymentClick } from "../utils/auth-settings-events"; import { Input, List, @@ -706,6 +706,7 @@ export function Settings() { type={"primary"} text={Locale.Settings.Access.SaasStart.ChatNow} onClick={() => { + trackSettingsPageGuideToCPaymentClick(); window.location.href = SAAS_CHAT_URL; }} /> diff --git a/app/utils/auth-settings-events.ts b/app/utils/auth-settings-events.ts new file mode 100644 index 000000000..4f354c5f0 --- /dev/null +++ b/app/utils/auth-settings-events.ts @@ -0,0 +1,19 @@ +import { sendGAEvent } from "@next/third-parties/google"; + +export function trackConversationGuideToCPaymentClick() { + sendGAEvent("event", "ConversationGuideToCPaymentClick", { value: 1 }); +} + +export function trackAuthorizationPageButtonToCPaymentClick() { + sendGAEvent("event", "AuthorizationPageButtonToCPaymentClick", { value: 1 }); +} + +export function trackAuthorizationPageBannerToCPaymentClick() { + sendGAEvent("event", "AuthorizationPageBannerToCPaymentClick", { + value: 1, + }); +} + +export function trackSettingsPageGuideToCPaymentClick() { + sendGAEvent("event", "SettingsPageGuideToCPaymentClick", { value: 1 }); +}