mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 12:43:12 +03:00
Исправил проверку статус кода, если client error (4xx), то в аналитику ничего не будет приходить
This commit is contained in:
parent
ce83d5df0f
commit
4e1a307e17
1 changed files with 4 additions and 0 deletions
|
@ -2,6 +2,7 @@ import httpx
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from user_agents import parse as ua_parse
|
from user_agents import parse as ua_parse
|
||||||
|
from http import HTTPStatus
|
||||||
|
|
||||||
config = yaml.safe_load(open('../config.yaml'))
|
config = yaml.safe_load(open('../config.yaml'))
|
||||||
|
|
||||||
|
@ -9,6 +10,9 @@ class PlausibleAnalytics:
|
||||||
async def __call__(self, request, call_next):
|
async def __call__(self, request, call_next):
|
||||||
response = await call_next(request)
|
response = await call_next(request)
|
||||||
|
|
||||||
|
if HTTPStatus(response.status_code).is_client_error:
|
||||||
|
return response
|
||||||
|
|
||||||
user_agent = request.headers.get('user-agent', 'unknown')
|
user_agent = request.headers.get('user-agent', 'unknown')
|
||||||
user_agent_parsed = ua_parse(user_agent)
|
user_agent_parsed = ua_parse(user_agent)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue