Customizing the Metadata captured by BugHerd

The BugHerd sidebar can also be configured to override some of its default behaviour as well as display extra information in any tasks that you pass in from a configuration object called BugHerdConfig.

When setting up BugHerd for the first time, you probably already know you need to add the following code to your site:

<script type="text/javascript">
   (function (d, t) {
     var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];
     bh.type = 'text/javascript';
     bh.src = 'https://1dxzo51kczdn42ieo716m9hr-wpengine.netdna-ssl.com/sidebarv2.js?apikey=YOUR-API-KEY-HERE';
     s.parentNode.insertBefore(bh, s);
   })(document, 'script');
</script>

The BugHerdConfig object is added to the initilisation script as shown below:

<script type="text/javascript"> var BugHerdConfig = { // META DATA metadata: { username: "foobar", version: "1.0", foo: "bar", logged_in: "true" } }; // BUGHERD INITIALISATION (function (d, t) { var bh = d.createElement(t), s = d.getElementsByTagName(t)[0]; bh.type = 'text/javascript'; bh.src = 'https://1dxzo51kczdn42ieo716m9hr-wpengine.netdna-ssl.com/sidebarv2.js?apikey=YOUR-API-KEY-HERE'; s.parentNode.insertBefore(bh, s); })(document, 'script'); </script>

 

Config options

metadata: object

Adding custom meta data to the “Additional Info” area for tasks created on your site is just a matter of adding an object called metadata to the BugHerdConfig object within the initialisation script.

The metadata object is comprised of simple key/value pairs.

 var BugHerdConfig = {
   // META DATA
   metadata: {
     username: "foobar",
     version: "1.0",
     foo: "bar",
     logged_in: "true"
  }
};

Note: the values are strings. If you want to pass in true as above, send it as the string "true".

You can use this to track all sorts of things, from user data to session data, or in our case the UserId and Rails controller/action. Anything you need to help you better diagnose and fix problems! Anything you add will appear under “additional info” in the task details.

pre-populate requester email

If users are logged in on your site, there is no point having them enter their email address again in your feedback widget. You can pre-set it if known.

var BugHerdConfig = {
  reporter: {
    email: "someone@example.com",
    required: "true"
  }
};

The value for “required” specifies whether you would like to make the email field mandatory or not. If “required” is set to “false” (default) the email address field can be left blank by your site visitors. You need to explicitly set the value for “required” to “true” if you’d like to make the field mandatory.

If you need help with any of the commands above, please feel free to get in touch!

Have more questions? Submit a request

Comments