Hawk is a platform for errors and logs monitoring.
You can find web interface and documentation on hawk.so/docs.
We recommend to add Hawk script to page above others to prevent missing any errors.
Install package
npm install hawk.javascript --saveyarn add hawk.javascriptThen require hawk.javascript module
const hawk = require('hawk.javascript');Get newest bundle path from RawGit — open site and paste link to JS bundle in repository.
https://github.com/codex-team/hawk.javascript/master/dist/hawk.js
Note: use
productionlink with commit hash to avoid issues with caching.
Then require this script on your site.
<script src="..." async></script>
Download hawk.js file and add it to all pages of your site.
<script src="hawk.js" async></script>
First of all, you should register an account on hawk.so.
Then create a new Project. You'll get an Integration Token.
Call the hawk.init() method when script will be ready and pass your Integration Token:
hawk.init({token: 'INTEGRATION_TOKEN'});
// or
hawk.init('INTEGRATION_TOKEN');Alternately, add onload="hawk.init({token: 'INTEGRATION_TOKEN'})" attribute to the <script> tag.
<script src="https://cdn.rawgit.com/codex-team/hawk.javascript/master/hawk.js" onload="hawk.init(token)"></script>Hawk supports JS SourceMaps for showing more useful information from your minified bundle. There a few conditions:
- Bundle ends with line contains anchor to the source map, like
//# sourceMappingURL=all.min.js.map. It can be absolute or relative (relatively the bundle) path. - Source map are publicly available by its URL.
- Every build you are updating the
revisionand pass it withinitmethod. It can be heximal-hash or simply file's modification timestamp.
hawk.init({token: 'INTEGRATION_TOKEN', revision: 12345654345})To make sure that Hawk is working right, call hawk.test() method in browser's console.
test method sends fake error to server. So if you get it in your profile, everything works correctly.
Also in browser's console you can find out some Hawk warnings and server responses.
For example, if you get Access denied response, something wrong with your token.