From 3b0b372f75f428a7f40b39c6df0fd19e62631316 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Thu, 26 Oct 2023 14:28:12 +0300 Subject: [PATCH] feat: playground token input usage tracking (#5157) Track usage of the new token input Closes # [1-1551](https://linear.app/unleash/issue/1-1551/plausible-track-usage-of-token-input) --------- Signed-off-by: andreas-unleash --- .../component/playground/Playground/AdvancedPlayground.tsx | 6 ++++++ frontend/src/hooks/usePlausibleTracker.ts | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/component/playground/Playground/AdvancedPlayground.tsx b/frontend/src/component/playground/Playground/AdvancedPlayground.tsx index d0e00bb063..b1cf2701eb 100644 --- a/frontend/src/component/playground/Playground/AdvancedPlayground.tsx +++ b/frontend/src/component/playground/Playground/AdvancedPlayground.tsx @@ -22,6 +22,7 @@ import { AdvancedPlaygroundResultsTable } from './AdvancedPlaygroundResultsTable import { AdvancedPlaygroundResponseSchema } from 'openapi'; import { createLocalStorage } from 'utils/createLocalStorage'; import { BadRequestError } from 'utils/apiUtils'; +import { usePlausibleTracker } from '../../../hooks/usePlausibleTracker'; const StyledAlert = styled(Alert)(({ theme }) => ({ marginBottom: theme.spacing(3), @@ -40,6 +41,7 @@ export const AdvancedPlayground: VFC<{ 'AdvancedPlayground:v1', defaultSettings, ); + const { trackEvent } = usePlausibleTracker(); const { environments: availableEnvironments } = useEnvironments(); const theme = useTheme(); @@ -182,6 +184,10 @@ export const AdvancedPlayground: VFC<{ setHasFormBeenSubmitted(true); + if (token) { + trackEvent('playground_token_input_used'); + } + await evaluatePlaygroundContext(environments, projects, context, () => { setURLParameters(); setValue({ diff --git a/frontend/src/hooks/usePlausibleTracker.ts b/frontend/src/hooks/usePlausibleTracker.ts index 00f1a60a00..d1979e1502 100644 --- a/frontend/src/hooks/usePlausibleTracker.ts +++ b/frontend/src/hooks/usePlausibleTracker.ts @@ -50,7 +50,8 @@ export type CustomEvents = | 'feature-naming-pattern' | 'project-mode' | 'dependent_features' - | 'oss-segments-splash-screen'; + | 'oss-segments-splash-screen' + | 'playground_token_input_used'; export const usePlausibleTracker = () => { const plausible = useContext(PlausibleContext);