Skip to content

Commit b6e2d4c

Browse files
ReverseanneSpecc
andauthored
refactor(workspaces): migrate sources to javascript workspace
* refactor(workspaces): migrate sources to javascript workspace * ci(workspaces): update workflows for javascript workspace publishing * Rename ESLint config and update references Renamed .eslintrc.js to .eslintrc.cjs and updated all npm scripts in package.json to reference the new config file. Also added a features section to the JavaScript package README to highlight key capabilities. --------- Co-authored-by: Peter Savchenko <[email protected]>
1 parent 19a028d commit b6e2d4c

34 files changed

+319
-261
lines changed

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
'node_modules/',
77
'package.json',
88
'tsconfig.json',
9+
'packages/*/dist/',
910
],
1011
env: {
1112
browser: true,

.github/workflows/npm-publish.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- run: yarn
1818
- run: yarn lint-test
1919
- run: yarn build
20-
- run: yarn publish --access=public
20+
- run: yarn workspace @hawk.so/javascript publish --access=public
2121
env:
2222
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2323
notify:
@@ -28,6 +28,8 @@ jobs:
2828
- name: Get package info
2929
id: package
3030
uses: codex-team/action-nodejs-package-info@v1
31+
with:
32+
path: packages/javascript
3133
- name: Send a message
3234
uses: codex-team/action-codexbot-notify@v1
3335
with:

README.md

Lines changed: 3 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Hawk JavaScript Catcher
1+
# Hawk JavaScript
22

33
Error tracking for JavaScript/TypeScript applications.
44

@@ -18,210 +18,9 @@ Error tracking for JavaScript/TypeScript applications.
1818
- <img src="https://cdn.svglogos.dev/logos/vue.svg" width="16" height="16"> &nbsp;Vue support
1919
- <img src="https://cdn.svglogos.dev/logos/react.svg" width="16" height="16"> &nbsp;React support
2020

21-
## Installation
21+
## Packages
2222

23-
We recommend adding Hawk script to page above others to prevent missing any errors.
24-
25-
### Install via NPM or Yarn
26-
27-
Install package
28-
29-
```shell
30-
npm install @hawk.so/javascript --save
31-
```
32-
33-
```shell
34-
yarn add @hawk.so/javascript
35-
```
36-
37-
Then import `@hawk.so/javascript` module to your code.
38-
39-
```js
40-
import HawkCatcher from '@hawk.so/javascript';
41-
````
42-
43-
### Load from CDN
44-
45-
Get 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.
46-
47-
Then require this script on your site.
48-
49-
```
50-
<script src="..." async></script>
51-
```
52-
53-
## Usage
54-
55-
### Get an Integration Token
56-
57-
First of all, you should register an account on [hawk.so](https://garage.hawk.so/sign-up).
58-
59-
Then create a Workspace and a Project in there. You'll get an Integration Token.
60-
61-
### Initialize Catcher
62-
63-
Create `HawkCatcher` class instance when script will be ready and pass your Integration Token:
64-
65-
```js
66-
const hawk = new HawkCatcher({token: 'INTEGRATION_TOKEN'});
67-
68-
// or
69-
70-
const hawk = new HawkCatcher('INTEGRATION_TOKEN');
71-
```
72-
73-
Alternately, add `onload="const hawk = new HawkCatcher({token: 'INTEGRATION_TOKEN'})"` attribute to the `<script>` tag.
74-
75-
```html
76-
<script src="https://cdn.rawgit.com/codex-team/hawk.javascript/master/hawk.js" onload="const hawk = new HawkCatcher({token: 'INTEGRATION_TOKEN'})"></script>
77-
```
78-
79-
Initialization settings:
80-
81-
| name | type | required | description |
82-
| -- | -- | -- | -- |
83-
| `token` | string | **required** | Your project's Integration Token |
84-
| `release` | string/number | optional | Unique identifier of the release. Used for source map consuming (see below) |
85-
| `user` | {id: string, name?: string, image?: string, url?: string} | optional | Current authenticated user |
86-
| `context` | object | optional | Any data you want to pass with every message. Has limitation of length. |
87-
| `vue` | Vue constructor | optional | Pass Vue constructor to set up the [Vue integration](#integrate-to-vue-application) |
88-
| `disableGlobalErrorsHandling` | boolean | optional | Do not initialize global errors handling |
89-
| `disableVueErrorHandler` | boolean | optional | Do not initialize Vue errors handling |
90-
| `consoleTracking` | boolean | optional | Initialize console logs tracking |
91-
| `beforeSend` | function(event) => event | optional | This Method allows you to filter any data you don't want sending to Hawk |
92-
93-
Other available [initial settings](types/hawk-initial-settings.d.ts) are described at the type definition.
94-
95-
## Manual sending
96-
97-
You can send errors or other messages to the Hawk manually, for example at your `catch` blocks or any debug conditions.
98-
99-
Use the `.send(message, context)` method for that. This method accepts the `message` of type `Error` or `string`
100-
as the first parameter. The second parameter is optional, it allows passing any additional data with the event.
101-
If you specify the `context` with the `HawkCatcher` constructor, it will be merged with the context passed to the `send` method.
102-
103-
```js
104-
// init Hawk Catcher instance
105-
const hawk = new HawkCatcher({token: 'INTEGRATION_TOKEN'});
106-
107-
// somewhere in try-catch block or other custom place
108-
hawk.send(new Error('Something went wrong'), {
109-
myOwnDebugInfo: '1234',
110-
});
111-
```
112-
113-
## User Management
114-
115-
You can dynamically manage user information after the catcher is initialized:
116-
117-
```js
118-
const hawk = new HawkCatcher({ token: 'INTEGRATION_TOKEN' });
119-
120-
// Set user information
121-
hawk.setUser({
122-
id: 'user123',
123-
name: 'John Doe',
124-
url: '/users/123',
125-
image: 'https://example.com/avatar.jpg',
126-
});
127-
128-
// Clear user (revert to generated user)
129-
hawk.clearUser();
130-
```
131-
132-
## Context Management
133-
134-
You can dynamically update context data that will be sent with all events:
135-
136-
```js
137-
const hawk = new HawkCatcher({ token: 'INTEGRATION_TOKEN' });
138-
139-
// Set context data
140-
hawk.setContext({
141-
feature: 'user-dashboard',
142-
version: '2.1.0',
143-
environment: 'production',
144-
});
145-
```
146-
147-
## Source maps consuming
148-
149-
If 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.
150-
151-
To enable source map consuming you should do two things:
152-
153-
- 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.
154-
- Pass the release identifier to the Hawk Catcher using `release` option.
155-
156-
## Testing and server responses
157-
158-
To make sure that Hawk is working right, call `test()` method from `HawkCatcher` class instance in browser's console.
159-
`test()` method sends fake error to server. Then, open Hawk and find a test event at the Project's page.
160-
161-
## Sensitive data filtering
162-
163-
You can filter any data that you don't want to send to Hawk. Use the `beforeSend()` hook for that reason.
164-
165-
```js
166-
window.hawk = new HawkCatcher({
167-
token: 'INTEGRATION TOKEN',
168-
beforeSend(event){
169-
if (event.user && event.user.name){
170-
delete event.user.name;
171-
}
172-
173-
return event;
174-
}
175-
})
176-
```
177-
178-
## Dismiss error
179-
180-
You can use the `beforeSend()` hook to prevent sending a particular event. Return `false` for that.
181-
182-
## Usage with &nbsp; <img src="https://cdn.svglogos.dev/logos/vue.svg" width="22"> &nbsp;Vue.js
183-
184-
Vue apps have their own error handler, so if you want to catcher errors thrown inside Vue components, you should set up a Vue integration.
185-
186-
Pass the Vue constructor with the initial settings:
187-
188-
```js
189-
import Vue from 'vue';
190-
191-
const hawk = new HawkCatcher({
192-
token: 'INTEGRATION_TOKEN',
193-
vue: Vue // the Vue constructor you tweak
194-
});
195-
```
196-
197-
or pass it any moment after Hawk Catcher was instantiated:
198-
199-
200-
```js
201-
import Vue from 'vue';
202-
203-
const hawk = new HawkCatcher({
204-
token: 'INTEGRATION_TOKEN',
205-
});
206-
207-
hawk.connectVue(Vue)
208-
```
209-
210-
211-
## Usage with &nbsp; <img src="https://cdn.svglogos.dev/logos/react.svg" width="22"> &nbsp;React
212-
213-
React is suppported out of the box. No additional setup required.
214-
215-
Create the Hawk Catcher instance in a `index.js` file of your project.
216-
217-
218-
```js
219-
import HawkCatcher from '@hawk.so/javascript';
220-
221-
const hawk = new HawkCatcher({
222-
token: 'INTEGRATION_TOKEN'
223-
});
224-
```
23+
- **[@hawk.so/javascript](./packages/javascript)** - Core JavaScript/TypeScript error tracking SDK
22524

22625
## License
22726

package.json

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,29 @@
11
{
2-
"name": "@hawk.so/javascript",
3-
"type": "commonjs",
4-
"version": "3.2.12",
5-
"description": "JavaScript errors tracking for Hawk.so",
6-
"files": [
7-
"dist"
2+
"private": true,
3+
"name": "hawk.javascript",
4+
"type": "module",
5+
"version": "0.0.0",
6+
"workspaces": [
7+
"packages/*"
88
],
9-
"main": "./dist/hawk.umd.js",
10-
"module": "./dist/hawk.mjs",
11-
"types": "dist/index.d.ts",
12-
"exports": {
13-
".": {
14-
"types": "./dist/index.d.ts",
15-
"import": "./dist/hawk.mjs",
16-
"require": "./dist/hawk.umd.js"
17-
}
18-
},
199
"scripts": {
20-
"dev": "vite",
21-
"build": "vite build",
22-
"stats": "size-limit > stats.txt",
23-
"lint": "eslint -c ./.eslintrc.js src/ --ext .ts,.js --fix",
24-
"lint-test": "eslint -c ./.eslintrc.js src/ --ext .ts,.js"
10+
"dev": "yarn workspace @hawk.so/javascript dev",
11+
"build": "yarn workspace @hawk.so/javascript build",
12+
"stats": "yarn workspace @hawk.so/javascript stats",
13+
"lint": "eslint -c ./.eslintrc.cjs packages/*/src --ext .ts,.js --fix",
14+
"lint-test": "eslint -c ./.eslintrc.cjs packages/*/src --ext .ts,.js"
2515
},
2616
"repository": {
2717
"type": "git",
2818
"url": "git+https://github.com/codex-team/hawk.javascript.git"
2919
},
30-
"author": {
31-
"name": "CodeX",
32-
"email": "[email protected]"
33-
},
34-
"license": "AGPL-3.0-only",
35-
"bugs": {
36-
"url": "https://github.com/codex-team/hawk.javascript/issues"
37-
},
38-
"homepage": "https://github.com/codex-team/hawk.javascript#readme",
3920
"devDependencies": {
4021
"@size-limit/preset-small-lib": "^11.1.6",
4122
"eslint": "^7.24.0",
4223
"eslint-config-codex": "^1.6.1",
4324
"rollup-plugin-license": "^3.5.3",
4425
"size-limit": "^11.1.6",
4526
"typescript": "^5.6.3",
46-
"vite": "^5.4.9",
47-
"vue": "^2"
48-
},
49-
"dependencies": {
50-
"@hawk.so/types": "^0.1.36",
51-
"error-stack-parser": "^2.1.4",
52-
"vite-plugin-dts": "^4.2.4"
27+
"vite": "^5.4.9"
5328
}
5429
}
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = [
22
{
3-
path: "dist/hawk.js",
3+
path: "dist/hawk.umd.js",
44
name: "hawk browser"
55
}
66
];

0 commit comments

Comments
 (0)