notamedia/yii2-sentry

A way to add the user feedback module?

cgsmith opened this issue · 3 comments

Any way to add user feedback for allowing a modal to popup to collect error reporting? https://docs.sentry.io/enriching-error-data/user-feedback/?platform=php

At the moment, it is impossible to make an automatic display of the Feedback form without serious code modification. We will try to do in the near future.

For now you can do this like in documentation (https://docs.sentry.io/enriching-error-data/user-feedback/?platform=php) in error template, for example this is error.php template with feedback form for https://github.com/yiisoft/yii2-app-basic

<?php

/* @var $this yii\web\View */
/* @var $name string */
/* @var $message string */
/* @var $exception Exception */

use yii\helpers\Html;

$this->title = $name;
$this->registerJsFile('https://browser.sentry-cdn.com/5.19.2/bundle.min.js');
?>
<div class="site-error">

    <h1><?= Html::encode($this->title) ?></h1>

    <div class="alert alert-danger">
        <?= nl2br(Html::encode($message)) ?>
    </div>

    <p>
        The above error occurred while the Web server was processing your request.
    </p>
    <p>
        Please contact us if you think this is a server error. Thank you.
    </p>

</div>

<?php if (Sentry\State\Hub::getCurrent()->getLastEventId()): ?>
    <?php $this->registerJs('
        Sentry.init({ dsn: "your_dsn" });
        Sentry.showReportDialog({ eventId: "'.Sentry\State\Hub::getCurrent()->getLastEventId().'" });
    '); ?>
<?php endif; ?>

Closed as since this library is for backend and the implementation of this functionality depends on the project