Skip to content

Commit

Permalink
fix: add telemtry
Browse files Browse the repository at this point in the history
  • Loading branch information
scopsy committed Dec 8, 2024
1 parent 3859087 commit 0acb870
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion apps/dashboard/src/components/shared/external-link.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
import { RiBookMarkedLine, RiExternalLinkLine, RiQuestionLine } from 'react-icons/ri';
import { cn } from '@/utils/ui';
import { useTelemetry } from '@/hooks/use-telemetry';
import { TelemetryEvent } from '@/utils/telemetry';

interface ExternalLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
children: React.ReactNode;
iconClassName?: string;
variant?: 'default' | 'documentation' | 'tip';
}

export function ExternalLink({ children, className, variant = 'default', iconClassName, ...props }: ExternalLinkProps) {
export function ExternalLink({
children,
className,
variant = 'default',
iconClassName,
href,
...props
}: ExternalLinkProps) {
const telemetry = useTelemetry();

const handleClick = () => {
telemetry(TelemetryEvent.EXTERNAL_LINK_CLICKED, {
href,
variant,
});
};

return (
<a
target="_blank"
rel="noopener noreferrer"
className={cn('text-foreground-600 inline-flex items-center gap-1 hover:underline', className)}
href={href}
onClick={handleClick}
{...props}
>
{variant === 'documentation' && <RiBookMarkedLine className={cn('size-4', iconClassName)} aria-hidden="true" />}
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/utils/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export enum TelemetryEvent {
INBOX_EMBED_SUCCESS_PAGE_VIEWED = 'Inbox embed success page viewed - [Onboarding]',
WORKFLOW_PREFERENCES_OVERRIDE_USED = 'Workflow preferences override used',
EXPORT_TO_CODE_BANNER_REACTION = 'Export to Code banner reaction - [Promotional]',
EXTERNAL_LINK_CLICKED = 'External link clicked',
}

0 comments on commit 0acb870

Please sign in to comment.