Skip to content

Commit 90ae61a

Browse files
author
Edward Marzal
committed
added error handler hook with datadogrum
1 parent 47ea394 commit 90ae61a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ui/src/hooks/useJsErrorTracker.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { TrackJS } from 'trackjs';
2+
import { datadogRum } from '@datadog/browser-rum';
3+
4+
const useJsErrorTracker = () => {
5+
const addMetadata = (key: string, value: string) => {
6+
datadogRum.setGlobalContextProperty(key, value);
7+
TrackJS.addMetadata(key, value);
8+
};
9+
const trackError = (error: any) => {
10+
TrackJS.track(error);
11+
//error tracking by dataDog RUM
12+
datadogRum.addError(error);
13+
};
14+
return { addMetadata, trackError };
15+
};
16+
17+
export default useJsErrorTracker;

0 commit comments

Comments
 (0)