From f044a451b9c3cfc524a1094e42d353725e9073d0 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 23 Apr 2024 03:22:38 +0530 Subject: [PATCH 1/3] fix sending track multiple times --- packages/www/components/ApiKeys/index.tsx | 6 +++++- packages/www/components/Header/index.tsx | 14 ++++++++++--- packages/www/components/Sidebar/index.tsx | 12 +++++++++-- .../MultistreamTargetsTable/index.tsx | 6 +++++- .../www/components/StreamDetails/Record.tsx | 7 ++++++- .../StreamDetails/StreamPlayerBox/index.tsx | 21 ++++++++++++++++--- .../StreamDetails/StreamSetupBox.tsx | 6 +++++- .../www/components/UsageSummary/index.tsx | 6 +++++- packages/www/hooks/use-june.tsx | 1 - .../www/pages/dashboard/billing/index.tsx | 6 +++++- packages/www/pages/register.tsx | 8 +++++-- 11 files changed, 76 insertions(+), 17 deletions(-) diff --git a/packages/www/components/ApiKeys/index.tsx b/packages/www/components/ApiKeys/index.tsx index 725137f6f5..351f652c43 100644 --- a/packages/www/components/ApiKeys/index.tsx +++ b/packages/www/components/ApiKeys/index.tsx @@ -40,6 +40,10 @@ const ApiKeysTable = ({ [userId] ); + const trackEvent = useCallback(() => { + if (June) June.track(events.developer.apiKeyCreate); + }, [June]); + return ( <> { - June.track(events.developer.apiKeyCreate); + trackEvent(); return createDialogState.onOn(); })} /> diff --git a/packages/www/components/Header/index.tsx b/packages/www/components/Header/index.tsx index 70c7ac7194..ef916e40a6 100644 --- a/packages/www/components/Header/index.tsx +++ b/packages/www/components/Header/index.tsx @@ -18,7 +18,7 @@ import SupportIcon from "../../public/img/icons/support.svg"; import DocumentationIcon from "../../public/img/icons/documentation.svg"; import PolygonIcon from "../../public/img/icons/polygonWithoutBorderBottom.svg"; import CheckedIcon from "../../public/img/icons/checked.svg"; -import { useEffect, useState, useRef } from "react"; +import { useEffect, useState, useRef, useCallback } from "react"; import { useApi, useHubspotForm } from "hooks"; import { useJune, events } from "hooks/use-june"; @@ -69,6 +69,14 @@ const Header = ({ breadcrumbs = [] }) => { } }, [user]); + const trackEvent = useCallback(() => { + if (June) June.track(events.all.documentation); + }, [June]); + + const trackFeedbackEvent = useCallback(() => { + if (June) June.track(events.all.feedback); + }, [June]); + return ( { as={A} target="_blank" size={2} - onClick={() => June.track(events.all.documentation)} + onClick={() => trackEvent()} css={{ cursor: "default", color: "$hiContrast", @@ -134,7 +142,7 @@ const Header = ({ breadcrumbs = [] }) => {