🐛📈 Fix the problem of unlimited restart. (#110)

🐛📈 修复国内环境关闭用户体验计划后仍然加载失败的问题。
This commit is contained in:
Xtao_dada 2021-07-18 14:37:15 +08:00 committed by GitHub
parent dc70679fe8
commit b284ca1468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,7 +43,6 @@ module_dir = __path__[0]
working_dir = getcwd()
config = None
help_messages = {}
mp = Mixpanel("7be1833326f803740214fe276f5a5a3d")
logs = getLogger(__name__)
logging_format = "%(levelname)s [%(asctime)s] [%(name)s] %(message)s"
logging_handler = StreamHandler()
@ -91,6 +90,10 @@ def lang(text: str) -> str:
return result
if strtobool(config['allow_analytics']):
mp = Mixpanel("7be1833326f803740214fe276f5a5a3d")
else:
mp = None
if strtobool(config['debug']):
logs.setLevel(DEBUG)
else:
@ -203,10 +206,12 @@ async def save_id():
user_id = me.id
if me.username is not None:
sentry_sdk.set_user({"id": user_id, "name": me.first_name, "username": me.username, "ip_address": "{{auto}}"})
mp.people_set(str(user_id), {'$first_name': me.first_name, "username": me.username})
if strtobool(config['allow_analytics']):
mp.people_set(str(user_id), {'$first_name': me.first_name, "username": me.username})
else:
sentry_sdk.set_user({"id": user_id, "name": me.first_name, "ip_address": "{{auto}}"})
mp.people_set(str(user_id), {'$first_name': me.first_name})
if strtobool(config['allow_analytics']):
mp.people_set(str(user_id), {'$first_name': me.first_name})
logs.info(f"{lang('save_id')} {me.first_name}({user_id})")