Skip to content

Commit db2da26

Browse files
chore: refactor example app, add new screen for custom traces, update native dependencies
1 parent b7e259a commit db2da26

File tree

9 files changed

+79
-14
lines changed

9 files changed

+79
-14
lines changed

android/native.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.ext.instabug = [
2-
version: '15.0.1.6985154-SNAPSHOT'
2+
version: '15.0.2.7020723-SNAPSHOT'
33
]
44

55
dependencies {

examples/default/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ target 'InstabugExample' do
1515
config = use_native_modules!
1616
rn_maps_path = '../node_modules/react-native-maps'
1717
pod 'react-native-google-maps', :path => rn_maps_path
18-
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/faeture-screen_rendering-release/15.1.15/Instabug.podspec'
18+
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/faeture-screen_rendering-release/15.1.16/Instabug.podspec'
1919
# Flags change depending on the env values.
2020
flags = get_default_flags()
2121

examples/default/src/navigation/HomeStack.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {
2222
import { GoogleMapsScreen } from '../screens/user-steps/GoogleMapsScreen';
2323
import { LargeImageListScreen } from '../screens/user-steps/LargeImageListScreen';
2424
import { APMScreen } from '../screens/apm/APMScreen';
25-
import { TracesScreen } from '../screens/apm/TracesScreen';
25+
import { ExecutionTraceScreen } from '../screens/apm/ExecutionTraceScreen';
26+
import { CustomUITraceScreen } from '../screens/apm/CustomUITraceScreen';
2627
import { NetworkScreen } from '../screens/apm/NetworkScreen';
2728
import { FlowsScreen } from '../screens/apm/FlowsScreen';
2829
import { SessionReplayScreen } from '../screens/SessionReplayScreen';
@@ -44,7 +45,7 @@ export type HomeStackParamList = {
4445
BasicComponents: undefined;
4546
ScrollView: undefined;
4647
FlatList: undefined;
47-
ComplexViews: undefined;
48+
ComplexViews: { initialDepth?: number; initialBreadth?: number } | undefined;
4849
SectionList: undefined;
4950
Gestures: undefined;
5051
GoogleMapsScreen: undefined;
@@ -58,6 +59,7 @@ export type HomeStackParamList = {
5859
APM: undefined;
5960
NetworkTraces: undefined;
6061
ExecutionTraces: undefined;
62+
CustomUITraces: undefined;
6163
AppFlows: undefined;
6264
WebViews: undefined;
6365
FullWebViews: undefined;
@@ -142,7 +144,8 @@ export const HomeStackNavigator: React.FC = () => {
142144
<HomeStack.Screen name="Gestures" component={GesturesScreen} />
143145
<HomeStack.Screen name="APM" component={APMScreen} />
144146
<HomeStack.Screen name="NetworkTraces" component={NetworkScreen} />
145-
<HomeStack.Screen name="ExecutionTraces" component={TracesScreen} />
147+
<HomeStack.Screen name="ExecutionTraces" component={ExecutionTraceScreen} />
148+
<HomeStack.Screen name="CustomUITraces" component={CustomUITraceScreen} />
146149
<HomeStack.Screen name="AppFlows" component={FlowsScreen} />
147150
<HomeStack.Screen
148151
name="LegacyMode"

examples/default/src/screens/apm/APMScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export const APMScreen: React.FC<NativeStackScreenProps<HomeStackParamList, 'APM
3434
{CustomGap.smallV}
3535
<ListTile title="End App launch" onPress={() => APM.endAppLaunch()} />
3636
<ListTile title="Network Screen" onPress={() => navigation.navigate('NetworkTraces')} />
37-
<ListTile title="Traces" onPress={() => navigation.navigate('ExecutionTraces')} />
37+
<ListTile title="Execution Traces" onPress={() => navigation.navigate('ExecutionTraces')} />
38+
<ListTile title="Custom UI Traces" onPress={() => navigation.navigate('CustomUITraces')} />
3839
<ListTile title="Flows" onPress={() => navigation.navigate('AppFlows')} />
3940
<ListTile title="WebViews" onPress={() => navigation.navigate('WebViews')} />
4041
<ListTile title="Complex Views" onPress={() => navigation.navigate('ComplexViews')} />
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import React, { useState } from 'react';
2+
import { APM } from 'instabug-reactnative';
3+
import { ScrollView } from 'react-native';
4+
import { Section } from '../../components/Section';
5+
import { Screen } from '../../components/Screen';
6+
import { VStack } from 'native-base';
7+
import { InputField } from '../../components/InputField';
8+
import { CustomButton } from '../../components/CustomButton';
9+
import BackgroundTimer from 'react-native-background-timer';
10+
11+
export const CustomUITraceScreen: React.FC = () => {
12+
const [traceName, setTraceName] = useState<string>('');
13+
14+
function startUITrace() {
15+
if (!traceName.trim()) {
16+
console.log('Please enter a trace name before starting.');
17+
return;
18+
}
19+
APM.startUITrace(traceName);
20+
21+
console.log(`UI trace "${traceName}" started.`);
22+
}
23+
24+
function startDelayedUITrace() {
25+
if (!traceName.trim()) {
26+
console.log('Please enter a trace name before starting.');
27+
return;
28+
}
29+
return BackgroundTimer.setTimeout(() => {
30+
APM.startUITrace(traceName);
31+
console.log(`Delayed UI trace "${traceName}" started.`);
32+
}, 5000);
33+
}
34+
35+
function endUITrace() {
36+
APM.endUITrace();
37+
console.log('UI trace ended.');
38+
}
39+
40+
return (
41+
<ScrollView>
42+
<Screen>
43+
<Section title="Custom UI Traces">
44+
<VStack space={2}>
45+
<InputField
46+
placeholder="UI Trace Name"
47+
onChangeText={(text) => setTraceName(text)}
48+
value={traceName}
49+
/>
50+
<CustomButton title="Start UI Trace" onPress={startUITrace} />
51+
<CustomButton title="Start 5s Delayed UI Trace" onPress={startDelayedUITrace} />
52+
<CustomButton title="End UI Trace" onPress={endUITrace} />
53+
</VStack>
54+
</Section>
55+
</Screen>
56+
</ScrollView>
57+
);
58+
};

examples/default/src/screens/apm/TracesScreen.tsx renamed to examples/default/src/screens/apm/ExecutionTraceScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { InputField } from '../../components/InputField';
88
import { CustomButton } from '../../components/CustomButton';
99
import BackgroundTimer from 'react-native-background-timer';
1010

11-
export const TracesScreen: React.FC = () => {
11+
export const ExecutionTraceScreen: React.FC = () => {
1212
const [traceName, setTraceName] = useState<string>('');
1313
const [traceAttributeKey, setTraceAttributeKey] = useState<string>('');
1414
const [traceAttributeValue, setTraceAttributeValue] = useState<string>('');

examples/default/src/screens/apm/ScreenRender.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ const ScreenRenderPage: React.FC<NativeStackScreenProps<HomeStackParamList, 'Scr
248248
};
249249

250250
const navigateToComplexPage = (): void => {
251-
navigation.navigate('ComplexViews');
251+
navigation.navigate('ComplexViews', { initialDepth: 10, initialBreadth: 2 });
252252
};
253253

254254
// Cleanup timeout on unmount
@@ -273,7 +273,7 @@ const ScreenRenderPage: React.FC<NativeStackScreenProps<HomeStackParamList, 'Scr
273273

274274
<View style={styles.buttonContainer}>
275275
<InstabugButton
276-
text={isBlocking ? 'Frames are Delayed! (Wait...)' : 'Trigger Frozen Frames (5s)'}
276+
text={isBlocking ? 'Frames are Delayed! (Wait...)' : 'Trigger Delayed Frames (5s)'}
277277
onPress={triggerFrozenFrames}
278278
disabled={isBlocking}
279279
/>

examples/default/src/screens/user-steps/ComplexViewsScreen.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React, { useRef, useState } from 'react';
2+
import type { NativeStackScreenProps } from '@react-navigation/native-stack';
3+
import type { HomeStackParamList } from '../../navigation/HomeStack';
24

35
import { Screen } from '../../components/Screen';
46
import { Section } from '../../components/Section';
@@ -7,10 +9,11 @@ import { Button } from 'react-native';
79
import { ScrollView, VStack } from 'native-base';
810
import { InputField } from '../../components/InputField';
911

10-
export const ComplexViewsScreen: React.FC = () => {
11-
const initialDepth = 10;
12-
const initialBreadth = 2;
13-
12+
export const ComplexViewsScreen: React.FC<
13+
NativeStackScreenProps<HomeStackParamList, 'ComplexViews'>
14+
> = ({ route }) => {
15+
const initialDepth = route.params?.initialDepth ?? 10;
16+
const initialBreadth = route.params?.initialBreadth ?? 2;
1417
const depthRef = useRef(initialDepth);
1518
const breadthRef = useRef(initialBreadth);
1619

ios/native.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$instabug = { :version => '15.1.15' }
1+
$instabug = { :version => '15.1.16' }
22

33
def use_instabug! (spec = nil)
44
version = $instabug[:version]

0 commit comments

Comments
 (0)