Skip to content

Commit 303502b

Browse files
authored
Merge pull request #130 from codex-team/feat/set-context-user
feat(hawk-js): add setContext and setUser methods
2 parents 5ba0baa + d15b84b commit 303502b

File tree

7 files changed

+422
-235
lines changed

7 files changed

+422
-235
lines changed

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,41 @@ const hawk = new HawkCatcher({token: 'INTEGRATION_TOKEN'});
106106

107107
// somewhere in try-catch block or other custom place
108108
hawk.send(new Error('Something went wrong'), {
109-
myOwnDebugInfo: '1234'
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',
110144
});
111145
```
112146

0 commit comments

Comments
 (0)