|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { ActivityIndicator } from 'react-native'; |
| 3 | +import Instabug from 'instabug-reactnative'; |
| 4 | +import { ListTile } from '../components/ListTile'; |
| 5 | +import { Screen } from '../components/Screen'; |
| 6 | +import { showNotification } from '../utils/showNotification'; |
| 7 | + |
| 8 | +export const LegacyModeScreen: React.FC = () => { |
| 9 | + const [loading, setLoading] = useState(false); |
| 10 | + |
| 11 | + const addMultipleInstabugLogs = async (numberOfLogs: number) => { |
| 12 | + setLoading(true); |
| 13 | + try { |
| 14 | + for (let i = 0; i < numberOfLogs; i++) { |
| 15 | + Instabug.logDebug(`log ${i}`); |
| 16 | + } |
| 17 | + showNotification('Success', 'Succeeded'); |
| 18 | + } catch (error) { |
| 19 | + showNotification('Error', 'Failed'); |
| 20 | + } finally { |
| 21 | + setLoading(false); |
| 22 | + } |
| 23 | + }; |
| 24 | + |
| 25 | + const addMultipleUserEvents = async (numberOfLogs: number) => { |
| 26 | + setLoading(true); |
| 27 | + try { |
| 28 | + for (let i = 0; i < numberOfLogs; i++) { |
| 29 | + Instabug.logUserEvent(`test user event ${i}`); |
| 30 | + } |
| 31 | + showNotification('Success', 'Succeeded'); |
| 32 | + } catch (error) { |
| 33 | + showNotification('Error', 'Failed'); |
| 34 | + } finally { |
| 35 | + setLoading(false); |
| 36 | + } |
| 37 | + }; |
| 38 | + |
| 39 | + const addMultipleTags = async (numberOfLogs: number) => { |
| 40 | + setLoading(true); |
| 41 | + try { |
| 42 | + for (let i = 0; i < numberOfLogs; i++) { |
| 43 | + Instabug.appendTags([`test tag ${i}`]); |
| 44 | + } |
| 45 | + showNotification('Success', 'Succeeded'); |
| 46 | + } catch (error) { |
| 47 | + showNotification('Error', 'Failed'); |
| 48 | + } finally { |
| 49 | + setLoading(false); |
| 50 | + } |
| 51 | + }; |
| 52 | + |
| 53 | + const addMultipleUserAttributes = async (numberOfLogs: number) => { |
| 54 | + setLoading(true); |
| 55 | + try { |
| 56 | + for (let i = 0; i < numberOfLogs; i++) { |
| 57 | + Instabug.setUserAttribute(`user${i}`, `user${i} value`); |
| 58 | + } |
| 59 | + showNotification('Success', 'Succeeded'); |
| 60 | + } catch (error) { |
| 61 | + showNotification('Error', 'Failed'); |
| 62 | + } finally { |
| 63 | + setLoading(false); |
| 64 | + } |
| 65 | + }; |
| 66 | + |
| 67 | + return ( |
| 68 | + <Screen> |
| 69 | + {loading && <ActivityIndicator size="large" color="#0000ff" />} |
| 70 | + |
| 71 | + <ListTile |
| 72 | + title="Attach 10 InstabugLogs at a time" |
| 73 | + onPress={() => addMultipleInstabugLogs(10)} |
| 74 | + /> |
| 75 | + <ListTile title="Attach 10 events at a time" onPress={() => addMultipleUserEvents(10)} /> |
| 76 | + <ListTile title="Attach 10 tags at a time" onPress={() => addMultipleTags(10)} /> |
| 77 | + <ListTile |
| 78 | + title="Attach 10 user attributes at a time" |
| 79 | + onPress={() => addMultipleUserAttributes(10)} |
| 80 | + /> |
| 81 | + </Screen> |
| 82 | + ); |
| 83 | +}; |
0 commit comments