-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
175 lines (149 loc) · 5.72 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import React, {Component} from 'react';
import { createStackNavigator, createAppContainer } from "react-navigation";
import { GoogleAnalyticsTracker } from "react-native-google-analytics-bridge";
import { Button, Text, View , ImageBackground } from 'react-native';
import firebase from 'react-native-firebase';
const tracker1 = new GoogleAnalyticsTracker("UA-8146561-2");
class HomeOne extends React.Component {
static navigationOptions = {
title: 'R-T-A Screen-One',
};
_triggerGA(){
tracker1.trackEvent("React-Test-App-Button-Click1","Click");
alert("Your event has been recorded to Google Analytics");
}
_triggerFA(){
firebase.analytics().logEvent("kasatria_FA_button_click");
alert("Your Firebase event has been recorded to Firebase Analytics");
}
render(){
tracker1.trackScreenView("React-Test-App-Screen-One");
firebase.analytics().setCurrentScreen("React-Test-App-Screen-One");
firebase.analytics().setUserProperty("Fullname","Kasatria React Native Test App");
firebase.analytics().setUserProperty("gender","Male");
firebase.analytics().setUserProperty("Organization","Kasatria");
return(
<View style={{
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
}}>
<View style={{height: 180, marginTop: 5, paddingTop: 30, paddingLeft: 10, paddingRight: 10, backgroundColor: 'white'}}>
<ImageBackground style={{ width: '100%', height: '100%'}} source={require('./logo.png')} />
</View>
<View style={{height: 50, marginTop: 5, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white'}}>
<Button
onPress={this._triggerGA}
title="GA Event Trigger"
/>
</View>
<View style={{height: 50, marginTop: 20, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white'}}>
<Button
onPress={this._triggerFA}
title="Firebase Event Trigger"
/>
</View>
<View style={{height: 70, marginTop: 20, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white', flexDirection: 'row', justifyContent: 'space-around'}}>
<Button
onPress={() => this.props.navigation.navigate('Detail')}
title="Screeen 2"
/>
<Button
onPress={() => this.props.navigation.navigate('Detail2')}
title="Screeen 3"
/>
</View>
</View>
);
}
}
class DetailsScreen extends React.Component {
static navigationOptions = {
title: 'R-T-A Screen-Two',
};
_triggerFA(){
tracker1.trackEvent("Kasatria_Checkout_Button","Click",{"itemId":"123AEFR","itemName":"SONY Xtra Bass Earbuds"});
firebase.analytics().logEvent("Kasatria_Checkout_Button",{"itemId":"123AEFR","itemName":"SONY Xtra Bass Earbuds"});
alert("Your item has been added to your cart");
}
render() {
tracker1.trackScreenView("React-Test-App-Screen-Two");
tracker1.trackEvent("React-Test-App-Click_Page_2","Click");
firebase.analytics().logEvent("kasatria_FA_click_page_two");
firebase.analytics().setCurrentScreen("React-Test-App-Screen-Two");
return (
<View style={{
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
}}>
<View style={{height: 180, marginTop: 5, paddingTop: 30, paddingLeft: 10, paddingRight: 10, backgroundColor: 'white'}}>
<ImageBackground style={{ width: '100%', height: '100%'}} source={require('./logo.png')} />
</View>
<View style={{height: 50, marginTop: 20, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white'}}>
<Button
onPress={this._triggerFA}
title="Sample Checkout"
/>
</View>
<View style={{height: 50, marginTop: 20, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white'}}>
<Button
onPress={() => this.props.navigation.navigate('Home')}
title="Back Home"
/>
</View>
</View>
);
}
}
class DetailsScreen2 extends React.Component {
static navigationOptions = {
title: 'R-T-A Screen-Three',
};
render() {
tracker1.trackScreenView("React-Test-App-Screen-Three");
tracker1.trackEvent("React-Test-App-Click_Page_3","Click");
firebase.analytics().logEvent("kasatria_FA_click_page_three");
firebase.analytics().setCurrentScreen("React-Test-App-Screen-Three");
return (
<View style={{
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
}}>
<View style={{height: 180, marginTop: 5, paddingTop: 30, paddingLeft: 10, paddingRight: 10, backgroundColor: 'white'}}>
<ImageBackground style={{ width: '100%', height: '100%'}} source={require('./logo.png')} />
</View>
<View style={{height: 50, marginTop: 20, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white'}}>
<Button
onPress={() => this.props.navigation.navigate('Home')}
title="Back Home"
/>
</View>
</View>
);
}
}
const AppNavigator = createStackNavigator(
{
Home : HomeOne,
Detail : DetailsScreen,
Detail2 : DetailsScreen2
},
{
initialRouteName: "Home",
defaultNavigationOptions: {
headerStyle: {
backgroundColor: '#000000',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
},
}
);
export default createAppContainer(AppNavigator);