evollu / react-native-firebase-analytics

React native bridge for firebase analytics
MIT License
206 stars 54 forks source link

Where do we need to put the code #24

Closed bondanherumurti closed 7 years ago

bondanherumurti commented 7 years ago

So where do we need to put the code

var Analytics = require('react-native-firebase-analytics');

componentWillMount() {
  if (environment === 'staging') {
    Analytics.setEnabled(false);
  }

  Analytics.setUserId('11111');
  Analytics.setUserProperty('propertyName', 'propertyValue');

  Analytics.logEvent('view_item', {
    'item_id': 'login'
  });

}

on every screen.js / index.ios.js ? and what is UserID? is that custom property or property defined from Google?

alexHlebnikov commented 7 years ago

You need to add it onlue in your App.js (or something) - in your root component.

alexHlebnikov commented 7 years ago

UersID is the same thing as Device ID, you can get it with this package https://github.com/rebeccahughes/react-native-device-info

evollu commented 7 years ago

looks like solved