Last active
June 24, 2017 16:54
-
-
Save siwananda/7d9b62b2a9b09442abb532a177187157 to your computer and use it in GitHub Desktop.
Analytics in react native using fabric
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Brief gists to enable user analytics in react native using fabric |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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'); | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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