ghl-sentry
Version:
23 lines (22 loc) • 1.05 kB
JavaScript
import { extractErrorMessageFromOrigException } from '../utils';
const ignoredErrorStrings = ['TypeError', 'Load failed', 'Request failed with status code', 'Network Error'].map(s => s.toLowerCase());
export const filterMacOsUnwantedExceptions = (event, hint) => {
const originalException = hint?.originalException;
const errorMessage = extractErrorMessageFromOrigException(originalException).toLowerCase();
if (ignoredErrorStrings.some(s => errorMessage.includes(s))) {
try {
const userAgent = window.navigator.userAgent;
const iOS = !!userAgent.match(/iPad/i) || !!userAgent.match(/iPhone/i);
const macos = !!userAgent.match(/Macintosh/i);
const safari = !!userAgent.match(/Safari/i) && !userAgent.match(/Chrome/i);
if ((iOS || macos) && safari) {
return true;
}
}
catch (error) {
console.warn('An error occurred while detecting the browser:', error);
return false;
}
}
return false;
};