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

Conversation

mifuyutsuki
Copy link
Contributor

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

Change references to SENTRY_TOKEN with SENTRY_DSN in docs (Error Tracking guide) and messages (interactions.ext.sentry:setup on error), in accordance with Sentry.io docs. This should avoid confusion by users possibly adding a Sentry.io auth token on setup.

Added as fix as this PR also includes a fix on an error when specifying dsn="dsn" but not token="dsn" on extension setup.

Changes

  • interactions.ext.sentry:setup: Add argument dsn in place of token
    • token is moved back and is accessible as a kwarg, avoiding breaking changes. However, dsn will take precedence when available.
    • This avoids an error when using dsn="dsn" without specifying token="dsn".
  • Replace references to token=SENTRY_TOKEN with dsn=SENTRY_DSN. Instead, an error would be emitted if both are unspecified or None.
  • Edited the Error Tracking guide accordingly
    • Added small information on what DSN looks like (a url).

Related Issues

Test Scenarios

A ZeroDivisionError event should appear on the Sentry.io project corresponding to the DSN. The DSN below is an example.

from interactions import Client, slash_command, SlashContext

@slash_command(name="test", description="Test command")
async def test_cmd(ctx: SlashContext):
  plant = 1 / 0
  await ctx.send("This message is never reached")

bot = Client()
bot.load_extension("interactions.ext.sentry", dsn="https://...@o1.ingest.sentry.io/1048576")
bot.start("token")

The load_extension should still work with token kwarg:

bot.load_extension("interactions.ext.sentry", token="https://...@o1.ingest.us.sentry.io/1048576")

Keyword dsn overrides token when available:

bot.load_extension("interactions.ext.sentry", token="bad link", dsn="https://...@o1.ingest.us.sentry.io/1048576")

The error message should show, this time for "no Sentry DSN".

bot.load_extension("interactions.ext.sentry")

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

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.
Copy link
Member

@AstreaTSS AstreaTSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should be classified as a feat or a fix (I'm leaning towards feat/fix), but either way, looks solid.

Copy link
Member

@silasary silasary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@silasary silasary merged commit 962084b into interactions-py:unstable Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants