Refactor monitoring package and improve error handling
The monitoring package has been significantly refactored to improve the granularity of error capture. Code from the 'capture-exception.ts' files in different locations have been deleted and replaced by a more unified approach in the 'use-baselime.ts' and 'use-sentry.ts' hooks. The README documentation has also been updated to reflect these changes and provide additional information about error monitoring setup and usage.
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
export function captureException(error: Error) {
|
||||
console.info(`No yet defined...`);
|
||||
return console.error(`Caught exception: ${JSON.stringify(error)}`);
|
||||
}
|
||||
1
packages/monitoring/baselime/src/client.ts
Normal file
1
packages/monitoring/baselime/src/client.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './hooks/use-baselime';
|
||||
20
packages/monitoring/baselime/src/hooks/use-baselime.ts
Normal file
20
packages/monitoring/baselime/src/hooks/use-baselime.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useBaselimeRum } from '@baselime/react-rum';
|
||||
|
||||
import { MonitoringService } from '../../../src/services/monitoring.service';
|
||||
|
||||
/**
|
||||
* @name useBaselime
|
||||
* @description Get the Baselime monitoring service for the browser.
|
||||
*/
|
||||
export function useBaselime(): MonitoringService {
|
||||
const { captureException, setUser } = useBaselimeRum();
|
||||
|
||||
return {
|
||||
captureException(error: Error, extra?: React.ErrorInfo | undefined) {
|
||||
void captureException(error, extra);
|
||||
},
|
||||
identifyUser(params) {
|
||||
setUser(params.id);
|
||||
},
|
||||
} satisfies MonitoringService;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { useBaselimeRum } from '@baselime/react-rum';
|
||||
|
||||
export function useCaptureException() {
|
||||
const { captureException } = useBaselimeRum();
|
||||
|
||||
return useCallback(
|
||||
(error: Error) => captureException(error),
|
||||
[captureException],
|
||||
);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from './capture-exception';
|
||||
1
packages/monitoring/baselime/src/server.ts
Normal file
1
packages/monitoring/baselime/src/server.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './services/baselime-server-monitoring.service';
|
||||
@@ -0,0 +1,9 @@
|
||||
import { MonitoringService } from '../../../src/services/monitoring.service';
|
||||
|
||||
export class BaselimeServerMonitoringService implements MonitoringService {
|
||||
captureException(error: Error | null) {
|
||||
console.error(`Caught exception: ${JSON.stringify(error)}`);
|
||||
}
|
||||
|
||||
identifyUser<Info extends { id: string }>(info: Info) {}
|
||||
}
|
||||
Reference in New Issue
Block a user