Skip to content

Commit 85ec6fd

Browse files
abdelhamid-f-nassermzelzoghbi
authored andcommitted
feat(example): add apm screen (#1141)
1 parent 1e27100 commit 85ec6fd

17 files changed

+592
-15
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858

5959
- Adds symbol files upload script ([#1137](https://github.com/Instabug/Instabug-React-Native/pull/1137))
6060
- Support enabling NDK crash capturing on Android ([#1132](https://github.com/Instabug/Instabug-React-Native/pull/1132)).
61+
- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).
62+
63+
### Deprecated
64+
65+
- Deprecate execution traces APIs `APM.startExecutionTrace`, `Trace.end` and `Trace.setFlowAttribute` in favor of the new app flow APIs ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).
6166

6267
### Deprecated
6368

@@ -84,6 +89,10 @@
8489

8590
- Bump Instabug Android SDK to v12.8.0 ([#1149](https://github.com/Instabug/Instabug-React-Native/pull/1149)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.8.0).
8691

92+
### Deprecated
93+
94+
- Deprecate Execution Traces APIs `APM.startExecutionTrace`, `Trace.end` and `Trace.setAttribute` in favor of the new App Flows APIs ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).
95+
8796
## [12.7.1](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.0...v12.7.1) (February 15, 2024)
8897

8998
### Changed

examples/default/ios/Podfile.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ PODS:
404404
- React-jsinspector (0.72.3)
405405
- React-logger (0.72.3):
406406
- glog
407+
- react-native-background-timer (2.4.1):
408+
- React-Core
407409
- react-native-config (1.5.1):
408410
- react-native-config/App (= 1.5.1)
409411
- react-native-config/App (1.5.1):
@@ -528,6 +530,8 @@ PODS:
528530
- React-jsi (= 0.72.3)
529531
- React-logger (= 0.72.3)
530532
- React-perflogger (= 0.72.3)
533+
- RNCClipboard (1.5.1):
534+
- React-Core
531535
- RNGestureHandler (2.13.4):
532536
- RCT-Folly (= 2021.07.22.00)
533537
- React-Core
@@ -623,6 +627,7 @@ DEPENDENCIES:
623627
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
624628
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
625629
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
630+
- react-native-background-timer (from `../node_modules/react-native-background-timer`)
626631
- react-native-config (from `../node_modules/react-native-config`)
627632
- react-native-google-maps (from `../node_modules/react-native-maps`)
628633
- react-native-maps (from `../node_modules/react-native-maps`)
@@ -645,6 +650,7 @@ DEPENDENCIES:
645650
- React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`)
646651
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
647652
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
653+
- "RNCClipboard (from `../node_modules/@react-native-community/clipboard`)"
648654
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
649655
- RNInstabug (from `../node_modules/instabug-reactnative`)
650656
- RNReanimated (from `../node_modules/react-native-reanimated`)
@@ -720,6 +726,8 @@ EXTERNAL SOURCES:
720726
:path: "../node_modules/react-native/ReactCommon/jsinspector"
721727
React-logger:
722728
:path: "../node_modules/react-native/ReactCommon/logger"
729+
react-native-background-timer:
730+
:path: "../node_modules/react-native-background-timer"
723731
react-native-config:
724732
:path: "../node_modules/react-native-config"
725733
react-native-google-maps:
@@ -764,6 +772,8 @@ EXTERNAL SOURCES:
764772
:path: "../node_modules/react-native/ReactCommon/react/utils"
765773
ReactCommon:
766774
:path: "../node_modules/react-native/ReactCommon"
775+
RNCClipboard:
776+
:path: "../node_modules/@react-native-community/clipboard"
767777
RNGestureHandler:
768778
:path: "../node_modules/react-native-gesture-handler"
769779
RNInstabug:
@@ -818,6 +828,7 @@ SPEC CHECKSUMS:
818828
React-jsiexecutor: 59d1eb03af7d30b7d66589c410f13151271e8006
819829
React-jsinspector: b511447170f561157547bc0bef3f169663860be7
820830
React-logger: c5b527272d5f22eaa09bb3c3a690fee8f237ae95
831+
react-native-background-timer: 17ea5e06803401a379ebf1f20505b793ac44d0fe
821832
react-native-config: 86038147314e2e6d10ea9972022aa171e6b1d4d8
822833
react-native-google-maps: 1bcc1f9f13f798fcf230db7fe476f3566d0bc0a3
823834
react-native-maps: 72a8a903f8a1b53e2c777ba79102078ab502e0bf
@@ -840,6 +851,7 @@ SPEC CHECKSUMS:
840851
React-runtimescheduler: 837c1bebd2f84572db17698cd702ceaf585b0d9a
841852
React-utils: bcb57da67eec2711f8b353f6e3d33bd8e4b2efa3
842853
ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9
854+
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
843855
RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee
844856
RNInstabug: 6fa68cd181533f83154df2ebba000d0c47ca7ba3
845857
RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87

examples/default/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@
1010
"postinstall": "patch-package"
1111
},
1212
"dependencies": {
13+
"@react-native-community/clipboard": "^1.5.1",
1314
"@react-native-community/slider": "^4.4.3",
1415
"@react-navigation/bottom-tabs": "^6.5.7",
1516
"@react-navigation/native": "^6.1.6",
1617
"@react-navigation/native-stack": "^6.9.12",
18+
"graphql": "^16.8.1",
19+
"graphql-request": "^6.1.0",
1720
"instabug-reactnative": "link:../..",
21+
"instabug-reactnative-ndk": "github:https://github.com/Instabug/Instabug-React-Native-NDK",
1822
"native-base": "^3.4.28",
1923
"react": "18.2.0",
2024
"react-native": "0.72.3",
25+
"react-native-background-timer": "^2.4.1",
2126
"react-native-config": "^1.5.1",
2227
"react-native-gesture-handler": "^2.13.4",
2328
"react-native-maps": "^1.10.3",
@@ -26,7 +31,7 @@
2631
"react-native-screens": "^3.20.0",
2732
"react-native-svg": "^13.9.0",
2833
"react-native-vector-icons": "^10.0.0",
29-
"instabug-reactnative-ndk": "github:https://github.com/Instabug/Instabug-React-Native-NDK"
34+
"react-query": "^3.39.3"
3035
},
3136
"devDependencies": {
3237
"@babel/core": "^7.20.0",
@@ -35,6 +40,7 @@
3540
"@react-native/metro-config": "^0.73.1",
3641
"@types/jest": "^29.2.1",
3742
"@types/react": "^18.0.24",
43+
"@types/react-native-background-timer": "^2.0.2",
3844
"@types/react-native-vector-icons": "^6.4.13",
3945
"@types/react-test-renderer": "^18.0.0",
4046
"babel-jest": "^29.2.1",

examples/default/src/App.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import { RootTabNavigator } from './navigation/RootTab';
1515
import { nativeBaseTheme } from './theme/nativeBaseTheme';
1616
import { navigationTheme } from './theme/navigationTheme';
1717

18+
import { QueryClient, QueryClientProvider } from 'react-query';
19+
20+
const queryClient = new QueryClient();
21+
1822
export const App: React.FC = () => {
1923
useEffect(() => {
2024
Instabug.init({
@@ -32,9 +36,11 @@ export const App: React.FC = () => {
3236
return (
3337
<GestureHandlerRootView style={styles.root}>
3438
<NativeBaseProvider theme={nativeBaseTheme}>
35-
<NavigationContainer onStateChange={Instabug.onStateChange} theme={navigationTheme}>
36-
<RootTabNavigator />
37-
</NavigationContainer>
39+
<QueryClientProvider client={queryClient}>
40+
<NavigationContainer onStateChange={Instabug.onStateChange} theme={navigationTheme}>
41+
<RootTabNavigator />
42+
</NavigationContainer>
43+
</QueryClientProvider>
3844
</NativeBaseProvider>
3945
</GestureHandlerRootView>
4046
);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React, { PropsWithChildren } from 'react';
2+
import { StyleProp, StyleSheet, TextStyle } from 'react-native';
3+
import PasteFromClipboardButton from './PasteFromClipboardButton';
4+
import { HStack } from 'native-base';
5+
import { InputField } from './InputField';
6+
7+
interface ClipboardTextInputProps extends PropsWithChildren {
8+
placeholder?: string;
9+
onChangeText?: (text: string) => void;
10+
value?: string;
11+
selectTextOnFocus?: boolean;
12+
style?: StyleProp<TextStyle>;
13+
}
14+
15+
export const ClipboardTextInput: React.FC<ClipboardTextInputProps> = ({
16+
onChangeText,
17+
style,
18+
...restProps
19+
}) => {
20+
return (
21+
<HStack alignItems="center" space="xs">
22+
<InputField onChangeText={onChangeText} style={[styles.inputField, style]} {...restProps} />
23+
<PasteFromClipboardButton onPress={handleClipboardPress} />
24+
</HStack>
25+
);
26+
27+
function handleClipboardPress(text: string) {
28+
onChangeText?.call(undefined, text);
29+
}
30+
};
31+
32+
export const styles = StyleSheet.create({
33+
inputField: {
34+
flex: 1,
35+
},
36+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React, { PropsWithChildren } from 'react';
2+
import type { StyleProp, TextStyle } from 'react-native';
3+
import { Button } from 'native-base';
4+
import { CustomText } from './CustomText';
5+
import { StyleSheet } from 'react-native';
6+
7+
interface CustomButtonProps extends PropsWithChildren {
8+
title?: string;
9+
onPress?: () => void;
10+
style?: StyleProp<TextStyle>;
11+
}
12+
13+
export const CustomButton: React.FC<CustomButtonProps> = ({
14+
style,
15+
title,
16+
children,
17+
...restProps
18+
}) => {
19+
return (
20+
<Button style={style} {...restProps}>
21+
<CustomText style={styles.text}>{title}</CustomText>
22+
{children}
23+
</Button>
24+
);
25+
};
26+
27+
export const styles = StyleSheet.create({
28+
text: {
29+
color: '#fff',
30+
},
31+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React, { PropsWithChildren } from 'react';
2+
import { StyleProp, StyleSheet, TextStyle, Text } from 'react-native';
3+
4+
interface CustomTextProps extends PropsWithChildren {
5+
style?: StyleProp<TextStyle>;
6+
}
7+
8+
export const CustomImage: React.FC<CustomTextProps> = ({ style, children }) => {
9+
return <Text style={[styles.text, style]}>{children}</Text>;
10+
};
11+
12+
export const styles = StyleSheet.create({
13+
text: {
14+
fontSize: 16,
15+
lineHeight: 24,
16+
},
17+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React, { PropsWithChildren } from 'react';
2+
import { StyleProp, StyleSheet, TextStyle, Text } from 'react-native';
3+
4+
interface CustomTextProps extends PropsWithChildren {
5+
style?: StyleProp<TextStyle>;
6+
}
7+
8+
export const CustomText: React.FC<CustomTextProps> = ({ style, children }) => {
9+
return <Text style={[styles.text, style]}>{children}</Text>;
10+
};
11+
12+
export const styles = StyleSheet.create({
13+
text: {
14+
fontSize: 16,
15+
lineHeight: 24,
16+
},
17+
});

examples/default/src/components/InputField.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import React, { forwardRef } from 'react';
22

3-
import { KeyboardTypeOptions, StyleSheet, TextInput, View } from 'react-native';
3+
import {
4+
KeyboardTypeOptions,
5+
StyleProp,
6+
StyleSheet,
7+
TextInput,
8+
ViewStyle,
9+
View,
10+
} from 'react-native';
411
import { Text } from 'native-base';
512

613
interface InputFieldProps {
714
placeholder?: string;
815
value?: string;
16+
style?: StyleProp<ViewStyle>;
917
onChangeText?: (text: string) => void;
1018
keyboardType?: KeyboardTypeOptions;
19+
selectTextOnFocus?: boolean | undefined;
1120
errorText?: string;
1221
maxLength?: number;
1322
accessibilityLabel?: string;
@@ -19,6 +28,7 @@ export const InputField = forwardRef<TextInput, InputFieldProps>(
1928
{
2029
placeholder,
2130
value,
31+
style,
2232
onChangeText,
2333
accessibilityLabel,
2434
maxLength,
@@ -33,7 +43,7 @@ export const InputField = forwardRef<TextInput, InputFieldProps>(
3343
<TextInput
3444
ref={ref}
3545
placeholder={placeholder}
36-
style={styles.textInput}
46+
style={[styles.textInput, style]}
3747
maxLength={maxLength}
3848
accessibilityLabel={accessibilityLabel}
3949
keyboardType={keyboardType}
@@ -52,7 +62,7 @@ const styles = StyleSheet.create({
5262
backgroundColor: 'white',
5363
borderWidth: 1,
5464
borderColor: '#ccc',
55-
paddingVertical: 16,
65+
paddingVertical: 10,
5666
paddingHorizontal: 24,
5767
fontSize: 16,
5868
borderRadius: 5,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Clipboard from '@react-native-community/clipboard';
2+
import { StyleProp, TextStyle, TouchableHighlight } from 'react-native';
3+
import React, { PropsWithChildren } from 'react';
4+
import Icon from 'react-native-vector-icons/Ionicons';
5+
6+
interface PasteFromClipboardButtonProps extends PropsWithChildren {
7+
onPress?: (text: string) => void;
8+
style?: StyleProp<TextStyle>;
9+
}
10+
11+
const PasteFromClipboardButton: React.FC<PasteFromClipboardButtonProps> = ({ onPress, style }) => {
12+
const handlePress = async () => {
13+
const text = await Clipboard.getString();
14+
onPress?.call(undefined, text); // Using call to pass the text to the callback
15+
};
16+
17+
return (
18+
<TouchableHighlight onPress={handlePress} style={style}>
19+
<Icon name="copy-outline" />
20+
</TouchableHighlight>
21+
);
22+
};
23+
24+
export default PasteFromClipboardButton;

examples/default/src/navigation/HomeStack.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import {
2121
} from '../screens/user-steps/BackAndForthScreen';
2222
import { GoogleMapsScreen } from '../screens/user-steps/GoogleMapsScreen';
2323
import { LargeImageListScreen } from '../screens/user-steps/LargeImageListScreen';
24+
import { APMScreen } from '../screens/apm/APMScreen';
25+
import { TracesScreen } from '../screens/apm/TracesScreen';
26+
import { NetworkScreen } from '../screens/apm/NetworkScreen';
27+
import { FlowsScreen } from '../screens/apm/FlowsScreen';
2428
import { SessionReplayScreen } from '../screens/SessionReplayScreen';
2529

2630
export type HomeStackParamList = {
@@ -41,6 +45,12 @@ export type HomeStackParamList = {
4145
LargeImageList: undefined;
4246
SessionReplay: undefined;
4347
BackAndForthScreen: BackAndForthScreenProp;
48+
49+
// APM //
50+
APM: undefined;
51+
NetworkTraces: undefined;
52+
ExecutionTraces: undefined;
53+
AppFlows: undefined;
4454
};
4555

4656
const HomeStack = createNativeStackNavigator<HomeStackParamList>();
@@ -65,7 +75,6 @@ export const HomeStackNavigator: React.FC = () => {
6575
options={{ title: 'Feature Requests' }}
6676
/>
6777
<HomeStack.Screen name="Replies" component={RepliesScreen} />
68-
6978
<HomeStack.Screen name="Surveys" component={SurveysScreen} />
7079
<HomeStack.Screen
7180
name="SessionReplay"
@@ -119,6 +128,10 @@ export const HomeStackNavigator: React.FC = () => {
119128
options={{ title: 'Large Image List' }}
120129
/>
121130
<HomeStack.Screen name="Gestures" component={GesturesScreen} />
131+
<HomeStack.Screen name="APM" component={APMScreen} />
132+
<HomeStack.Screen name="NetworkTraces" component={NetworkScreen} />
133+
<HomeStack.Screen name="ExecutionTraces" component={TracesScreen} />
134+
<HomeStack.Screen name="AppFlows" component={FlowsScreen} />
122135
</HomeStack.Navigator>
123136
);
124137
};

examples/default/src/screens/HomeScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const HomeScreen: React.FC<NativeStackScreenProps<HomeStackParamList, 'Ho
1717
<ListTile title="Replies" onPress={() => navigation.navigate('Replies')} />
1818
<ListTile title="Surveys" onPress={() => navigation.navigate('Surveys')} />
1919
<ListTile title="User Steps" onPress={() => navigation.navigate('UserSteps')} />
20+
<ListTile title="APM" onPress={() => navigation.navigate('APM')} />
2021
<ListTile title="Session Replay" onPress={() => navigation.navigate('SessionReplay')} />
2122
</Screen>
2223
);

0 commit comments

Comments
 (0)