thebergamo / react-native-fbsdk-next

MIT License
692 stars 166 forks source link

Calling `logPurchase` with invalid currency causes native crash. #570

Open nixolas1 opened 1 month ago

nixolas1 commented 1 month ago

🐛 Bug Report

Calling AppEventsLogger.logPurchase with invalid currency causes native app crash on Android. AppEventsLogger.logPurchase(10.0, "FAKE_CURRENCY")

java.lang.IllegalArgumentException: The input currency code is not 3-letter alphabetic code.
    at android.icu.util.Currency.getInstance(Currency.java:289)
    at java.util.Currency.getInstance(Currency.java:278)
    at com.facebook.reactnative.androidsdk.FBAppEventsLoggerModule.logPurchase(FBAppEventsLoggerModule.java:191)

To Reproduce

On android:

const price = 10
const currency = undefined;
AppEventsLogger.logPurchase(price, currency ?? "NOT_SET");

(app closes)

Expected Behavior

Function throws error, but only in JS space, so a try/catch stops the error from crashing the app. Having a tracking function crash the entire app is not so good.

Environment

Expo 51 "react-native-fbsdk-next": "^13.1.3"

SDKs: Android SDK: API Levels:

  • "31"
  • "33"
  • "34" Build Tools:
  • 30.0.3
  • 31.0.0
  • 33.0.0
  • 33.0.1
  • 33.0.2
  • 34.0.0
  • 35.0.0 System Images:
  • android-30 | Google APIs ARM 64 v8a
  • android-31 | Google Play ARM 64 v8a
  • android-33 | Google Play ARM 64 v8a
  • android-34 | Google APIs ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2024.1 AI-241.18034.62.2412.12266719 Languages: Java: version: 17.0.10 path: /usr/bin/javac

npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.74.5 wanted: 0.74.5 npmGlobalPackages: "react-native": Not Found Android: hermesEnabled: Not found newArchEnabled: Not found

stale[bot] commented 11 hours ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.