Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Analytics in react native using fabric
Brief gists to enable user analytics in react native using fabric
...
import { Crashlytics, Answers } from 'react-native-fabric'; //Add Answers
export default class FabricAnalytics extends Component {
componentDidMount(){
...
//Additional answers
Answers.logContentView('To Do 1', 'To-Do', 'to-do-42');
Answers.logContentView('To Do 2', 'To-Do', 'to-do-42');
}
...
}
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import { Crashlytics } from 'react-native-fabric'; //Get Crashlytics component
export default class FabricAnalytics extends Component {
componentDidMount(){
//Sets user details
Crashlytics.setUserName('megaman');
Crashlytics.setUserEmail('user@email.com');
Crashlytics.setUserIdentifier('1234');
}
render() {
return (
<View style={styles.container}>
<Text style={styles.text}>
React native fabric
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
text: {
fontSize: 20,
textAlign: 'center',
margin: 10,
}
});
AppRegistry.registerComponent('FabricAnalytics', () => FabricAnalytics);
export default class FabricAnalytics extends Component {
componentDidMount(){
...
setTimeout(()=> Crashlytics.crash(), 5000); //simulates a crash after 5 seconds
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment