Collecting User Feedback

We don't want our users to be interrupted by errors, but sometimes it does happen. Honeybadger helps you work with your users to fix errors by linking user requests to error occurrences and allowing users to leave relevant feedback on errors.

If you're using Laravel, the honeybadger-io/honeybadger-laravel package comes with a few handy Blade directives to make your error pages more proactive.

Prerequisites

First off, you'll need to publish Laravel's inbuilt error pages or create your own. Then you can add our directives to the Blade template. If you're using Laravel's error views, the default base template is minimal.blade.php.

Note that if you're on development, you'll only see the Ignition error page. To see the production error views, set APP_DEBUG in your .env file to false.

Displaying the Error ID

Whenever you send an error to Honeybadger, we return a unique UUID for that occurrence. You can easily jump to the error details at any time by visiting https://app.honeybadger.io/notice/{the-error-uuid}. You can also set the UUID to be automatically displayed on error pages, to serve as a reference.

To do this, use the @honeybadgerError directive in your Blade error template:

php
<div class="flex items-center pt-8 sm:justify-start sm:pt-0"> <div class="px-4 text-lg text-gray-500 border-r border-gray-400 tracking-wider"> @yield('code') </div> <div class="ml-4 text-lg text-gray-500 uppercase tracking-wider"> @yield('message') </div> @honeybadgerError </div>

You can place the directive anywhere you wish on your page, and we'll replace it with

Error ID: {the error ID}

If you wish to style the error view or customize the text, you can also pass class or text arguments to the directive:

php
@honeybadgerError(["class" => "uppercase text-gray-500", "text" => "Your error ID is: "])

Displaying a Feedback Form

Honeybadger comes with an HTML form so users can provide additional helpful information about what led up to that error. Feedback responses are displayed inline in the Comments section on the error detail page.

To include the feedback form on your error page, use the @honeybadgerFeedback directive.

Feedback Form on Laravel

You can change the text displayed in the form via the Laravel localization system. Here’s an example:

php
// resources/lang/vendor/honeybadger/en/feedback.php return [ 'thanks' => 'Thanks for the feedback!', 'heading' => 'Care to help us fix this?', 'explanation' => 'Any information you can provide will help our technical team get to the bottom of this issue.', 'labels' => [ 'name' => 'Your name', 'phone' => 'Your phone number', 'email' => 'Your email address', 'comment' => 'Comment (required)', ], 'submit' => 'Send', ];

Advanced Customization

We've optimized the error ID and feedback form so they render well in the default Laravel error template (minimal.blade.php), but your setup might be different from that. In that case, you can publish the corresponding views and customize them as you like:

bash
php artisan vendor:publish --tag honeybadger-views

The views will be published to resources/views/vendor/honeybadger, where you can customize them as you wish, and Laravel will load your customized version.