B2B-88: add starter kit structure and elements
This commit is contained in:
30
packages/monitoring/baselime/src/hooks/use-baselime.ts
Normal file
30
packages/monitoring/baselime/src/hooks/use-baselime.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { useBaselimeRum } from '@baselime/react-rum';
|
||||
|
||||
import { MonitoringService } from '@kit/monitoring-core';
|
||||
|
||||
/**
|
||||
* @name useBaselime
|
||||
* @description Get the Baselime monitoring service for the browser.
|
||||
*/
|
||||
export function useBaselime(): MonitoringService {
|
||||
const { captureException, setUser, sendEvent } = useBaselimeRum();
|
||||
|
||||
return useMemo(() => {
|
||||
return {
|
||||
captureException(error: Error, extra?: React.ErrorInfo) {
|
||||
void captureException(error, extra);
|
||||
},
|
||||
identifyUser(params) {
|
||||
setUser(params.id);
|
||||
},
|
||||
captureEvent<Extra extends object>(event: string, extra?: Extra) {
|
||||
return sendEvent(event, extra);
|
||||
},
|
||||
ready() {
|
||||
return Promise.resolve();
|
||||
},
|
||||
} satisfies MonitoringService;
|
||||
}, [captureException, sendEvent, setUser]);
|
||||
}
|
||||
Reference in New Issue
Block a user