Skip to content

Commit

Permalink
feat(dashboard): improve telemetry for env (#7571)
Browse files Browse the repository at this point in the history
  • Loading branch information
scopsy authored Jan 23, 2025
1 parent 692100c commit 88635d4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
7 changes: 7 additions & 0 deletions apps/dashboard/src/components/create-environment-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { useForm } from 'react-hook-form';
import { RiAddLine, RiArrowRightSLine } from 'react-icons/ri';
import { useNavigate } from 'react-router-dom';
import { z } from 'zod';
import { useTelemetry } from '../hooks/use-telemetry';
import { TelemetryEvent } from '../utils/telemetry';
import { ColorPicker } from './primitives/color-picker';
import { showErrorToast, showSuccessToast } from './primitives/sonner-helpers';
import { Tooltip, TooltipContent, TooltipTrigger } from './primitives/tooltip';
Expand Down Expand Up @@ -74,6 +76,7 @@ export const CreateEnvironmentButton = (props: CreateEnvironmentButtonProps) =>
const { mutateAsync, isPending } = useCreateEnvironment();
const { subscription } = useFetchSubscription();
const navigate = useNavigate();
const track = useTelemetry();

const isBusinessTier = subscription?.apiServiceLevel === ApiServiceLevelEnum.BUSINESS;
const isTrialActive = subscription?.trial?.isActive;
Expand Down Expand Up @@ -109,6 +112,10 @@ export const CreateEnvironmentButton = (props: CreateEnvironmentButtonProps) =>
};

const handleClick = () => {
track(TelemetryEvent.CREATE_ENVIRONMENT_CLICK, {
createAllowed: !!canCreateEnvironment,
});

if (!canCreateEnvironment) {
navigate(ROUTES.SETTINGS_BILLING);
return;
Expand Down
9 changes: 9 additions & 0 deletions apps/dashboard/src/pages/environments.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { PageMeta } from '@/components/page-meta';
import { useEffect } from 'react';
import { CreateEnvironmentButton } from '../components/create-environment-button';
import { DashboardLayout } from '../components/dashboard-layout';
import { EnvironmentsList } from '../components/environments-list';
import { useTelemetry } from '../hooks/use-telemetry';
import { TelemetryEvent } from '../utils/telemetry';

export function EnvironmentsPage() {
const track = useTelemetry();

useEffect(() => {
track(TelemetryEvent.ENVIRONMENTS_PAGE_VIEWED);
}, [track]);

return (
<>
<PageMeta title={`Environments`} />
Expand Down
14 changes: 6 additions & 8 deletions apps/dashboard/src/pages/workflows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const WorkflowsPage = () => {
buildRoute(ROUTES.TEMPLATE_STORE_CREATE_WORKFLOW, {
environmentSlug: environmentSlug || '',
templateId: template.id,
})
}) + '?source=template-store-card-row'
);
};

Expand Down Expand Up @@ -183,14 +183,13 @@ export const WorkflowsPage = () => {
</DropdownMenuItem>
<DropdownMenuItem
className="cursor-pointer"
onSelect={() =>
onSelect={() => {
navigate(
buildRoute(ROUTES.TEMPLATE_STORE, {
environmentSlug: environmentSlug || '',
source: 'create-workflow-dropdown',
})
)
}
}) + '?source=create-workflow-dropdown'
);
}}
>
<RiFileMarkedLine />
View Workflow Gallery
Expand Down Expand Up @@ -224,8 +223,7 @@ export const WorkflowsPage = () => {
navigate(
buildRoute(ROUTES.TEMPLATE_STORE, {
environmentSlug: environmentSlug || '',
source: 'start-with',
})
}) + '?source=start-with'
)
}
trailingIcon={RiArrowRightSLine}
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/src/utils/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ export enum TelemetryEvent {
CREATE_WORKFLOW_CLICK = 'Create Workflow Click',
GENERATE_WORKFLOW_CLICK = 'Generate Workflow Click',
TEMPLATE_WORKFLOW_CLICK = 'Template Workflow Click',
ENVIRONMENTS_PAGE_VIEWED = 'Environments Page Viewed',
CREATE_ENVIRONMENT_CLICK = 'Create Environment Click',
}

0 comments on commit 88635d4

Please sign in to comment.