From 7e79dfaaa86b46a208f0ee95b0f118a768594d7e Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Thu, 25 Apr 2024 01:38:26 +0530 Subject: [PATCH] fix june trigger (#2145) * fix sending track multiple times * add missing imports * replace track with page method --- packages/www/components/ApiKeys/index.tsx | 6 +++++- packages/www/components/Header/index.tsx | 14 ++++++++++--- packages/www/components/Sidebar/index.tsx | 17 +++++++++++++-- .../MultistreamTargetsTable/index.tsx | 6 +++++- .../www/components/StreamDetails/Record.tsx | 7 ++++++- .../StreamDetails/StreamPlayerBox/index.tsx | 21 ++++++++++++++++--- .../StreamDetails/StreamSetupBox.tsx | 7 ++++++- .../www/components/UsageSummary/index.tsx | 8 +++++-- packages/www/hooks/use-june.tsx | 1 - packages/www/hooks/use-logged-in.tsx | 15 ++++++++++--- .../www/pages/dashboard/billing/index.tsx | 6 +++++- packages/www/pages/register.tsx | 8 +++++-- 12 files changed, 95 insertions(+), 21 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 = [] }) => {