@@ -16,7 +16,7 @@ import {
16
16
ScrollView
17
17
} from 'react-native' ;
18
18
19
- import Instabug from 'instabug-reactnative' ;
19
+ import Instabug , { BugReporting , FeatureRequests , Surveys , Chats , CrashReporting , Replies } from 'instabug-reactnative' ;
20
20
21
21
22
22
const instructions = Platform . select ( {
@@ -31,12 +31,12 @@ export default class App extends Component<{}> {
31
31
constructor ( props ) {
32
32
super ( props ) ;
33
33
this . state = {
34
- switchValue : false ,
35
- colorTheme : 'Dark '
34
+ switchValue : true ,
35
+ colorTheme : 'Light '
36
36
} ;
37
- Instabug . startWithToken ( "APP_TOKEN" , Instabug . invocationEvent . shake ) ;
38
- Instabug . setReportCategories ( "Performance" , "UI" , "Flow" , "Other" ) ;
39
- Instabug . setPromptOptionsEnabled ( true , true , true ) ;
37
+
38
+ Instabug . startWithToken ( "APP_TOKEN" , [ Instabug . invocationEvent . shake ] ) ;
39
+ BugReporting . setReportTypes ( [ BugReporting . reportType . bug , BugReporting . reportType . feedback ] ) ;
40
40
Instabug . setLocale ( Instabug . locale . english ) ;
41
41
}
42
42
@@ -48,9 +48,6 @@ export default class App extends Component<{}> {
48
48
Hello { "Instabug's" } awesome user! The purpose of this application is to show you the different
49
49
options for customizing the SDK and how easy it is to integrate it to your existing app
50
50
</ Text >
51
- < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showIntroMessage ( ) } >
52
- < Text style = { styles . text } > SHOW INTRO MESSAGE </ Text >
53
- </ TouchableOpacity >
54
51
< TouchableOpacity style = { styles . button } onPress = { ( ) => this . invoke ( ) } >
55
52
< Text style = { styles . text } > INVOKE </ Text >
56
53
</ TouchableOpacity >
@@ -60,27 +57,31 @@ export default class App extends Component<{}> {
60
57
< TouchableOpacity style = { styles . button } onPress = { ( ) => this . sendFeedback ( ) } >
61
58
< Text style = { styles . text } > SEND FEEDBACK </ Text >
62
59
</ TouchableOpacity >
60
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . sendCrashReport ( ) } >
61
+ < Text style = { styles . text } > THROW HANDLED EXCEPTION </ Text >
62
+ </ TouchableOpacity >
63
63
< TouchableOpacity style = { styles . button } onPress = { ( ) => this . startNewConversation ( ) } >
64
64
< Text style = { styles . text } > START A NEW CONVERSATION </ Text >
65
65
</ TouchableOpacity >
66
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showNpsSurvey ( ) } >
67
+ < Text style = { styles . text } > SHOW NPS SURVEY </ Text >
68
+ </ TouchableOpacity >
69
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showMultipleQuestionSurvey ( ) } >
70
+ < Text style = { styles . text } > SHOW MULTIPLE QUESTION SURVEY </ Text >
71
+ </ TouchableOpacity >
72
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showFeatureRequests ( ) } >
73
+ < Text style = { styles . text } > SHOW FEATURE REQUESTS </ Text >
74
+ </ TouchableOpacity >
66
75
< TouchableOpacity style = { styles . button } onPress = { ( ) => this . showUnreadMessagesCount ( ) } >
67
76
< Text style = { styles . text } > GET UNREAD MESSAGES COUNT </ Text >
68
77
</ TouchableOpacity >
69
78
{ this . invocationEvent ( ) }
70
79
< Text style = { styles . textColor } > Set primary color </ Text >
71
80
< View style = { styles . rowView } >
72
- < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . setPrimaryColor ( '#FF0000' ) } >
73
- < Text style = { styles . text } > RED </ Text >
74
- </ TouchableOpacity >
75
- < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . setPrimaryColor ( '#00FF00' ) } >
76
- < Text style = { styles . text } > GREEN </ Text >
77
- </ TouchableOpacity >
78
- < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . setPrimaryColor ( '#0000FF' ) } >
79
- < Text style = { styles . text } > BLUE </ Text >
80
- </ TouchableOpacity >
81
- < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . setPrimaryColor ( '#FFFF00' ) } >
82
- < Text style = { styles . text } > YELLOW </ Text >
83
- </ TouchableOpacity >
81
+ < TouchableOpacity style = { buttonColor ( '#FF0000' ) } onPress = { ( ) => this . setPrimaryColor ( '#FF0000' ) } />
82
+ < TouchableOpacity style = { buttonColor ( '#00FF00' ) } onPress = { ( ) => this . setPrimaryColor ( '#00FF00' ) } />
83
+ < TouchableOpacity style = { buttonColor ( '#0000FF' ) } onPress = { ( ) => this . setPrimaryColor ( '#0000FF' ) } />
84
+ < TouchableOpacity style = { buttonColor ( '#FFFF00' ) } onPress = { ( ) => this . setPrimaryColor ( '#FFFF00' ) } />
84
85
</ View >
85
86
< View style = { styles . switchView } >
86
87
< Text style = { styles . textSwitchStyle } > Color Theme: { this . state . colorTheme } </ Text >
@@ -94,28 +95,28 @@ export default class App extends Component<{}> {
94
95
}
95
96
96
97
invocationEvent ( ) {
97
- if ( Platform . OS === 'ios ') {
98
98
return (
99
99
< View >
100
100
< Text style = { styles . textColor } > Change Invocation Event < / T e x t >
101
101
< View style = { styles . rowView } >
102
102
< TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Shake' ) } >
103
103
< Text style = { styles . textInvoke } > SHAKE </ Text >
104
104
</ TouchableOpacity >
105
- < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Button' ) } >
106
- < Text style = { styles . textInvoke } > FLOATING BUTTON </ Text >
107
- </ TouchableOpacity >
108
105
< TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Screenshot' ) } >
109
106
< Text style = { styles . textInvoke } > SCREENSHOT </ Text >
110
107
</ TouchableOpacity >
108
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'twoFingersSwipe' ) } >
109
+ < Text style = { styles . textInvoke } > TWO FINGERS SWIPE LEFT</ Text >
110
+ </ TouchableOpacity >
111
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Button' ) } >
112
+ < Text style = { styles . textInvoke } > FLOATING BUTTON </ Text >
113
+ </ TouchableOpacity >
111
114
< TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'None' ) } >
112
115
< Text style = { styles . textInvoke } > NONE </ Text >
113
116
</ TouchableOpacity >
114
117
</ View >
115
118
< / V i e w >
116
119
) ;
117
- }
118
- return ;
119
120
}
120
121
121
122
toggleSwitch = ( value ) => {
@@ -138,44 +139,78 @@ export default class App extends Component<{}> {
138
139
}
139
140
140
141
invoke ( ) {
141
- Instabug . invoke ( ) ;
142
+ Instabug . show ( ) ;
143
+ }
144
+
145
+ showMultipleQuestionSurvey ( ) {
146
+ Surveys . showSurvey ( "ZAKSlVz98QdPyOx1wIt8BA" ) ;
147
+ }
148
+
149
+ showNpsSurvey ( ) {
150
+ Surveys . showSurvey ( "pcV_mE2ttqHxT1iqvBxL0w" ) ;
151
+ }
152
+
153
+ showFeatureRequests ( ) {
154
+ FeatureRequests . show ( ) ;
142
155
}
143
156
144
157
sendBugReport ( ) {
145
- Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newBug ) ;
158
+ BugReporting . showWithOptions ( BugReporting . reportType . bug ) ;
159
+ }
160
+
161
+ sendCrashReport ( ) {
162
+ try {
163
+ throw new Error ( 'Text Handled Exception From Instabug Test App' ) ;
164
+ } catch ( Exception ) {
165
+ CrashReporting . reportJSException ( Exception ) ;
166
+ alert ( 'Crash report Sent!' ) ;
167
+ }
146
168
}
147
169
148
170
sendFeedback ( ) {
149
- Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newFeedback ) ;
171
+ BugReporting . showWithOptions ( BugReporting . reportType . feedback , [ BugReporting . option . emailFieldHidden ] ) ;
172
+
150
173
}
151
174
152
175
changeInvocationEvent ( invocationEvent ) {
153
176
if ( invocationEvent === 'Shake' )
154
- Instabug . setInvocationEvent ( Instabug . invocationEvent . shake ) ;
177
+ BugReporting . setInvocationEvents ( [ BugReporting . invocationEvent . shake ] ) ;
155
178
if ( invocationEvent === 'Button' )
156
- Instabug . setInvocationEvent ( Instabug . invocationEvent . floatingButton ) ;
179
+ BugReporting . setInvocationEvents ( [ BugReporting . invocationEvent . floatingButton ] ) ;
157
180
if ( invocationEvent === 'Screenshot' )
158
- Instabug . setInvocationEvent ( Instabug . invocationEvent . screenshot ) ;
181
+ BugReporting . setInvocationEvents ( [ BugReporting . invocationEvent . screenshot ] ) ;
182
+ if ( invocationEvent === 'twoFingersSwipe' )
183
+ BugReporting . setInvocationEvents ( [ BugReporting . invocationEvent . twoFingersSwipe ] ) ;
159
184
if ( invocationEvent === 'None' )
160
- Instabug . setInvocationEvent ( Instabug . invocationEvent . none ) ;
185
+ BugReporting . setInvocationEvents ( [ BugReporting . invocationEvent . none ] ) ;
161
186
}
162
187
163
188
startNewConversation ( ) {
164
- Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newChat ) ;
189
+ Chats . show ( ) ;
165
190
}
166
191
167
192
showUnreadMessagesCount ( ) {
168
- Instabug . getUnreadMessagesCount ( ( count ) => {
193
+ Replies . getUnreadRepliesCount ( ( count ) => {
169
194
alert ( "Messages: " + count ) ;
170
195
} ) ;
171
196
}
172
197
}
173
-
198
+ buttonColor = function ( myColor ) {
199
+ return {
200
+ marginTop : 10 ,
201
+ padding : 20 ,
202
+ paddingRight : 40 ,
203
+ alignItems : 'center' ,
204
+ borderRadius : 5 ,
205
+ marginRight : 5 ,
206
+ backgroundColor : myColor ,
207
+ }
208
+ }
174
209
const styles = StyleSheet . create ( {
175
210
container : {
176
211
flex : 1 ,
177
212
alignItems : 'center' ,
178
- backgroundColor : '#F5FCFF' ,
213
+ backgroundColor : '#F5FCFF'
179
214
} ,
180
215
details : {
181
216
textAlign : 'center' ,
@@ -197,7 +232,10 @@ const styles = StyleSheet.create({
197
232
} ,
198
233
rowView : {
199
234
flexDirection : 'row' ,
200
- marginTop : 10
235
+ marginTop : 10 ,
236
+ maxWidth : '100%' ,
237
+ flexGrow : 1 ,
238
+ flexWrap : 'wrap'
201
239
} ,
202
240
textColor : {
203
241
fontSize : 14 ,
0 commit comments