Skip to content

Commit 6fdbbab

Browse files
committed
Add sentry integration
1 parent d98b124 commit 6fdbbab

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

app.json

+10
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
"value": "",
5252
"required": true
5353
},
54+
"SENTRY_DSN": {
55+
"description": "Sentry.io token for error tracking",
56+
"value": "",
57+
"required": true
58+
},
59+
"ENVIRONMENT": {
60+
"description": "Type of app environment i.e local or production",
61+
"value": "production",
62+
"required": false
63+
},
5464
"START_ADS": {
5565
"description": "Send message from a channel to a user when they start the bot",
5666
"value": "false",

app/plugins/functions/init.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def add_admins(self):
2828
await self.Client.DB.merge(new_admin)
2929

3030
except ValueError:
31-
logger.error(f"Invalid user id: {user_id}")
31+
logger.warning(f"Invalid user id: {user_id}")
3232

3333
async def add_commands(self):
3434
logger.info("Setting bot commands")
@@ -66,7 +66,7 @@ async def add_commands(self):
6666
),
6767
)
6868
except pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid as err:
69-
logger.error(f"Error setting commands for admins: {err}")
69+
logger.warning(f"Error setting commands for admins: {err}")
7070

7171

7272
all_commands = [

app/plugins/functions/misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def message_admins(self, message):
4444
)
4545

4646
except Exception as err:
47-
logger.error(f"Error sending message to admin: {err}")
47+
logger.warning(f"Error sending message to admin: {err}")
4848
pass
4949

5050
# Get user language

app/torrenthunt.py

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from sys import argv
66

77
import uvloop
8+
import sentry_sdk
89
from apis.requests import Requests
910
from apis.torrenthunt import TorrentHunt
1011
from database import DataBase
@@ -21,6 +22,12 @@
2122
from py1337x import py1337x
2223
from pyrogram import Client, filters
2324

25+
# Initializing sentry for error tracking
26+
sentry_sdk.init(
27+
dsn=environ.get("SENTRY_DSN"),
28+
environment=environ.get("ENVIRONMENT") or "local"
29+
)
30+
2431
# Installing UVloop for better performance
2532
logger.info("Installing uvloop")
2633
uvloop.install()

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ requests==2.31.0
3535
requests-cache==1.1.1
3636
scikit-learn==1.2.2
3737
scipy==1.12.0
38+
sentry-sdk==2.1.1
3839
six==1.16.0
3940
soupsieve==2.5
4041
SQLAlchemy==2.0.25

sample.env

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ START_ADS=false
1616
START_ADS_CHANNEL=
1717
START_ADS_MESSAGE=
1818

19+
# Sentry.io for error tracing
20+
SENTRY_DSN=
21+
1922
# MISC
2023
WORKDIR=
2124
LOGFILE=
25+
ENVIRONMENT=local

0 commit comments

Comments
 (0)