Remove analytics and add more update headers

This commit is contained in:
Gregory Schier
2025-02-24 06:31:49 -08:00
parent af7782c93b
commit 05ac836265
62 changed files with 146 additions and 519 deletions

View File

@@ -4,7 +4,6 @@ import type { HTMLAttributes, ReactNode } from 'react';
import { forwardRef, useImperativeHandle, useRef } from 'react';
import type { HotkeyAction } from '../../hooks/useHotKey';
import { useFormattedHotkey, useHotKey } from '../../hooks/useHotKey';
import { trackEvent } from '../../lib/analytics';
import { Icon } from './Icon';
import { LoadingIcon } from './LoadingIcon';
@@ -22,7 +21,6 @@ export type ButtonProps = Omit<HTMLAttributes<HTMLButtonElement>, 'color' | 'onC
leftSlot?: ReactNode;
rightSlot?: ReactNode;
hotkeyAction?: HotkeyAction;
event?: string | { id: string; [attr: string]: number | string };
};
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
@@ -43,7 +41,6 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
hotkeyAction,
title,
onClick,
event,
...props
}: ButtonProps,
ref,
@@ -107,12 +104,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
type={type}
className={classes}
disabled={disabled}
onClick={(e) => {
onClick?.(e);
if (event != null) {
trackEvent('button', 'click', typeof event === 'string' ? { id: event } : event);
}
}}
onClick={onClick}
onDoubleClick={(e) => {
// Kind of a hack? This prevents double-clicks from going through buttons. For example, when
// double-clicking the workspace header to toggle window maximization

View File

@@ -1,6 +1,5 @@
import classNames from 'classnames';
import { type ReactNode } from 'react';
import { trackEvent } from '../../lib/analytics';
import { Icon } from './Icon';
import { HStack } from './Stacks';
@@ -13,7 +12,6 @@ export interface CheckboxProps {
inputWrapperClassName?: string;
hideLabel?: boolean;
fullWidth?: boolean;
event?: string;
}
export function Checkbox({
@@ -25,7 +23,6 @@ export function Checkbox({
title,
hideLabel,
fullWidth,
event,
}: CheckboxProps) {
return (
<HStack as="label" space={2} className={classNames(className, 'text-text mr-auto')}>
@@ -42,9 +39,6 @@ export function Checkbox({
disabled={disabled}
onChange={() => {
onChange(checked === 'indeterminate' ? true : !checked);
if (event != null) {
trackEvent('button', 'click', { id: event, checked: checked ? 'on' : 'off' });
}
}}
/>
<div className="absolute inset-0 flex items-center justify-center">

View File

@@ -1,15 +1,13 @@
import { Link as RouterLink } from '@tanstack/react-router';
import classNames from 'classnames';
import type { HTMLAttributes } from 'react';
import { Link as RouterLink } from '@tanstack/react-router';
import { trackEvent } from '../../lib/analytics';
import { Icon } from './Icon';
interface Props extends HTMLAttributes<HTMLAnchorElement> {
href: string;
event?: string;
}
export function Link({ href, children, className, event, ...other }: Props) {
export function Link({ href, children, className, ...other }: Props) {
const isExternal = href.match(/^https?:\/\//);
className = classNames(className, 'relative underline hover:text-violet-600');
@@ -23,9 +21,6 @@ export function Link({ href, children, className, event, ...other }: Props) {
className={classNames(className, 'pr-4 inline-flex items-center')}
onClick={(e) => {
e.preventDefault();
if (event != null) {
trackEvent('link', 'click', { id: event });
}
}}
{...other}
>

View File

@@ -261,7 +261,6 @@ export const PairEditor = forwardRef<PairEditorRef, PairEditorProps>(function Pa
variant="border"
className="m-2"
size="xs"
event="pairs.reveal-more"
>
Show {pairs.length - MAX_INITIAL_PAIRS} More
</Button>

View File

@@ -2,18 +2,17 @@ import classNames from 'classnames';
import { useRef } from 'react';
import { useStateWithDeps } from '../../hooks/useStateWithDeps';
import type { IconProps } from './Icon';
import type { IconButtonProps } from './IconButton';
import { IconButton } from './IconButton';
import { HStack } from './Stacks';
interface Props<T extends string> {
options: { value: T; label: string; icon: IconProps['icon']; event?: IconButtonProps['event'] }[];
options: { value: T; label: string; icon: IconProps['icon'] }[];
onChange: (value: T) => void;
value: T;
name: string;
}
export function SegmentedControl<T extends string>({ value, onChange, options, name }: Props<T>) {
export function SegmentedControl<T extends string>({ value, onChange, options }: Props<T>) {
const [selectedValue, setSelectedValue] = useStateWithDeps<T>(value, [value]);
const containerRef = useRef<HTMLDivElement>(null);
return (
@@ -45,14 +44,13 @@ export function SegmentedControl<T extends string>({ value, onChange, options, n
<IconButton
size="xs"
variant="solid"
color={isActive ? "secondary" : undefined}
color={isActive ? 'secondary' : undefined}
role="radio"
event={{ id: name, value: String(o.value) }}
tabIndex={isSelected ? 0 : -1}
className={classNames(
isActive && '!text-text',
'!px-1.5 !w-auto',
'focus:ring-border-focus',
isActive && '!text-text',
'!px-1.5 !w-auto',
'focus:ring-border-focus',
)}
key={i}
title={o.label}

View File

@@ -2,7 +2,6 @@ import classNames from 'classnames';
import type { CSSProperties, ReactNode } from 'react';
import { useState } from 'react';
import { useOsInfo } from '../../hooks/useOsInfo';
import { trackEvent } from '../../lib/analytics';
import type { ButtonProps } from './Button';
import { Button } from './Button';
import { Label } from './Label';
@@ -22,7 +21,6 @@ export interface SelectProps<T extends string> {
onChange: (value: T) => void;
size?: ButtonProps['size'];
className?: string;
event?: string;
disabled?: boolean;
}
@@ -38,7 +36,6 @@ export function Select<T extends string>({
leftSlot,
onChange,
className,
event,
size = 'md',
}: SelectProps<T>) {
const osInfo = useOsInfo();
@@ -48,9 +45,6 @@ export function Select<T extends string>({
const handleChange = (value: T) => {
onChange?.(value);
if (event != null) {
trackEvent('select', 'click', { id: event, value });
}
};
return (

View File

@@ -1,7 +1,6 @@
import classNames from 'classnames';
import type { ReactNode } from 'react';
import { memo, useEffect, useRef } from 'react';
import { trackEvent } from '../../../lib/analytics';
import { Icon } from '../Icon';
import type { RadioDropdownProps } from '../RadioDropdown';
import { RadioDropdown } from '../RadioDropdown';
@@ -104,14 +103,7 @@ export function Tabs({
onChange={t.options.onChange}
>
<button
onClick={
isActive
? undefined
: () => {
trackEvent('tab', 'click', { label, tab: t.value });
onChangeValue(t.value);
}
}
onClick={isActive ? undefined : () => onChangeValue(t.value)}
className={btnClassName}
>
{option && 'shortLabel' in option && option.shortLabel
@@ -133,14 +125,7 @@ export function Tabs({
return (
<button
key={t.value}
onClick={
isActive
? undefined
: () => {
trackEvent('tab', 'click', { label, tab: t.value });
onChangeValue(t.value);
}
}
onClick={isActive ? undefined : () => onChangeValue(t.value)}
className={btnClassName}
>
{t.label}