diff --git a/docs/src/Guides/25 Error Tracking.md b/docs/src/Guides/25 Error Tracking.md index 5a348c6e0..73b979fcc 100644 --- a/docs/src/Guides/25 Error Tracking.md +++ b/docs/src/Guides/25 Error Tracking.md @@ -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://...@o9253.sentry.io/1048576`. # What does this do that vanilla Sentry doesn't? diff --git a/interactions/ext/sentry.py b/interactions/ext/sentry.py index e1311092f..2d1787f60 100644 --- a/interactions/ext/sentry.py +++ b/interactions/ext/sentry.py @@ -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. """ @@ -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)