0.9.1 • Published 7 months ago

bar-analytics v0.9.1

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

bar-analytics

Installation

yarn add bar-analytics
npx expo install @react-native-firebase/analytics @react-native-firebase/app expo-build-properties

Setup

  1. Create Firebase Project, if not already done
  2. Create Firebase Android App, if not already done
  3. Download the google-service.json file and place it in your app's main folder
  4. Create Firebase iOS App, if not already done
  5. Download the GoogleService-Info.plist file and place it in your app's main folder
  6. Update you app.json as follows:
{
  "expo": {
    // ...
    "ios": {
      "googleServicesFile": "./GoogleService-Info.plist",
      // ...
    },
    "android": {
      "googleServicesFile": "./google-services.json",
      // ...
    },
    "plugins": [
      "@react-native-firebase/app",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}

Usage

Here is a very basic example that will capture screen views and automatically assign the name given in the Tab/Stack:

import { AnalyticsNavigationContainer } from 'bar-analytics';

const App = () => (
  <AnalyticsNavigationContainer>
    <BottomTabNav />
  </AnalyticsNavigationContainer>
);

export default App;

You can also fire any event, same as if you were using firebase's react native import.

import analytics from 'bar-analytics';

const Screen = () => {
  const onPress = React.useCallback(() => {
    // Your onPress logic

    analytics().logEvent('press_event');
  });

  // ...
};

License

MIT


Made with create-react-native-library