segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
366 stars 189 forks source link

Mixpanel device-mode integration conflict with Facebook SDK #334

Closed migue1s closed 3 years ago

migue1s commented 3 years ago

๐Ÿ› Bug Report

App is crashing on app startup on iOS. This seems to be an issue between the mixpanel version and the facebook sdk.

+[MPSwizzler swizzleSelector:onClass:withBlock:named:async:]: unrecognized selector sent to class 0x107ac4aa8
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[MPSwizzler swizzleSelector:onClass:withBlock:named:async:]: unrecognized selector sent to class 0x107ac4aa8'
*** First throw call stack:
(0x1a46bd9d8 0x1b8a40b54 0x1a45d2070 0x1a46c001c 0x1a46c1f8c 0x1040f1558 0x107a1e488 0x10a811528 0x10a8208a8 0x10a811528 0x10a81f994 0x1a463d5e0 0x1a4637a88 0x1a4636ba0 0x1bb39c598 0x1a6f282f4 0x1a6f2d874 0x10276caf8 0x1a4315568)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[MPSwizzler swizzleSelector:onClass:withBlock:named:async:]: unrecognized selector sent to class 0x107ac4aa8'
terminating with uncaught exception of type NSException

To Reproduce

Settings.initializeSDK();

- Build and run

## Expected Behavior
- App works as before

## Actual Behavior
- App crashes on startup

## Further information

Initially reported on https://github.com/thebergamo/react-native-fbsdk-next/issues/54. 

From the findings in that issue, it is a conflict in the mixpanel library for a now-deprecated feature, likely to be https://github.com/mixpanel/mixpanel-iphone/issues/934. It is fixed on v4 beta of their native lib.

Another user reported that using the `mixpanel-react-native` directly solved their issue.

This was reproducible by me using the following dependencies:
```js
    "@segment/analytics-react-native": "1.4.8",
    "@segment/analytics-react-native-mixpanel": "1.4.8", // This is the 3.7.1 Mixpanel SDK 
    "react-native-fbsdk-next": "4.3.0" // This includes the v9 FB SDK

Environment

System: OS: macOS 11.2.3 CPU: (8) x64 Apple M1 Memory: 270.97 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.2 - /var/folders/py/_bdk2p1n13v1hc7fq1bhs2000000gn/T/yarn--1623436645989-0.8183305738118558/node Yarn: 1.22.10 - /var/folders/py/_bdk2p1n13v1hc7fq1bhs2000000gn/T/yarn--1623436645989-0.8183305738118558/yarn npm: 6.14.9 - ~/.nvm/versions/node/v14.15.2/bin/npm Watchman: 4.9.0 - /opt/homebrew/bin/watchman Managers: CocoaPods: Not Found // using 1.10.1 with bundler SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2 System Images: android-S | Google APIs ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 4.2 AI-202.7660.26.42.7351085 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: ^0.63.3 => 0.63.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

alanjcharles commented 3 years ago

Hi @migue1s ! If you are trying to use Facebook App Events have you considered using the Segment package rather than implementing it natively? Thanks for bringing this to our attention, we can definitely bump Mixpanel to remove their deprecated functionality, but we can't push that into production until version 4.0.0 is no longer in beta on the Mixpanel side. Please let me know if adding that package works works for you or if you're still running into issues

migue1s commented 3 years ago

Hi @alanjcharles, we currently are using an older version of the facebook sdk in the meantime. The use-case for the FBSDK was actually facebook login, so the segment package is not a replacement for it. Thanks for the suggestion and definitely understand waiting until it's out of the beta phase!

cwhenderson20 commented 3 years ago

@alanjcharles Mixpanel released a new minor version of the lib that disables automatic push tracking by default (thus fixing the default initializer/method swizzling issue). Would it be possible to bump to that version (from 3.7.1 to 3.9.0)?

alanjcharles commented 3 years ago

Thanks for letting me know @cwhenderson20. I can definitely do that. We have a code freeze for the holiday but happy to make that happen first thing Monday morning. I'll follow up when it's live.

cwhenderson20 commented 3 years ago

Thank you!

alanjcharles commented 3 years ago

@cwhenderson20 @migue1s The release is live.

Please pull down the latest versions and re-open if you're still running into issues and we can go from there.