Skip to content

fix: change SENTRY_TOKEN to SENTRY_DSN #1633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/Guides/25 Error Tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ And this is great when debugging. But it consumes your rate limit, can run into

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

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)
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://[email protected]/1048576`.

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

Expand Down
12 changes: 7 additions & 5 deletions interactions/ext/sentry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Sets up a Sentry Logger

And then call `bot.load_extension('interactions.ext.sentry', token=SENTRY_TOKEN)`
And then call `bot.load_extension('interactions.ext.sentry', dsn=SENTRY_DSN)`
Optionally takes a filter function that will be called before sending the event to Sentry.
"""

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

def setup(
bot: Client,
token: str | None = None,
dsn: str | None = None,
filter: Optional[Callable[[dict[str, Any], dict[str, Any]], Optional[dict[str, Any]]]] = None,
token: str | None = None,
**kwargs,
) -> None:
if not token:
bot.logger.error("Cannot enable sentry integration, no token provided")
dsn = dsn or token
if not dsn:
bot.logger.error("Cannot enable sentry integration, no Sentry DSN provided")
return
if filter is None:
filter = default_sentry_filter
sentry_sdk.init(token, before_send=filter, **kwargs)
sentry_sdk.init(dsn, before_send=filter, **kwargs)
Task.on_error_sentry_hook = HookedTask.on_error_sentry_hook # type: ignore
SentryExtension(bot)