mirror of
https://github.com/Starlio-app/Starlio-web.git
synced 2024-11-05 17:03:58 +03:00
если 4хх ошибка, то аналитика не будет обрабатываться
This commit is contained in:
parent
7aa8a15cbd
commit
544a15f612
1 changed files with 5 additions and 1 deletions
|
@ -1,9 +1,10 @@
|
|||
import httpx
|
||||
import yaml
|
||||
|
||||
from http import HTTPStatus
|
||||
from user_agents import parse as ua_parse
|
||||
|
||||
config = yaml.safe_load(open('../config.yaml'))
|
||||
config = yaml.safe_load(open('./config.yaml'))
|
||||
|
||||
class PlausibleAnalytics:
|
||||
async def __call__(self, request, call_next):
|
||||
|
@ -12,6 +13,9 @@ class PlausibleAnalytics:
|
|||
user_agent = request.headers.get('user-agent', 'unknown')
|
||||
user_agent_parsed = ua_parse(user_agent)
|
||||
|
||||
if HTTPStatus(response.status_code).is_client_error:
|
||||
return
|
||||
|
||||
event = {
|
||||
"domain": config['analytics']['domain'],
|
||||
"name": request.url.path or '404 - Not Found',
|
||||
|
|
Loading…
Reference in a new issue