Skip to content

Commit cc3f317

Browse files
authored
Merge pull request #147 from codex-team/feat/breadcrumbs-management
feat: add breadcrumb management to Catcher class
2 parents 0f7864c + 184a712 commit cc3f317

16 files changed

Lines changed: 1251 additions & 30 deletions

File tree

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
CI_JOB_NUMBER: 1
99
steps:
1010
- uses: actions/checkout@v1
11-
- name: Use Node.js 20.x
12-
uses: actions/setup-node@v1
11+
- name: Use Node.js from .nvmrc
12+
uses: actions/setup-node@v3
1313
with:
14-
node-version: 20.x
14+
node-version-file: '.nvmrc'
1515
- run: yarn install
1616
- run: yarn lint-test
1717

@@ -21,9 +21,9 @@ jobs:
2121
CI_JOB_NUMBER: 2
2222
steps:
2323
- uses: actions/checkout@v1
24-
- name: Use Node.js 20.x
25-
uses: actions/setup-node@v1
24+
- name: Use Node.js from .nvmrc
25+
uses: actions/setup-node@v3
2626
with:
27-
node-version: 20.x
27+
node-version-file: '.nvmrc'
2828
- run: yarn install
2929
- run: yarn build

.github/workflows/npm-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
- uses: actions/setup-node@v1
13+
- uses: actions/setup-node@v3
1414
with:
15-
node-version: 20
15+
node-version-file: '.nvmrc'
1616
registry-url: https://registry.npmjs.org/
1717
- run: yarn
1818
- run: yarn lint-test

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.18.0
1+
24.12.0

packages/javascript/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Initialization settings:
8888
| `disableGlobalErrorsHandling` | boolean | optional | Do not initialize global errors handling |
8989
| `disableVueErrorHandler` | boolean | optional | Do not initialize Vue errors handling |
9090
| `consoleTracking` | boolean | optional | Initialize console logs tracking |
91+
| `breadcrumbs` | false or BreadcrumbsOptions object | optional | Configure breadcrumbs tracking (see below) |
9192
| `beforeSend` | function(event) => event | optional | This Method allows you to filter any data you don't want sending to Hawk |
9293

9394
Other available [initial settings](types/hawk-initial-settings.d.ts) are described at the type definition.
@@ -145,6 +146,92 @@ hawk.setContext({
145146
});
146147
```
147148

149+
## Breadcrumbs
150+
151+
Breadcrumbs track user interactions and events leading up to an error, providing context for debugging.
152+
153+
### Default Configuration
154+
155+
By default, breadcrumbs are enabled with tracking for fetch/XHR requests, navigation, and UI clicks:
156+
157+
```js
158+
const hawk = new HawkCatcher({
159+
token: 'INTEGRATION_TOKEN'
160+
// breadcrumbs enabled by default
161+
});
162+
```
163+
164+
### Disabling Breadcrumbs
165+
166+
To disable breadcrumbs entirely:
167+
168+
```js
169+
const hawk = new HawkCatcher({
170+
token: 'INTEGRATION_TOKEN',
171+
breadcrumbs: false
172+
});
173+
```
174+
175+
### Custom Configuration
176+
177+
Configure breadcrumbs tracking behavior:
178+
179+
```js
180+
const hawk = new HawkCatcher({
181+
token: 'INTEGRATION_TOKEN',
182+
breadcrumbs: {
183+
maxBreadcrumbs: 20, // Maximum breadcrumbs to store (default: 15)
184+
trackFetch: true, // Track fetch/XHR requests (default: true)
185+
trackNavigation: true, // Track navigation events (default: true)
186+
trackClicks: true, // Track UI clicks (default: true)
187+
beforeBreadcrumb: (breadcrumb, hint) => {
188+
// Filter or modify breadcrumbs before storing
189+
if (breadcrumb.category === 'fetch' && breadcrumb.data?.url?.includes('/sensitive')) {
190+
return null; // Discard this breadcrumb
191+
}
192+
return breadcrumb;
193+
}
194+
}
195+
});
196+
```
197+
198+
### Breadcrumbs Options
199+
200+
| Option | Type | Default | Description |
201+
|--------|------|---------|-------------|
202+
| `maxBreadcrumbs` | `number` | `15` | Maximum number of breadcrumbs to store. When the limit is reached, oldest breadcrumbs are removed (FIFO). |
203+
| `trackFetch` | `boolean` | `true` | Automatically track `fetch()` and `XMLHttpRequest` calls as breadcrumbs. Captures request URL, method, status code, and response time. |
204+
| `trackNavigation` | `boolean` | `true` | Automatically track navigation events (History API: `pushState`, `replaceState`, `popstate`). Captures route changes. |
205+
| `trackClicks` | `boolean` | `true` | Automatically track UI click events. Captures element selector, coordinates, and other click metadata. |
206+
| `beforeBreadcrumb` | `function` | `undefined` | Hook called before each breadcrumb is stored. Receives `(breadcrumb, hint)` and can return modified breadcrumb, `null` to discard it, or the original breadcrumb. Useful for filtering sensitive data or PII. |
207+
208+
### Manual Breadcrumbs
209+
210+
Add custom breadcrumbs manually:
211+
212+
```js
213+
hawk.breadcrumbs.add({
214+
type: 'logic',
215+
category: 'auth',
216+
message: 'User logged in',
217+
level: 'info',
218+
data: { userId: '123' }
219+
});
220+
```
221+
222+
### Breadcrumb Methods
223+
224+
```js
225+
// Add a breadcrumb
226+
hawk.breadcrumbs.add(breadcrumb, hint);
227+
228+
// Get current breadcrumbs
229+
const breadcrumbs = hawk.breadcrumbs.get();
230+
231+
// Clear all breadcrumbs
232+
hawk.breadcrumbs.clear();
233+
```
234+
148235
## Source maps consuming
149236
150237
If your bundle is minified, it is useful to pass source-map files to the Hawk. After that you will see beautiful

0 commit comments

Comments
 (0)