React Native Tracking

Hey @tfinkel,

I’m actually in the middle of digging into this. It definitely works (100% confirmed for iOS, untested for android but high degree of confidence), but in its current iteration it needs a lot of manual configuration & can be painful. The readme as it stands doesn’t look like it covers everything required (I hope to update this once I’m on top of it).

One of the causes of this is that react-native and react-native-cli updates have introduced breaking changes to how to automatically import it. I’ve not yet verified it for RN 0.60.x but I suspect there will be a bit of work in updating it for that, since native module imports have changed in that release.

We’d welcome contributions and suggestions on how to go about improving it, especially from people who know their way around react native - for now we’re keen to get the current functionality into a stage where it’s as automatic and easy to use as possible.

Even reporting back any issues you face in trying to use it would be really helpful to us at this point.

It’s in early stage development but having navigated some of the complexities I’m feeling confident in the outlook for the tracker once we get it into shape. (I’m not the one to say how that’s roadmapped, but it looks feasible to eventually land in a place where all the functionality of the native mobile trackers are available).

Here’s a dump of my notes on steps to get it running in for iOS for the demo app in the repo, hopefully that’d be a good starting point towards getting it sorted for another project:

From the DemoApp folder:

npm install
npm audit fix (this may not be necessary but it’s a good idea regardless - the next version of the tracker should update the package.json)
cd ios && pod install (may not be necessary in all cases)

The above steps ensure that all dependencies are present. However the Xcode project may not have the dependencies linked correctly (there’s been a change to how linking is handled in the cli since the tracker was built, so using the react-native method of autolinking appears not to work).

xed DemoApp.xcodeproj/ to open the project in xcode.

Navigate to DemoApp > Targets - DemoApp > Build Phases > Link Binary with Libraries

Everything in there should be a framework. Remove all the files, then + and Add Files in the drop down.

Add DemoApp/ios/Pods/Pods.xcodeproj .

Add all the frameworks that aren’t there already (I’m assuming all are necessary, yet to test what might be stripped out).

Once you’ve done that, your project should build on cmd+B . If you’re using Xcode < 11, I believe you should also be able to run with cmd+R or react-native run-ios from the DemoApp folder (I’m on Xcode 11 so I haven’t verified this - let me know if it doesn’t).

However Xcode11 introduced a bug which was fixed in the next version of react native, so if you’re on Xcode11, you’ll need these additional steps:

  • Bump the react-native dependency in package.json to ^0.59.9 (I’m yet to test any later versions)
  "dependencies": {
    "@snowplow/react-native-tracker": "0.1.0-alpha.9",
    "react": "^16.8.3",
    "react-native": "^0.59.9"
  },
  • From the DemoApp folder, rm -rf node_modules && npm install

react-native run-ios should now run successfully and send data. (It’s best to terminate the metro server & iOS simulator first, and perhaps to clean the build in xcode with cmd+opt+k to ensure a clean build from first principles).