sbugert / react-native-admob

A react-native component for Google AdMob banners
BSD 2-Clause "Simplified" License
1.13k stars 532 forks source link

How to avoid calling createErrorFromErrorData #513

Open MarcosHY opened 4 years ago

MarcosHY commented 4 years ago

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.