diff --git a/package.json b/package.json index b8ff901c..71f90cae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "umami", - "version": "0.26.0", + "version": "0.27.0", "description": "A simple, fast, website analytics alternative to Google Analytics. ", "author": "Mike Cao ", "license": "MIT", @@ -59,6 +59,7 @@ "geolite2-redist": "^1.0.7", "immer": "^7.0.8", "is-localhost-ip": "^1.4.0", + "isbot-fast": "^1.2.0", "jose": "^1.28.0", "maxmind": "^4.1.4", "moment-timezone": "^0.5.31", diff --git a/pages/api/collect.js b/pages/api/collect.js index 56d2ea79..399e88e9 100644 --- a/pages/api/collect.js +++ b/pages/api/collect.js @@ -1,8 +1,13 @@ import { savePageView, saveEvent } from 'lib/queries'; import { useCors, useSession } from 'lib/middleware'; import { ok, badRequest } from 'lib/response'; +import isBot from 'isbot-fast'; export default async (req, res) => { + if (isBot(req.headers['user-agent'])) { + return ok(res); + } + await useCors(req, res); await useSession(req, res); diff --git a/yarn.lock b/yarn.lock index 52c57c7e..7e0a5f74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4965,6 +4965,11 @@ isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= +isbot-fast@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/isbot-fast/-/isbot-fast-1.2.0.tgz#ef0ef1d5db34eb60777250ae26fceb72b94153e2" + integrity sha512-twjuQzy2gKMDVfKGQyQqrx6Uy4opu/fiVUTTpdqtFsd7OQijIp5oXvb27n5EemYXaijh5fomndJt/SPRLsEdSg== + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"