From 0290edfa33aee31fef8112cc7b16820213b656e7 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:46:49 -0500 Subject: [PATCH] Filter metrics for internal users (#10943) --- .../Linodes/LinodeCreatev2/Actions.tsx | 10 +++++-- .../AnsibleIntegrationResources.tsx | 17 +++++++---- .../ApiAwarenessModal/ApiAwarenessModal.tsx | 11 +++++-- .../ApiAwarenessModal/CurlTabPanel.tsx | 27 +++++++++++------ .../ApiAwarenessModal/GoSDKResources.tsx | 11 +++++-- .../ApiAwarenessModal/LinodeCLIPanel.tsx | 30 +++++++++++-------- .../ApiAwarenessModal/PythonSDKResources.tsx | 11 +++++-- .../TerraformIntegrationResources.tsx | 17 +++++++---- .../LinodesCreate/CodeBlock/CodeBlock.tsx | 4 ++- 9 files changed, 92 insertions(+), 46 deletions(-) diff --git a/packages/manager/src/features/Linodes/LinodeCreatev2/Actions.tsx b/packages/manager/src/features/Linodes/LinodeCreatev2/Actions.tsx index d5a706eb31d..0f95404a91c 100644 --- a/packages/manager/src/features/Linodes/LinodeCreatev2/Actions.tsx +++ b/packages/manager/src/features/Linodes/LinodeCreatev2/Actions.tsx @@ -6,6 +6,7 @@ import { Box } from 'src/components/Box'; import { Button } from 'src/components/Button/Button'; import { LD_DX_TOOLS_METRICS_KEYS } from 'src/constants'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsAkamaiAccount } from 'src/hooks/useIsAkamaiAccount'; import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck'; import { sendApiAwarenessClickEvent } from 'src/utilities/analytics/customEventAnalytics'; import { sendLinodeCreateFormInputEvent } from 'src/utilities/analytics/formEventAnalytics'; @@ -23,6 +24,7 @@ export const Actions = () => { const flags = useFlags(); const ldClient = useLDClient(); const { params } = useLinodeCreateQueryParams(); + const { isAkamaiAccount: isInternalAccount } = useIsAkamaiAccount(); const [isAPIAwarenessModalOpen, setIsAPIAwarenessModalOpen] = useState(false); @@ -51,10 +53,12 @@ export const Actions = () => { if (await trigger()) { // If validation is successful, we open the dialog. setIsAPIAwarenessModalOpen(true); + if (!isInternalAccount) { + ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.OPEN_MODAL, { + variation: apicliButtonCopy, + }); + } - ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.OPEN_MODAL, { - variation: apicliButtonCopy, - }); ldClient?.flush(); } else { scrollErrorIntoView(undefined, { behavior: 'smooth' }); diff --git a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/AnsibleIntegrationResources.tsx b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/AnsibleIntegrationResources.tsx index 1df0644d3f0..396b631bad1 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/AnsibleIntegrationResources.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/AnsibleIntegrationResources.tsx @@ -5,6 +5,7 @@ import { ResourceLinks } from 'src/components/EmptyLandingPageResources/Resource import { Typography } from 'src/components/Typography'; import { LD_DX_TOOLS_METRICS_KEYS } from 'src/constants'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsAkamaiAccount } from 'src/hooks/useIsAkamaiAccount'; import type { ResourcesLinks } from 'src/components/EmptyLandingPageResources/ResourcesLinksTypes'; @@ -42,16 +43,20 @@ export const gettingStartedGuides: ResourcesLinks['links'] = [ export const AnsibleIntegrationResources = () => { const ldClient = useLDClient(); const flags = useFlags(); + const { isAkamaiAccount: isInternalAccount } = useIsAkamaiAccount(); const apicliButtonCopy = flags?.testdxtoolabexperiment; const handleClick = () => { - ldClient?.track( - LD_DX_TOOLS_METRICS_KEYS.INTEGRATION_ANSIBLE_RESOURCE_LINKS, - { - variation: apicliButtonCopy, - } - ); + if (!isInternalAccount) { + ldClient?.track( + LD_DX_TOOLS_METRICS_KEYS.INTEGRATION_ANSIBLE_RESOURCE_LINKS, + { + variation: apicliButtonCopy, + } + ); + } + ldClient?.flush(); }; return ( diff --git a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/ApiAwarenessModal.tsx b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/ApiAwarenessModal.tsx index 6bedd03c86a..9d51b921b93 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/ApiAwarenessModal.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/ApiAwarenessModal.tsx @@ -14,6 +14,7 @@ import { Tabs } from 'src/components/Tabs/Tabs'; import { Typography } from 'src/components/Typography'; import { LD_DX_TOOLS_METRICS_KEYS } from 'src/constants'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsAkamaiAccount } from 'src/hooks/useIsAkamaiAccount'; import { useInProgressEvents } from 'src/queries/events/events'; import { sendApiAwarenessClickEvent } from 'src/utilities/analytics/customEventAnalytics'; @@ -63,6 +64,7 @@ export const ApiAwarenessModal = (props: ApiAwarenessModalProps) => { const ldClient = useLDClient(); const history = useHistory(); const { data: events } = useInProgressEvents(); + const { isAkamaiAccount: isInternalAccount } = useIsAkamaiAccount(); const linodeCreationEvent = events?.find( (event) => @@ -97,9 +99,12 @@ export const ApiAwarenessModal = (props: ApiAwarenessModalProps) => { : undefined; if (trackingKey) { - ldClient?.track(trackingKey, { - variation: apicliButtonCopy, - }); + if (!isInternalAccount) { + ldClient?.track(trackingKey, { + variation: apicliButtonCopy, + }); + } + ldClient?.flush(); } }; diff --git a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/CurlTabPanel.tsx b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/CurlTabPanel.tsx index a7fb9bfddd6..872b2ca8950 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/CurlTabPanel.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/CurlTabPanel.tsx @@ -7,6 +7,7 @@ import { SafeTabPanel } from 'src/components/Tabs/SafeTabPanel'; import { Typography } from 'src/components/Typography'; import { LD_DX_TOOLS_METRICS_KEYS } from 'src/constants'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsAkamaiAccount } from 'src/hooks/useIsAkamaiAccount'; import { sendApiAwarenessClickEvent } from 'src/utilities/analytics/customEventAnalytics'; import { generateCurlCommand } from 'src/utilities/codesnippets/generate-cURL'; @@ -24,6 +25,7 @@ export const CurlTabPanel = ({ index, payLoad, title }: CurlTabPanelProps) => { const flags = useFlags(); const ldClient = useLDClient(); const theme = useTheme(); + const { isAkamaiAccount: isInternalAccount } = useIsAkamaiAccount(); const curlCommand = useMemo( () => generateCurlCommand(payLoad, '/linode/instances'), [payLoad] @@ -36,9 +38,12 @@ export const CurlTabPanel = ({ index, payLoad, title }: CurlTabPanelProps) => { { sendApiAwarenessClickEvent('link', 'personal access token'); - ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.CURL_RESOURCE_LINKS, { - variation: apicliButtonCopy, - }); + if (!isInternalAccount) { + ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.CURL_RESOURCE_LINKS, { + variation: apicliButtonCopy, + }); + } + ldClient?.flush(); }} to="/profile/tokens" @@ -53,10 +58,12 @@ export const CurlTabPanel = ({ index, payLoad, title }: CurlTabPanelProps) => { 'link', 'Get Started with the Linode API' ); + if (!isInternalAccount) { + ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.CURL_RESOURCE_LINKS, { + variation: apicliButtonCopy, + }); + } - ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.CURL_RESOURCE_LINKS, { - variation: apicliButtonCopy, - }); ldClient?.flush(); }} to="https://www.linode.com/docs/products/tools/api/get-started/" @@ -67,10 +74,12 @@ export const CurlTabPanel = ({ index, payLoad, title }: CurlTabPanelProps) => { { sendApiAwarenessClickEvent('link', 'Linode API Guides'); + if (!isInternalAccount) { + ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.CURL_RESOURCE_LINKS, { + variation: apicliButtonCopy, + }); + } - ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.CURL_RESOURCE_LINKS, { - variation: apicliButtonCopy, - }); ldClient?.flush(); }} to="https://www.linode.com/docs/products/tools/api/guides/" diff --git a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/GoSDKResources.tsx b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/GoSDKResources.tsx index cc843e1be04..9f3d8ac7b9f 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/GoSDKResources.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/GoSDKResources.tsx @@ -5,6 +5,7 @@ import { ResourceLinks } from 'src/components/EmptyLandingPageResources/Resource import { Typography } from 'src/components/Typography'; import { LD_DX_TOOLS_METRICS_KEYS } from 'src/constants'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsAkamaiAccount } from 'src/hooks/useIsAkamaiAccount'; import type { ResourcesLinks } from 'src/components/EmptyLandingPageResources/ResourcesLinksTypes'; @@ -27,13 +28,17 @@ export const gettingStartedGuides: ResourcesLinks['links'] = [ export const GoSDKResources = () => { const ldClient = useLDClient(); const flags = useFlags(); + const { isAkamaiAccount: isInternalAccount } = useIsAkamaiAccount(); const apicliButtonCopy = flags?.testdxtoolabexperiment; const handleClick = () => { - ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.SDK_GO_RESOURCE_LINKS, { - variation: apicliButtonCopy, - }); + if (!isInternalAccount) { + ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.SDK_GO_RESOURCE_LINKS, { + variation: apicliButtonCopy, + }); + } + ldClient?.flush(); }; return ( diff --git a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/LinodeCLIPanel.tsx b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/LinodeCLIPanel.tsx index 6d4b252b9fe..215be0d306d 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/LinodeCLIPanel.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/LinodeCLIPanel.tsx @@ -6,6 +6,7 @@ import { SafeTabPanel } from 'src/components/Tabs/SafeTabPanel'; import { Typography } from 'src/components/Typography'; import { LD_DX_TOOLS_METRICS_KEYS } from 'src/constants'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsAkamaiAccount } from 'src/hooks/useIsAkamaiAccount'; import { sendApiAwarenessClickEvent } from 'src/utilities/analytics/customEventAnalytics'; import { generateCLICommand } from 'src/utilities/codesnippets/generate-cli'; @@ -26,6 +27,7 @@ export const LinodeCLIPanel = ({ }: LinodeCLIPanelProps) => { const ldClient = useLDClient(); const flags = useFlags(); + const { isAkamaiAccount: isInternalAccount } = useIsAkamaiAccount(); const cliCommand = useMemo(() => generateCLICommand(payLoad), [payLoad]); const apicliButtonCopy = flags?.testdxtoolabexperiment; @@ -40,12 +42,14 @@ export const LinodeCLIPanel = ({ 'link', 'Install and Configure the Linode CLI' ); - ldClient?.track( - LD_DX_TOOLS_METRICS_KEYS.LINODE_CLI_RESOURCE_LINKS, - { - variation: apicliButtonCopy, - } - ); + if (!isInternalAccount) { + ldClient?.track( + LD_DX_TOOLS_METRICS_KEYS.LINODE_CLI_RESOURCE_LINKS, + { + variation: apicliButtonCopy, + } + ); + } ldClient?.flush(); }} to="https://www.linode.com/docs/products/tools/cli/guides/install/" @@ -57,12 +61,14 @@ export const LinodeCLIPanel = ({ { sendApiAwarenessClickEvent('link', 'Linode CLI Guides'); - ldClient?.track( - LD_DX_TOOLS_METRICS_KEYS.LINODE_CLI_RESOURCE_LINKS, - { - variation: apicliButtonCopy, - } - ); + if (!isInternalAccount) { + ldClient?.track( + LD_DX_TOOLS_METRICS_KEYS.LINODE_CLI_RESOURCE_LINKS, + { + variation: apicliButtonCopy, + } + ); + } ldClient?.flush(); }} to="https://www.linode.com/docs/products/tools/cli/guides/" diff --git a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/PythonSDKResources.tsx b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/PythonSDKResources.tsx index e42eff29963..1a1271c3d44 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/PythonSDKResources.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/PythonSDKResources.tsx @@ -5,6 +5,7 @@ import { ResourceLinks } from 'src/components/EmptyLandingPageResources/Resource import { Typography } from 'src/components/Typography'; import { LD_DX_TOOLS_METRICS_KEYS } from 'src/constants'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsAkamaiAccount } from 'src/hooks/useIsAkamaiAccount'; import type { ResourcesLinks } from 'src/components/EmptyLandingPageResources/ResourcesLinksTypes'; @@ -27,13 +28,17 @@ export const gettingStartedGuides: ResourcesLinks['links'] = [ export const PythonSDKResources = () => { const ldClient = useLDClient(); const flags = useFlags(); + const { isAkamaiAccount: isInternalAccount } = useIsAkamaiAccount(); const apicliButtonCopy = flags?.testdxtoolabexperiment; const handleClick = () => { - ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.SDK_PYTHON_RESOURCE_LINKS, { - variation: apicliButtonCopy, - }); + if (!isInternalAccount) { + ldClient?.track(LD_DX_TOOLS_METRICS_KEYS.SDK_PYTHON_RESOURCE_LINKS, { + variation: apicliButtonCopy, + }); + } + ldClient?.flush(); }; return ( diff --git a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/TerraformIntegrationResources.tsx b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/TerraformIntegrationResources.tsx index 621571ae457..b2d31558b55 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/TerraformIntegrationResources.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/ApiAwarenessModal/TerraformIntegrationResources.tsx @@ -5,6 +5,7 @@ import { ResourceLinks } from 'src/components/EmptyLandingPageResources/Resource import { Typography } from 'src/components/Typography'; import { LD_DX_TOOLS_METRICS_KEYS } from 'src/constants'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsAkamaiAccount } from 'src/hooks/useIsAkamaiAccount'; import type { ResourcesLinks } from 'src/components/EmptyLandingPageResources/ResourcesLinksTypes'; @@ -48,16 +49,20 @@ export const gettingStartedGuides: ResourcesLinks['links'] = [ export const TerraformIntegrationResources = () => { const ldClient = useLDClient(); const flags = useFlags(); + const { isAkamaiAccount: isInternalAccount } = useIsAkamaiAccount(); const apicliButtonCopy = flags?.testdxtoolabexperiment; const handleClick = () => { - ldClient?.track( - LD_DX_TOOLS_METRICS_KEYS.INTEGRATION_TERRAFORM_RESOURCE_LINKS, - { - variation: apicliButtonCopy, - } - ); + if (!isInternalAccount) { + ldClient?.track( + LD_DX_TOOLS_METRICS_KEYS.INTEGRATION_TERRAFORM_RESOURCE_LINKS, + { + variation: apicliButtonCopy, + } + ); + } + ldClient?.flush(); }; return ( diff --git a/packages/manager/src/features/Linodes/LinodesCreate/CodeBlock/CodeBlock.tsx b/packages/manager/src/features/Linodes/LinodesCreate/CodeBlock/CodeBlock.tsx index b300d210e87..9b97e149287 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/CodeBlock/CodeBlock.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/CodeBlock/CodeBlock.tsx @@ -2,6 +2,7 @@ import { useLDClient } from 'launchdarkly-react-client-sdk'; import React from 'react'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsAkamaiAccount } from 'src/hooks/useIsAkamaiAccount'; import { sendApiAwarenessClickEvent } from 'src/utilities/analytics/customEventAnalytics'; import { @@ -20,6 +21,7 @@ export interface CodeBlockProps { export const CodeBlock = (props: CodeBlockProps) => { const flags = useFlags(); const ldClient = useLDClient(); + const { isAkamaiAccount: isInternalAccount } = useIsAkamaiAccount(); const { command, commandType, language, ldTrackingKey } = props; @@ -27,7 +29,7 @@ export const CodeBlock = (props: CodeBlockProps) => { const handleCopyIconClick = () => { sendApiAwarenessClickEvent('Copy Icon', commandType); - if (ldTrackingKey) { + if (ldTrackingKey && !isInternalAccount) { ldClient?.track(ldTrackingKey, { variation: apicliButtonCopy, });