Skip to content

Commit 962084b

Browse files
authored
fix: change SENTRY_TOKEN to SENTRY_DSN (#1633)
Updates the Error Tracking guide to use SENTRY_DSN in line with Sentry.io documentation, as well as any other references of "Sentry token", such as in the setup error message. Add `dsn` to args of interactions.ext.sentry.setup(). This argument will be used over `token` if set, but existing users who use `load_extension(..., token="dsn")` should not be affected by this fix.
1 parent 05cbcc8 commit 962084b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

docs/src/Guides/25 Error Tracking.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ And this is great when debugging. But it consumes your rate limit, can run into
3636

3737
interactions.py contains built-in support for Sentry.io, a cloud error tracking platform.
3838

39-
To enable it, call `bot.load_extension('interactions.ext.sentry', token=SENTRY_TOKEN)` as early as possible in your startup. (Load it before your own extensions, so it can catch intitialization errors in those extensions)
39+
To enable it, call `bot.load_extension('interactions.ext.sentry', dsn=SENTRY_DSN)` as early as possible in your startup. Load this extension before your own extensions, so it can catch intitialization errors in those extensions. `SENTRY_DSN` is provided by your Sentry.io project and should look something like `https://...@o9253.sentry.io/1048576`.
4040

4141
# What does this do that vanilla Sentry doesn't?
4242

interactions/ext/sentry.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Sets up a Sentry Logger
33
4-
And then call `bot.load_extension('interactions.ext.sentry', token=SENTRY_TOKEN)`
4+
And then call `bot.load_extension('interactions.ext.sentry', dsn=SENTRY_DSN)`
55
Optionally takes a filter function that will be called before sending the event to Sentry.
66
"""
77

@@ -90,15 +90,17 @@ def on_error_sentry_hook(self: Task, error: Exception) -> None:
9090

9191
def setup(
9292
bot: Client,
93-
token: str | None = None,
93+
dsn: str | None = None,
9494
filter: Optional[Callable[[dict[str, Any], dict[str, Any]], Optional[dict[str, Any]]]] = None,
95+
token: str | None = None,
9596
**kwargs,
9697
) -> None:
97-
if not token:
98-
bot.logger.error("Cannot enable sentry integration, no token provided")
98+
dsn = dsn or token
99+
if not dsn:
100+
bot.logger.error("Cannot enable sentry integration, no Sentry DSN provided")
99101
return
100102
if filter is None:
101103
filter = default_sentry_filter
102-
sentry_sdk.init(token, before_send=filter, **kwargs)
104+
sentry_sdk.init(dsn, before_send=filter, **kwargs)
103105
Task.on_error_sentry_hook = HookedTask.on_error_sentry_hook # type: ignore
104106
SentryExtension(bot)

0 commit comments

Comments
 (0)