📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Searchable dropdowns for custom events
Blue Mouse731744f1dac6
diff --git a/web/app/components/FeedbackModal.tsx b/web/app/components/FeedbackModal.tsxindex abfe2ddd5..262ffc77d 100644--- a/web/app/components/FeedbackModal.tsx+++ b/web/app/components/FeedbackModal.tsx@@ -234,7 +234,7 @@ const FeedbackModal = ({ isOpened, onClose }: FeedbackModalProps) => {maxLength={MAX_MESSAGE_LENGTH}placeholder={t('feedback.placeholder')}aria-label={t('feedback.inputLabel')}- error={error || false}+ error={error}disabled={isSubmitting}classes={{ textarea: 'min-h-32 resize-none' }}onChange={(event) => {diff --git a/web/app/pages/Auth/CreateNewPassword/CreateNewPassword.tsx b/web/app/pages/Auth/CreateNewPassword/CreateNewPassword.tsxindex 16321a69a..c3dd5d0eb 100644--- a/web/app/pages/Auth/CreateNewPassword/CreateNewPassword.tsx+++ b/web/app/pages/Auth/CreateNewPassword/CreateNewPassword.tsx@@ -43,6 +43,7 @@ const CreateNewPassword = () => {<Inputname='password'type='password'+ autoComplete='new-password'label={t('auth.recovery.newPassword')}hint={t('auth.common.hint', { amount: MIN_PASSWORD_CHARS })}error={actionData?.fieldErrors?.password}@@ -51,6 +52,7 @@ const CreateNewPassword = () => {<Inputname='repeat'type='password'+ autoComplete='new-password'label={t('auth.common.repeat')}error={actionData?.fieldErrors?.repeat}disabled={isSubmitting}diff --git a/web/app/pages/Auth/ForgotPassword/ForgotPassword.tsx b/web/app/pages/Auth/ForgotPassword/ForgotPassword.tsxindex 897f084b1..f16d8a9b3 100644--- a/web/app/pages/Auth/ForgotPassword/ForgotPassword.tsx+++ b/web/app/pages/Auth/ForgotPassword/ForgotPassword.tsx@@ -58,6 +58,7 @@ const ForgotPassword = () => {<Inputname='email'type='email'+ autoComplete='email'label={t('auth.common.email')}error={actionData?.fieldErrors?.email}placeholder='[email protected]'diff --git a/web/app/pages/Auth/Signin/Signin.tsx b/web/app/pages/Auth/Signin/Signin.tsxindex 205f85bc1..ad4920d13 100644--- a/web/app/pages/Auth/Signin/Signin.tsx+++ b/web/app/pages/Auth/Signin/Signin.tsx@@ -370,6 +370,7 @@ const Signin = () => {<Inputlabel={t('auth.linkAccount.enterPassword')}type='password'+ autoComplete='current-password'value={linkingPassword}onChange={(e) => setLinkingPassword(e.target.value)}disabled={isLinkingLoading}@@ -384,6 +385,8 @@ const Signin = () => {<Inputlabel={t('auth.linkAccount.enter2FA')}value={linking2FACode}+ autoComplete='one-time-code'+ inputMode='numeric'placeholder={t('auth.signin.6digitCode')}onChange={(e) => setLinking2FACode(e.target.value)}disabled={isLinkingLoading}@@ -442,6 +445,8 @@ const Signin = () => {<Inputlabel={t('profileSettings.enter2faToDisable')}value={twoFACode}+ autoComplete='one-time-code'+ inputMode='numeric'placeholder={t('auth.signin.6digitCode')}onChange={handle2FAInput}disabled={is2FALoading}@@ -548,6 +553,7 @@ const Signin = () => {<Inputname='email'type='email'+ autoComplete='email'label={t('auth.common.email')}error={getFieldError('email')}placeholder='[email protected]'@@ -557,6 +563,7 @@ const Signin = () => {<Inputname='password'type='password'+ autoComplete='current-password'label={t('auth.common.password')}labelCorner={<Linkdiff --git a/web/app/pages/Auth/Signup/InvitationSignup.tsx b/web/app/pages/Auth/Signup/InvitationSignup.tsxindex cb71ab514..7a9f4e926 100644--- a/web/app/pages/Auth/Signup/InvitationSignup.tsx+++ b/web/app/pages/Auth/Signup/InvitationSignup.tsx@@ -137,6 +137,7 @@ const InvitationSignup = () => {<Inputname='password'type='password'+ autoComplete='new-password'label={t('auth.common.password')}hint={t('auth.common.hint', { amount: MIN_PASSWORD_CHARS })}error={getFieldError('password')}diff --git a/web/app/pages/Auth/Signup/Signup.tsx b/web/app/pages/Auth/Signup/Signup.tsxindex b2e2f4437..525ff9db8 100644--- a/web/app/pages/Auth/Signup/Signup.tsx+++ b/web/app/pages/Auth/Signup/Signup.tsx@@ -304,6 +304,7 @@ const Signup = () => {<Inputname='email'type='email'+ autoComplete='email'label={t('auth.common.email')}error={getFieldError('email')}placeholder='[email protected]'@@ -314,6 +315,7 @@ const Signup = () => {<Inputname='password'type='password'+ autoComplete='new-password'label={t('auth.common.password')}hint={t('auth.common.hint', { amount: MIN_PASSWORD_CHARS })}error={getFieldError('password')}diff --git a/web/app/pages/Project/Settings/Alerts/ProjectAlertsSettings.tsx b/web/app/pages/Project/Settings/Alerts/ProjectAlertsSettings.tsxindex b8adbeb97..8a4c3e156 100644--- a/web/app/pages/Project/Settings/Alerts/ProjectAlertsSettings.tsx+++ b/web/app/pages/Project/Settings/Alerts/ProjectAlertsSettings.tsx@@ -1,6 +1,11 @@import {CheckCircleIcon,ClockIcon,+ CursorClickIcon,+ EyeIcon,+ PulseIcon,+ UsersIcon,+ WarningIcon,WarningOctagonIcon,XCircleIcon,} from '@phosphor-icons/react'@@ -12,22 +17,25 @@ import _size from 'lodash/size'import _split from 'lodash/split'import _toNumber from 'lodash/toNumber'import _values from 'lodash/values'-import React, { useEffect, useMemo, useState } from 'react'+import React, { useEffect, useMemo, useRef, useState } from 'react'import { useTranslation, Trans } from 'react-i18next'import { Link } from '~/ui/Link'import { useFetcher } from 'react-router'import { toast } from 'sonner'+import { getDimensionValues } from '~/api/v2/endpoints'import { useDeduplicateFetcherResponse } from '~/hooks/useDeduplicateFetcherResponse'import { QUERY_CONDITION, QUERY_METRIC, QUERY_TIME } from '~/lib/constants'import { Alerts } from '~/lib/models/Alerts'import type { NotificationChannel } from '~/lib/models/NotificationChannel'import { useAuth } from '~/providers/AuthProvider'+import { useTheme } from '~/providers/ThemeProvider'import type { NotificationChannelActionData } from '~/routes/notification-channel'import type { ProjectViewActionData } from '~/routes/projects.$id'import Button from '~/ui/Button'import Checkbox from '~/ui/Checkbox'import FeedbackButton from '~/ui/FeedbackButton'+import FilterValueInput from '~/ui/FilterValueInput'import Input from '~/ui/Input'import Loader from '~/ui/Loader'import Alert from '~/ui/Alert'@@ -45,6 +53,14 @@ import {import AlertTemplateEditor from './AlertTemplateEditor'import { BackButton } from '../../View/components/BackButton'+const QUERY_METRIC_ICONS: Record<string, React.ReactNode> = {+ [QUERY_METRIC.PAGE_VIEWS]: <EyeIcon className='size-4' />,+ [QUERY_METRIC.UNIQUE_PAGE_VIEWS]: <UsersIcon className='size-4' />,+ [QUERY_METRIC.ONLINE_USERS]: <PulseIcon className='size-4' />,+ [QUERY_METRIC.CUSTOM_EVENTS]: <CursorClickIcon className='size-4' />,+ [QUERY_METRIC.ERRORS]: <WarningIcon className='size-4' />,+}+interface ProjectAlertsSettingsProps {alertId?: string | nullprojectId: string@@ -65,8 +81,12 @@ const ProjectAlertsSettings = ({backLink,}: ProjectAlertsSettingsProps) => {const { isLoading: authLoading } = useAuth()+ const { theme } = useTheme()- const { t } = useTranslation('common')+ const {+ t,+ i18n: { language },+ } = useTranslation('common')const fetcher = useFetcher<ProjectViewActionData>()const channelsFetcher = useFetcher<NotificationChannelActionData>()const shouldHandleFetcherData =@@ -97,6 +117,35 @@ const ProjectAlertsSettings = ({const [availableChannels, setAvailableChannels] = useState<NotificationChannel[]>([])+ const [customEvents, setCustomEvents] = useState<string[]>([])+ const [customEventsLoading, setCustomEventsLoading] = useState(false)+ const customEventsFetchedRef = useRef(false)++ useEffect(() => {+ if (+ form.queryMetric !== QUERY_METRIC.CUSTOM_EVENTS ||+ customEventsFetchedRef.current+ ) {+ return+ }++ customEventsFetchedRef.current = true+ setCustomEventsLoading(true)+ getDimensionValues(projectId, 'event', { type: 'traffic' })+ .then(({ data }) => {+ setCustomEvents(+ (data || []).filter(+ (item): item is string => typeof item === 'string',+ ),+ )+ })+ .catch((reason) => {+ console.error('Failed to fetch custom events:', reason)+ })+ .finally(() => {+ setCustomEventsLoading(false)+ })+ }, [form.queryMetric, projectId])useEffect(() => {const fd = new FormData()@@ -546,40 +595,79 @@ const ProjectAlertsSettings = ({<Selectid='queryMetric'label={t('alert.metric')}- items={_values(queryMetricTMapping)}+ items={_values(QUERY_METRIC)}+ labelExtractor={(item) => queryMetricTMapping[item]}+ iconExtractor={(item) => (+ <span className='text-gray-500 dark:text-gray-400'>+ {QUERY_METRIC_ICONS[item]}+ </span>+ )}title={- form.queryMetric ? queryMetricTMapping[form.queryMetric] : ''+ form.queryMetric ? (+ <span className='flex items-center gap-2'>+ <span className='text-gray-500 dark:text-gray-400'>+ {QUERY_METRIC_ICONS[form.queryMetric]}+ </span>+ {queryMetricTMapping[form.queryMetric]}+ </span>+ ) : (+ ''+ )}onSelect={(item) => {- const key = _findKey(- queryMetricTMapping,- (predicate) => predicate === item,- )-- // @ts-expect-errorsetForm((prevForm) => ({...prevForm,- queryMetric: key,+ queryMetric: item,}))}}capitalise- selectedItem={- form.queryMetric- ? queryMetricTMapping[form.queryMetric]- : undefined- }+ selectedItem={form.queryMetric}/></div>{form.queryMetric === QUERY_METRIC.CUSTOM_EVENTS ? (- <Input- name='queryCustomEvent'- label={t('alert.customEvent')}- value={form.queryCustomEvent || ''}- placeholder={t('alert.customEvent')}- className='mt-4'- onChange={handleInput}- error={beenSubmitted ? errors.queryCustomEvent : null}- />+ <div className='mt-4 flex flex-col gap-1'>+ <Text+ as='span'+ className='flex leading-tight'+ size='sm'+ weight='medium'+ colour='primary'+ >+ {t('alert.customEvent')}+ </Text>+ <input+ type='hidden'+ name='queryCustomEvent'+ value={form.queryCustomEvent || ''}+ />+ <FilterValueInput+ items={customEvents}+ value={form.queryCustomEvent || ''}+ onChange={(value) =>+ setForm((prevForm) => ({+ ...prevForm,+ queryCustomEvent: value,+ }))+ }+ placeholder={t('project.filterSearchOrType')}+ column='event'+ language={language}+ isLoading={customEventsLoading}+ theme={theme}+ commitOnType+ />+ {beenSubmitted && errors.queryCustomEvent ? (+ <Text+ as='span'+ className='block'+ size='sm'+ colour='error'+ role='alert'+ >+ {errors.queryCustomEvent}+ </Text>+ ) : null}+ </div>) : null}{form.queryMetric === QUERY_METRIC.CUSTOM_EVENTS ? (<Checkboxdiff --git a/web/app/pages/Project/Settings/ProjectSettings.tsx b/web/app/pages/Project/Settings/ProjectSettings.tsxindex 3e1d4015b..55842bd23 100644--- a/web/app/pages/Project/Settings/ProjectSettings.tsx+++ b/web/app/pages/Project/Settings/ProjectSettings.tsx@@ -1432,6 +1432,7 @@ const ProjectSettings = () => {}name='captchaSecretKey'type='password'+ autoComplete='off'className='mt-4 lg:w-1/2'value={captchaSecretKey}readOnly@@ -1608,6 +1609,7 @@ const ProjectSettings = () => {<Inputname='password'type='password'+ autoComplete='new-password'label={t('project.settings.password')}value={form?.password || ''}className='mt-4 px-4 sm:px-0'diff --git a/web/app/pages/Project/Settings/tabs/Revenue.tsx b/web/app/pages/Project/Settings/tabs/Revenue.tsxindex 448b57ffd..9cbc9c361 100644--- a/web/app/pages/Project/Settings/tabs/Revenue.tsx+++ b/web/app/pages/Project/Settings/tabs/Revenue.tsx@@ -284,6 +284,7 @@ const Revenue = ({ projectId }: Props) => {<Inputname={`${provider}ApiKey`}type='password'+ autoComplete='off'label={t('project.settings.revenue.providerApiKey', {provider: config.label,})}diff --git a/web/app/pages/Project/View/components/PasswordRequiredModal.tsx b/web/app/pages/Project/View/components/PasswordRequiredModal.tsxindex f9f1b0f2d..28bbf17d9 100644--- a/web/app/pages/Project/View/components/PasswordRequiredModal.tsx+++ b/web/app/pages/Project/View/components/PasswordRequiredModal.tsx@@ -100,6 +100,7 @@ const PasswordRequiredModal = ({<Inputname='password'type='password'+ autoComplete='current-password'label={t('auth.common.password')}value={password}placeholder={t('auth.common.password')}diff --git a/web/app/pages/UserSettings/UserSettings.tsx b/web/app/pages/UserSettings/UserSettings.tsxindex ba2b8d285..05c75709d 100644--- a/web/app/pages/UserSettings/UserSettings.tsx+++ b/web/app/pages/UserSettings/UserSettings.tsx@@ -1564,6 +1564,7 @@ const UserSettings = () => {<Inputname='email'type='email'+ autoComplete='email'label={t('profileSettings.newEmail')}value={form.email}placeholder={t('auth.common.email')}@@ -1597,6 +1598,7 @@ const UserSettings = () => {label={t('profileSettings.apiKey')}name='apiKey'type='password'+ autoComplete='off'value={user.apiKey}readOnly/>@@ -1852,6 +1854,7 @@ const UserSettings = () => {<Inputname='currentPassword'type='password'+ autoComplete='current-password'label={t('profileSettings.currentPassword')}value={form.currentPassword}placeholder={t('auth.common.password')}@@ -1863,6 +1866,7 @@ const UserSettings = () => {<Inputname='password'type='password'+ autoComplete='new-password'label={t('profileSettings.newPassword')}value={form.password}placeholder={t('auth.common.password')}@@ -1873,6 +1877,7 @@ const UserSettings = () => {<Inputname='repeat'type='password'+ autoComplete='new-password'label={t('profileSettings.repeatPassword')}value={form.repeat}placeholder={t('auth.common.repeat')}@@ -2830,6 +2835,7 @@ const UserSettings = () => {<Inputname='deletePassword'type='password'+ autoComplete='current-password'label={t('profileSettings.enterPasswordToDelete')}value={deletionPassword}placeholder={t('auth.common.password')}diff --git a/web/app/pages/UserSettings/components/TwoFA.tsx b/web/app/pages/UserSettings/components/TwoFA.tsxindex 9deb80823..2638223a0 100644--- a/web/app/pages/UserSettings/components/TwoFA.tsx+++ b/web/app/pages/UserSettings/components/TwoFA.tsx@@ -152,6 +152,8 @@ const TwoFA = () => {<Inputlabel={t('profileSettings.enter2faToDisable')}value={twoFACode}+ autoComplete='one-time-code'+ inputMode='numeric'placeholder={t('profileSettings.yourOneTimeCode')}className='sm:col-span-3'onChange={handle2FAInput}@@ -219,6 +221,8 @@ const TwoFA = () => {<Inputlabel={t('profileSettings.enter2faToEnable')}value={twoFACode}+ autoComplete='one-time-code'+ inputMode='numeric'placeholder={t('profileSettings.yourOneTimeCode')}className='sm:col-span-3'onChange={handle2FAInput}diff --git a/web/app/ui/FilterValueInput.tsx b/web/app/ui/FilterValueInput.tsxindex 1bc336037..107121674 100644--- a/web/app/ui/FilterValueInput.tsx+++ b/web/app/ui/FilterValueInput.tsx@@ -126,6 +126,9 @@ interface FilterValueInputProps {isLoading?: booleantheme: stringclassName?: string+ // Commit the raw typed text on every keystroke instead of only on+ // Enter / item selection. Used in forms where the value must never be lost.+ commitOnType?: boolean}const FilterValueInput = ({@@ -139,6 +142,7 @@ const FilterValueInput = ({isLoading,theme,className,+ commitOnType,}: FilterValueInputProps) => {const { t } = useTranslation('common')const [inputValue, setInputValue] = useState('')@@ -325,6 +329,9 @@ const FilterValueInput = ({const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {const newValue = e.target.valuesetInputValue(newValue)+ if (commitOnType) {+ onChange(newValue)+ }}const handleSelectItem = (item: string) => {diff --git a/web/app/ui/Input.tsx b/web/app/ui/Input.tsxindex c1404b8ac..a6dea7e4b 100644--- a/web/app/ui/Input.tsx+++ b/web/app/ui/Input.tsx@@ -5,7 +5,6 @@ import {Label,} from '@headlessui/react'import cx from 'clsx'-import _isEmpty from 'lodash/isEmpty'import { EyeIcon, EyeSlashIcon } from '@phosphor-icons/react'import React, { memo, useState } from 'react'import { Text } from './Text'@@ -16,7 +15,7 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {hint?: React.ReactNodeleadingIcon?: React.ReactNodeclassName?: string- error?: string | null | boolean+ error?: string | nulldisabled?: booleanreadOnly?: booleanclasses?: {@@ -43,7 +42,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(},ref,) => {- const isError = !_isEmpty(error)+ const isError = Boolean(error)const type = rest.type || 'text'const isPassword = type === 'password'const hasLeadingIcon = Boolean(leadingIcon)@@ -75,6 +74,9 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(invalid={isError}aria-invalid={isError || undefined}{...restWithoutType}+ autoComplete={+ rest.autoComplete ?? (isPassword ? 'current-password' : undefined)+ }type={isPassword && showPassword ? 'text' : type}/>)@@ -158,15 +160,11 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>() : null}{inputWithAdornments}{isError ? (- <Text- as='span'- className='block'- size='sm'- colour='error'- role='alert'- >- {error}- </Text>+ <Description as='div' role='alert'>+ <Text as='span' className='block' size='sm' colour='error'>+ {error}+ </Text>+ </Description>) : null}</Field>)diff --git a/web/app/ui/RadioCardGroup.tsx b/web/app/ui/RadioCardGroup.tsxindex c18676974..dd3bb6df7 100644--- a/web/app/ui/RadioCardGroup.tsx+++ b/web/app/ui/RadioCardGroup.tsx@@ -20,7 +20,7 @@ interface RadioCardGroupProps<T extends string> {options: RadioCardOption<T>[]value: T | nullonChange: (value: T) => void- error?: string | boolean | null+ error?: string | nulldisabled?: booleanclassName?: string/** When true, options stack with shared borders. Otherwise each card stands alone. */@@ -167,7 +167,7 @@ export function RadioCardGroup<T extends string>({)})}</RadioGroup>- {isError && typeof error === 'string' ? (+ {isError ? (<Text as='span' className='block' size='sm' colour='error' role='alert'>{error}</Text>diff --git a/web/app/ui/Textarea.tsx b/web/app/ui/Textarea.tsxindex 41f6879a9..5966bc1ab 100644--- a/web/app/ui/Textarea.tsx+++ b/web/app/ui/Textarea.tsx@@ -4,7 +4,6 @@ import {Label,Textarea as HeadlessTextarea,} from '@headlessui/react'-import _isEmpty from 'lodash/isEmpty'import React, { forwardRef, memo } from 'react'import { cn } from '~/utils/generic'@@ -19,7 +18,7 @@ interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElementcontainer?: stringtextarea?: string}- error?: string | boolean+ error?: string | null}const Textarea = memo(@@ -41,7 +40,7 @@ const Textarea = memo(},ref,) => {- const isError = !_isEmpty(error)+ const isError = Boolean(error)return (<Field@@ -101,15 +100,11 @@ const Textarea = memo({...rest}/>{isError ? (- <Text- as='span'- className='block'- size='sm'- colour='error'- role='alert'- >- {error}- </Text>+ <Description as='div' role='alert'>+ <Text as='span' className='block' size='sm' colour='error'>+ {error}+ </Text>+ </Description>) : null}</Field>)