0.9.1 • Published 7 months ago
bar-analytics v0.9.1
bar-analytics
Installation
yarn add bar-analytics
npx expo install @react-native-firebase/analytics @react-native-firebase/app expo-build-properties
Setup
- Create Firebase Project, if not already done
- Create Firebase Android App, if not already done
- Download the google-service.json file and place it in your app's main folder
- Create Firebase iOS App, if not already done
- Download the GoogleService-Info.plist file and place it in your app's main folder
- 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
0.9.1
7 months ago