From 6cb3ec713d23fb8e281f29a5de19170cd480414b Mon Sep 17 00:00:00 2001 From: hana-mostafaa Date: Mon, 8 Sep 2025 14:30:51 +0300 Subject: [PATCH 1/4] Update settings screen to include user data, events, tags --- .../src/components/VerticalListTile.tsx | 1 + .../src/screens/settings/SettingsScreen.tsx | 140 ++++++++++++++++++ 2 files changed, 141 insertions(+) diff --git a/examples/default/src/components/VerticalListTile.tsx b/examples/default/src/components/VerticalListTile.tsx index 923a0b6e0..f16d7b953 100644 --- a/examples/default/src/components/VerticalListTile.tsx +++ b/examples/default/src/components/VerticalListTile.tsx @@ -17,6 +17,7 @@ export const VerticalListTile: React.FC = ({ title, onPress, chil borderBottomWidth="1" borderColor="coolGray.300" bg="coolGray.100" + accessible={false} _pressed={{ bg: 'coolGray.200' }}> {title} diff --git a/examples/default/src/screens/settings/SettingsScreen.tsx b/examples/default/src/screens/settings/SettingsScreen.tsx index e8e1a7e60..a4ac9ef5c 100644 --- a/examples/default/src/screens/settings/SettingsScreen.tsx +++ b/examples/default/src/screens/settings/SettingsScreen.tsx @@ -6,6 +6,7 @@ import Instabug, { InvocationEvent, Locale, NetworkLogger, + WelcomeMessageMode, ReproStepsMode, } from 'instabug-reactnative'; import { InputGroup, InputLeftAddon, useToast, VStack, Button } from 'native-base'; @@ -30,12 +31,19 @@ export const SettingsScreen: React.FC(true); + const [isSessionProfilerEnabled, setIsSessionProfilerEnabled] = useState(true); const toast = useToast(); const [userAttributesFormError, setUserAttributesFormError] = useState({}); + const [userDataFormError, setUserDataFormError] = useState({}) + const [userEventFormError, setUserEventFormError] = useState({}) + const [tagFormError, setTagFormError] = useState({}) const [featureFlagFormError, setFeatureFlagFormError] = useState({}); const { addItem } = useCallbackHandlers(); @@ -50,6 +58,30 @@ export const SettingsScreen: React.FC { + const errors: any = {}; + if (userData.length === 0) { + errors.userDataValue = 'Value is required'; + } + setUserDataFormError(errors); + return Object.keys(errors).length === 0; + }; + const validateUserEventForm = () => { + const errors: any = {}; + if (userData.length === 0) { + errors.userEventValue = 'Value is required'; + } + setUserEventFormError(errors); + return Object.keys(errors).length === 0; + }; + const validateTagForm = () => { + const errors: any = {}; + if (userData.length === 0) { + errors.tagValue = 'Value is required'; + } + setTagFormError(errors); + return Object.keys(errors).length === 0; + }; const validateFeatureFlagForm = () => { const errors: any = {}; if (featureFlagName.length === 0) { @@ -89,6 +121,35 @@ export const SettingsScreen: React.FC { + if (validateUserDataForm()) { + Instabug.setUserData(userData); + toast.show({ + description: 'User Data added successfully', + }); + setUserData('') + } + }; + const saveUserEvent = () => { + if (validateUserEventForm()) { + Instabug.logUserEvent(userEvent); + toast.show({ + description: 'User Event added successfully', + }); + setUserData('') + } + }; + const saveTag = () => { + if (validateTagForm()) { + Instabug.appendTags([tag]) + toast.show({ + description: 'Tag added successfully', + }); + setTag('') + } + }; + const saveFeatureFlags = () => { if (validateFeatureFlagForm()) { Instabug.addFeatureFlag({ @@ -250,6 +311,31 @@ export const SettingsScreen: React.FC + + { + navigation.navigate('SessionProfiler', { + isEnabled: isSessionProfilerEnabled, + setIsEnabled: (enabled: boolean) => { + setIsSessionProfilerEnabled(enabled); + Instabug.setSessionProfilerEnabled(enabled); + navigation.goBack(); + }, + }); + }} + testID="id_session_profiler" + /> + + Instabug.showWelcomeMessage(WelcomeMessageMode.beta)} + /> + Instabug.showWelcomeMessage(WelcomeMessageMode.live)} + /> @@ -316,6 +402,60 @@ export const SettingsScreen: React.FC + + + + + setUserData(userData)} + value={userData} + errorText={userDataFormError.userDataValue} + /> + + + + + + + + + + + setUserEvent(userEvent)} + value={userEvent} + errorText={userEventFormError.userEventValue} + /> + + + + + + + + + + + setTag(tag)} + value={tag} + errorText={tagFormError.tagValue} + /> + + + + + + From 3ef113ef0c25ef52561174dac567f640d2da47cc Mon Sep 17 00:00:00 2001 From: hana-mostafaa Date: Tue, 9 Sep 2025 13:36:22 +0300 Subject: [PATCH 2/4] update sample app logging --- .../default/src/screens/apm/HttpScreen.tsx | 26 ++++++ .../src/screens/settings/SettingsScreen.tsx | 80 +++++++++++++------ 2 files changed, 81 insertions(+), 25 deletions(-) diff --git a/examples/default/src/screens/apm/HttpScreen.tsx b/examples/default/src/screens/apm/HttpScreen.tsx index 472e1e56a..e1cfe3802 100644 --- a/examples/default/src/screens/apm/HttpScreen.tsx +++ b/examples/default/src/screens/apm/HttpScreen.tsx @@ -29,6 +29,31 @@ export const HttpScreen: React.FC = () => { showNotification('Error', 'Failed'); } }; + const makeGetCallWithTrace = async () => { + setLoading(true); + const url = 'https://httpbin.org/anything'; + try { + const response = await fetch(url, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'traceparent': 'non-ibg-trace-value', + 'tracestate': 'non-ibg=value', + }, + }); + + const responseBody = await response.json(); + console.log('Response with trace headers:', responseBody); + + setLoading(false); + showNotification('Success', 'Succeeded with trace'); + } catch (error) { + console.error('Error with trace call:', error); + setLoading(false); + showNotification('Error', 'Failed with trace'); + } + }; + const makePostCall = async () => { setLoading(true); @@ -157,6 +182,7 @@ export const HttpScreen: React.FC = () => { {loading && } + diff --git a/examples/default/src/screens/settings/SettingsScreen.tsx b/examples/default/src/screens/settings/SettingsScreen.tsx index a4ac9ef5c..29982b23f 100644 --- a/examples/default/src/screens/settings/SettingsScreen.tsx +++ b/examples/default/src/screens/settings/SettingsScreen.tsx @@ -34,6 +34,8 @@ export const SettingsScreen: React.FC('debug'); + const [instabugLog, setInstabugLog] = useState('') const [featureFlagName, setFeatureFlagName] = useState(''); const [featureFlagVariant, setfeatureFlagVariant] = useState(''); const [isUserStepEnabled, setIsUserStepEnabled] = useState(true); @@ -201,6 +203,34 @@ export const SettingsScreen: React.FC { + if (!instabugLog.trim()) { + toast.show({ description: 'Please enter a log message' }); + return; + } + + switch (instabugLogLevel) { + case 'verbose': + Instabug.logVerbose(instabugLog); + break; + case 'debug': + Instabug.logDebug(instabugLog); + break; + case 'info': + Instabug.logInfo(instabugLog); + break; + case 'warn': + Instabug.logWarn(instabugLog); + break; + case 'error': + Instabug.logError(instabugLog); + break; + } + + toast.show({ description: `Logged ${instabugLogLevel} message` }); + setInstabugLog(''); + }; + return ( @@ -552,33 +582,33 @@ export const SettingsScreen: React.FC - + - Instabug.logVerbose('log Verbose message')} - /> - Instabug.logDebug('log Debug message')} - /> - Instabug.logWarn('log Warn message')} - /> - Instabug.logError('log Error message')} - /> - Instabug.logInfo('log Info message')} +