Skip to content

📈 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!

botsProtectionLevel setting

Blue Moused5ae1df055d0
diff --git a/web/app/pages/Project/Settings/ProjectSettings.tsx b/web/app/pages/Project/Settings/ProjectSettings.tsx
index 0daa5936d..ed7caca3e 100644
--- a/web/app/pages/Project/Settings/ProjectSettings.tsx
+++ b/web/app/pages/Project/Settings/ProjectSettings.tsx
@@ -1,7 +1,7 @@
import React, { useState, useEffect, useMemo, memo } from 'react'
import type i18next from 'i18next'
import { toast } from 'sonner'
-import { useNavigate, useParams } from '@remix-run/react'
+import { useNavigate } from '@remix-run/react'
import { useTranslation } from 'react-i18next'
import cx from 'clsx'
import _isEmpty from 'lodash/isEmpty'
@@ -47,6 +47,8 @@ import { getFormatDate } from '../View/ViewProject.helpers'
import People from './People'
import Emails from './Emails'
+import Select from 'ui/Select'
+import { useRequiredParams } from 'hooks/useRequiredParams'
const MAX_NAME_LENGTH = 50
const MAX_ORIGINS_LENGTH = 300
@@ -284,12 +286,7 @@ const ProjectSettings = ({
t,
i18n: { language },
} = useTranslation('common')
- // @ts-ignore
- const {
- id,
- }: {
- id: string
- } = useParams()
+ const { id } = useRequiredParams<{ id: string }>()
const project: IProjectForShared = useMemo(
() =>
_find([...projects, ..._map(sharedProjects, (item) => item.project)], (p) => p.id === id) ||
@@ -305,6 +302,7 @@ const ProjectSettings = ({
isPasswordProtected: false,
origins: null,
ipBlacklist: null,
+ botsProtectionLevel: 'basic',
})
const [validated, setValidated] = useState<boolean>(false)
const [errors, setErrors] = useState<{
@@ -334,6 +332,19 @@ const ProjectSettings = ({
? dashboardPaginationPageShared * ENTRIES_PER_PAGE_DASHBOARD
: dashboardPaginationPage * ENTRIES_PER_PAGE_DASHBOARD
+ const botsProtectionLevels = useMemo(() => {
+ return [
+ {
+ name: 'off',
+ title: t('project.settings.botsProtectionLevel.levels.off'),
+ },
+ {
+ name: 'basic',
+ title: t('project.settings.botsProtectionLevel.levels.basic'),
+ },
+ ] as const
+ }, [t])
+
useEffect(() => {
if (authLoading || initialised) {
return
@@ -607,6 +618,25 @@ const ProjectSettings = ({
onChange={handleInput}
error={beenSubmitted ? errors.ipBlacklist : null}
/>
+ <div className='mt-4'>
+ <Select
+ id='botsProtectionLevel'
+ label={t('project.settings.botsProtectionLevel.title')}
+ // @ts-expect-error
+ items={botsProtectionLevels}
+ title={_find(botsProtectionLevels, (predicate) => predicate.name === form.botsProtectionLevel)?.title || ''}
+ labelExtractor={(item: any) => item.title}
+ onSelect={(item) => {
+ const key = _find(botsProtectionLevels, (predicate) => predicate.title === item)?.name || 'basic'
+
+ setForm((prevForm) => ({
+ ...prevForm,
+ botsProtectionLevel: key,
+ }))
+ }}
+ capitalise
+ />
+ </div>
<h3 className='mt-6 text-lg font-bold text-gray-900 dark:text-gray-50'>{t('project.settings.access')}</h3>
<Checkbox
diff --git a/web/app/redux/models/IProject.ts b/web/app/redux/models/IProject.ts
index f34ddde46..771050f0c 100644
--- a/web/app/redux/models/IProject.ts
+++ b/web/app/redux/models/IProject.ts
@@ -98,6 +98,7 @@ export interface IProject {
isLocked: boolean
isDataExists: boolean
isErrorDataExists: boolean
+ botsProtectionLevel: 'off' | 'basic'
}
export interface ICaptchaProject {
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index 37945827a..c7bc7d5fb 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -927,6 +927,13 @@
"settings": {
"shields": "Shields",
"access": "Access settings",
+ "botsProtectionLevel": {
+ "title": "Bots protection level",
+ "levels": {
+ "off": "Off: we allow all incoming traffic",
+ "basic": "Basic: we detect bots based on their user agent (Googlebot, Bingbot, curl, etc.)"
+ }
+ },
"verify": "Please, verify your email address first",
"updated": "The project's settings were updated",
"created": "The project has been created",