There are some error coming from third party like Script error., promise rejection not handle, how can i avoid and don't capture these kind of error
import { isServer } from '@utils/appAgent'
function checkApmError(err: any) {
return err && err.message && err.message.indexOf('Script error') !== -1 ? true : false
}
export default function logError(e: any) {
const errorObject = {
result: 'error',
errorStack: e.stack,
rootURL: window.location.href,
errorMessage: e.message
}
setTimeout(() => {
// eslint-disable-next-line
if (e.message && e.message !== 'Network Error' && !(e.message.indexOf('failed with status') > -1)) {
if (typeof newrelic == 'object') {
newrelic.addPageAction('pwa-error-ssr', {
result: 'error',
errorStack: e.stack,
rootURL: window.location.href,
errorMessage: e.message
})
}
if (!isServer() && window?.apm && checkApmError(e) ) {
window?.apm.captureError(new Error(JSON.stringify(errorObject)));
}
}
console.error(e)
})
}
I am using Nextjs, "@elastic/apm-rum": "^5.16.0",, macos