{"id":18887991,"url":"https://github.com/codex-team/hawk.javascript","last_synced_at":"2025-05-12T05:09:56.962Z","repository":{"id":21741826,"uuid":"93921174","full_name":"codex-team/hawk.javascript","owner":"codex-team","description":"JavaScript errors tracker","archived":false,"fork":false,"pushed_at":"2025-04-26T14:50:32.000Z","size":790,"stargazers_count":26,"open_issues_count":21,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-30T19:08:58.924Z","etag":null,"topics":["error-monitoring","hawk","javascript","js"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codex-team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-06-10T06:45:41.000Z","updated_at":"2025-04-08T19:47:15.000Z","dependencies_parsed_at":"2024-01-23T21:16:01.145Z","dependency_job_id":"0a3442d7-ab82-43f8-b87a-2e7bb0968fc5","html_url":"https://github.com/codex-team/hawk.javascript","commit_stats":{"total_commits":118,"total_committers":7,"mean_commits":"16.857142857142858","dds":0.5508474576271186,"last_synced_commit":"0dacbde09bc687a81d9f3caf2f416be5d722435e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codex-team%2Fhawk.javascript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codex-team%2Fhawk.javascript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codex-team%2Fhawk.javascript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codex-team%2Fhawk.javascript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codex-team","download_url":"https://codeload.github.com/codex-team/hawk.javascript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253601000,"owners_count":21934246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["error-monitoring","hawk","javascript","js"],"created_at":"2024-11-08T07:41:04.091Z","updated_at":"2025-05-12T05:09:56.935Z","avatar_url":"https://github.com/codex-team.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hawk JavaScript Catcher\n\n[Hawk](https://github.com/codex-team/hawk) allows to track JavaScript and TypeScript errors in your applications.\n\nHere is the [Hawk Web](//garage.hawk.so) client and here is the [Documentation](//docs.hawk.so).\n\n## Installation\n\nWe recommend adding Hawk script to page above others to prevent missing any errors.\n\n### Install via NPM or Yarn\n\nInstall package\n\n```shell\nnpm install @hawk.so/javascript --save\n```\n\n```shell\nyarn add @hawk.so/javascript\n```\n\nThen import `@hawk.so/javascript` module to your code.\n\n```js\nimport HawkCatcher from '@hawk.so/javascript';\n````\n\n### Load from CDN\n\nGet the newest bundle path from [@hawk.so/javascript](https://www.jsdelivr.com/package/npm/@hawk.so/javascript) — open site and get the link to latest distributed JS bundle.\n\nThen require this script on your site.\n\n```\n\u003cscript src=\"...\" async\u003e\u003c/script\u003e\n```\n\n## Usage\n\n### Get an Integration Token\n\nFirst of all, you should register an account on [hawk.so](https://garage.hawk.so/sign-up).\n\nThen create a Workspace and a Project in there. You'll get an Integration Token.\n\n### Initialize Catcher\n\nCreate `HawkCatcher` class instance when script will be ready and pass your Integration Token:\n\n```js\nconst hawk = new HawkCatcher({token: 'INTEGRATION_TOKEN'});\n\n// or\n\nconst hawk = new HawkCatcher('INTEGRATION_TOKEN');\n```\n\nAlternately, add `onload=\"const hawk = new HawkCatcher({token: 'INTEGRATION_TOKEN'})\"` attribute to the `\u003cscript\u003e` tag.\n\n```html\n\u003cscript src=\"https://cdn.rawgit.com/codex-team/hawk.javascript/master/hawk.js\" onload=\"const hawk = new HawkCatcher({token: 'INTEGRATION_TOKEN'})\"\u003e\u003c/script\u003e\n```\n\nInitialization settings:\n\n| name | type | required | description |\n| -- | -- | -- | -- |\n| `token` | string | **required** | Your project's Integration Token |\n| `release` | string/number | optional | Unique identifier of the release. Used for source map consuming (see below) |\n| `user` | {id: string, name?: string, image?: string, url?: string} | optional | Current authenticated user |\n| `context` | object | optional | Any data you want to pass with every message. Has limitation of length. |\n| `vue` | Vue constructor | optional | Pass Vue constructor to set up the [Vue integration](#integrate-to-vue-application) |\n| `disableGlobalErrorsHandling` | boolean | optional | Do not initialize global errors handling |\n| `disableVueErrorHandler` | boolean | optional | Do not initialize Vue errors handling |\n| `beforeSend` | function(event) =\u003e event | optional | This Method allows you to filter any data you don't want sending to Hawk |\n\nOther available [initial settings](types/hawk-initial-settings.d.ts) are described at the type definition.\n\n### Usage in React project\n\nYou can use the JavaScript catcher in your React project. Create the Hawk Catcher instance in a `index.js` file of your project.\n\n## Manual sending\n\nYou can send errors or other messages to the Hawk manually, for example at your `catch` blocks or any debug conditions.\n\nUse the `.send(message, context)` method for that. This method accepts the `message` of type `Error` or `string`\nas the first parameter. The second parameter is optional, it allows passing any additional data with the event.\nIf you specify the `context` with the `HawkCatcher` constructor, it will be merged with the context passed to the `send` method.\n\n```js\n// init Hawk Catcher instance\nconst hawk = new HawkCatcher({token: 'INTEGRATION_TOKEN'});\n\n// somewhere in try-catch block or other custom place\nhawk.send(new Error('Something went wrong'), {\n  myOwnDebugInfo: '1234'\n});\n```\n\n## Source maps consuming\n\nIf your bundle is minified, it is useful to pass source-map files to the Hawk. After that you will see beautiful original source code lines in Hawk Garage instead of minified code.\n\nTo enable source map consuming you should do two things:\n\n- Send the source map and the release identifier to the Hawk after you build a new version of the script. For example with the [Hawk Webpack Plugin](https://github.com/codex-team/hawk.webpack.plugin) or with cURL request.\n- Pass the release identifier to the Hawk Catcher using `release` option.\n\n## Testing and server responses\n\nTo make sure that Hawk is working right, call `test()` method from `HawkCatcher` class instance in browser's console.\n`test()` method sends fake error to server. Then, open Hawk and find a test event at the Project's page.\n\n## Sensitive data filtering\n\nYou can filter any data that you don't want to send to Hawk. Use the `beforeSend()` hook for that reason.\n\n```js\nwindow.hawk = new HawkCatcher({\n  token: 'INTEGRATION TOKEN',\n  beforeSend(event){\n    if (event.user \u0026\u0026 event.user.name){\n      delete event.user.name;\n    }\n\n    return event;\n  }\n})\n```\n\n## Dismiss error\n\nYou can use the `beforeSend()` hook to prevent sending a particular event. Return `false` for that.\n\n## Integrate to Vue application\n\nVue apps have their own error handler, so if you want to catcher errors thrown inside Vue components, you should set up a Vue integration.\n\nPass the Vue constructor with the initial settings:\n\n```js\nimport Vue from 'vue';\n\nconst hawk = new HawkCatcher({\n  token: 'INTEGRATION_TOKEN',\n  vue: Vue // the Vue constructor you tweak\n});\n```\n\nor pass it any moment after Hawk Catcher was instantiated:\n\n\n```js\nimport Vue from 'vue';\n\nconst hawk = new HawkCatcher({\n  token: 'INTEGRATION_TOKEN',\n});\n\nhawk.connectVue(Vue)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodex-team%2Fhawk.javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodex-team%2Fhawk.javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodex-team%2Fhawk.javascript/lists"}