5

I'm trying to use Segment for analytics on my React Native app. I want it to work for both Android and iOs. This issue persists on both OS's.

I installed the NPM library as explained here by doing:

yarn add @segment/analytics-react-native
yarn react-native link

Expected behaviour: I'm able to use analytics in the app

Actual behaviour: an error is thrown with message "Failed to load Analytics native module"

Code: (i do this in App.tsx/componentDidMount)

import Segment from '@segment/analytics-react-native';
import FirebaseAnalytics from '@segment/analytics-react-native-firebase'

Segment.setup(keys.segment.writeKey, {
  recordScreenViews: true,
  trackAppLifecycleEvents: true,
  trackAttributionData: true,
  using: [FirebaseAnalytics]
})

This is pretty much what they use in the documents. I'm not sure what I'm doing wrong. One thing to note is that I'm using Expo, not plain react-native.

I've tried solutions mentioned here and here but to no avail.

Isonlaxman
  • 93
  • 8

0 Answers0