Skip to content

Latest commit

 

History

History
69 lines (48 loc) · 2.87 KB

README.md

File metadata and controls

69 lines (48 loc) · 2.87 KB

Contao Sentry Bundle

This Contao bundle provides an easy integration of sentry.io for Contao 4.13 and 5.x.

Author Software License Total Downloads

--

This is a "wrapper extension" for the sentry/sentry-symfony bundle.

Setup in the Contao Managed Edition

The basic integration is automatically configured to some sane defaults. To enable the integration, configure the SENTRY_DSN variable in your .env.local file.

Additionally, you can name the SENTRY_ENV in your .env.local file, which can be useful if you e.g. have a test and prod installation.

If you need to change any of the defaults, simply configure the sentry/sentry-symfony bundle according to the Documentation.

Manual configuration

If you do not use the Contao Managed Edition, you need to configure this bundle as you would configure the sentry/sentry-symfony bundle: Documentation

User feedback

On the other hand you might want to implement the User feedback feature of sentry. The user feedback is primarily useful to let the users know that you've gotten notified about the issue and to let users give the opportunity to add some comments.

In order to integrate this feature, you have to alter the error page template. Place a copy of vendor/contao/core-bundle/src/Resources/views/Error/layout.html.twig in the directory templates/ContaoCoreBundle/views/Error/.

Modify the copied template and place the following snippet just before the closing </body> tag:

{% set sentry_id = ''|sentry_last_event_id %}
{% if sentry_id %}
    <script src="https://browser.sentry-cdn.com/5.7.1/bundle.min.js"
            integrity="sha384-KMv6bBTABABhv0NI+rVWly6PIRvdippFEgjpKyxUcpEmDWZTkDOiueL5xW+cztZZ"
            crossorigin="anonymous"></script>
    <script>
        Sentry.init({dsn: '{{ ''|sentry_dsn }}'});
        Sentry.showReportDialog({eventId: '{{ sentry_id }}'})

        // You can also bind the "show" method to an event, e.g. to open the modal on button click
        {#document.querySelector('.btn-report').addEventListener('click', function (e) {#}
        {#    e.preventDefault();#}
        {#    Sentry.showReportDialog({eventId: '{{ sentry_id }}'})#}
        {#});#}
    </script>
{% endif %}

User Feedback in action