@@ -5,7 +5,7 @@ import React, { Component } from 'react';
55import { Image , View , Text , TextInput , Switch , SectionList , TouchableOpacity , NativeModules } from 'react-native' ;
66import ImagePicker from 'react-native-image-picker' ;
77
8- import Crashes from 'appcenter-crashes' ;
8+ import Crashes , { ExceptionModel } from 'appcenter-crashes' ;
99
1010import AttachmentsProvider from '../AttachmentsProvider' ;
1111import SharedStyles from '../SharedStyles' ;
@@ -72,6 +72,16 @@ export default class CrashesScreen extends Component {
7272 foo . method1 ( ) ;
7373 }
7474
75+ async trackError ( includeProperties ) {
76+ try {
77+ throw new Error ( 'Custom error' ) ;
78+ } catch ( error ) {
79+ const properties = includeProperties ? { property1 : '100' , property2 : '200' } : null ;
80+ const attachments = await AttachmentsProvider . getErrorAttachments ( ) ;
81+ Crashes . trackError ( ExceptionModel . createFromError ( error ) , properties , attachments ) ;
82+ }
83+ }
84+
7585 async nativeCrash ( ) {
7686 // In Android debug or non app store environment for iOS.
7787 await Crashes . generateTestCrash ( ) ;
@@ -168,6 +178,20 @@ export default class CrashesScreen extends Component {
168178 ] ,
169179 renderItem : actionRenderItem
170180 } ,
181+ {
182+ title : 'Track error' ,
183+ data : [
184+ {
185+ title : 'Track error' ,
186+ action : ( ) => this . trackError ( false )
187+ } ,
188+ {
189+ title : 'Track error with properties' ,
190+ action : ( ) => this . trackError ( true )
191+ } ,
192+ ] ,
193+ renderItem : actionRenderItem
194+ } ,
171195 {
172196 title : 'Miscellaneous' ,
173197 data : [
@@ -184,7 +208,7 @@ export default class CrashesScreen extends Component {
184208 }
185209 ] ,
186210 renderItem : valueRenderItem
187- }
211+ } ,
188212 ] }
189213 />
190214 </ View >
0 commit comments