Hawk JavaScript Catcher
Hawk is a platform for errors and logs monitoring.
You can find web interface and documentation on hawk.so/docs.
Installation
We recommend to add Hawk script to page above others to prevent missing any errors.
Install via NPM or Yarn
Install package
npm install hawk.javascript --save
yarn add hawk.javascript
Then require hawk.javascript
module
const hawk = ;
Load from CDN
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
production
link with commit hash to avoid issues with caching.
Then require this script on your site.
<script src="..." async></script>
Or upload it to your project
Download hawk.js file and add it to all pages of your site.
<script src="hawk.js" async></script>
Usage
Get token
First of all, you should register an account on hawk.so.
Then create a new Project. You'll get an Integration Token.
Initialize Hawk
Call the hawk.init()
method when script will be ready and pass your Integration Token:
hawk; // or hawk;
Alternately, add onload="hawk.init({token: 'INTEGRATION_TOKEN'})"
attribute to the <script>
tag.
Source map support
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
revision
and pass it withinit
method. It can be heximal-hash or simply file's modification timestamp.
hawk
Testing and server responses
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.