mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
fix: sentry removed duplicates of User, Chat
This commit is contained in:
parent
1020aaffc1
commit
50e3142342
1 changed files with 2 additions and 7 deletions
|
|
@ -3,7 +3,7 @@ from sentry_sdk import (start_transaction, Hub,
|
|||
from sentry_sdk.tracing import Span
|
||||
|
||||
from aiogram.dispatcher.middlewares import BaseMiddleware
|
||||
from aiogram.types import Chat, User
|
||||
from aiogram.types import User
|
||||
|
||||
|
||||
class SentryMiddleware(BaseMiddleware):
|
||||
|
|
@ -134,18 +134,13 @@ class SentryMiddleware(BaseMiddleware):
|
|||
|
||||
@staticmethod
|
||||
def _save_base_context():
|
||||
""" Saving contexts if User and Chat. """
|
||||
""" Saving user data. """
|
||||
user = User.get_current()
|
||||
if isinstance(user, User):
|
||||
user_data = {"id": user.id}
|
||||
if user.username is not None:
|
||||
user_data["username"] = user.username
|
||||
set_user(user_data)
|
||||
set_context("user", user.to_python())
|
||||
|
||||
chat = Chat.get_current()
|
||||
if isinstance(chat, Chat):
|
||||
set_context("chat", chat.to_python())
|
||||
|
||||
@staticmethod
|
||||
def _finish_span():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue