react-native-admob
react-native-admob copied to clipboard
How to avoid calling createErrorFromErrorData
I am using banners and rewarded ads and want to avoid the errors generated by Admob without having to change node_modules, because they're all related to Google not being able to send an ad due to lack of inventory, bad connection etc. and they flooded my Sentry. With banners, I can ignore createErrorFromErrorData by just not adding onAdFailedToLoad. But on the rewarded ones, it is built inside the own listener.
RNAdMobRewarded.js:
listener = eventEmitter.addListener(mappedEvent, error => handler(createErrorFromErrorData(error)));
will call, in utils.js:
export const createErrorFromErrorData = (errorData) => {
const {
message,
...extraErrorInfo
} = errorData || {};
const error = new Error(message);
error.framesToPop = 1;
return Object.assign(error, extraErrorInfo);
}
Which even if error in createErrorFromErrorData is empty, it'll still send one (errorData || {})
FIXED: I updated sentry to "@sentry/react-native": "^1.4.5" where I can use the beforeSend() method.