Debug the widget on your site
Turn on the widget's console log, send it to your error tracker, and check which version runs.
Last updated
When the widget doesn't do what you expect, its own log usually says why. By default it writes only warnings and errors to the browser console.
Turn on more detail#
- For one page load, add
?helpai-debug=debugto the page's address (&helpai-debug=debugif it already has a?). - Across reloads, run
HelpAI.setDebug('debug')in the console once the widget has loaded. This browser remembers it until you runHelpAI.setDebug(false). With the NPM package it'schat.setDebug('debug').
The address wins over a remembered level. HelpAI.debugLevel() shows the current one.
Debug and trace lines use the console's debug level. In Chrome, show Verbose messages to see them.
Send the log to your error tracker#
<script>
window.HelpAI = window.HelpAI || function () { (HelpAI.q = HelpAI.q || []).push(arguments); };
HelpAI('onLog', (entry) => {
// entry is { level, scope, message, payload }
if (entry.level === 'error' || entry.level === 'warn') {
myErrorTracker.log(entry.level, 'help.ai: ' + entry.message, entry.payload);
}
});
</script>myErrorTracker stands for your own tool, such as Sentry or Datadog. Put this before the widget's script to catch its first lines too. Only lines that pass the current level reach it, and HelpAI('onLog', null) stops it.
To react to failures in your own code, listen for the error event: chat.on('error', (error) => …).
Check which version runs#
Type HelpAI.version in the console. It shows the widget's version, such as 1.11.0.
Common problems#
Asking a customer to reproduce a problem? Have them add ?helpai-debug=trace to the page's address and send you the console output.