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
Add Sentry component #30422
Add Sentry component #30422
Conversation
New to contributing to home assistant, so I'd appreciate any feedback. The sensor seemed like the right approach here, but it also feels a little odd. Given I created it, I figured I'd at least try to make use of it (with the latest_event_id). |
Aside, one improvement that might be more difficult would be to automatically embed the @sentry/browser SDK in the frontend when configured. |
816341d
to
58f9a8b
Compare
I wonder if you even need the entity at all, and just call I guess it would be good to support |
You can add |
No way to unload Sentry right now. Its technically possible but we don't provide any native hooks to "unpatch the world". |
Also if anyones curious, here's what it ends up looking like: https://sentry.io/share/issue/734ef4655f88491a847748eb89de6e69/ (there's more detail when you're authenticated/have access to the event) |
Do ya'll need docs bundled in a PR while this one is pending or can I follow up on that after? We may also add this to the official Sentry docs, though I imagine people wouldn't really look for it there. |
Docs PR has to be made against home-assistant.io repository |
Thanks! Excellent first contribution 👍 |
* Add documentation for Sentry See also home-assistant/core#30422 * Fix YAML formatting * Add ha_category, ha_iot_class * Update category, add ha_release * Remove optional params Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the comments in a new PR. Thanks!
if conf is not None: | ||
hass.async_create_task( | ||
hass.config_entries.flow.async_init( | ||
DOMAIN, context={"source": config_entries.SOURCE_IMPORT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not passing the config as data. That should be done to make it available in the import step in the config flow.
) | ||
|
||
sentry_sdk.init( | ||
dsn=conf.get(CONF_DSN), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use dict[key]
for required config keys and keys with default schema values.
return {"title": "Sentry"} | ||
|
||
|
||
class DomainConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rename this class to something integration specific, eg SentryConfigFlow
.
"user": { | ||
"title": "Sentry", | ||
"description": "Enter your Sentry DSN" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data dict representing the input form data schema is missing here.
assert result["errors"] == {} | ||
|
||
with patch( | ||
"homeassistant.components.sentry.config_flow.validate_input", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't patch our own code under test. We should patch the library function we use in the input validation function. We want all our code in the config flow to be covered.
) | ||
|
||
with patch( | ||
"homeassistant.components.sentry.config_flow.validate_input", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
Description:
Add a component to register a Sentry error handler plus logging integration. This will pipe uncaught exceptions as well as error-level logs up to a Sentry instance of your choice.
Example entry for
configuration.yaml
: