@@ -16,7 +16,7 @@ import {
1616 ScrollView
1717} from 'react-native' ;
1818
19- import Instabug from 'instabug-reactnative' ;
19+ import Instabug , { BugReporting , FeatureRequests , Surveys , Chats , CrashReporting , Replies } from 'instabug-reactnative' ;
2020
2121
2222const instructions = Platform . select ( {
@@ -31,12 +31,12 @@ export default class App extends Component<{}> {
3131 constructor ( props ) {
3232 super ( props ) ;
3333 this . state = {
34- switchValue : false ,
35- colorTheme : 'Dark '
34+ switchValue : true ,
35+ colorTheme : 'Light '
3636 } ;
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 ] ) ;
4040 Instabug . setLocale ( Instabug . locale . english ) ;
4141 }
4242
@@ -48,9 +48,6 @@ export default class App extends Component<{}> {
4848 Hello { "Instabug's" } awesome user! The purpose of this application is to show you the different
4949 options for customizing the SDK and how easy it is to integrate it to your existing app
5050 </ Text >
51- < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showIntroMessage ( ) } >
52- < Text style = { styles . text } > SHOW INTRO MESSAGE </ Text >
53- </ TouchableOpacity >
5451 < TouchableOpacity style = { styles . button } onPress = { ( ) => this . invoke ( ) } >
5552 < Text style = { styles . text } > INVOKE </ Text >
5653 </ TouchableOpacity >
@@ -60,27 +57,31 @@ export default class App extends Component<{}> {
6057 < TouchableOpacity style = { styles . button } onPress = { ( ) => this . sendFeedback ( ) } >
6158 < Text style = { styles . text } > SEND FEEDBACK </ Text >
6259 </ TouchableOpacity >
60+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . sendCrashReport ( ) } >
61+ < Text style = { styles . text } > THROW HANDLED EXCEPTION </ Text >
62+ </ TouchableOpacity >
6363 < TouchableOpacity style = { styles . button } onPress = { ( ) => this . startNewConversation ( ) } >
6464 < Text style = { styles . text } > START A NEW CONVERSATION </ Text >
6565 </ 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 >
6675 < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showUnreadMessagesCount ( ) } >
6776 < Text style = { styles . text } > GET UNREAD MESSAGES COUNT </ Text >
6877 </ TouchableOpacity >
6978 { this . invocationEvent ( ) }
7079 < Text style = { styles . textColor } > Set primary color </ Text >
7180 < 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' ) } />
8485 </ View >
8586 < View style = { styles . switchView } >
8687 < Text style = { styles . textSwitchStyle } > Color Theme: { this . state . colorTheme } </ Text >
@@ -94,28 +95,28 @@ export default class App extends Component<{}> {
9495 }
9596
9697 invocationEvent ( ) {
97- if ( Platform . OS === 'ios ') {
9898 return (
9999 < View >
100100 < Text style = { styles . textColor } > Change Invocation Event < / T e x t >
101101 < View style = { styles . rowView } >
102102 < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Shake' ) } >
103103 < Text style = { styles . textInvoke } > SHAKE </ Text >
104104 </ TouchableOpacity >
105- < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Button' ) } >
106- < Text style = { styles . textInvoke } > FLOATING BUTTON </ Text >
107- </ TouchableOpacity >
108105 < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Screenshot' ) } >
109106 < Text style = { styles . textInvoke } > SCREENSHOT </ Text >
110107 </ 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 >
111114 < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'None' ) } >
112115 < Text style = { styles . textInvoke } > NONE </ Text >
113116 </ TouchableOpacity >
114117 </ View >
115118 < / V i e w >
116119 ) ;
117- }
118- return ;
119120 }
120121
121122 toggleSwitch = ( value ) => {
@@ -138,44 +139,78 @@ export default class App extends Component<{}> {
138139 }
139140
140141 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 ( ) ;
142155 }
143156
144157 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+ }
146168 }
147169
148170 sendFeedback ( ) {
149- Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newFeedback ) ;
171+ BugReporting . showWithOptions ( BugReporting . reportType . feedback , [ BugReporting . option . emailFieldHidden ] ) ;
172+
150173 }
151174
152175 changeInvocationEvent ( invocationEvent ) {
153176 if ( invocationEvent === 'Shake' )
154- Instabug . setInvocationEvent ( Instabug . invocationEvent . shake ) ;
177+ BugReporting . setInvocationEvents ( [ BugReporting . invocationEvent . shake ] ) ;
155178 if ( invocationEvent === 'Button' )
156- Instabug . setInvocationEvent ( Instabug . invocationEvent . floatingButton ) ;
179+ BugReporting . setInvocationEvents ( [ BugReporting . invocationEvent . floatingButton ] ) ;
157180 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 ] ) ;
159184 if ( invocationEvent === 'None' )
160- Instabug . setInvocationEvent ( Instabug . invocationEvent . none ) ;
185+ BugReporting . setInvocationEvents ( [ BugReporting . invocationEvent . none ] ) ;
161186 }
162187
163188 startNewConversation ( ) {
164- Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newChat ) ;
189+ Chats . show ( ) ;
165190 }
166191
167192 showUnreadMessagesCount ( ) {
168- Instabug . getUnreadMessagesCount ( ( count ) => {
193+ Replies . getUnreadRepliesCount ( ( count ) => {
169194 alert ( "Messages: " + count ) ;
170195 } ) ;
171196 }
172197}
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+ }
174209const styles = StyleSheet . create ( {
175210 container : {
176211 flex : 1 ,
177212 alignItems : 'center' ,
178- backgroundColor : '#F5FCFF' ,
213+ backgroundColor : '#F5FCFF'
179214 } ,
180215 details : {
181216 textAlign : 'center' ,
@@ -197,7 +232,10 @@ const styles = StyleSheet.create({
197232 } ,
198233 rowView : {
199234 flexDirection : 'row' ,
200- marginTop : 10
235+ marginTop : 10 ,
236+ maxWidth : '100%' ,
237+ flexGrow : 1 ,
238+ flexWrap : 'wrap'
201239 } ,
202240 textColor : {
203241 fontSize : 14 ,
0 commit comments