From 1ddc5e38a7a8ca5f6533f2b8b36db3765571853b Mon Sep 17 00:00:00 2001 From: Abdelhamid Nasser <38096011+abdelhamid-f-nasser@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:26:49 +0530 Subject: [PATCH 01/40] feat(example): add apm screen (#1141) --- CHANGELOG.md | 9 ++ examples/default/ios/Podfile.lock | 12 ++ examples/default/package.json | 8 +- examples/default/src/App.tsx | 12 +- .../src/components/ClipboardTextInput.tsx | 36 +++++ .../default/src/components/CustomButton.tsx | 31 ++++ .../default/src/components/CustomImage.tsx | 17 ++ .../default/src/components/CustomText.tsx | 17 ++ .../default/src/components/InputField.tsx | 16 +- .../components/PasteFromClipboardButton.tsx | 24 +++ examples/default/src/navigation/HomeStack.tsx | 15 +- examples/default/src/screens/HomeScreen.tsx | 1 + .../default/src/screens/apm/APMScreen.tsx | 17 ++ .../default/src/screens/apm/FlowsScreen.tsx | 63 ++++++++ .../default/src/screens/apm/NetworkScreen.tsx | 110 +++++++++++++ .../default/src/screens/apm/TracesScreen.tsx | 70 ++++++++ examples/default/yarn.lock | 149 +++++++++++++++++- 17 files changed, 592 insertions(+), 15 deletions(-) create mode 100644 examples/default/src/components/ClipboardTextInput.tsx create mode 100644 examples/default/src/components/CustomButton.tsx create mode 100644 examples/default/src/components/CustomImage.tsx create mode 100644 examples/default/src/components/CustomText.tsx create mode 100644 examples/default/src/components/PasteFromClipboardButton.tsx create mode 100644 examples/default/src/screens/apm/APMScreen.tsx create mode 100644 examples/default/src/screens/apm/FlowsScreen.tsx create mode 100644 examples/default/src/screens/apm/NetworkScreen.tsx create mode 100644 examples/default/src/screens/apm/TracesScreen.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index ba9af205a5..fccae4fc43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,11 @@ - Adds symbol files upload script ([#1137](https://github.com/Instabug/Instabug-React-Native/pull/1137)) - Support enabling NDK crash capturing on Android ([#1132](https://github.com/Instabug/Instabug-React-Native/pull/1132)). +- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). + +### Deprecated + +- 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)). ### Deprecated @@ -84,6 +89,10 @@ - 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). +### Deprecated + +- 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)). + ## [12.7.1](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.0...v12.7.1) (February 15, 2024) ### Changed diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock index ee026b369c..dcaa1c6971 100644 --- a/examples/default/ios/Podfile.lock +++ b/examples/default/ios/Podfile.lock @@ -404,6 +404,8 @@ PODS: - React-jsinspector (0.72.3) - React-logger (0.72.3): - glog + - react-native-background-timer (2.4.1): + - React-Core - react-native-config (1.5.1): - react-native-config/App (= 1.5.1) - react-native-config/App (1.5.1): @@ -528,6 +530,8 @@ PODS: - React-jsi (= 0.72.3) - React-logger (= 0.72.3) - React-perflogger (= 0.72.3) + - RNCClipboard (1.5.1): + - React-Core - RNGestureHandler (2.13.4): - RCT-Folly (= 2021.07.22.00) - React-Core @@ -623,6 +627,7 @@ DEPENDENCIES: - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) - React-logger (from `../node_modules/react-native/ReactCommon/logger`) + - react-native-background-timer (from `../node_modules/react-native-background-timer`) - react-native-config (from `../node_modules/react-native-config`) - react-native-google-maps (from `../node_modules/react-native-maps`) - react-native-maps (from `../node_modules/react-native-maps`) @@ -645,6 +650,7 @@ DEPENDENCIES: - React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`) - React-utils (from `../node_modules/react-native/ReactCommon/react/utils`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - "RNCClipboard (from `../node_modules/@react-native-community/clipboard`)" - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) - RNInstabug (from `../node_modules/instabug-reactnative`) - RNReanimated (from `../node_modules/react-native-reanimated`) @@ -720,6 +726,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/jsinspector" React-logger: :path: "../node_modules/react-native/ReactCommon/logger" + react-native-background-timer: + :path: "../node_modules/react-native-background-timer" react-native-config: :path: "../node_modules/react-native-config" react-native-google-maps: @@ -764,6 +772,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/react/utils" ReactCommon: :path: "../node_modules/react-native/ReactCommon" + RNCClipboard: + :path: "../node_modules/@react-native-community/clipboard" RNGestureHandler: :path: "../node_modules/react-native-gesture-handler" RNInstabug: @@ -818,6 +828,7 @@ SPEC CHECKSUMS: React-jsiexecutor: 59d1eb03af7d30b7d66589c410f13151271e8006 React-jsinspector: b511447170f561157547bc0bef3f169663860be7 React-logger: c5b527272d5f22eaa09bb3c3a690fee8f237ae95 + react-native-background-timer: 17ea5e06803401a379ebf1f20505b793ac44d0fe react-native-config: 86038147314e2e6d10ea9972022aa171e6b1d4d8 react-native-google-maps: 1bcc1f9f13f798fcf230db7fe476f3566d0bc0a3 react-native-maps: 72a8a903f8a1b53e2c777ba79102078ab502e0bf @@ -840,6 +851,7 @@ SPEC CHECKSUMS: React-runtimescheduler: 837c1bebd2f84572db17698cd702ceaf585b0d9a React-utils: bcb57da67eec2711f8b353f6e3d33bd8e4b2efa3 ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9 + RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495 RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee RNInstabug: 6fa68cd181533f83154df2ebba000d0c47ca7ba3 RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87 diff --git a/examples/default/package.json b/examples/default/package.json index 5c6b173c17..529521802d 100644 --- a/examples/default/package.json +++ b/examples/default/package.json @@ -10,14 +10,19 @@ "postinstall": "patch-package" }, "dependencies": { + "@react-native-community/clipboard": "^1.5.1", "@react-native-community/slider": "^4.4.3", "@react-navigation/bottom-tabs": "^6.5.7", "@react-navigation/native": "^6.1.6", "@react-navigation/native-stack": "^6.9.12", + "graphql": "^16.8.1", + "graphql-request": "^6.1.0", "instabug-reactnative": "link:../..", + "instabug-reactnative-ndk": "github:https://github.com/Instabug/Instabug-React-Native-NDK", "native-base": "^3.4.28", "react": "18.2.0", "react-native": "0.72.3", + "react-native-background-timer": "^2.4.1", "react-native-config": "^1.5.1", "react-native-gesture-handler": "^2.13.4", "react-native-maps": "^1.10.3", @@ -26,7 +31,7 @@ "react-native-screens": "^3.20.0", "react-native-svg": "^13.9.0", "react-native-vector-icons": "^10.0.0", - "instabug-reactnative-ndk": "github:https://github.com/Instabug/Instabug-React-Native-NDK" + "react-query": "^3.39.3" }, "devDependencies": { "@babel/core": "^7.20.0", @@ -35,6 +40,7 @@ "@react-native/metro-config": "^0.73.1", "@types/jest": "^29.2.1", "@types/react": "^18.0.24", + "@types/react-native-background-timer": "^2.0.2", "@types/react-native-vector-icons": "^6.4.13", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.2.1", diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx index 4bc1447056..d92db633c1 100644 --- a/examples/default/src/App.tsx +++ b/examples/default/src/App.tsx @@ -15,6 +15,10 @@ import { RootTabNavigator } from './navigation/RootTab'; import { nativeBaseTheme } from './theme/nativeBaseTheme'; import { navigationTheme } from './theme/navigationTheme'; +import { QueryClient, QueryClientProvider } from 'react-query'; + +const queryClient = new QueryClient(); + export const App: React.FC = () => { useEffect(() => { Instabug.init({ @@ -32,9 +36,11 @@ export const App: React.FC = () => { return ( - - - + + + + + ); diff --git a/examples/default/src/components/ClipboardTextInput.tsx b/examples/default/src/components/ClipboardTextInput.tsx new file mode 100644 index 0000000000..05d9c35ec6 --- /dev/null +++ b/examples/default/src/components/ClipboardTextInput.tsx @@ -0,0 +1,36 @@ +import React, { PropsWithChildren } from 'react'; +import { StyleProp, StyleSheet, TextStyle } from 'react-native'; +import PasteFromClipboardButton from './PasteFromClipboardButton'; +import { HStack } from 'native-base'; +import { InputField } from './InputField'; + +interface ClipboardTextInputProps extends PropsWithChildren { + placeholder?: string; + onChangeText?: (text: string) => void; + value?: string; + selectTextOnFocus?: boolean; + style?: StyleProp; +} + +export const ClipboardTextInput: React.FC = ({ + onChangeText, + style, + ...restProps +}) => { + return ( + + + + + ); + + function handleClipboardPress(text: string) { + onChangeText?.call(undefined, text); + } +}; + +export const styles = StyleSheet.create({ + inputField: { + flex: 1, + }, +}); diff --git a/examples/default/src/components/CustomButton.tsx b/examples/default/src/components/CustomButton.tsx new file mode 100644 index 0000000000..07bcf9798c --- /dev/null +++ b/examples/default/src/components/CustomButton.tsx @@ -0,0 +1,31 @@ +import React, { PropsWithChildren } from 'react'; +import type { StyleProp, TextStyle } from 'react-native'; +import { Button } from 'native-base'; +import { CustomText } from './CustomText'; +import { StyleSheet } from 'react-native'; + +interface CustomButtonProps extends PropsWithChildren { + title?: string; + onPress?: () => void; + style?: StyleProp; +} + +export const CustomButton: React.FC = ({ + style, + title, + children, + ...restProps +}) => { + return ( + + ); +}; + +export const styles = StyleSheet.create({ + text: { + color: '#fff', + }, +}); diff --git a/examples/default/src/components/CustomImage.tsx b/examples/default/src/components/CustomImage.tsx new file mode 100644 index 0000000000..5c5d051ebe --- /dev/null +++ b/examples/default/src/components/CustomImage.tsx @@ -0,0 +1,17 @@ +import React, { PropsWithChildren } from 'react'; +import { StyleProp, StyleSheet, TextStyle, Text } from 'react-native'; + +interface CustomTextProps extends PropsWithChildren { + style?: StyleProp; +} + +export const CustomImage: React.FC = ({ style, children }) => { + return {children}; +}; + +export const styles = StyleSheet.create({ + text: { + fontSize: 16, + lineHeight: 24, + }, +}); diff --git a/examples/default/src/components/CustomText.tsx b/examples/default/src/components/CustomText.tsx new file mode 100644 index 0000000000..5e36221280 --- /dev/null +++ b/examples/default/src/components/CustomText.tsx @@ -0,0 +1,17 @@ +import React, { PropsWithChildren } from 'react'; +import { StyleProp, StyleSheet, TextStyle, Text } from 'react-native'; + +interface CustomTextProps extends PropsWithChildren { + style?: StyleProp; +} + +export const CustomText: React.FC = ({ style, children }) => { + return {children}; +}; + +export const styles = StyleSheet.create({ + text: { + fontSize: 16, + lineHeight: 24, + }, +}); diff --git a/examples/default/src/components/InputField.tsx b/examples/default/src/components/InputField.tsx index 1a5700c27c..feef8fd7b5 100644 --- a/examples/default/src/components/InputField.tsx +++ b/examples/default/src/components/InputField.tsx @@ -1,13 +1,22 @@ import React, { forwardRef } from 'react'; -import { KeyboardTypeOptions, StyleSheet, TextInput, View } from 'react-native'; +import { + KeyboardTypeOptions, + StyleProp, + StyleSheet, + TextInput, + ViewStyle, + View, +} from 'react-native'; import { Text } from 'native-base'; interface InputFieldProps { placeholder?: string; value?: string; + style?: StyleProp; onChangeText?: (text: string) => void; keyboardType?: KeyboardTypeOptions; + selectTextOnFocus?: boolean | undefined; errorText?: string; maxLength?: number; accessibilityLabel?: string; @@ -19,6 +28,7 @@ export const InputField = forwardRef( { placeholder, value, + style, onChangeText, accessibilityLabel, maxLength, @@ -33,7 +43,7 @@ export const InputField = forwardRef( void; + style?: StyleProp; +} + +const PasteFromClipboardButton: React.FC = ({ onPress, style }) => { + const handlePress = async () => { + const text = await Clipboard.getString(); + onPress?.call(undefined, text); // Using call to pass the text to the callback + }; + + return ( + + + + ); +}; + +export default PasteFromClipboardButton; diff --git a/examples/default/src/navigation/HomeStack.tsx b/examples/default/src/navigation/HomeStack.tsx index 184e36f03d..b4a8ca3e69 100644 --- a/examples/default/src/navigation/HomeStack.tsx +++ b/examples/default/src/navigation/HomeStack.tsx @@ -21,6 +21,10 @@ import { } from '../screens/user-steps/BackAndForthScreen'; import { GoogleMapsScreen } from '../screens/user-steps/GoogleMapsScreen'; import { LargeImageListScreen } from '../screens/user-steps/LargeImageListScreen'; +import { APMScreen } from '../screens/apm/APMScreen'; +import { TracesScreen } from '../screens/apm/TracesScreen'; +import { NetworkScreen } from '../screens/apm/NetworkScreen'; +import { FlowsScreen } from '../screens/apm/FlowsScreen'; import { SessionReplayScreen } from '../screens/SessionReplayScreen'; export type HomeStackParamList = { @@ -41,6 +45,12 @@ export type HomeStackParamList = { LargeImageList: undefined; SessionReplay: undefined; BackAndForthScreen: BackAndForthScreenProp; + + // APM // + APM: undefined; + NetworkTraces: undefined; + ExecutionTraces: undefined; + AppFlows: undefined; }; const HomeStack = createNativeStackNavigator(); @@ -65,7 +75,6 @@ export const HomeStackNavigator: React.FC = () => { options={{ title: 'Feature Requests' }} /> - { options={{ title: 'Large Image List' }} /> + + + + ); }; diff --git a/examples/default/src/screens/HomeScreen.tsx b/examples/default/src/screens/HomeScreen.tsx index 086dc0650f..690d41cc2d 100644 --- a/examples/default/src/screens/HomeScreen.tsx +++ b/examples/default/src/screens/HomeScreen.tsx @@ -17,6 +17,7 @@ export const HomeScreen: React.FC navigation.navigate('Replies')} /> navigation.navigate('Surveys')} /> navigation.navigate('UserSteps')} /> + navigation.navigate('APM')} /> navigation.navigate('SessionReplay')} /> ); diff --git a/examples/default/src/screens/apm/APMScreen.tsx b/examples/default/src/screens/apm/APMScreen.tsx new file mode 100644 index 0000000000..2bc4dbca0d --- /dev/null +++ b/examples/default/src/screens/apm/APMScreen.tsx @@ -0,0 +1,17 @@ +import type { NativeStackScreenProps } from '@react-navigation/native-stack'; +import type { HomeStackParamList } from '../../navigation/HomeStack'; +import React from 'react'; +import { ListTile } from '../../components/ListTile'; +import { Screen } from '../../components/Screen'; + +export const APMScreen: React.FC> = ({ + navigation, +}) => { + return ( + + navigation.navigate('NetworkTraces')} /> + navigation.navigate('ExecutionTraces')} /> + navigation.navigate('AppFlows')} /> + + ); +}; diff --git a/examples/default/src/screens/apm/FlowsScreen.tsx b/examples/default/src/screens/apm/FlowsScreen.tsx new file mode 100644 index 0000000000..be9b0fec70 --- /dev/null +++ b/examples/default/src/screens/apm/FlowsScreen.tsx @@ -0,0 +1,63 @@ +import React, { useState } from 'react'; +import { APM } from 'instabug-reactnative'; +import { ScrollView } from 'react-native'; +import { Section } from '../../components/Section'; +import { Screen } from '../../components/Screen'; +import { VStack } from 'native-base'; +import { InputField } from '../../components/InputField'; +import { CustomButton } from '../../components/CustomButton'; +import BackgroundTimer from 'react-native-background-timer'; + +export const FlowsScreen: React.FC = () => { + const [flowName, setFlowName] = useState(''); + const [flowAttributeKey, setFlowAttributeKey] = useState(''); + const [flowAttributeValue, setFlowAttributeValue] = useState(''); + + async function startFlow() { + return APM.startFlow(flowName); + } + + async function startDelayedFlow() { + return BackgroundTimer.setTimeout(() => { + APM.startFlow(flowName); + }, 5000); + } + + function setFlowAttribute() { + return APM.setFlowAttribute(flowName, flowAttributeKey, flowAttributeValue); + } + + function endFlow() { + APM.endFlow(flowName); + } + + return ( + + +
+ + setFlowName(text)} + value={flowName} + /> + + + setFlowAttributeKey(text)} + value={flowAttributeKey} + /> + setFlowAttributeValue(text)} + value={flowAttributeValue} + /> + + + +
+
+
+ ); +}; diff --git a/examples/default/src/screens/apm/NetworkScreen.tsx b/examples/default/src/screens/apm/NetworkScreen.tsx new file mode 100644 index 0000000000..467a621f21 --- /dev/null +++ b/examples/default/src/screens/apm/NetworkScreen.tsx @@ -0,0 +1,110 @@ +import React, { useState } from 'react'; +import { Image, ScrollView, StyleSheet, Text, useWindowDimensions, View } from 'react-native'; +import { Section } from '../../components/Section'; +import { Screen } from '../../components/Screen'; +import { ClipboardTextInput } from '../../components/ClipboardTextInput'; +import { useQuery } from 'react-query'; +import { HStack, VStack } from 'native-base'; +import { gql, request } from 'graphql-request'; +import { CustomButton } from '../../components/CustomButton'; + +export const NetworkScreen: React.FC = () => { + const [endpointUrl, setEndpointUrl] = useState(''); + const { width, height } = useWindowDimensions(); + const defaultRequestUrl = 'https://jsonplaceholder.typicode.com/posts/1'; + const imageUrls = [ + 'https://fastly.picsum.photos/id/57/200/300.jpg?hmac=l908G1qVr4r7dP947-tak2mY8Vvic_vEYzCXUCKKskY', + 'https://fastly.picsum.photos/id/619/200/300.jpg?hmac=WqBGwlGjuY9RCdpzRaG9G-rc9Fi7TGUINX_-klAL2kA', + ]; + + async function sendRequestToUrl() { + let urlToSend = ''; + + if (endpointUrl.trim() !== '') { + urlToSend = endpointUrl; + console.log('Sending request to: ', endpointUrl); + } else { + // Use json placeholder URL as a default if endpointUrl is empty + console.log('sending request to default json placeholder'); + urlToSend = defaultRequestUrl; + } + + try { + // Perform the request using the urlToSend + const response = await fetch(urlToSend); + const data = await response.json(); + + // Format the JSON response for better logging + const formattedData = JSON.stringify(data, null, 2); + + // Log the formatted response + console.log('Response:', formattedData); + } catch (error) { + // Handle errors appropriately + console.error('Error:', error); + } + } + + const fetchGraphQlData = async () => { + const document = gql` + query { + country(code: "EG") { + emoji + name + } + } + `; + + return request<{ country: { emoji: string; name: string } }>( + 'https://countries.trevorblades.com/graphql', + document, + ); + }; + + const { data, isError, isSuccess, isLoading, refetch } = useQuery('helloQuery', fetchGraphQlData); + + return ( + + +
+ + setEndpointUrl(text)} + selectTextOnFocus={true} + value={endpointUrl} + /> + + refetch} title="Reload GraphQL" /> + + {isLoading && Loading...} + {isSuccess && GraphQL Data: {data.country.emoji}} + {isError && Error!} + + +
+
+ + {imageUrls.map((imageUrl) => ( + + ))} + +
+
+
+ ); +}; +const styles = StyleSheet.create({ + image: { + resizeMode: 'contain', + }, + // Todo: Text Component + // Todo: Button Component + // Todo: Image Component +}); diff --git a/examples/default/src/screens/apm/TracesScreen.tsx b/examples/default/src/screens/apm/TracesScreen.tsx new file mode 100644 index 0000000000..bd3e41838a --- /dev/null +++ b/examples/default/src/screens/apm/TracesScreen.tsx @@ -0,0 +1,70 @@ +import React, { useState } from 'react'; +import { APM, Trace } from 'instabug-reactnative'; +import { ScrollView } from 'react-native'; +import { Section } from '../../components/Section'; +import { Screen } from '../../components/Screen'; +import { VStack } from 'native-base'; +import { InputField } from '../../components/InputField'; +import { CustomButton } from '../../components/CustomButton'; +import BackgroundTimer from 'react-native-background-timer'; + +export const TracesScreen: React.FC = () => { + const [traceName, setTraceName] = useState(''); + const [traceAttributeKey, setTraceAttributeKey] = useState(''); + const [traceAttributeValue, setTraceAttributeValue] = useState(''); + let executionTrace: Trace; + + async function startTrace() { + executionTrace = await APM.startExecutionTrace(traceName ?? ''); + } + + async function startDelayedTrace() { + return BackgroundTimer.setTimeout(async () => { + executionTrace = await APM.startExecutionTrace(traceName ?? ''); + }, 5000); + } + + function setTraceAttribute() { + if (!executionTrace) { + console.log('Please, start a trace before setting attributes.'); + } + return executionTrace.setAttribute(traceAttributeKey ?? '', traceAttributeValue ?? ''); + } + + function endExecutionTrace() { + if (!executionTrace) { + console.log('Please, start a trace before ending it.'); + } + return executionTrace.end(); + } + + return ( + + +
+ + setTraceName(text)} + value={traceName} + /> + + + setTraceAttributeKey(text)} + value={traceAttributeKey} + /> + setTraceAttributeValue(text)} + value={traceAttributeValue} + /> + + + +
+
+
+ ); +}; diff --git a/examples/default/yarn.lock b/examples/default/yarn.lock index e388f66821..74f7ce0e3b 100644 --- a/examples/default/yarn.lock +++ b/examples/default/yarn.lock @@ -1279,6 +1279,13 @@ dependencies: regenerator-runtime "^0.13.11" +"@babel/runtime@^7.23.8", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2": + version "7.23.9" + resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.9.tgz#47791a15e4603bb5f905bc0753801cf21d6345f7" + integrity sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw== + dependencies: + regenerator-runtime "^0.14.0" + "@babel/template@^7.0.0", "@babel/template@^7.22.5", "@babel/template@^7.3.3": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.5.tgz#0c8c4d944509875849bd0344ff0050756eefc6ec" @@ -1391,6 +1398,11 @@ dependencies: tslib "^2.4.0" +"@graphql-typed-document-node/core@^3.2.0": + version "3.2.0" + resolved "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" + integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== + "@hapi/hoek@^9.0.0": version "9.3.0" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb" @@ -2313,6 +2325,11 @@ prompts "^2.4.0" semver "^6.3.0" +"@react-native-community/clipboard@^1.5.1": + version "1.5.1" + resolved "https://registry.npmjs.org/@react-native-community/clipboard/-/clipboard-1.5.1.tgz#32abb3ea2eb91ee3f9c5fb1d32d5783253c9fabe" + integrity sha512-AHAmrkLEH5UtPaDiRqoULERHh3oNv7Dgs0bTC0hO5Z2GdNokAMPT5w8ci8aMcRemcwbtdHjxChgtjbeA38GBdA== + "@react-native-community/slider@^4.4.3": version "4.4.3" resolved "https://registry.yarnpkg.com/@react-native-community/slider/-/slider-4.4.3.tgz#9b9dc639b88f5bfda72bd72a9dff55cbf9f777ed" @@ -3018,6 +3035,11 @@ resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf" integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w== +"@types/react-native-background-timer@^2.0.2": + version "2.0.2" + resolved "https://registry.npmjs.org/@types/react-native-background-timer/-/react-native-background-timer-2.0.2.tgz#22f9126124068a0ee6a812e16f98e270c2b9b2c7" + integrity sha512-cMAep0M5yqUHjiiRPvGiviqiJYdI45KSjbI5ufsIFSQGFwHwrHJC/8yawNhy0G3Gix6fufWLsEj6jC5niUNHiQ== + "@types/react-native-vector-icons@^6.4.13": version "6.4.13" resolved "https://registry.yarnpkg.com/@types/react-native-vector-icons/-/react-native-vector-icons-6.4.13.tgz#28b34d15094e040718beefb67cb3eff0c4994cb6" @@ -3366,6 +3388,11 @@ base64-js@^1.1.2, base64-js@^1.3.1: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== +big-integer@^1.6.16: + version "1.6.52" + resolved "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz#60a887f3047614a8e1bffe5d7173490a97dc8c85" + integrity sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg== + bl@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" @@ -3407,6 +3434,20 @@ braces@^3.0.2: dependencies: fill-range "^7.0.1" +broadcast-channel@^3.4.1: + version "3.7.0" + resolved "https://registry.npmjs.org/broadcast-channel/-/broadcast-channel-3.7.0.tgz#2dfa5c7b4289547ac3f6705f9c00af8723889937" + integrity sha512-cIAKJXAxGJceNZGTZSBzMxzyOn72cVgPnKx4dc6LRjQgbaJUQqhy5rzL3zbMxkMWsGKkv2hSFkPRMEXfoMZ2Mg== + dependencies: + "@babel/runtime" "^7.7.2" + detect-node "^2.1.0" + js-sha3 "0.8.0" + microseconds "0.2.0" + nano-time "1.0.0" + oblivious-set "1.0.0" + rimraf "3.0.2" + unload "2.2.0" + browser-process-hrtime@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" @@ -3780,6 +3821,13 @@ cosmiconfig@^5.0.5, cosmiconfig@^5.1.0: js-yaml "^3.13.1" parse-json "^4.0.0" +cross-fetch@^3.1.5: + version "3.1.8" + resolved "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" + integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== + dependencies: + node-fetch "^2.6.12" + cross-spawn@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" @@ -3922,6 +3970,11 @@ detect-newline@^3.0.0: resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== +detect-node@^2.0.4, detect-node@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1" + integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g== + detox@^20.9.0: version "20.11.2" resolved "https://registry.yarnpkg.com/detox/-/detox-20.11.2.tgz#7628ad7909b343069e164fbada428ac12464eb67" @@ -4415,6 +4468,19 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.2.0, resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== +graphql-request@^6.1.0: + version "6.1.0" + resolved "https://registry.npmjs.org/graphql-request/-/graphql-request-6.1.0.tgz#f4eb2107967af3c7a5907eb3131c671eac89be4f" + integrity sha512-p+XPfS4q7aIpKVcgmnZKhMNqhltk20hfXtkaIkTfjjmiKMJ5xrt5c743cL03y/K7y1rg3WrIC49xGiEQ4mxdNw== + dependencies: + "@graphql-typed-document-node/core" "^3.2.0" + cross-fetch "^3.1.5" + +graphql@^16.8.1: + version "16.8.1" + resolved "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07" + integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw== + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -5180,6 +5246,11 @@ js-queue@2.0.2: dependencies: easy-stack "^1.0.1" +js-sha3@0.8.0: + version "0.8.0" + resolved "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" + integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== + "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -5496,6 +5567,14 @@ makeerror@1.0.12: dependencies: tmpl "1.0.5" +match-sorter@^6.0.2: + version "6.3.4" + resolved "https://registry.npmjs.org/match-sorter/-/match-sorter-6.3.4.tgz#afa779d8e922c81971fbcb4781c7003ace781be7" + integrity sha512-jfZW7cWS5y/1xswZo8VBOdudUiSd9nifYRWphc9M5D/ee4w4AoXLgBEdRbgVaxbMuagBPeUC5y2Hi8DO6o9aDg== + dependencies: + "@babel/runtime" "^7.23.8" + remove-accents "0.5.0" + mdn-data@2.0.14: version "2.0.14" resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50" @@ -6016,6 +6095,11 @@ micromatch@^4.0.2, micromatch@^4.0.4: braces "^3.0.2" picomatch "^2.3.1" +microseconds@0.2.0: + version "0.2.0" + resolved "https://registry.npmjs.org/microseconds/-/microseconds-0.2.0.tgz#233b25f50c62a65d861f978a4a4f8ec18797dc39" + integrity sha512-n7DHHMjR1avBbSpsTBj6fmMGh2AGrifVV4e+WYc3Q9lO+xnSZ3NyhcBND3vzzatt05LFhoKFRxrIyklmLlUtyA== + mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": version "1.52.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" @@ -6116,6 +6200,13 @@ nan@^2.14.0: resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb" integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ== +nano-time@1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/nano-time/-/nano-time-1.0.0.tgz#b0554f69ad89e22d0907f7a12b0993a5d96137ef" + integrity sha512-flnngywOoQ0lLQOTRNexn2gGSNuM9bKj9RZAWSzhQ+UJYaAFG9bac4DW9VHjUAzrOaIcajHybCTHe/bkvozQqA== + dependencies: + big-integer "^1.6.16" + nanoid@^3.1.23: version "3.3.6" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" @@ -6206,6 +6297,13 @@ node-fetch@^2.2.0, node-fetch@^2.6.0: dependencies: whatwg-url "^5.0.0" +node-fetch@^2.6.12: + version "2.7.0" + resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -6279,6 +6377,11 @@ object-keys@^1.1.1: resolved "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== +oblivious-set@1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/oblivious-set/-/oblivious-set-1.0.0.tgz#c8316f2c2fb6ff7b11b6158db3234c49f733c566" + integrity sha512-z+pI07qxo4c2CulUHCDf9lcqDlMSo72N/4rLUpRXf6fu+q8vjt8y0xS+Tlf8NTJDdTXHbdeO1n3MlbctwEoXZw== + on-finished@2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" @@ -6626,6 +6729,11 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== +react-native-background-timer@^2.4.1: + version "2.4.1" + resolved "https://registry.npmjs.org/react-native-background-timer/-/react-native-background-timer-2.4.1.tgz#a3bc1cafa8c1e3aeefd0611de120298b67978a0f" + integrity sha512-TE4Kiy7jUyv+hugxDxitzu38sW1NqjCk4uE5IgU2WevLv7sZacaBc6PZKOShNRPGirLl1NWkaG3LDEkdb9Um5g== + react-native-config@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/react-native-config/-/react-native-config-1.5.1.tgz#73c94f511493e9b7ff9350cdf351d203a1b05acc" @@ -6730,6 +6838,15 @@ react-native@0.72.3: ws "^6.2.2" yargs "^17.6.2" +react-query@^3.39.3: + version "3.39.3" + resolved "https://registry.npmjs.org/react-query/-/react-query-3.39.3.tgz#4cea7127c6c26bdea2de5fb63e51044330b03f35" + integrity sha512-nLfLz7GiohKTJDuT4us4X3h/8unOh+00MLb2yJoGTPjxKs2bc1iDhkNx2bd5MKklXnOD3NrVZ+J2UXujA5In4g== + dependencies: + "@babel/runtime" "^7.5.5" + broadcast-channel "^3.4.1" + match-sorter "^6.0.2" + react-refresh@^0.14.0: version "0.14.0" resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.0.tgz#4e02825378a5f227079554d4284889354e5f553e" @@ -6818,6 +6935,11 @@ regenerator-runtime@^0.13.11, regenerator-runtime@^0.13.2: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== +regenerator-runtime@^0.14.0: + version "0.14.1" + resolved "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" + integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== + regenerator-transform@^0.15.1: version "0.15.1" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.15.1.tgz#f6c4e99fc1b4591f780db2586328e4d9a9d8dc56" @@ -6844,6 +6966,11 @@ regjsparser@^0.9.1: dependencies: jsesc "~0.5.0" +remove-accents@0.5.0: + version "0.5.0" + resolved "https://registry.npmjs.org/remove-accents/-/remove-accents-0.5.0.tgz#77991f37ba212afba162e375b627631315bed687" + integrity sha512-8g3/Otx1eJaVD12e31UbJj1YzdtVvzH85HV7t+9MJYk/u3XmkOUJ5Ys9wQrf9PCPK8+xn4ymzqYCiZl6QWKn+A== + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -6903,6 +7030,13 @@ retry@^0.12.0: resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" integrity sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow== +rimraf@3.0.2, rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + rimraf@^2.6.3: version "2.7.1" resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" @@ -6910,13 +7044,6 @@ rimraf@^2.6.3: dependencies: glob "^7.1.3" -rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - rimraf@~2.4.0: version "2.4.5" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.4.5.tgz#ee710ce5d93a8fdb856fb5ea8ff0e2d75934b2da" @@ -7490,6 +7617,14 @@ universalify@^2.0.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== +unload@2.2.0: + version "2.2.0" + resolved "https://registry.npmjs.org/unload/-/unload-2.2.0.tgz#ccc88fdcad345faa06a92039ec0f80b488880ef7" + integrity sha512-B60uB5TNBLtN6/LsgAf3udH9saB5p7gqJwcFfbOEZ8BcBHnGwCf6G/TGiEqkRAxX7zAFIUtzdrXQSdL3Q/wqNA== + dependencies: + "@babel/runtime" "^7.6.2" + detect-node "^2.0.4" + unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" From 0222c64f730ccd9f2dd8e29615a35c7da9ae3224 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:58:56 +0300 Subject: [PATCH 02/40] fix(android): resolve an OOM in network logs (#1244) --- CHANGELOG.md | 6 + .../reactlibrary/RNInstabugAPMModule.java | 84 ++++--- .../RNInstabugReactnativeModule.java | 55 +++-- .../ios/InstabugTests/InstabugSampleTests.m | 56 +++++ ios/RNInstabug/InstabugReactBridge.h | 17 ++ ios/RNInstabug/InstabugReactBridge.m | 93 +++---- ios/RNInstabug/Util/IBGNetworkLogger+CP.h | 16 ++ src/modules/NetworkLogger.ts | 34 ++- src/native/NativeAPM.ts | 19 +- src/native/NativeInstabug.ts | 32 ++- src/utils/InstabugConstants.ts | 13 +- src/utils/InstabugUtils.ts | 72 ++++++ src/utils/XhrNetworkInterceptor.ts | 8 +- test/mocks/mockAPM.ts | 2 +- test/mocks/mockInstabug.ts | 3 +- test/mocks/mockInstabugUtils.ts | 2 + test/modules/NetworkLogger.spec.ts | 228 ++++++++++++------ test/utils/InstabugUtils.spec.ts | 98 +++++++- 18 files changed, 621 insertions(+), 217 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fccae4fc43..7ec9aad5b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...dev) + +### Fixed + +- Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)). + ## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024) ### Changed diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java index d7662c6536..7ffaf4de73 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java @@ -5,6 +5,8 @@ import android.util.Log; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; @@ -312,56 +314,58 @@ public void run() { }); } - /** - * Send Apm network log by Reflection - */ @ReactMethod - public void networkLog(String networkData) throws JSONException { - try{ - APMNetworkLogger apmNetworkLogger = new APMNetworkLogger(); - JSONObject jsonObject = new JSONObject(networkData); - final String requestUrl = (String) jsonObject.get("url"); - final String requestBody = (String) jsonObject.get("requestBody"); - final String responseBody = (String) jsonObject.get("responseBody"); - final String requestMethod = (String) jsonObject.get("method"); - //-------------------------------------------- - final String requestContentType = (String) jsonObject.get("requestContentType"); - final String responseContentType = (String) jsonObject.get("contentType"); - //-------------------------------------------- - final long requestBodySize = ((Number) jsonObject.get("requestBodySize")).longValue(); - final long responseBodySize = ((Number) jsonObject.get("responseBodySize")).longValue(); - //-------------------------------------------- - final String errorDomain = (String) jsonObject.get("errorDomain"); - final Integer statusCode = (Integer) jsonObject.get("responseCode"); - final long requestDuration = ((Number) jsonObject.get("duration")).longValue(); - final long requestStartTime = ((Number) jsonObject.get("startTime")).longValue() * 1000; - final String requestHeaders = (String) jsonObject.get("requestHeaders").toString(); - final String responseHeaders = (String) jsonObject.get("responseHeaders").toString(); - final String errorMessage; - if(errorDomain.equals("")) { - errorMessage = null; - } else { - errorMessage = errorDomain; - } - //-------------------------------------------- - String gqlQueryName = null; - if(jsonObject.has("gqlQueryName")){ - gqlQueryName = (String) jsonObject.get("gqlQueryName"); - } - final String serverErrorMessage = (String) jsonObject.get("serverErrorMessage"); + private void networkLogAndroid(final double requestStartTime, + final double requestDuration, + final String requestHeaders, + final String requestBody, + final double requestBodySize, + final String requestMethod, + final String requestUrl, + final String requestContentType, + final String responseHeaders, + final String responseBody, + final double responseBodySize, + final double statusCode, + final String responseContentType, + @Nullable final String errorDomain, + @Nullable final String gqlQueryName, + @Nullable final String serverErrorMessage) { + try { + APMNetworkLogger networkLogger = new APMNetworkLogger(); + + final boolean hasError = errorDomain != null && !errorDomain.isEmpty(); + final String errorMessage = hasError ? errorDomain : null; try { Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class); if (method != null) { - method.invoke(apmNetworkLogger, requestStartTime, requestDuration, requestHeaders, requestBody, requestBodySize, requestMethod, requestUrl, requestContentType, responseHeaders, responseBody, responseBodySize, statusCode, responseContentType, errorMessage, gqlQueryName, serverErrorMessage); + method.invoke( + networkLogger, + requestStartTime, + requestDuration, + requestHeaders, + requestBody, + requestBodySize, + requestMethod, + requestUrl, + requestContentType, + responseHeaders, + responseBody, + responseBodySize, + statusCode, + responseContentType, + errorMessage, + gqlQueryName, + serverErrorMessage + ); } else { - Log.e("IB-CP-Bridge", "apmNetworkLogByReflection was not found by reflection"); + Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection"); } } catch (Throwable e) { e.printStackTrace(); } - } - catch(Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index c056f15831..7d14656089 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -5,6 +5,7 @@ import android.app.Application; import android.graphics.Bitmap; import android.net.Uri; +import android.util.Log; import android.view.View; import androidx.annotation.UiThread; @@ -34,6 +35,7 @@ import com.instabug.library.model.NetworkLog; import com.instabug.library.model.Report; import com.instabug.library.ui.onboarding.WelcomeMessage; +import com.instabug.library.util.InstabugSDKLogger; import com.instabug.reactlibrary.utils.ArrayUtil; import com.instabug.reactlibrary.utils.EventEmitterModule; import com.instabug.reactlibrary.utils.MainThreadHandler; @@ -60,7 +62,7 @@ */ public class RNInstabugReactnativeModule extends EventEmitterModule { - private static final String TAG = RNInstabugReactnativeModule.class.getSimpleName(); + private static final String TAG = "IBG-RN-Core"; private InstabugCustomTextPlaceHolder placeHolders; private static Report currentReport; @@ -895,27 +897,38 @@ public void run() { }); } - /** - * Extracts HTTP connection properties. Request method, Headers, Date, Url and Response code - * - * @param jsonObject the JSON object containing all HTTP connection properties - * @throws JSONException - */ @ReactMethod - public void networkLog(String jsonObject) throws JSONException { - NetworkLog networkLog = new NetworkLog(); - String date = System.currentTimeMillis()+""; - networkLog.setDate(date); - JSONObject newJSONObject = new JSONObject(jsonObject); - networkLog.setUrl(newJSONObject.getString("url")); - networkLog.setRequest(newJSONObject.getString("requestBody")); - networkLog.setResponse(newJSONObject.getString("responseBody")); - networkLog.setMethod(newJSONObject.getString("method")); - networkLog.setResponseCode(newJSONObject.getInt("responseCode")); - networkLog.setRequestHeaders(newJSONObject.getString("requestHeaders")); - networkLog.setResponseHeaders(newJSONObject.getString("responseHeaders")); - networkLog.setTotalDuration(newJSONObject.getLong("duration")); - networkLog.insert(); + public void networkLogAndroid(final String url, + final String requestBody, + final String responseBody, + final String method, + final double responseCode, + final String requestHeaders, + final String responseHeaders, + final double duration) { + try { + final String date = String.valueOf(System.currentTimeMillis()); + + NetworkLog networkLog = new NetworkLog(); + networkLog.setDate(date); + networkLog.setUrl(url); + networkLog.setMethod(method); + networkLog.setResponseCode((int) responseCode); + networkLog.setTotalDuration((long) duration); + + try { + networkLog.setRequest(requestBody); + networkLog.setResponse(responseBody); + networkLog.setRequestHeaders(requestHeaders); + networkLog.setResponseHeaders(responseHeaders); + } catch (OutOfMemoryError | Exception exception) { + Log.d(TAG, "Error: " + exception.getMessage() + "while trying to set network log contents (request body, response body, request headers, and response headers)."); + } + + networkLog.insert(); + } catch (OutOfMemoryError | Exception exception) { + Log.d(TAG, "Error: " + exception.getMessage() + "while trying to insert a network log"); + } } @UiThread diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m index bf4edbd434..37990b450c 100644 --- a/examples/default/ios/InstabugTests/InstabugSampleTests.m +++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m @@ -13,6 +13,7 @@ #import #import "IBGConstants.h" #import "RNInstabug.h" +#import @protocol InstabugCPTestProtocol /** @@ -313,6 +314,61 @@ - (void)testSetWelcomeMessageMode { OCMVerify([mock setWelcomeMessageMode:welcomeMessageMode]); } +- (void)testNetworkLogIOS { + id mIBGNetworkLogger = OCMClassMock([IBGNetworkLogger class]); + + NSString *url = @"https://api.instabug.com"; + NSString *method = @"GET"; + NSString *requestBody = @"requestBody"; + double requestBodySize = 10; + NSString *responseBody = @"responseBody"; + double responseBodySize = 15; + double responseCode = 200; + NSDictionary *requestHeaders = @{ @"accept": @"application/json" }; + NSDictionary *responseHeaders = @{ @"cache-control": @"no-store" }; + NSString *contentType = @"application/json"; + double errorCode = 0; + NSString *errorDomain = nil; + double startTime = 1719847101199; + double duration = 150; + NSString *gqlQueryName = nil; + NSString *serverErrorMessage = nil; + + [self.instabugBridge networkLogIOS:url + method:method + requestBody:requestBody + requestBodySize:requestBodySize + responseBody:responseBody + responseBodySize:responseBodySize + responseCode:responseCode + requestHeaders:requestHeaders + responseHeaders:responseHeaders + contentType:contentType + errorDomain:errorDomain + errorCode:errorCode + startTime:startTime + duration:duration + gqlQueryName:gqlQueryName + serverErrorMessage:serverErrorMessage]; + + OCMVerify([mIBGNetworkLogger addNetworkLogWithUrl:url + method:method + requestBody:requestBody + requestBodySize:requestBodySize + responseBody:responseBody + responseBodySize:responseBodySize + responseCode:responseCode + requestHeaders:requestHeaders + responseHeaders:responseHeaders + contentType:contentType + errorDomain:errorDomain + errorCode:errorCode + startTime:startTime * 1000 + duration:duration * 1000 + gqlQueryName:gqlQueryName + serverErrorMessage:serverErrorMessage]); +} + - (void)testSetFileAttachment { id mock = OCMClassMock([Instabug class]); NSString *fileLocation = @"test"; diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h index 9e9a8db489..5da9b9cc71 100644 --- a/ios/RNInstabug/InstabugReactBridge.h +++ b/ios/RNInstabug/InstabugReactBridge.h @@ -107,6 +107,23 @@ - (void)setNetworkLoggingEnabled:(BOOL)isEnabled; +- (void)networkLogIOS:(NSString * _Nonnull)url + method:(NSString * _Nonnull)method + requestBody:(NSString * _Nonnull)requestBody + requestBodySize:(double)requestBodySize + responseBody:(NSString * _Nonnull)responseBody + responseBodySize:(double)responseBodySize + responseCode:(double)responseCode + requestHeaders:(NSDictionary * _Nonnull)requestHeaders + responseHeaders:(NSDictionary * _Nonnull)responseHeaders + contentType:(NSString * _Nonnull)contentType + errorDomain:(NSString * _Nullable)errorDomain + errorCode:(double)errorCode + startTime:(double)startTime + duration:(double)duration + gqlQueryName:(NSString * _Nullable)gqlQueryName + serverErrorMessage:(NSString * _Nullable)serverErrorMessage; + /* +------------------------------------------------------------------------+ | Experiments | diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index 01dd41aa87..2f2b24f27a 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -15,6 +15,7 @@ #import #import #import "RNInstabug.h" +#import "Util/IBGNetworkLogger+CP.h" @interface Instabug (PrivateWillSendAPI) + (void)setWillSendReportHandler_private:(void(^)(IBGReport *report, void(^reportCompletionHandler)(IBGReport *)))willSendReportHandler_private; @@ -283,66 +284,38 @@ - (dispatch_queue_t)methodQueue { } } -RCT_EXPORT_METHOD(networkLog:(NSDictionary *) networkData) { - NSString* url = networkData[@"url"]; - NSString* method = networkData[@"method"]; - NSString* requestBody = networkData[@"requestBody"]; - int64_t requestBodySize = [networkData[@"requestBodySize"] integerValue]; - NSString* responseBody = nil; - if (networkData[@"responseBody"] != [NSNull null]) { - responseBody = networkData[@"responseBody"]; - } - int64_t responseBodySize = [networkData[@"responseBodySize"] integerValue]; - int32_t responseCode = [networkData[@"responseCode"] integerValue]; - NSDictionary* requestHeaders = @{}; - if([networkData[@"requestHeaders"] isKindOfClass:[NSDictionary class]]){ - requestHeaders = networkData[@"requestHeaders"]; - } - NSDictionary* responseHeaders = @{}; - if([networkData[@"responseHeaders"] isKindOfClass:[NSDictionary class]]){ - responseHeaders = networkData[@"responseHeaders"]; - } - NSString* contentType = networkData[@"contentType"]; - NSString* errorDomain = networkData[@"errorDomain"]; - int32_t errorCode = [networkData[@"errorCode"] integerValue]; - int64_t startTime = [networkData[@"startTime"] integerValue] * 1000; - int64_t duration = [networkData[@"duration"] doubleValue] * 1000; - - NSString* gqlQueryName = nil; - NSString* serverErrorMessage = nil; - if (networkData[@"gqlQueryName"] != [NSNull null]) { - gqlQueryName = networkData[@"gqlQueryName"]; - } - if (networkData[@"serverErrorMessage"] != [NSNull null]) { - serverErrorMessage = networkData[@"serverErrorMessage"]; - } - - SEL networkLogSEL = NSSelectorFromString(@"addNetworkLogWithUrl:method:requestBody:requestBodySize:responseBody:responseBodySize:responseCode:requestHeaders:responseHeaders:contentType:errorDomain:errorCode:startTime:duration:gqlQueryName:serverErrorMessage:"); - - if([[IBGNetworkLogger class] respondsToSelector:networkLogSEL]) { - NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[IBGNetworkLogger class] methodSignatureForSelector:networkLogSEL]]; - [inv setSelector:networkLogSEL]; - [inv setTarget:[IBGNetworkLogger class]]; - - [inv setArgument:&(url) atIndex:2]; - [inv setArgument:&(method) atIndex:3]; - [inv setArgument:&(requestBody) atIndex:4]; - [inv setArgument:&(requestBodySize) atIndex:5]; - [inv setArgument:&(responseBody) atIndex:6]; - [inv setArgument:&(responseBodySize) atIndex:7]; - [inv setArgument:&(responseCode) atIndex:8]; - [inv setArgument:&(requestHeaders) atIndex:9]; - [inv setArgument:&(responseHeaders) atIndex:10]; - [inv setArgument:&(contentType) atIndex:11]; - [inv setArgument:&(errorDomain) atIndex:12]; - [inv setArgument:&(errorCode) atIndex:13]; - [inv setArgument:&(startTime) atIndex:14]; - [inv setArgument:&(duration) atIndex:15]; - [inv setArgument:&(gqlQueryName) atIndex:16]; - [inv setArgument:&(serverErrorMessage) atIndex:17]; - - [inv invoke]; - } +RCT_EXPORT_METHOD(networkLogIOS:(NSString * _Nonnull)url + method:(NSString * _Nonnull)method + requestBody:(NSString * _Nonnull)requestBody + requestBodySize:(double)requestBodySize + responseBody:(NSString * _Nonnull)responseBody + responseBodySize:(double)responseBodySize + responseCode:(double)responseCode + requestHeaders:(NSDictionary * _Nonnull)requestHeaders + responseHeaders:(NSDictionary * _Nonnull)responseHeaders + contentType:(NSString * _Nonnull)contentType + errorDomain:(NSString * _Nullable)errorDomain + errorCode:(double)errorCode + startTime:(double)startTime + duration:(double)duration + gqlQueryName:(NSString * _Nullable)gqlQueryName + serverErrorMessage:(NSString * _Nullable)serverErrorMessage) { + [IBGNetworkLogger addNetworkLogWithUrl:url + method:method + requestBody:requestBody + requestBodySize:requestBodySize + responseBody:responseBody + responseBodySize:responseBodySize + responseCode:responseCode + requestHeaders:requestHeaders + responseHeaders:responseHeaders + contentType:contentType + errorDomain:errorDomain + errorCode:errorCode + startTime:startTime * 1000 + duration:duration * 1000 + gqlQueryName:gqlQueryName + serverErrorMessage:serverErrorMessage]; } RCT_EXPORT_METHOD(addPrivateView: (nonnull NSNumber *)reactTag) { diff --git a/ios/RNInstabug/Util/IBGNetworkLogger+CP.h b/ios/RNInstabug/Util/IBGNetworkLogger+CP.h index ae5d32d669..5ae464785f 100644 --- a/ios/RNInstabug/Util/IBGNetworkLogger+CP.h +++ b/ios/RNInstabug/Util/IBGNetworkLogger+CP.h @@ -5,6 +5,22 @@ NS_ASSUME_NONNULL_BEGIN @interface IBGNetworkLogger (CP) + (void)disableAutomaticCapturingOfNetworkLogs; ++ (void)addNetworkLogWithUrl:(NSString *)url + method:(NSString *)method + requestBody:(NSString *)request + requestBodySize:(int64_t)requestBodySize + responseBody:(NSString *)response + responseBodySize:(int64_t)responseBodySize + responseCode:(int32_t)code + requestHeaders:(NSDictionary *)requestHeaders + responseHeaders:(NSDictionary *)responseHeaders + contentType:(NSString *)contentType + errorDomain:(NSString *)errorDomain + errorCode:(int32_t)errorCode + startTime:(int64_t)startTime + duration:(int64_t) duration + gqlQueryName:(NSString * _Nullable)gqlQueryName + serverErrorMessage:(NSString * _Nullable)serverErrorMessage; @end diff --git a/src/modules/NetworkLogger.ts b/src/modules/NetworkLogger.ts index 8e102e3ab3..67f3a54ccf 100644 --- a/src/modules/NetworkLogger.ts +++ b/src/modules/NetworkLogger.ts @@ -1,11 +1,8 @@ -import { Platform } from 'react-native'; - import type { RequestHandler } from '@apollo/client'; -import { NativeAPM } from '../native/NativeAPM'; -import { NativeInstabug } from '../native/NativeInstabug'; import InstabugConstants from '../utils/InstabugConstants'; import xhr, { NetworkData, ProgressCallback } from '../utils/XhrNetworkInterceptor'; +import { reportNetworkLog, isContentTypeNotAllowed } from '../utils/InstabugUtils'; export type { NetworkData }; @@ -30,12 +27,31 @@ export const setEnabled = (isEnabled: boolean) => { network = await _networkDataObfuscationHandler(network); } - if (Platform.OS === 'android') { - NativeInstabug.networkLog(JSON.stringify(network)); - NativeAPM.networkLog(JSON.stringify(network)); - } else { - NativeInstabug.networkLog(network); + if (network.requestBodySize > InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES) { + network.requestBody = InstabugConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE; + console.warn('IBG-RN:', InstabugConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE); + } + + if (network.responseBodySize > InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES) { + network.responseBody = InstabugConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE; + console.warn('IBG-RN:', InstabugConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE); + } + + if (network.requestBody && isContentTypeNotAllowed(network.requestContentType)) { + network.requestBody = `Body is omitted because content type ${network.requestContentType} isn't supported`; + console.warn( + `IBG-RN: The request body for the network request with URL ${network.url} has been omitted because the content type ${network.requestContentType} isn't supported.`, + ); + } + + if (network.responseBody && isContentTypeNotAllowed(network.contentType)) { + network.responseBody = `Body is omitted because content type ${network.contentType} isn't supported`; + console.warn( + `IBG-RN: The response body for the network request with URL ${network.url} has been omitted because the content type ${network.contentType} isn't supported.`, + ); } + + reportNetworkLog(network); } catch (e) { console.error(e); } diff --git a/src/native/NativeAPM.ts b/src/native/NativeAPM.ts index 2c2121587c..b1981cfe37 100644 --- a/src/native/NativeAPM.ts +++ b/src/native/NativeAPM.ts @@ -7,7 +7,24 @@ export interface ApmNativeModule extends NativeModule { setEnabled(isEnabled: boolean): void; // Network APIs // - networkLog(data: string): void; + networkLogAndroid( + requestStartTime: number, + requestDuration: number, + requestHeaders: string, + requestBody: string, + requestBodySize: number, + requestMethod: string, + requestUrl: string, + requestContentType: string, + responseHeaders: string, + responseBody: string | null, + responseBodySize: number, + statusCode: number, + responseContentType: string, + errorDomain: string, + gqlQueryName?: string, + serverErrorMessage?: string, + ): void; // App Launches APIs // setAppLaunchEnabled(isEnabled: boolean): void; diff --git a/src/native/NativeInstabug.ts b/src/native/NativeInstabug.ts index 3ff68de26b..3990da4c8b 100644 --- a/src/native/NativeInstabug.ts +++ b/src/native/NativeInstabug.ts @@ -10,7 +10,6 @@ import type { StringKey, WelcomeMessageMode, } from '../utils/Enums'; -import type { NetworkData } from '../utils/XhrNetworkInterceptor'; import type { NativeConstants } from './NativeConstants'; import { NativeModules } from './NativePackage'; @@ -40,7 +39,36 @@ export interface InstabugNativeModule extends NativeModule { setString(string: string, key: StringKey): void; // Network APIs // - networkLog(network: NetworkData | string): void; + networkLogAndroid( + url: string, + requestBody: string, + responseBody: string | null, + method: string, + responseCode: number, + requestHeaders: string, + responseHeaders: string, + duration: number, + ): void; + + networkLogIOS( + url: string, + method: string, + requestBody: string | null, + requestBodySize: number, + responseBody: string | null, + responseBodySize: number, + responseCode: number, + requestHeaders: Record, + responseHeaders: Record, + contentType: string, + errorDomain: string, + errorCode: number, + startTime: number, + duration: number, + gqlQueryName: string | undefined, + serverErrorMessage: string | undefined, + ): void; + setNetworkLoggingEnabled(isEnabled: boolean): void; // Repro Steps APIs // diff --git a/src/utils/InstabugConstants.ts b/src/utils/InstabugConstants.ts index c7b4988771..59bdb2324f 100644 --- a/src/utils/InstabugConstants.ts +++ b/src/utils/InstabugConstants.ts @@ -1,5 +1,12 @@ -enum InstabugConstants { - GRAPHQL_HEADER = 'ibg-graphql-header', -} +const InstabugConstants = { + GRAPHQL_HEADER: 'ibg-graphql-header', + + // TODO: dyanmically get the max size from the native SDK and update the error message to reflect the dynamic size. + MAX_NETWORK_BODY_SIZE_IN_BYTES: 1024 * 10, // 10 KB + MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE: + 'The response body has not been logged because it exceeds the maximum size of 10 Kb', + MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE: + 'The request body has not been logged because it exceeds the maximum size of 10 Kb', +}; export default InstabugConstants; diff --git a/src/utils/InstabugUtils.ts b/src/utils/InstabugUtils.ts index 6a8dfb7405..d4238f14f0 100644 --- a/src/utils/InstabugUtils.ts +++ b/src/utils/InstabugUtils.ts @@ -8,7 +8,10 @@ import type { NavigationState as NavigationStateV5, PartialState } from '@react- import type { NavigationState as NavigationStateV4 } from 'react-navigation'; import type { CrashData } from '../native/NativeCrashReporting'; +import type { NetworkData } from './XhrNetworkInterceptor'; import { NativeCrashReporting } from '../native/NativeCrashReporting'; +import { NativeInstabug } from '../native/NativeInstabug'; +import { NativeAPM } from '../native/NativeAPM'; export const parseErrorStack = (error: ExtendedError): StackFrame[] => { return parseErrorStackLib(error); @@ -124,6 +127,75 @@ export async function sendCrashReport( return remoteSenderCallback(jsonObject); } +export function isContentTypeNotAllowed(contentType: string) { + const allowed = [ + 'application/protobuf', + 'application/json', + 'application/xml', + 'text/xml', + 'text/html', + 'text/plain', + ]; + + return allowed.every((type) => !contentType.includes(type)); +} + +export function reportNetworkLog(network: NetworkData) { + if (Platform.OS === 'android') { + const requestHeaders = JSON.stringify(network.requestHeaders); + const responseHeaders = JSON.stringify(network.responseHeaders); + + NativeInstabug.networkLogAndroid( + network.url, + network.requestBody, + network.responseBody, + network.method, + network.responseCode, + requestHeaders, + responseHeaders, + network.duration, + ); + + NativeAPM.networkLogAndroid( + network.startTime, + network.duration, + requestHeaders, + network.requestBody, + network.requestBodySize, + network.method, + network.url, + network.requestContentType, + responseHeaders, + network.responseBody, + network.responseBodySize, + network.responseCode, + network.contentType, + network.errorDomain, + network.gqlQueryName, + network.serverErrorMessage, + ); + } else { + NativeInstabug.networkLogIOS( + network.url, + network.method, + network.requestBody, + network.requestBodySize, + network.responseBody, + network.responseBodySize, + network.responseCode, + network.requestHeaders, + network.responseHeaders, + network.contentType, + network.errorDomain, + network.errorCode, + network.startTime, + network.duration, + network.gqlQueryName, + network.serverErrorMessage, + ); + } +} + export default { parseErrorStack, captureJsErrors, diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index ad79f2d4fa..701533f15c 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -1,4 +1,5 @@ import InstabugConstants from './InstabugConstants'; +import { stringifyIfNotString } from './InstabugUtils'; export type ProgressCallback = (totalBytesSent: number, totalBytesExpectedToSend: number) => void; export type NetworkDataCallback = (data: NetworkData) => void; @@ -80,7 +81,12 @@ export default { }; XMLHttpRequest.prototype.setRequestHeader = function (header, value) { - network.requestHeaders[header] = typeof value === 'string' ? value : JSON.stringify(value); + // According to the HTTP RFC, headers are case-insensitive, so we convert + // them to lower-case to make accessing headers predictable. + // This avoid issues like failing to get the Content-Type header for a request + // because the header is set as 'Content-Type' instead of 'content-type'. + const key = header.toLowerCase(); + network.requestHeaders[key] = stringifyIfNotString(value); originalXHRSetRequestHeader.apply(this, [header, value]); }; diff --git a/test/mocks/mockAPM.ts b/test/mocks/mockAPM.ts index ca9dd297de..27644c694a 100644 --- a/test/mocks/mockAPM.ts +++ b/test/mocks/mockAPM.ts @@ -16,7 +16,7 @@ const mockAPM: ApmNativeModule = { endUITrace: jest.fn(), endAppLaunch: jest.fn(), ibgSleep: jest.fn(), - networkLog: jest.fn(), + networkLogAndroid: jest.fn(), }; export default mockAPM; diff --git a/test/mocks/mockInstabug.ts b/test/mocks/mockInstabug.ts index bb69eda517..c2dac12b5a 100644 --- a/test/mocks/mockInstabug.ts +++ b/test/mocks/mockInstabug.ts @@ -52,7 +52,8 @@ const mockInstabug: InstabugNativeModule = { addExperiments: jest.fn(), removeExperiments: jest.fn(), clearAllExperiments: jest.fn(), - networkLog: jest.fn(), + networkLogIOS: jest.fn(), + networkLogAndroid: jest.fn(), appendTagToReport: jest.fn(), appendConsoleLogToReport: jest.fn(), setUserAttributeToReport: jest.fn(), diff --git a/test/mocks/mockInstabugUtils.ts b/test/mocks/mockInstabugUtils.ts index 335dd5c016..7d58be394e 100644 --- a/test/mocks/mockInstabugUtils.ts +++ b/test/mocks/mockInstabugUtils.ts @@ -10,5 +10,7 @@ jest.mock('../../src/utils/InstabugUtils', () => { sendCrashReport: jest.fn(), getStackTrace: jest.fn().mockReturnValue('javascriptStackTrace'), getFullRoute: jest.fn().mockImplementation(() => 'ScreenName'), + reportNetworkLog: jest.fn(), + isContentTypeNotAllowed: jest.fn(), }; }); diff --git a/test/modules/NetworkLogger.spec.ts b/test/modules/NetworkLogger.spec.ts index de121c636e..71dd2dd778 100644 --- a/test/modules/NetworkLogger.spec.ts +++ b/test/modules/NetworkLogger.spec.ts @@ -1,34 +1,40 @@ import '../mocks/mockXhrNetworkInterceptor'; - -import { Platform } from 'react-native'; +import '../mocks/mockInstabugUtils'; import waitForExpect from 'wait-for-expect'; import * as NetworkLogger from '../../src/modules/NetworkLogger'; -import { NativeAPM } from '../../src/native/NativeAPM'; -import { NativeInstabug } from '../../src/native/NativeInstabug'; import Interceptor from '../../src/utils/XhrNetworkInterceptor'; +import { isContentTypeNotAllowed, reportNetworkLog } from '../../src/utils/InstabugUtils'; +import InstabugConstants from '../../src/utils/InstabugConstants'; -const clone = (obj: any) => { +const clone = (obj: T): T => { return JSON.parse(JSON.stringify(obj)); }; describe('NetworkLogger Module', () => { - const network = { + const network: NetworkLogger.NetworkData = { url: 'https://api.instabug.com', requestBody: '', - requestHeaders: { 'Content-type': 'application/json' }, + requestHeaders: { 'content-type': 'application/json' }, method: 'GET', responseBody: '', responseCode: 200, - responseHeaders: '', + responseHeaders: { 'content-type': 'application/json' }, contentType: 'application/json', duration: 0, + requestBodySize: 0, + responseBodySize: 0, + errorDomain: '', + errorCode: 0, + startTime: 0, + serverErrorMessage: '', + requestContentType: 'application/json', }; beforeEach(() => { - // @ts-ignore NetworkLogger.setNetworkDataObfuscationHandler(null); + NetworkLogger.setRequestFilterExpression('false'); }); it('should set onProgressCallback with callback', () => { @@ -52,52 +58,18 @@ describe('NetworkLogger Module', () => { expect(Interceptor.disableInterception).toBeCalledTimes(1); }); - it('should send log network when Platform is ios', () => { - Platform.OS = 'ios'; + it('should report the network log', () => { Interceptor.setOnDoneCallback = jest .fn() .mockImplementation((callback) => callback(clone(network))); - NetworkLogger.setEnabled(true); - expect(NativeInstabug.networkLog).toBeCalledTimes(1); - expect(NativeInstabug.networkLog).toBeCalledWith(network); - }); - - it('should send log network when Platform is android', () => { - Platform.OS = 'android'; - Interceptor.setOnDoneCallback = jest - .fn() - .mockImplementation((callback) => callback(clone(network))); NetworkLogger.setEnabled(true); - expect(NativeInstabug.networkLog).toBeCalledWith(JSON.stringify(network)); - expect(NativeAPM.networkLog).toBeCalledWith(JSON.stringify(network)); - }); - - it('should not break if it fails to stringify to JSON on network log if platform is android', () => { - Platform.OS = 'android'; - - // Avoid the console.error to clutter the test log - const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); - - // Make a circular object, this should make JSON.stringify fail - const networkResult = clone(network); - networkResult.responseBody = {}; - networkResult.responseBody.result = { body: networkResult.responseBody }; - - Interceptor.setOnDoneCallback = jest - .fn() - .mockImplementation((callback) => callback(networkResult)); - - expect(() => NetworkLogger.setEnabled(true)).not.toThrow(); - expect(NativeInstabug.networkLog).not.toBeCalled(); - expect(NativeAPM.networkLog).not.toBeCalled(); - - consoleSpy.mockRestore(); + expect(reportNetworkLog).toBeCalledTimes(1); + expect(reportNetworkLog).toBeCalledWith(network); }); - it('should send log network when setNetworkDataObfuscationHandler is set and Platform is ios', async () => { - Platform.OS = 'ios'; + it('should send log network when setNetworkDataObfuscationHandler is set', async () => { const randomString = '28930q938jqhd'; Interceptor.setOnDoneCallback = jest .fn() @@ -111,33 +83,11 @@ describe('NetworkLogger Module', () => { await waitForExpect(() => { const newData = clone(network); newData.requestHeaders.token = randomString; - expect(NativeInstabug.networkLog).toBeCalledWith(newData); + expect(reportNetworkLog).toBeCalledWith(newData); }); }); - it('should send log network when setNetworkDataObfuscationHandler is set and Platform is android', async () => { - Platform.OS = 'android'; - const randomString = '28930q938jqhd'; - Interceptor.setOnDoneCallback = jest - .fn() - .mockImplementation((callback) => callback(clone(network))); - NetworkLogger.setNetworkDataObfuscationHandler((networkData) => { - networkData.requestHeaders.token = randomString; - return Promise.resolve(networkData); - }); - NetworkLogger.setEnabled(true); - - await waitForExpect(() => { - const newData = clone(network); - newData.requestHeaders.token = randomString; - expect(NativeInstabug.networkLog).toBeCalledWith(JSON.stringify(newData)); - expect(NativeAPM.networkLog).toBeCalledWith(JSON.stringify(newData)); - }); - }); - - it('should not break if network data obfuscation fails when platform is android', async () => { - Platform.OS = 'android'; - + it('should not break if network data obfuscation fails', async () => { // Avoid the console.error to clutter the test log const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); @@ -152,8 +102,7 @@ describe('NetworkLogger Module', () => { NetworkLogger.setNetworkDataObfuscationHandler(handler); expect(() => NetworkLogger.setEnabled(true)).not.toThrow(); - expect(NativeInstabug.networkLog).not.toBeCalled(); - expect(NativeAPM.networkLog).not.toBeCalled(); + expect(reportNetworkLog).not.toBeCalled(); consoleSpy.mockRestore(); }); @@ -164,12 +113,11 @@ describe('NetworkLogger Module', () => { .mockImplementation((callback) => callback(clone(network))); NetworkLogger.setRequestFilterExpression( - "network.requestHeaders['Content-type'] === 'application/json'", + "network.requestHeaders['content-type'] === 'application/json'", ); NetworkLogger.setEnabled(true); - expect(NativeInstabug.networkLog).not.toBeCalled(); - expect(NativeAPM.networkLog).not.toBeCalled(); + expect(reportNetworkLog).not.toBeCalled(); }); it('should test that operationSetContext at apollo handler called', async () => { @@ -200,4 +148,132 @@ describe('NetworkLogger Module', () => { consoleSpy.mockRestore(); }); + + it('should omit request body if its content type is not allowed', () => { + const consoleWarn = jest.spyOn(console, 'warn').mockImplementation(); + jest.mocked(isContentTypeNotAllowed).mockReturnValueOnce(true); + + const networkData = { + ...network, + requestBody: 'some request body', + }; + + Interceptor.setOnDoneCallback = jest + .fn() + .mockImplementation((callback) => callback(networkData)); + + NetworkLogger.setEnabled(true); + + expect(reportNetworkLog).toHaveBeenCalledWith({ + ...networkData, + requestBody: expect.stringContaining('omitted'), + }); + + expect(consoleWarn).toBeCalledTimes(1); + + consoleWarn.mockRestore(); + }); + + it('should omit response body if its content type is not allowed', () => { + const consoleWarn = jest.spyOn(console, 'warn').mockImplementation(); + jest.mocked(isContentTypeNotAllowed).mockReturnValueOnce(true); + + const networkData = { + ...network, + responseBody: 'some response body', + }; + + Interceptor.setOnDoneCallback = jest + .fn() + .mockImplementation((callback) => callback(networkData)); + + NetworkLogger.setEnabled(true); + + expect(reportNetworkLog).toHaveBeenCalledWith({ + ...networkData, + responseBody: expect.stringContaining('omitted'), + }); + + expect(consoleWarn).toBeCalledTimes(1); + + consoleWarn.mockRestore(); + }); + + it('should omit request body if its size exceeds the maximum allowed size', () => { + const consoleWarn = jest.spyOn(console, 'warn').mockImplementation(); + + const networkData = { + ...network, + requestBodySize: InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES + 1, + }; + + Interceptor.setOnDoneCallback = jest + .fn() + .mockImplementation((callback) => callback(networkData)); + + NetworkLogger.setEnabled(true); + + expect(reportNetworkLog).toHaveBeenCalledWith({ + ...networkData, + requestBody: InstabugConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE, + }); + + expect(consoleWarn).toBeCalledTimes(1); + + consoleWarn.mockRestore(); + }); + + it('should not omit request body if its size does not exceed the maximum allowed size', () => { + const networkData = { + ...network, + requestBodySize: InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES, + }; + + Interceptor.setOnDoneCallback = jest + .fn() + .mockImplementation((callback) => callback(networkData)); + + NetworkLogger.setEnabled(true); + + expect(reportNetworkLog).toHaveBeenCalledWith(networkData); + }); + + it('should omit response body if its size exceeds the maximum allowed size', () => { + const consoleWarn = jest.spyOn(console, 'warn').mockImplementation(); + + const networkData = { + ...network, + responseBodySize: InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES + 1, + }; + + Interceptor.setOnDoneCallback = jest + .fn() + .mockImplementation((callback) => callback(networkData)); + + NetworkLogger.setEnabled(true); + + expect(reportNetworkLog).toHaveBeenCalledWith({ + ...networkData, + responseBody: InstabugConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE, + }); + + expect(consoleWarn).toBeCalledTimes(1); + + consoleWarn.mockRestore(); + }); + + it('should not omit response body if its size does not exceed the maximum allowed size', () => { + const networkData = { + ...network, + responseBodySize: InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES, + }; + + Interceptor.setOnDoneCallback = jest + .fn() + .mockImplementation((callback) => callback(networkData)); + + NetworkLogger.setEnabled(true); + + expect(reportNetworkLog).toHaveBeenCalledWith(networkData); + }); }); diff --git a/test/utils/InstabugUtils.spec.ts b/test/utils/InstabugUtils.spec.ts index 9ecb2332a2..becfccc0e9 100644 --- a/test/utils/InstabugUtils.spec.ts +++ b/test/utils/InstabugUtils.spec.ts @@ -5,8 +5,14 @@ import parseErrorStackLib from 'react-native/Libraries/Core/Devtools/parseErrorS import * as Instabug from '../../src/modules/Instabug'; import { NativeCrashReporting } from '../../src/native/NativeCrashReporting'; -import { InvocationEvent, NonFatalErrorLevel } from '../../src'; -import InstabugUtils, { getStackTrace, sendCrashReport } from '../../src/utils/InstabugUtils'; +import { InvocationEvent, NetworkData, NonFatalErrorLevel } from '../../src'; +import InstabugUtils, { + getStackTrace, + reportNetworkLog, + sendCrashReport, +} from '../../src/utils/InstabugUtils'; +import { NativeInstabug } from '../../src/native/NativeInstabug'; +import { NativeAPM } from '../../src/native/NativeAPM'; describe('Test global error handler', () => { beforeEach(() => { @@ -233,3 +239,91 @@ describe('Instabug Utils', () => { ); }); }); + +describe('reportNetworkLog', () => { + const network: NetworkData = { + url: 'https://api.instabug.com', + method: 'GET', + requestBody: 'requestBody', + requestHeaders: { request: 'header' }, + responseBody: 'responseBody', + responseCode: 200, + responseHeaders: { response: 'header' }, + contentType: 'application/json', + startTime: 1, + duration: 2, + requestBodySize: 3, + responseBodySize: 4, + errorCode: 5, + errorDomain: 'errorDomain', + serverErrorMessage: 'serverErrorMessage', + requestContentType: 'requestContentType', + }; + + it('reportNetworkLog should send network logs to native with the correct parameters on Android', () => { + Platform.OS = 'android'; + + const requestHeaders = JSON.stringify(network.requestHeaders); + const responseHeaders = JSON.stringify(network.responseHeaders); + + reportNetworkLog(network); + + expect(NativeInstabug.networkLogAndroid).toHaveBeenCalledTimes(1); + expect(NativeInstabug.networkLogAndroid).toHaveBeenCalledWith( + network.url, + network.requestBody, + network.responseBody, + network.method, + network.responseCode, + requestHeaders, + responseHeaders, + network.duration, + ); + + expect(NativeAPM.networkLogAndroid).toHaveBeenCalledTimes(1); + expect(NativeAPM.networkLogAndroid).toHaveBeenCalledWith( + network.startTime, + network.duration, + requestHeaders, + network.requestBody, + network.requestBodySize, + network.method, + network.url, + network.requestContentType, + responseHeaders, + network.responseBody, + network.responseBodySize, + network.responseCode, + network.contentType, + network.errorDomain, + network.gqlQueryName, + network.serverErrorMessage, + ); + }); + + it('reportNetworkLog should send network logs to native with the correct parameters on iOS', () => { + Platform.OS = 'ios'; + + reportNetworkLog(network); + + expect(NativeInstabug.networkLogIOS).toHaveBeenCalledTimes(1); + expect(NativeInstabug.networkLogIOS).toHaveBeenCalledWith( + network.url, + network.method, + network.requestBody, + network.requestBodySize, + network.responseBody, + network.responseBodySize, + network.responseCode, + network.requestHeaders, + network.responseHeaders, + network.contentType, + network.errorDomain, + network.errorCode, + network.startTime, + network.duration, + network.gqlQueryName, + network.serverErrorMessage, + ); + }); +}); From 635cd479e555c059c7f150f373a026c2f23a3adc Mon Sep 17 00:00:00 2001 From: kholood Date: Tue, 23 Jul 2024 10:15:55 +0300 Subject: [PATCH 03/40] fix(android): APM network logging(#1253) * fix(android): add W3C External Trace Attributes placeholder * chore: add CHANGLOG * chore: add CHANGLOG * fix: remove ios sub module --- CHANGELOG.md | 1 + .../reactlibrary/RNInstabugAPMModule.java | 42 ++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ec9aad5b6..4221fa8a26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixed +- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). - Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)). ## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java index 7ffaf4de73..70487f8cc5 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java @@ -14,6 +14,7 @@ import com.instabug.apm.APM; import com.instabug.apm.model.ExecutionTrace; import com.instabug.apm.networking.APMNetworkLogger; +import com.instabug.apm.networkinterception.cp.APMCPNetworkLog; import com.instabug.reactlibrary.utils.MainThreadHandler; import org.json.JSONException; @@ -338,27 +339,28 @@ private void networkLogAndroid(final double requestStartTime, final String errorMessage = hasError ? errorDomain : null; try { - Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class); + Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class, APMCPNetworkLog.W3CExternalTraceAttributes.class); if (method != null) { - method.invoke( - networkLogger, - requestStartTime, - requestDuration, - requestHeaders, - requestBody, - requestBodySize, - requestMethod, - requestUrl, - requestContentType, - responseHeaders, - responseBody, - responseBodySize, - statusCode, - responseContentType, - errorMessage, - gqlQueryName, - serverErrorMessage - ); + method.invoke( + networkLogger, + (long) requestStartTime, + (long) requestDuration, + requestHeaders, + requestBody, + (long) requestBodySize, + requestMethod, + requestUrl, + requestContentType, + responseHeaders, + responseBody, + (long)responseBodySize, + (int) statusCode, + responseContentType, + errorMessage, + gqlQueryName, + serverErrorMessage, + null + ); } else { Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection"); } From 61e1f3f1b710fd4c3a529c5514b865ab89125cc8 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Wed, 24 Jul 2024 15:21:26 +0300 Subject: [PATCH 04/40] feat/support-capture-client-error-in-xhr-requests --- CHANGELOG.md | 4 ++++ src/utils/XhrNetworkInterceptor.ts | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4221fa8a26..5ced6ab28f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ - Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). - Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)). +### Added + +- Add support for capturing client error message in network interceptor([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). + ## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024) ### Changed diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index 701533f15c..b25e64d615 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -148,11 +148,27 @@ export default { cloneNetwork.errorCode = 0; cloneNetwork.errorDomain = 'ClientError'; + // detect error message when the make xhr requests like using axios + // @ts-ignore + if (this._response != null && this._response.toString().length > 0) { + if (typeof this.response === 'string' || this.response instanceof String) { + // @ts-ignore + cloneNetwork.errorDomain = this._response; + } else { + // @ts-ignore + cloneNetwork.errorDomain = JSON.stringify(this._response); + } + } // @ts-ignore const _response = this._response; cloneNetwork.requestBody = typeof _response === 'string' ? _response : JSON.stringify(_response); cloneNetwork.responseBody = null; + + // @ts-ignore + } else if (this._timedOut) { + cloneNetwork.errorCode = 0; + cloneNetwork.errorDomain = 'TimeOutError'; } if (this.response) { From 50bc3be71b42bf37482907e2763376646db6b94e Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Wed, 24 Jul 2024 15:21:26 +0300 Subject: [PATCH 05/40] feat/support-capture-client-error-in-xhr-requests --- src/utils/XhrNetworkInterceptor.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index b25e64d615..10358157fd 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -160,12 +160,6 @@ export default { } } // @ts-ignore - const _response = this._response; - cloneNetwork.requestBody = - typeof _response === 'string' ? _response : JSON.stringify(_response); - cloneNetwork.responseBody = null; - - // @ts-ignore } else if (this._timedOut) { cloneNetwork.errorCode = 0; cloneNetwork.errorDomain = 'TimeOutError'; From 9b23d7afa5377f3c181ded7a5f4c5d2a764646ed Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Mon, 29 Jul 2024 04:38:09 +0300 Subject: [PATCH 06/40] fix: Pr comments --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ced6ab28f..557682d719 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ### Added -- Add support for capturing client error message in network interceptor([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). +- Enhance the network interceptor to capture some client error messages([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). ## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024) From 99ce7c82ddf0650ba99fe4ea67a543def3b8d824 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Mon, 29 Jul 2024 18:28:06 +0300 Subject: [PATCH 07/40] fix: Pr comments --- CHANGELOG.md | 2 +- src/utils/XhrNetworkInterceptor.ts | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 557682d719..6e5943343e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ### Added -- Enhance the network interceptor to capture some client error messages([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). +- Enhance the network interceptor to capture some client error messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). ## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024) diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index 10358157fd..dab64ec78c 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -151,13 +151,8 @@ export default { // detect error message when the make xhr requests like using axios // @ts-ignore if (this._response != null && this._response.toString().length > 0) { - if (typeof this.response === 'string' || this.response instanceof String) { - // @ts-ignore - cloneNetwork.errorDomain = this._response; - } else { - // @ts-ignore - cloneNetwork.errorDomain = JSON.stringify(this._response); - } + // @ts-ignore + cloneNetwork.errorDomain = stringifyIfNotString(this._response); } // @ts-ignore } else if (this._timedOut) { From d8d43eb809a12a43bfd310fa23bf37714055dd0d Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Tue, 30 Jul 2024 11:46:56 +0300 Subject: [PATCH 08/40] fix: Pr comments --- src/utils/XhrNetworkInterceptor.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index dab64ec78c..67c43e567b 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -148,12 +148,15 @@ export default { cloneNetwork.errorCode = 0; cloneNetwork.errorDomain = 'ClientError'; - // detect error message when the make xhr requests like using axios // @ts-ignore - if (this._response != null && this._response.toString().length > 0) { - // @ts-ignore - cloneNetwork.errorDomain = stringifyIfNotString(this._response); + const _response = this._response; + if (_response != null && _response.toString().length > 0) { + cloneNetwork.errorDomain = stringifyIfNotString(_response); } + cloneNetwork.requestBody = + typeof _response === 'string' ? _response : JSON.stringify(_response); + cloneNetwork.responseBody = null; + // @ts-ignore } else if (this._timedOut) { cloneNetwork.errorCode = 0; From 5864aac52c3ac87ef34edb750dd3e4467f4acca5 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Tue, 30 Jul 2024 19:35:19 +0300 Subject: [PATCH 09/40] fix: Pr comments --- src/utils/XhrNetworkInterceptor.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index 67c43e567b..6d1a6506cb 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -150,12 +150,10 @@ export default { // @ts-ignore const _response = this._response; + // detect error message when the make xhr requests like using axios if (_response != null && _response.toString().length > 0) { - cloneNetwork.errorDomain = stringifyIfNotString(_response); + cloneNetwork.errorDomain = typeof _response === 'string' ? _response : ''; } - cloneNetwork.requestBody = - typeof _response === 'string' ? _response : JSON.stringify(_response); - cloneNetwork.responseBody = null; // @ts-ignore } else if (this._timedOut) { @@ -170,6 +168,9 @@ export default { } else if (['text', '', 'json'].includes(this.responseType)) { cloneNetwork.responseBody = JSON.stringify(this.response); } + } else { + cloneNetwork.responseBody = ''; + cloneNetwork.contentType = 'text/plain'; } cloneNetwork.requestBodySize = cloneNetwork.requestBody.length; From faa33ed515621d64259267006367aec315808c54 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Wed, 31 Jul 2024 13:15:48 +0300 Subject: [PATCH 10/40] fix: Pr comments --- src/utils/XhrNetworkInterceptor.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index 6d1a6506cb..283c036d2f 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -150,9 +150,9 @@ export default { // @ts-ignore const _response = this._response; - // detect error message when the make xhr requests like using axios - if (_response != null && _response.toString().length > 0) { - cloneNetwork.errorDomain = typeof _response === 'string' ? _response : ''; + // Detect a more descriptive error message. + if (typeof _response === 'string' && _response.length > 0) { + cloneNetwork.errorDomain = _response; } // @ts-ignore From d00c708bf08d6364c17a20b06ea7f35328cc71c9 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Wed, 31 Jul 2024 15:58:18 +0300 Subject: [PATCH 11/40] fix: Pr comments --- test/utils/XhrNetworkInterceptor.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/XhrNetworkInterceptor.spec.ts b/test/utils/XhrNetworkInterceptor.spec.ts index b014bc9d9c..7ec818278f 100644 --- a/test/utils/XhrNetworkInterceptor.spec.ts +++ b/test/utils/XhrNetworkInterceptor.spec.ts @@ -236,7 +236,7 @@ describe('Network Interceptor', () => { expect.objectContaining({ errorDomain: 'ClientError', errorCode: 0, - responseBody: null, + responseBody: '', }), ); }); From a53508c5daefa476ed4db3f8f5d1f3c2dda10c99 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Wed, 31 Jul 2024 16:45:53 +0300 Subject: [PATCH 12/40] fix: Pr comments --- CHANGELOG.md | 308 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 212 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e5943343e..cf1c8eb0fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,113 +2,143 @@ ## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...dev) -### Fixed +### Added -- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). -- Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)). +- Enhance the network interceptor to capture some client error + messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). +- -### Added +### Fixed -- Enhance the network interceptor to capture some client error messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). +- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). +- Fix an OOM (out-of-memory) crash while saving network logs on + Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)). ## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024) ### Changed -- Bump Instabug Android SDK to v13.2.0 ([#1245](https://github.com/Instabug/Instabug-React-Native/pull/1245)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.2.0). -- Bump Instabug iOS SDK to v13.2.0 ([#1246](https://github.com/Instabug/Instabug-React-Native/pull/1246)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.2.0). +- Bump Instabug Android SDK to + v13.2.0 ([#1245](https://github.com/Instabug/Instabug-React-Native/pull/1245)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.2.0). +- Bump Instabug iOS SDK to + v13.2.0 ([#1246](https://github.com/Instabug/Instabug-React-Native/pull/1246)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.2.0). ### Fixed -- Change parameters used inside inner classes to `final` in Android code to maintain compatibility with Java 7 and earlier ([#1239](https://github.com/Instabug/Instabug-React-Native/pull/1239)). +- Change parameters used inside inner classes to `final` in Android code to maintain compatibility with Java 7 and + earlier ([#1239](https://github.com/Instabug/Instabug-React-Native/pull/1239)). ## [13.1.1](https://github.com/Instabug/Instabug-React-Native/compare/v13.0.5...v13.1.1) (June 6, 2024) ### Added -- Add support for passing a grouping fingerprint, error level, and user attributes to the `CrashReporting.reportError` non-fatals API ([#1194](https://github.com/Instabug/Instabug-React-Native/pull/1194)). +- Add support for passing a grouping fingerprint, error level, and user attributes to the `CrashReporting.reportError` + non-fatals API ([#1194](https://github.com/Instabug/Instabug-React-Native/pull/1194)). ### Changed -- Bump Instabug iOS SDK to v13.1.0 ([#1227](https://github.com/Instabug/Instabug-React-Native/pull/1227)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.1.0). -- Bump Instabug android SDK to v13.1.1 ([#1228](https://github.com/Instabug/Instabug-React-Native/pull/1228)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.1.0). +- Bump Instabug iOS SDK to + v13.1.0 ([#1227](https://github.com/Instabug/Instabug-React-Native/pull/1227)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.1.0). +- Bump Instabug android SDK to + v13.1.1 ([#1228](https://github.com/Instabug/Instabug-React-Native/pull/1228)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.1.0). ### Fixed -- Read `INSTABUG_APP_TOKEN` from system environment when there is no default value ([#1232](https://github.com/Instabug/Instabug-React-Native/pull/1232)). +- Read `INSTABUG_APP_TOKEN` from system environment when there is no default + value ([#1232](https://github.com/Instabug/Instabug-React-Native/pull/1232)). ## [13.0.5](https://github.com/Instabug/Instabug-React-Native/compare/v13.0.4...v13.0.5) (May 18, 2024) ### Changed -- Bump Instabug iOS SDK to v13.0.5 ([#1213](https://github.com/Instabug/Instabug-React-Native/pull/1213)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.5). +- Bump Instabug iOS SDK to + v13.0.5 ([#1213](https://github.com/Instabug/Instabug-React-Native/pull/1213)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.5). ## [13.0.4](https://github.com/Instabug/Instabug-React-Native/compare/v13.0.0...v13.0.4) (May 14, 2024) ### Changed -- Support reading environment variables from `ios/.xcode.env` and `ios/.xcode.env.local` files when present in the iOS source maps upload script ([#1200](https://github.com/Instabug/Instabug-React-Native/pull/1200)). -- Bump Instabug Android SDK to v13.0.3 ([#1206](https://github.com/Instabug/Instabug-React-Native/pull/1206)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.3). -- Bump Instabug iOS SDK to v13.0.3 ([#1208](https://github.com/Instabug/Instabug-React-Native/pull/1208)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.3). +- Support reading environment variables from `ios/.xcode.env` and `ios/.xcode.env.local` files when present in the iOS + source maps upload script ([#1200](https://github.com/Instabug/Instabug-React-Native/pull/1200)). +- Bump Instabug Android SDK to + v13.0.3 ([#1206](https://github.com/Instabug/Instabug-React-Native/pull/1206)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.3). +- Bump Instabug iOS SDK to + v13.0.3 ([#1208](https://github.com/Instabug/Instabug-React-Native/pull/1208)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.3). ## [13.0.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.9.0...v13.0.0) (April 19, 2024) ### Added -- Add `Instabug.willRedirectToStore` API for use in custom app rating prompts ([#1186](https://github.com/Instabug/Instabug-React-Native/pull/1186)). -- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). +- Add `Instabug.willRedirectToStore` API for use in custom app rating + prompts ([#1186](https://github.com/Instabug/Instabug-React-Native/pull/1186)). +- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and + `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). ### Changed -- Bump Instabug iOS SDK to v13.0.0 ([#1189](https://github.com/Instabug/Instabug-React-Native/pull/1189)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.0). -- Bump Instabug Android SDK to v13.0.0 ([#1188](https://github.com/Instabug/Instabug-React-Native/pull/1188)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.0). +- Bump Instabug iOS SDK to + v13.0.0 ([#1189](https://github.com/Instabug/Instabug-React-Native/pull/1189)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.0). +- Bump Instabug Android SDK to + v13.0.0 ([#1188](https://github.com/Instabug/Instabug-React-Native/pull/1188)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.0). ## [12.9.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.8.0...12.9.0)(April 2, 2024) ### Added - Adds symbol files upload script ([#1137](https://github.com/Instabug/Instabug-React-Native/pull/1137)) -- Support enabling NDK crash capturing on Android ([#1132](https://github.com/Instabug/Instabug-React-Native/pull/1132)). -- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). +- Support enabling NDK crash capturing on + Android ([#1132](https://github.com/Instabug/Instabug-React-Native/pull/1132)). +- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and + `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). ### Deprecated -- 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)). +- 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)). ### Deprecated -- 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)). +- 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)). ### Changed -- Bump Instabug Android SDK to v12.9.0 ([#1168](https://github.com/Instabug/Instabug-React-Native/pull/1168)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.9.0). -- Bump Instabug iOS SDK to v12.9.0 ([#1168](https://github.com/Instabug/Instabug-React-Native/pull/1168)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.9.0). +- Bump Instabug Android SDK to + v12.9.0 ([#1168](https://github.com/Instabug/Instabug-React-Native/pull/1168)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.9.0). +- Bump Instabug iOS SDK to + v12.9.0 ([#1168](https://github.com/Instabug/Instabug-React-Native/pull/1168)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.9.0). ### Fixed -- Remove the use of the nullish coalescing assignment operator (`??=`) causing a syntax error with older TypeScript versions ([#1166](https://github.com/Instabug/Instabug-React-Native/pull/1166)), closes [#1161 +- Remove the use of the nullish coalescing assignment operator (`??=`) causing a syntax error with older TypeScript + versions ([#1166](https://github.com/Instabug/Instabug-React-Native/pull/1166)), closes [#1161 ](https://github.com/Instabug/Instabug-React-Native/issues/1161). ## [12.8.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.1...v12.8.0) (February 25, 2024) ### Added -- Add `SessionReplay.getSessionReplayLink` API which retrieves the current session's replay link ([#1142](https://github.com/Instabug/Instabug-React-Native/pull/1142)). -- Support setting the Code Push version after SDK initialization ([#1143](https://github.com/Instabug/Instabug-React-Native/pull/1143)). +- Add `SessionReplay.getSessionReplayLink` API which retrieves the current session's replay + link ([#1142](https://github.com/Instabug/Instabug-React-Native/pull/1142)). +- Support setting the Code Push version after SDK + initialization ([#1143](https://github.com/Instabug/Instabug-React-Native/pull/1143)). ### Changed -- 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). +- 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). ### Deprecated -- 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)). +- 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)). ## [12.7.1](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.0...v12.7.1) (February 15, 2024) ### Changed -- Bump Instabug Android SDK to v12.7.1 ([#1134](https://github.com/Instabug/Instabug-React-Native/pull/1134)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.7.1). +- Bump Instabug Android SDK to + v12.7.1 ([#1134](https://github.com/Instabug/Instabug-React-Native/pull/1134)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.7.1). ## [12.7.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.6.0...v12.7.0) (February 10, 2024) @@ -119,19 +149,25 @@ ### Changed -- Bump Instabug iOS SDK to v12.7.0 ([#1125](https://github.com/Instabug/Instabug-React-Native/pull/1125)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.7.0). -- Bump Instabug Android SDK to v12.7.0 ([#1126](https://github.com/Instabug/Instabug-React-Native/pull/1126)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.7.0). +- Bump Instabug iOS SDK to + v12.7.0 ([#1125](https://github.com/Instabug/Instabug-React-Native/pull/1125)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.7.0). +- Bump Instabug Android SDK to + v12.7.0 ([#1126](https://github.com/Instabug/Instabug-React-Native/pull/1126)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.7.0). ### Fixed -- Fix an Android `NullPointerException` crash in private views APIs ([#1121](https://github.com/Instabug/Instabug-React-Native/pull/1121)), closes [#514](https://github.com/Instabug/Instabug-React-Native/issues/514). +- Fix an Android `NullPointerException` crash in private views + APIs ([#1121](https://github.com/Instabug/Instabug-React-Native/pull/1121)), + closes [#514](https://github.com/Instabug/Instabug-React-Native/issues/514). ## [12.6.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.5.0...v12.6.0) (January 14, 2024) ### Changed -- Bump Instabug iOS SDK to v12.6.0 ([#1095](https://github.com/Instabug/Instabug-React-Native/pull/1095)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.6.0). -- Bump Instabug Android SDK to v12.6.0 ([#1096](https://github.com/Instabug/Instabug-React-Native/pull/1096)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.6.0). +- Bump Instabug iOS SDK to + v12.6.0 ([#1095](https://github.com/Instabug/Instabug-React-Native/pull/1095)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.6.0). +- Bump Instabug Android SDK to + v12.6.0 ([#1096](https://github.com/Instabug/Instabug-React-Native/pull/1096)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.6.0). ### Added @@ -141,117 +177,180 @@ ### Changed -- Bump Instabug iOS SDK to v12.5.0 ([#1085](https://github.com/Instabug/Instabug-React-Native/pull/1085)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.5.0). -- Bump Instabug Android SDK to v12.5.1 ([#1088](https://github.com/Instabug/Instabug-React-Native/pull/1085)). See release notes for [v12.5.0](https://github.com/Instabug/android/releases/tag/v12.5.0) and [v12.5.1](https://github.com/Instabug/android/releases/tag/v12.5.1). +- Bump Instabug iOS SDK to + v12.5.0 ([#1085](https://github.com/Instabug/Instabug-React-Native/pull/1085)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.5.0). +- Bump Instabug Android SDK to v12.5.1 ([#1088](https://github.com/Instabug/Instabug-React-Native/pull/1085)). See + release notes for [v12.5.0](https://github.com/Instabug/android/releases/tag/v12.5.0) + and [v12.5.1](https://github.com/Instabug/android/releases/tag/v12.5.1). ### Fixed -- Fix a delay issue in reporting the 'Current View' that resulted in displaying outdated values ([#1080](https://github.com/Instabug/Instabug-React-Native/pull/1080)). +- Fix a delay issue in reporting the 'Current View' that resulted in displaying outdated + values ([#1080](https://github.com/Instabug/Instabug-React-Native/pull/1080)). ## [12.4.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.2.0...v12.4.0) (December 7, 2023) ### Changed -- Bump Instabug iOS SDK to v12.4.0 ([#1074](https://github.com/Instabug/Instabug-React-Native/pull/1074)). See release notes for [v12.3.0](https://github.com/instabug/instabug-ios/releases/tag/12.3.0) and [v12.4.0](https://github.com/instabug/instabug-ios/releases/tag/12.4.0). -- Bump Instabug Android SDK to v12.4.1 ([#1076](https://github.com/Instabug/Instabug-React-Native/pull/1076)). See release notes for [v12.3.0](https://github.com/Instabug/android/releases/tag/v12.3.0), [v12.3.1](https://github.com/Instabug/android/releases/tag/v12.3.1), [v12.4.0](https://github.com/Instabug/android/releases/tag/v12.4.0) and [v12.4.1](https://github.com/Instabug/android/releases/tag/v12.4.1). +- Bump Instabug iOS SDK to v12.4.0 ([#1074](https://github.com/Instabug/Instabug-React-Native/pull/1074)). See release + notes for [v12.3.0](https://github.com/instabug/instabug-ios/releases/tag/12.3.0) + and [v12.4.0](https://github.com/instabug/instabug-ios/releases/tag/12.4.0). +- Bump Instabug Android SDK to v12.4.1 ([#1076](https://github.com/Instabug/Instabug-React-Native/pull/1076)). See + release notes + for [v12.3.0](https://github.com/Instabug/android/releases/tag/v12.3.0), [v12.3.1](https://github.com/Instabug/android/releases/tag/v12.3.1), [v12.4.0](https://github.com/Instabug/android/releases/tag/v12.4.0) + and [v12.4.1](https://github.com/Instabug/android/releases/tag/v12.4.1). ### Fixed -- Fix an issue with `Instabug.init` on Android causing the app to crash while trying to get the current `Application` instance through the current activity which can be `null` in some cases by utilizing the React context instead ([#1069](https://github.com/Instabug/Instabug-React-Native/pull/1069)). -- Fix an issue with unhandled JavaScript crashes not getting linked with the current session causing inaccurate session metrics ([#1071](https://github.com/Instabug/Instabug-React-Native/pull/1071)). +- Fix an issue with `Instabug.init` on Android causing the app to crash while trying to get the current `Application` + instance through the current activity which can be `null` in some cases by utilizing the React context + instead ([#1069](https://github.com/Instabug/Instabug-React-Native/pull/1069)). +- Fix an issue with unhandled JavaScript crashes not getting linked with the current session causing inaccurate session + metrics ([#1071](https://github.com/Instabug/Instabug-React-Native/pull/1071)). ## [12.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.1.0...v12.2.0) (November 14, 2023) ### Added -- Add an iOS-side init API which allows capturing crashes that happen early in the app lifecycle and before the JavaScript code has started ([#1056](https://github.com/Instabug/Instabug-React-Native/pull/1056)). +- Add an iOS-side init API which allows capturing crashes that happen early in the app lifecycle and before the + JavaScript code has started ([#1056](https://github.com/Instabug/Instabug-React-Native/pull/1056)). ### Changed -- Bump Instabug iOS SDK to v12.2.0 ([#1053](https://github.com/Instabug/Instabug-React-Native/pull/1053)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.2.0). -- Bump Instabug Android SDK to v12.2.0 ([#1052](https://github.com/Instabug/Instabug-React-Native/pull/1052)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.2.0). +- Bump Instabug iOS SDK to + v12.2.0 ([#1053](https://github.com/Instabug/Instabug-React-Native/pull/1053)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.2.0). +- Bump Instabug Android SDK to + v12.2.0 ([#1052](https://github.com/Instabug/Instabug-React-Native/pull/1052)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.2.0). ### Fixed -- Fix an issue with Android Gradle Plugin namespace support required for React Native 0.73 and backward compatibility with previous versions ([#1044](https://github.com/Instabug/Instabug-React-Native/pull/1044)). -- Fix an issue with unhandled JavaScript crashes being reported as native iOS crashes ([#1054](https://github.com/Instabug/Instabug-React-Native/pull/1054)) -- Re-enable screenshot capturing for Crash Reporting and Session Replay by removing redundant mapping ([#1055](https://github.com/Instabug/Instabug-React-Native/pull/1055)). +- Fix an issue with Android Gradle Plugin namespace support required for React Native 0.73 and backward compatibility + with previous versions ([#1044](https://github.com/Instabug/Instabug-React-Native/pull/1044)). +- Fix an issue with unhandled JavaScript crashes being reported as native iOS + crashes ([#1054](https://github.com/Instabug/Instabug-React-Native/pull/1054)) +- Re-enable screenshot capturing for Crash Reporting and Session Replay by removing redundant + mapping ([#1055](https://github.com/Instabug/Instabug-React-Native/pull/1055)). ## [12.1.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.14.0...v12.1.0) (October 3, 2023) ### Added -- Add support for Session Replay, which includes capturing session details, visual reproduction of sessions as well as support for user steps, network and Instabug logs. ([#1034](https://github.com/Instabug/Instabug-React-Native/pull/1034)). +- Add support for Session Replay, which includes capturing session details, visual reproduction of sessions as well as + support for user steps, network and Instabug + logs. ([#1034](https://github.com/Instabug/Instabug-React-Native/pull/1034)). ### Changed -- **BREAKING** Remove deprecated APIs ([#1027](https://github.com/Instabug/Instabug-React-Native/pull/1027)). See migration guide for more details. -- Bump Instabug iOS SDK to v12.1.0 ([#1031](https://github.com/Instabug/Instabug-React-Native/pull/1031)). See release notes for [v12.0.0](https://github.com/instabug/instabug-ios/releases/tag/12.0.0) and [v12.1.0](https://github.com/instabug/instabug-ios/releases/tag/12.1.0). -- Bump Instabug Android SDK to v12.1.0 ([#1032](https://github.com/Instabug/Instabug-React-Native/pull/1032)). See release notes for [v12.0.0](https://github.com/Instabug/Instabug-Android/releases/tag/v12.0.0), [v12.0.1](https://github.com/Instabug/Instabug-Android/releases/tag/v12.0.1) and [v12.1.0](https://github.com/Instabug/Instabug-Android/releases/tag/v12.1.0). +- **BREAKING** Remove deprecated APIs ([#1027](https://github.com/Instabug/Instabug-React-Native/pull/1027)). See + migration guide for more details. +- Bump Instabug iOS SDK to v12.1.0 ([#1031](https://github.com/Instabug/Instabug-React-Native/pull/1031)). See release + notes for [v12.0.0](https://github.com/instabug/instabug-ios/releases/tag/12.0.0) + and [v12.1.0](https://github.com/instabug/instabug-ios/releases/tag/12.1.0). +- Bump Instabug Android SDK to v12.1.0 ([#1032](https://github.com/Instabug/Instabug-React-Native/pull/1032)). See + release notes + for [v12.0.0](https://github.com/Instabug/Instabug-Android/releases/tag/v12.0.0), [v12.0.1](https://github.com/Instabug/Instabug-Android/releases/tag/v12.0.1) + and [v12.1.0](https://github.com/Instabug/Instabug-Android/releases/tag/v12.1.0). ## [11.14.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.13.0...11.14.0) (September 15, 2023) ### Added -- Add support for automatic capturing of unhandled Promise rejection crashes ([#1014](https://github.com/Instabug/Instabug-React-Native/pull/1014)). -- Add new strings (`StringKey.discardAlertStay` and `StringKey.discardAlertDiscard`) for overriding the discard alert buttons for consistency between iOS and Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)). -- Add a new string (`StringKey.reproStepsListItemNumberingTitle`) for overriding the repro steps list item (screen) title for consistency between iOS and Android ([#1002](https://github.com/Instabug/Instabug-React-Native/pull/1002)). -- Add support for RN version 0.73 by updating the `build.gradle` file with the `namespace` ([#1004](https://github.com/Instabug/Instabug-React-Native/pull/1004)) -- Add native-side init API which can be used to catch and report startup crashes on android. ([#1012](https://github.com/Instabug/Instabug-React-Native/pull/1012)) -- Add the new repro steps configuration API `Instabug.setReproStepsConfig` ([#1024](https://github.com/Instabug/Instabug-React-Native/pull/1024)). +- Add support for automatic capturing of unhandled Promise rejection + crashes ([#1014](https://github.com/Instabug/Instabug-React-Native/pull/1014)). +- Add new strings (`StringKey.discardAlertStay` and `StringKey.discardAlertDiscard`) for overriding the discard alert + buttons for consistency between iOS and + Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)). +- Add a new string (`StringKey.reproStepsListItemNumberingTitle`) for overriding the repro steps list item (screen) + title for consistency between iOS and Android ([#1002](https://github.com/Instabug/Instabug-React-Native/pull/1002)). +- Add support for RN version 0.73 by updating the `build.gradle` file with the + `namespace` ([#1004](https://github.com/Instabug/Instabug-React-Native/pull/1004)) +- Add native-side init API which can be used to catch and report startup crashes on + android. ([#1012](https://github.com/Instabug/Instabug-React-Native/pull/1012)) +- Add the new repro steps configuration API + `Instabug.setReproStepsConfig` ([#1024](https://github.com/Instabug/Instabug-React-Native/pull/1024)). ### Changed -- Bump Instabug iOS SDK to v11.14.0 ([#1020](https://github.com/Instabug/Instabug-React-Native/pull/1020)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.14.0). -- Bump Instabug Android SDK to v11.14.0 ([#1019](https://github.com/Instabug/Instabug-React-Native/pull/1019)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.14.0). +- Bump Instabug iOS SDK to + v11.14.0 ([#1020](https://github.com/Instabug/Instabug-React-Native/pull/1020)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.14.0). +- Bump Instabug Android SDK to + v11.14.0 ([#1019](https://github.com/Instabug/Instabug-React-Native/pull/1019)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.14.0). ### Deprecated -- Deprecate the old `StringKey.discardAlertCancel` and `StringKey.discardAlertAction` string keys for overriding the discard alert buttons as they had inconsistent behavior between iOS and Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)). -- Deprecate the old `StringKey.reproStepsListItemTitle` string key for overriding the repro steps list item (screen) title as it had inconsistent behavior between iOS and Android ([#1002](https://github.com/Instabug/Instabug-React-Native/pull/1002)). -- Deprecate `Instabug.setReproStepsMode` in favor of the new `Instabug.setReproStepsConfig` ([#1024](https://github.com/Instabug/Instabug-React-Native/pull/1024)). -- Deprecate the old `StringKey.invalidCommentMessage` and `StringKey.invalidCommentTitle` in favor of `StringKey.insufficientContentMessage` and `StringKey.insufficientContentTitle` ([#1026](https://github.com/Instabug/Instabug-React-Native/pull/1026)). +- Deprecate the old `StringKey.discardAlertCancel` and `StringKey.discardAlertAction` string keys for overriding the + discard alert buttons as they had inconsistent behavior between iOS and + Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)). +- Deprecate the old `StringKey.reproStepsListItemTitle` string key for overriding the repro steps list item (screen) + title as it had inconsistent behavior between iOS and + Android ([#1002](https://github.com/Instabug/Instabug-React-Native/pull/1002)). +- Deprecate `Instabug.setReproStepsMode` in favor of the new + `Instabug.setReproStepsConfig` ([#1024](https://github.com/Instabug/Instabug-React-Native/pull/1024)). +- Deprecate the old `StringKey.invalidCommentMessage` and `StringKey.invalidCommentTitle` in favor of + `StringKey.insufficientContentMessage` and + `StringKey.insufficientContentTitle` ([#1026](https://github.com/Instabug/Instabug-React-Native/pull/1026)). ## [11.13.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.12.0...v11.13.0) (July 10, 2023) ### Changed -- Bump Instabug iOS SDK to v11.13.3 ([#997](https://github.com/Instabug/Instabug-React-Native/pull/997)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.13.3). -- Bump Instabug Android SDK to v11.13.0 ([#996](https://github.com/Instabug/Instabug-React-Native/pull/996)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.13.0). +- Bump Instabug iOS SDK to + v11.13.3 ([#997](https://github.com/Instabug/Instabug-React-Native/pull/997)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.13.3). +- Bump Instabug Android SDK to + v11.13.0 ([#996](https://github.com/Instabug/Instabug-React-Native/pull/996)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.13.0). ### Fixed -- Fix an issue with the Android sourcemaps upload Gradle task getting recreated when both `bundleReleaseJsAndAssets` and `createBundleReleaseJsAndAssets` tasks exist in the same Android project ([#991](https://github.com/Instabug/Instabug-React-Native/pull/991)), closes [#989](https://github.com/Instabug/Instabug-React-Native/issues/989). -- Fix an issue with JaCoCo gradle plugin replacing the `enabled` method with `required` prop to prevent gradle scripts breaking on version `0.72` ([#995](https://github.com/Instabug/Instabug-React-Native/pull/995)), closes [#994](https://github.com/Instabug/Instabug-React-Native/issues/994). +- Fix an issue with the Android sourcemaps upload Gradle task getting recreated when both `bundleReleaseJsAndAssets` and + `createBundleReleaseJsAndAssets` tasks exist in the same Android + project ([#991](https://github.com/Instabug/Instabug-React-Native/pull/991)), + closes [#989](https://github.com/Instabug/Instabug-React-Native/issues/989). +- Fix an issue with JaCoCo gradle plugin replacing the `enabled` method with `required` prop to prevent gradle scripts + breaking on version `0.72` ([#995](https://github.com/Instabug/Instabug-React-Native/pull/995)), + closes [#994](https://github.com/Instabug/Instabug-React-Native/issues/994). ## [11.12.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.10.0...11.12.0) (May 30, 2023) ### Changed -- Bump Instabug Android SDK to v11.12.0 ([#985](https://github.com/Instabug/Instabug-React-Native/pull/985)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.12.0). -- Bump Instabug iOS SDK to v11.12.0 ([#986](https://github.com/Instabug/Instabug-React-Native/pull/986)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.12.0). +- Bump Instabug Android SDK to + v11.12.0 ([#985](https://github.com/Instabug/Instabug-React-Native/pull/985)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.12.0). +- Bump Instabug iOS SDK to + v11.12.0 ([#986](https://github.com/Instabug/Instabug-React-Native/pull/986)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.12.0). ### Deprecated -- Deprecate `instabugUploadEnable` gradle property to disable Android sourcemaps auto upload in favor of `INSTABUG_SOURCEMAPS_UPLOAD_DISABLE` env variable ([#983](https://github.com/Instabug/Instabug-React-Native/pull/983)). +- Deprecate `instabugUploadEnable` gradle property to disable Android sourcemaps auto upload in favor of + `INSTABUG_SOURCEMAPS_UPLOAD_DISABLE` env + variable ([#983](https://github.com/Instabug/Instabug-React-Native/pull/983)). ### Fixed -- Fix an issue with unhandled JavaScript crashes being reported as native Android crashes ([#980](https://github.com/Instabug/Instabug-React-Native/pull/980)). -- Fix an issue with the Android sourcemaps upload script, causing the build to fail on older versions of Gradle ([#970](https://github.com/Instabug/Instabug-React-Native/pull/970)), closes [#969](https://github.com/Instabug/Instabug-React-Native/issues/969). -- Fix an issue with the Android sourcemaps upload script, causing the build to fail when using product flavors ([#975](https://github.com/Instabug/Instabug-React-Native/pull/975)), closes [#974](https://github.com/Instabug/Instabug-React-Native/issues/974). -- Fix an issue with the network interceptor reverting the user's changes to `XMLHttpRequest` after disabling network logging ([#984](https://github.com/Instabug/Instabug-React-Native/pull/984)), closes [#981](https://github.com/Instabug/Instabug-React-Native/issues/981). +- Fix an issue with unhandled JavaScript crashes being reported as native Android + crashes ([#980](https://github.com/Instabug/Instabug-React-Native/pull/980)). +- Fix an issue with the Android sourcemaps upload script, causing the build to fail on older versions of + Gradle ([#970](https://github.com/Instabug/Instabug-React-Native/pull/970)), + closes [#969](https://github.com/Instabug/Instabug-React-Native/issues/969). +- Fix an issue with the Android sourcemaps upload script, causing the build to fail when using product + flavors ([#975](https://github.com/Instabug/Instabug-React-Native/pull/975)), + closes [#974](https://github.com/Instabug/Instabug-React-Native/issues/974). +- Fix an issue with the network interceptor reverting the user's changes to `XMLHttpRequest` after disabling network + logging ([#984](https://github.com/Instabug/Instabug-React-Native/pull/984)), + closes [#981](https://github.com/Instabug/Instabug-React-Native/issues/981). ## [11.10.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.9.1...11.10.0) (April 20, 2023) ### Added -- Add support for Android automatic source map file upload on Windows; this requires setting the `INSTABUG_APP_TOKEN` environment variable ([#938](https://github.com/Instabug/Instabug-React-Native/pull/938)). +- Add support for Android automatic source map file upload on Windows; this requires setting the `INSTABUG_APP_TOKEN` + environment variable ([#938](https://github.com/Instabug/Instabug-React-Native/pull/938)). ### Changed -- Bump Instabug Android SDK to v11.11.0 ([#963](https://github.com/Instabug/Instabug-React-Native/pull/963)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.11.0). -- Bump Instabug iOS SDK to v11.10.1 ([#964](https://github.com/Instabug/Instabug-React-Native/pull/964)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.10.1). +- Bump Instabug Android SDK to + v11.11.0 ([#963](https://github.com/Instabug/Instabug-React-Native/pull/963)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.11.0). +- Bump Instabug iOS SDK to + v11.10.1 ([#964](https://github.com/Instabug/Instabug-React-Native/pull/964)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.10.1). - Return a `Promise` from the below APIs ([#948](https://github.com/Instabug/Instabug-React-Native/pull/948)): - `Instabug.getTags` @@ -268,22 +367,28 @@ const tags = await Instabug.getTags(); ``` -- Improve release variant's build time on Android, by using the react-native-generated source map file, instead of generating it within our scripts ([#938](https://github.com/Instabug/Instabug-React-Native/pull/938)). -- Improve debug variant's build time on iOS, by disabling automatic source map file uploads ([#942](https://github.com/Instabug/Instabug-React-Native/pull/942)). +- Improve release variant's build time on Android, by using the react-native-generated source map file, instead of + generating it within our scripts ([#938](https://github.com/Instabug/Instabug-React-Native/pull/938)). +- Improve debug variant's build time on iOS, by disabling automatic source map file + uploads ([#942](https://github.com/Instabug/Instabug-React-Native/pull/942)). ### Deprecated -- Deprecate the callback parameter in the aforementioned methods ([#948](https://github.com/Instabug/Instabug-React-Native/pull/948)). +- Deprecate the callback parameter in the aforementioned + methods ([#948](https://github.com/Instabug/Instabug-React-Native/pull/948)). ## [11.9.1](https://github.com/Instabug/Instabug-React-Native/compare/v11.9.0...v11.9.1) (March 01, 2023) ### Changed -- Re-export `NetworkData` type ([#932](https://github.com/Instabug/Instabug-React-Native/pull/932)), closes [#930](https://github.com/Instabug/Instabug-React-Native/issues/930). +- Re-export `NetworkData` type ([#932](https://github.com/Instabug/Instabug-React-Native/pull/932)), + closes [#930](https://github.com/Instabug/Instabug-React-Native/issues/930). ### Fixed -- Fix a TS compilation error due to a broken entry point path ([#931](https://github.com/Instabug/Instabug-React-Native/pull/931)), closes [#930](https://github.com/Instabug/Instabug-React-Native/issues/930). +- Fix a TS compilation error due to a broken entry point + path ([#931](https://github.com/Instabug/Instabug-React-Native/pull/931)), + closes [#930](https://github.com/Instabug/Instabug-React-Native/issues/930). ## 11.9.0 (2023-02-20) @@ -298,10 +403,13 @@ }); ``` - Adds monorepo support for source maps automatic upload scripts. -- Adds gradle and ruby files to integrate native SDKs within exiting native apps. See [#919](https://github.com/Instabug/Instabug-React-Native/pull/919) for more info. -- Deprecates all module-enums (e.g. `Instabug.invocationEvent`) in favour of standalone-enums (e.g. `InvocationEvent`). See [#914](https://github.com/Instabug/Instabug-React-Native/pull/914) for more info and the detailed list of Enums. +- Adds gradle and ruby files to integrate native SDKs within exiting native apps. + See [#919](https://github.com/Instabug/Instabug-React-Native/pull/919) for more info. +- Deprecates all module-enums (e.g. `Instabug.invocationEvent`) in favour of standalone-enums (e.g. `InvocationEvent`). + See [#914](https://github.com/Instabug/Instabug-React-Native/pull/914) for more info and the detailed list of Enums. - Deprecates `Instabug.start` in favour of `Instabug.init`. -- Deprecates `Instabug.setDebugEnabled`, `Instabug.setSdkDebugLogsLevel`, and `APM.setLogLevel` in favour of `debugLogsLevel` property of `Instabug.init`. +- Deprecates `Instabug.setDebugEnabled`, `Instabug.setSdkDebugLogsLevel`, and `APM.setLogLevel` in favour of + `debugLogsLevel` property of `Instabug.init`. - Deprecates `Instabug.isRunningLive` API. - Fixes external global error handlers not being called after initializing Instabug. - Fixes `BugReporting.setDidSelectPromptOptionHandler` on iOS. @@ -329,7 +437,8 @@ - Adds Romanian locale support - Adds BugReporting.setDisclaimerText API - Adds BugReporting.setCommentMinimumCharacterCount API -- Deprecates Instabug.enable and Instabug.disable APIs in favour of a new API Instabug.setEnabled, which works on both platforms +- Deprecates Instabug.enable and Instabug.disable APIs in favour of a new API Instabug.setEnabled, which works on both + platforms - Fixes a compilation error on Android projects without buildToolsVersion property set - Fixes an issue with Hermes source maps generation script on React Native versions prior to 0.65.0 @@ -348,7 +457,8 @@ - Bumps the minimum supported React Native version to 0.60.0 - Drops manual linking support - Adjusts source maps auto upload script on Android to support the bundled Hermes in React Native v0.69 -- Fixes an issue with Hermes source maps generation script causing JS crashes on Android not getting deobfuscated correctly +- Fixes an issue with Hermes source maps generation script causing JS crashes on Android not getting deobfuscated + correctly - Adds support for iOS source maps auto upload when Hermes is enabled ## 11.0.2 (2022-07-20) @@ -373,7 +483,8 @@ - Removes the deprecated APIs. Check the migration guide referenced in our docs - Removes Surveys.setThresholdForReshowingSurveyAfterDismiss - Removes the string keys: surveysCustomThanksTitle and surveysCustomThanksSubtitle -- Renames BugReporting.setAutoScreenRecordingMaxDuration to BugReporting.setAutoScreenRecordingDurationIOS to target iOS only +- Renames BugReporting.setAutoScreenRecordingMaxDuration to BugReporting.setAutoScreenRecordingDurationIOS to target iOS + only - Fixes an issue with the setRequestFilterExpression API not working with Hermes - Fixes an issue with the swipe invocation event not working on Android @@ -425,7 +536,8 @@ - Fixes crashes related to the network request data not being parsed correctly - Fixes issues related to the automatic sourcemap file upload on Android - Adds missing TypeScript definitions -- Deprecates Instabug.setVideoRecordingFloatingButtonPosition in favor of BugReporting.setVideoRecordingFloatingButtonPosition +- Deprecates Instabug.setVideoRecordingFloatingButtonPosition in favor of + BugReporting.setVideoRecordingFloatingButtonPosition - Includes native fix which removes the usage of android:requestLegacyExternalStorage permission - Various other bug fixes and improvements @@ -461,7 +573,8 @@ ## v9.1.6 (2020-07-16) - Fixes an issue that caused XHR Response not to be logged. -- Adds support for Repro Steps. Repro Steps list all of the actions an app user took before reporting a bug or crash, grouped by the screens they visited in your app. +- Adds support for Repro Steps. Repro Steps list all of the actions an app user took before reporting a bug or crash, + grouped by the screens they visited in your app. - Bump Native SDKs to v9.1.6 ## v9.1.1 (2020-04-06) @@ -517,7 +630,8 @@ ## v8.6.4 (2019-09-13) -- Fixes an issue on Android that would result in a build error with the message `null is not an object (evaluating u.invocationEventNone)` +- Fixes an issue on Android that would result in a build error with the message + `null is not an object (evaluating u.invocationEventNone)` ## v8.6.3 (2019-08-29) @@ -546,7 +660,8 @@ ## v8.5.4 (2019-08-10) -- Hot Fixes an issue with `Instabug.setFloatingButtonEdge` and `Instabug.setEnabledAttachmentTypes` causing the app to crash. +- Hot Fixes an issue with `Instabug.setFloatingButtonEdge` and `Instabug.setEnabledAttachmentTypes` causing the app to + crash. ## v8.5.3 (2019-08-08) @@ -566,7 +681,8 @@ ## v8.5.0 (2019-07-11) -**⚠️ If you are using React Native 0.60, please follow our migration guide [here](https://github.com/Instabug/Instabug-React-Native/blob/master/README.md#updating-to-version-85)** +**⚠️ If you are using React Native 0.60, please follow our migration +guide [here](https://github.com/Instabug/Instabug-React-Native/blob/master/README.md#updating-to-version-85)** - Support for React Native 0.60 - Updates native iOS and Android SDKs to version 8.5 From 13ac3ad74a4908f396bc8a25afede3f3f86c9100 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Wed, 31 Jul 2024 17:26:13 +0300 Subject: [PATCH 13/40] fix: Pr comments --- CHANGELOG.md | 302 ++++++++++++++++----------------------------------- 1 file changed, 93 insertions(+), 209 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf1c8eb0fe..d2540e03d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,141 +4,111 @@ ### Added -- Enhance the network interceptor to capture some client error - messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). -- +- Enhance the network interceptor to capture some client error messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). ### Fixed - Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). -- Fix an OOM (out-of-memory) crash while saving network logs on - Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)). +- Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)). ## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024) ### Changed -- Bump Instabug Android SDK to - v13.2.0 ([#1245](https://github.com/Instabug/Instabug-React-Native/pull/1245)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.2.0). -- Bump Instabug iOS SDK to - v13.2.0 ([#1246](https://github.com/Instabug/Instabug-React-Native/pull/1246)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.2.0). +- Bump Instabug Android SDK to v13.2.0 ([#1245](https://github.com/Instabug/Instabug-React-Native/pull/1245)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.2.0). +- Bump Instabug iOS SDK to v13.2.0 ([#1246](https://github.com/Instabug/Instabug-React-Native/pull/1246)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.2.0). ### Fixed -- Change parameters used inside inner classes to `final` in Android code to maintain compatibility with Java 7 and - earlier ([#1239](https://github.com/Instabug/Instabug-React-Native/pull/1239)). +- Change parameters used inside inner classes to `final` in Android code to maintain compatibility with Java 7 and earlier ([#1239](https://github.com/Instabug/Instabug-React-Native/pull/1239)). ## [13.1.1](https://github.com/Instabug/Instabug-React-Native/compare/v13.0.5...v13.1.1) (June 6, 2024) ### Added -- Add support for passing a grouping fingerprint, error level, and user attributes to the `CrashReporting.reportError` - non-fatals API ([#1194](https://github.com/Instabug/Instabug-React-Native/pull/1194)). +- Add support for passing a grouping fingerprint, error level, and user attributes to the `CrashReporting.reportError` non-fatals API ([#1194](https://github.com/Instabug/Instabug-React-Native/pull/1194)). ### Changed -- Bump Instabug iOS SDK to - v13.1.0 ([#1227](https://github.com/Instabug/Instabug-React-Native/pull/1227)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.1.0). -- Bump Instabug android SDK to - v13.1.1 ([#1228](https://github.com/Instabug/Instabug-React-Native/pull/1228)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.1.0). +- Bump Instabug iOS SDK to v13.1.0 ([#1227](https://github.com/Instabug/Instabug-React-Native/pull/1227)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.1.0). +- Bump Instabug android SDK to v13.1.1 ([#1228](https://github.com/Instabug/Instabug-React-Native/pull/1228)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.1.0). ### Fixed -- Read `INSTABUG_APP_TOKEN` from system environment when there is no default - value ([#1232](https://github.com/Instabug/Instabug-React-Native/pull/1232)). +- Read `INSTABUG_APP_TOKEN` from system environment when there is no default value ([#1232](https://github.com/Instabug/Instabug-React-Native/pull/1232)). ## [13.0.5](https://github.com/Instabug/Instabug-React-Native/compare/v13.0.4...v13.0.5) (May 18, 2024) ### Changed -- Bump Instabug iOS SDK to - v13.0.5 ([#1213](https://github.com/Instabug/Instabug-React-Native/pull/1213)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.5). +- Bump Instabug iOS SDK to v13.0.5 ([#1213](https://github.com/Instabug/Instabug-React-Native/pull/1213)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.5). ## [13.0.4](https://github.com/Instabug/Instabug-React-Native/compare/v13.0.0...v13.0.4) (May 14, 2024) ### Changed -- Support reading environment variables from `ios/.xcode.env` and `ios/.xcode.env.local` files when present in the iOS - source maps upload script ([#1200](https://github.com/Instabug/Instabug-React-Native/pull/1200)). -- Bump Instabug Android SDK to - v13.0.3 ([#1206](https://github.com/Instabug/Instabug-React-Native/pull/1206)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.3). -- Bump Instabug iOS SDK to - v13.0.3 ([#1208](https://github.com/Instabug/Instabug-React-Native/pull/1208)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.3). +- Support reading environment variables from `ios/.xcode.env` and `ios/.xcode.env.local` files when present in the iOS source maps upload script ([#1200](https://github.com/Instabug/Instabug-React-Native/pull/1200)). +- Bump Instabug Android SDK to v13.0.3 ([#1206](https://github.com/Instabug/Instabug-React-Native/pull/1206)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.3). +- Bump Instabug iOS SDK to v13.0.3 ([#1208](https://github.com/Instabug/Instabug-React-Native/pull/1208)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.3). ## [13.0.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.9.0...v13.0.0) (April 19, 2024) ### Added -- Add `Instabug.willRedirectToStore` API for use in custom app rating - prompts ([#1186](https://github.com/Instabug/Instabug-React-Native/pull/1186)). -- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and - `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). +- Add `Instabug.willRedirectToStore` API for use in custom app rating prompts ([#1186](https://github.com/Instabug/Instabug-React-Native/pull/1186)). +- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). ### Changed -- Bump Instabug iOS SDK to - v13.0.0 ([#1189](https://github.com/Instabug/Instabug-React-Native/pull/1189)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.0). -- Bump Instabug Android SDK to - v13.0.0 ([#1188](https://github.com/Instabug/Instabug-React-Native/pull/1188)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.0). +- Bump Instabug iOS SDK to v13.0.0 ([#1189](https://github.com/Instabug/Instabug-React-Native/pull/1189)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.0). +- Bump Instabug Android SDK to v13.0.0 ([#1188](https://github.com/Instabug/Instabug-React-Native/pull/1188)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.0). ## [12.9.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.8.0...12.9.0)(April 2, 2024) ### Added - Adds symbol files upload script ([#1137](https://github.com/Instabug/Instabug-React-Native/pull/1137)) -- Support enabling NDK crash capturing on - Android ([#1132](https://github.com/Instabug/Instabug-React-Native/pull/1132)). -- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and - `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). +- Support enabling NDK crash capturing on Android ([#1132](https://github.com/Instabug/Instabug-React-Native/pull/1132)). +- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). ### Deprecated -- 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)). +- 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)). ### Deprecated -- 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)). +- 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)). ### Changed -- Bump Instabug Android SDK to - v12.9.0 ([#1168](https://github.com/Instabug/Instabug-React-Native/pull/1168)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.9.0). -- Bump Instabug iOS SDK to - v12.9.0 ([#1168](https://github.com/Instabug/Instabug-React-Native/pull/1168)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.9.0). +- Bump Instabug Android SDK to v12.9.0 ([#1168](https://github.com/Instabug/Instabug-React-Native/pull/1168)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.9.0). +- Bump Instabug iOS SDK to v12.9.0 ([#1168](https://github.com/Instabug/Instabug-React-Native/pull/1168)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.9.0). ### Fixed -- Remove the use of the nullish coalescing assignment operator (`??=`) causing a syntax error with older TypeScript - versions ([#1166](https://github.com/Instabug/Instabug-React-Native/pull/1166)), closes [#1161 +- Remove the use of the nullish coalescing assignment operator (`??=`) causing a syntax error with older TypeScript versions ([#1166](https://github.com/Instabug/Instabug-React-Native/pull/1166)), closes [#1161 ](https://github.com/Instabug/Instabug-React-Native/issues/1161). ## [12.8.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.1...v12.8.0) (February 25, 2024) ### Added -- Add `SessionReplay.getSessionReplayLink` API which retrieves the current session's replay - link ([#1142](https://github.com/Instabug/Instabug-React-Native/pull/1142)). -- Support setting the Code Push version after SDK - initialization ([#1143](https://github.com/Instabug/Instabug-React-Native/pull/1143)). +- Add `SessionReplay.getSessionReplayLink` API which retrieves the current session's replay link ([#1142](https://github.com/Instabug/Instabug-React-Native/pull/1142)). +- Support setting the Code Push version after SDK initialization ([#1143](https://github.com/Instabug/Instabug-React-Native/pull/1143)). ### Changed -- 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). +- 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). ### Deprecated -- 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)). +- 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)). ## [12.7.1](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.0...v12.7.1) (February 15, 2024) ### Changed -- Bump Instabug Android SDK to - v12.7.1 ([#1134](https://github.com/Instabug/Instabug-React-Native/pull/1134)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.7.1). +- Bump Instabug Android SDK to v12.7.1 ([#1134](https://github.com/Instabug/Instabug-React-Native/pull/1134)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.7.1). ## [12.7.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.6.0...v12.7.0) (February 10, 2024) @@ -149,25 +119,19 @@ ### Changed -- Bump Instabug iOS SDK to - v12.7.0 ([#1125](https://github.com/Instabug/Instabug-React-Native/pull/1125)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.7.0). -- Bump Instabug Android SDK to - v12.7.0 ([#1126](https://github.com/Instabug/Instabug-React-Native/pull/1126)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.7.0). +- Bump Instabug iOS SDK to v12.7.0 ([#1125](https://github.com/Instabug/Instabug-React-Native/pull/1125)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.7.0). +- Bump Instabug Android SDK to v12.7.0 ([#1126](https://github.com/Instabug/Instabug-React-Native/pull/1126)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.7.0). ### Fixed -- Fix an Android `NullPointerException` crash in private views - APIs ([#1121](https://github.com/Instabug/Instabug-React-Native/pull/1121)), - closes [#514](https://github.com/Instabug/Instabug-React-Native/issues/514). +- Fix an Android `NullPointerException` crash in private views APIs ([#1121](https://github.com/Instabug/Instabug-React-Native/pull/1121)), closes [#514](https://github.com/Instabug/Instabug-React-Native/issues/514). ## [12.6.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.5.0...v12.6.0) (January 14, 2024) ### Changed -- Bump Instabug iOS SDK to - v12.6.0 ([#1095](https://github.com/Instabug/Instabug-React-Native/pull/1095)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.6.0). -- Bump Instabug Android SDK to - v12.6.0 ([#1096](https://github.com/Instabug/Instabug-React-Native/pull/1096)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.6.0). +- Bump Instabug iOS SDK to v12.6.0 ([#1095](https://github.com/Instabug/Instabug-React-Native/pull/1095)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.6.0). +- Bump Instabug Android SDK to v12.6.0 ([#1096](https://github.com/Instabug/Instabug-React-Native/pull/1096)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.6.0). ### Added @@ -177,180 +141,117 @@ ### Changed -- Bump Instabug iOS SDK to - v12.5.0 ([#1085](https://github.com/Instabug/Instabug-React-Native/pull/1085)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.5.0). -- Bump Instabug Android SDK to v12.5.1 ([#1088](https://github.com/Instabug/Instabug-React-Native/pull/1085)). See - release notes for [v12.5.0](https://github.com/Instabug/android/releases/tag/v12.5.0) - and [v12.5.1](https://github.com/Instabug/android/releases/tag/v12.5.1). +- Bump Instabug iOS SDK to v12.5.0 ([#1085](https://github.com/Instabug/Instabug-React-Native/pull/1085)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.5.0). +- Bump Instabug Android SDK to v12.5.1 ([#1088](https://github.com/Instabug/Instabug-React-Native/pull/1085)). See release notes for [v12.5.0](https://github.com/Instabug/android/releases/tag/v12.5.0) and [v12.5.1](https://github.com/Instabug/android/releases/tag/v12.5.1). ### Fixed -- Fix a delay issue in reporting the 'Current View' that resulted in displaying outdated - values ([#1080](https://github.com/Instabug/Instabug-React-Native/pull/1080)). +- Fix a delay issue in reporting the 'Current View' that resulted in displaying outdated values ([#1080](https://github.com/Instabug/Instabug-React-Native/pull/1080)). ## [12.4.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.2.0...v12.4.0) (December 7, 2023) ### Changed -- Bump Instabug iOS SDK to v12.4.0 ([#1074](https://github.com/Instabug/Instabug-React-Native/pull/1074)). See release - notes for [v12.3.0](https://github.com/instabug/instabug-ios/releases/tag/12.3.0) - and [v12.4.0](https://github.com/instabug/instabug-ios/releases/tag/12.4.0). -- Bump Instabug Android SDK to v12.4.1 ([#1076](https://github.com/Instabug/Instabug-React-Native/pull/1076)). See - release notes - for [v12.3.0](https://github.com/Instabug/android/releases/tag/v12.3.0), [v12.3.1](https://github.com/Instabug/android/releases/tag/v12.3.1), [v12.4.0](https://github.com/Instabug/android/releases/tag/v12.4.0) - and [v12.4.1](https://github.com/Instabug/android/releases/tag/v12.4.1). +- Bump Instabug iOS SDK to v12.4.0 ([#1074](https://github.com/Instabug/Instabug-React-Native/pull/1074)). See release notes for [v12.3.0](https://github.com/instabug/instabug-ios/releases/tag/12.3.0) and [v12.4.0](https://github.com/instabug/instabug-ios/releases/tag/12.4.0). +- Bump Instabug Android SDK to v12.4.1 ([#1076](https://github.com/Instabug/Instabug-React-Native/pull/1076)). See release notes for [v12.3.0](https://github.com/Instabug/android/releases/tag/v12.3.0), [v12.3.1](https://github.com/Instabug/android/releases/tag/v12.3.1), [v12.4.0](https://github.com/Instabug/android/releases/tag/v12.4.0) and [v12.4.1](https://github.com/Instabug/android/releases/tag/v12.4.1). ### Fixed -- Fix an issue with `Instabug.init` on Android causing the app to crash while trying to get the current `Application` - instance through the current activity which can be `null` in some cases by utilizing the React context - instead ([#1069](https://github.com/Instabug/Instabug-React-Native/pull/1069)). -- Fix an issue with unhandled JavaScript crashes not getting linked with the current session causing inaccurate session - metrics ([#1071](https://github.com/Instabug/Instabug-React-Native/pull/1071)). +- Fix an issue with `Instabug.init` on Android causing the app to crash while trying to get the current `Application` instance through the current activity which can be `null` in some cases by utilizing the React context instead ([#1069](https://github.com/Instabug/Instabug-React-Native/pull/1069)). +- Fix an issue with unhandled JavaScript crashes not getting linked with the current session causing inaccurate session metrics ([#1071](https://github.com/Instabug/Instabug-React-Native/pull/1071)). ## [12.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.1.0...v12.2.0) (November 14, 2023) ### Added -- Add an iOS-side init API which allows capturing crashes that happen early in the app lifecycle and before the - JavaScript code has started ([#1056](https://github.com/Instabug/Instabug-React-Native/pull/1056)). +- Add an iOS-side init API which allows capturing crashes that happen early in the app lifecycle and before the JavaScript code has started ([#1056](https://github.com/Instabug/Instabug-React-Native/pull/1056)). ### Changed -- Bump Instabug iOS SDK to - v12.2.0 ([#1053](https://github.com/Instabug/Instabug-React-Native/pull/1053)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.2.0). -- Bump Instabug Android SDK to - v12.2.0 ([#1052](https://github.com/Instabug/Instabug-React-Native/pull/1052)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.2.0). +- Bump Instabug iOS SDK to v12.2.0 ([#1053](https://github.com/Instabug/Instabug-React-Native/pull/1053)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/12.2.0). +- Bump Instabug Android SDK to v12.2.0 ([#1052](https://github.com/Instabug/Instabug-React-Native/pull/1052)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.2.0). ### Fixed -- Fix an issue with Android Gradle Plugin namespace support required for React Native 0.73 and backward compatibility - with previous versions ([#1044](https://github.com/Instabug/Instabug-React-Native/pull/1044)). -- Fix an issue with unhandled JavaScript crashes being reported as native iOS - crashes ([#1054](https://github.com/Instabug/Instabug-React-Native/pull/1054)) -- Re-enable screenshot capturing for Crash Reporting and Session Replay by removing redundant - mapping ([#1055](https://github.com/Instabug/Instabug-React-Native/pull/1055)). +- Fix an issue with Android Gradle Plugin namespace support required for React Native 0.73 and backward compatibility with previous versions ([#1044](https://github.com/Instabug/Instabug-React-Native/pull/1044)). +- Fix an issue with unhandled JavaScript crashes being reported as native iOS crashes ([#1054](https://github.com/Instabug/Instabug-React-Native/pull/1054)) +- Re-enable screenshot capturing for Crash Reporting and Session Replay by removing redundant mapping ([#1055](https://github.com/Instabug/Instabug-React-Native/pull/1055)). ## [12.1.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.14.0...v12.1.0) (October 3, 2023) ### Added -- Add support for Session Replay, which includes capturing session details, visual reproduction of sessions as well as - support for user steps, network and Instabug - logs. ([#1034](https://github.com/Instabug/Instabug-React-Native/pull/1034)). +- Add support for Session Replay, which includes capturing session details, visual reproduction of sessions as well as support for user steps, network and Instabug logs. ([#1034](https://github.com/Instabug/Instabug-React-Native/pull/1034)). ### Changed -- **BREAKING** Remove deprecated APIs ([#1027](https://github.com/Instabug/Instabug-React-Native/pull/1027)). See - migration guide for more details. -- Bump Instabug iOS SDK to v12.1.0 ([#1031](https://github.com/Instabug/Instabug-React-Native/pull/1031)). See release - notes for [v12.0.0](https://github.com/instabug/instabug-ios/releases/tag/12.0.0) - and [v12.1.0](https://github.com/instabug/instabug-ios/releases/tag/12.1.0). -- Bump Instabug Android SDK to v12.1.0 ([#1032](https://github.com/Instabug/Instabug-React-Native/pull/1032)). See - release notes - for [v12.0.0](https://github.com/Instabug/Instabug-Android/releases/tag/v12.0.0), [v12.0.1](https://github.com/Instabug/Instabug-Android/releases/tag/v12.0.1) - and [v12.1.0](https://github.com/Instabug/Instabug-Android/releases/tag/v12.1.0). +- **BREAKING** Remove deprecated APIs ([#1027](https://github.com/Instabug/Instabug-React-Native/pull/1027)). See migration guide for more details. +- Bump Instabug iOS SDK to v12.1.0 ([#1031](https://github.com/Instabug/Instabug-React-Native/pull/1031)). See release notes for [v12.0.0](https://github.com/instabug/instabug-ios/releases/tag/12.0.0) and [v12.1.0](https://github.com/instabug/instabug-ios/releases/tag/12.1.0). +- Bump Instabug Android SDK to v12.1.0 ([#1032](https://github.com/Instabug/Instabug-React-Native/pull/1032)). See release notes for [v12.0.0](https://github.com/Instabug/Instabug-Android/releases/tag/v12.0.0), [v12.0.1](https://github.com/Instabug/Instabug-Android/releases/tag/v12.0.1) and [v12.1.0](https://github.com/Instabug/Instabug-Android/releases/tag/v12.1.0). ## [11.14.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.13.0...11.14.0) (September 15, 2023) ### Added -- Add support for automatic capturing of unhandled Promise rejection - crashes ([#1014](https://github.com/Instabug/Instabug-React-Native/pull/1014)). -- Add new strings (`StringKey.discardAlertStay` and `StringKey.discardAlertDiscard`) for overriding the discard alert - buttons for consistency between iOS and - Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)). -- Add a new string (`StringKey.reproStepsListItemNumberingTitle`) for overriding the repro steps list item (screen) - title for consistency between iOS and Android ([#1002](https://github.com/Instabug/Instabug-React-Native/pull/1002)). -- Add support for RN version 0.73 by updating the `build.gradle` file with the - `namespace` ([#1004](https://github.com/Instabug/Instabug-React-Native/pull/1004)) -- Add native-side init API which can be used to catch and report startup crashes on - android. ([#1012](https://github.com/Instabug/Instabug-React-Native/pull/1012)) -- Add the new repro steps configuration API - `Instabug.setReproStepsConfig` ([#1024](https://github.com/Instabug/Instabug-React-Native/pull/1024)). +- Add support for automatic capturing of unhandled Promise rejection crashes ([#1014](https://github.com/Instabug/Instabug-React-Native/pull/1014)). +- Add new strings (`StringKey.discardAlertStay` and `StringKey.discardAlertDiscard`) for overriding the discard alert buttons for consistency between iOS and Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)). +- Add a new string (`StringKey.reproStepsListItemNumberingTitle`) for overriding the repro steps list item (screen) title for consistency between iOS and Android ([#1002](https://github.com/Instabug/Instabug-React-Native/pull/1002)). +- Add support for RN version 0.73 by updating the `build.gradle` file with the `namespace` ([#1004](https://github.com/Instabug/Instabug-React-Native/pull/1004)) +- Add native-side init API which can be used to catch and report startup crashes on android. ([#1012](https://github.com/Instabug/Instabug-React-Native/pull/1012)) +- Add the new repro steps configuration API `Instabug.setReproStepsConfig` ([#1024](https://github.com/Instabug/Instabug-React-Native/pull/1024)). ### Changed -- Bump Instabug iOS SDK to - v11.14.0 ([#1020](https://github.com/Instabug/Instabug-React-Native/pull/1020)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.14.0). -- Bump Instabug Android SDK to - v11.14.0 ([#1019](https://github.com/Instabug/Instabug-React-Native/pull/1019)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.14.0). +- Bump Instabug iOS SDK to v11.14.0 ([#1020](https://github.com/Instabug/Instabug-React-Native/pull/1020)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.14.0). +- Bump Instabug Android SDK to v11.14.0 ([#1019](https://github.com/Instabug/Instabug-React-Native/pull/1019)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.14.0). ### Deprecated -- Deprecate the old `StringKey.discardAlertCancel` and `StringKey.discardAlertAction` string keys for overriding the - discard alert buttons as they had inconsistent behavior between iOS and - Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)). -- Deprecate the old `StringKey.reproStepsListItemTitle` string key for overriding the repro steps list item (screen) - title as it had inconsistent behavior between iOS and - Android ([#1002](https://github.com/Instabug/Instabug-React-Native/pull/1002)). -- Deprecate `Instabug.setReproStepsMode` in favor of the new - `Instabug.setReproStepsConfig` ([#1024](https://github.com/Instabug/Instabug-React-Native/pull/1024)). -- Deprecate the old `StringKey.invalidCommentMessage` and `StringKey.invalidCommentTitle` in favor of - `StringKey.insufficientContentMessage` and - `StringKey.insufficientContentTitle` ([#1026](https://github.com/Instabug/Instabug-React-Native/pull/1026)). +- Deprecate the old `StringKey.discardAlertCancel` and `StringKey.discardAlertAction` string keys for overriding the discard alert buttons as they had inconsistent behavior between iOS and Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)). +- Deprecate the old `StringKey.reproStepsListItemTitle` string key for overriding the repro steps list item (screen) title as it had inconsistent behavior between iOS and Android ([#1002](https://github.com/Instabug/Instabug-React-Native/pull/1002)). +- Deprecate `Instabug.setReproStepsMode` in favor of the new `Instabug.setReproStepsConfig` ([#1024](https://github.com/Instabug/Instabug-React-Native/pull/1024)). +- Deprecate the old `StringKey.invalidCommentMessage` and `StringKey.invalidCommentTitle` in favor of `StringKey.insufficientContentMessage` and `StringKey.insufficientContentTitle` ([#1026](https://github.com/Instabug/Instabug-React-Native/pull/1026)). ## [11.13.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.12.0...v11.13.0) (July 10, 2023) ### Changed -- Bump Instabug iOS SDK to - v11.13.3 ([#997](https://github.com/Instabug/Instabug-React-Native/pull/997)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.13.3). -- Bump Instabug Android SDK to - v11.13.0 ([#996](https://github.com/Instabug/Instabug-React-Native/pull/996)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.13.0). +- Bump Instabug iOS SDK to v11.13.3 ([#997](https://github.com/Instabug/Instabug-React-Native/pull/997)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.13.3). +- Bump Instabug Android SDK to v11.13.0 ([#996](https://github.com/Instabug/Instabug-React-Native/pull/996)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.13.0). ### Fixed -- Fix an issue with the Android sourcemaps upload Gradle task getting recreated when both `bundleReleaseJsAndAssets` and - `createBundleReleaseJsAndAssets` tasks exist in the same Android - project ([#991](https://github.com/Instabug/Instabug-React-Native/pull/991)), - closes [#989](https://github.com/Instabug/Instabug-React-Native/issues/989). -- Fix an issue with JaCoCo gradle plugin replacing the `enabled` method with `required` prop to prevent gradle scripts - breaking on version `0.72` ([#995](https://github.com/Instabug/Instabug-React-Native/pull/995)), - closes [#994](https://github.com/Instabug/Instabug-React-Native/issues/994). +- Fix an issue with the Android sourcemaps upload Gradle task getting recreated when both `bundleReleaseJsAndAssets` and `createBundleReleaseJsAndAssets` tasks exist in the same Android project ([#991](https://github.com/Instabug/Instabug-React-Native/pull/991)), closes [#989](https://github.com/Instabug/Instabug-React-Native/issues/989). +- Fix an issue with JaCoCo gradle plugin replacing the `enabled` method with `required` prop to prevent gradle scripts breaking on version `0.72` ([#995](https://github.com/Instabug/Instabug-React-Native/pull/995)), closes [#994](https://github.com/Instabug/Instabug-React-Native/issues/994). ## [11.12.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.10.0...11.12.0) (May 30, 2023) ### Changed -- Bump Instabug Android SDK to - v11.12.0 ([#985](https://github.com/Instabug/Instabug-React-Native/pull/985)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.12.0). -- Bump Instabug iOS SDK to - v11.12.0 ([#986](https://github.com/Instabug/Instabug-React-Native/pull/986)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.12.0). +- Bump Instabug Android SDK to v11.12.0 ([#985](https://github.com/Instabug/Instabug-React-Native/pull/985)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.12.0). +- Bump Instabug iOS SDK to v11.12.0 ([#986](https://github.com/Instabug/Instabug-React-Native/pull/986)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.12.0). ### Deprecated -- Deprecate `instabugUploadEnable` gradle property to disable Android sourcemaps auto upload in favor of - `INSTABUG_SOURCEMAPS_UPLOAD_DISABLE` env - variable ([#983](https://github.com/Instabug/Instabug-React-Native/pull/983)). +- Deprecate `instabugUploadEnable` gradle property to disable Android sourcemaps auto upload in favor of `INSTABUG_SOURCEMAPS_UPLOAD_DISABLE` env variable ([#983](https://github.com/Instabug/Instabug-React-Native/pull/983)). ### Fixed -- Fix an issue with unhandled JavaScript crashes being reported as native Android - crashes ([#980](https://github.com/Instabug/Instabug-React-Native/pull/980)). -- Fix an issue with the Android sourcemaps upload script, causing the build to fail on older versions of - Gradle ([#970](https://github.com/Instabug/Instabug-React-Native/pull/970)), - closes [#969](https://github.com/Instabug/Instabug-React-Native/issues/969). -- Fix an issue with the Android sourcemaps upload script, causing the build to fail when using product - flavors ([#975](https://github.com/Instabug/Instabug-React-Native/pull/975)), - closes [#974](https://github.com/Instabug/Instabug-React-Native/issues/974). -- Fix an issue with the network interceptor reverting the user's changes to `XMLHttpRequest` after disabling network - logging ([#984](https://github.com/Instabug/Instabug-React-Native/pull/984)), - closes [#981](https://github.com/Instabug/Instabug-React-Native/issues/981). +- Fix an issue with unhandled JavaScript crashes being reported as native Android crashes ([#980](https://github.com/Instabug/Instabug-React-Native/pull/980)). +- Fix an issue with the Android sourcemaps upload script, causing the build to fail on older versions of Gradle ([#970](https://github.com/Instabug/Instabug-React-Native/pull/970)), closes [#969](https://github.com/Instabug/Instabug-React-Native/issues/969). +- Fix an issue with the Android sourcemaps upload script, causing the build to fail when using product flavors ([#975](https://github.com/Instabug/Instabug-React-Native/pull/975)), closes [#974](https://github.com/Instabug/Instabug-React-Native/issues/974). +- Fix an issue with the network interceptor reverting the user's changes to `XMLHttpRequest` after disabling network logging ([#984](https://github.com/Instabug/Instabug-React-Native/pull/984)), closes [#981](https://github.com/Instabug/Instabug-React-Native/issues/981). ## [11.10.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.9.1...11.10.0) (April 20, 2023) ### Added -- Add support for Android automatic source map file upload on Windows; this requires setting the `INSTABUG_APP_TOKEN` - environment variable ([#938](https://github.com/Instabug/Instabug-React-Native/pull/938)). +- Add support for Android automatic source map file upload on Windows; this requires setting the `INSTABUG_APP_TOKEN` environment variable ([#938](https://github.com/Instabug/Instabug-React-Native/pull/938)). ### Changed -- Bump Instabug Android SDK to - v11.11.0 ([#963](https://github.com/Instabug/Instabug-React-Native/pull/963)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.11.0). -- Bump Instabug iOS SDK to - v11.10.1 ([#964](https://github.com/Instabug/Instabug-React-Native/pull/964)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.10.1). +- Bump Instabug Android SDK to v11.11.0 ([#963](https://github.com/Instabug/Instabug-React-Native/pull/963)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v11.11.0). +- Bump Instabug iOS SDK to v11.10.1 ([#964](https://github.com/Instabug/Instabug-React-Native/pull/964)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/11.10.1). - Return a `Promise` from the below APIs ([#948](https://github.com/Instabug/Instabug-React-Native/pull/948)): - `Instabug.getTags` @@ -367,28 +268,22 @@ const tags = await Instabug.getTags(); ``` -- Improve release variant's build time on Android, by using the react-native-generated source map file, instead of - generating it within our scripts ([#938](https://github.com/Instabug/Instabug-React-Native/pull/938)). -- Improve debug variant's build time on iOS, by disabling automatic source map file - uploads ([#942](https://github.com/Instabug/Instabug-React-Native/pull/942)). +- Improve release variant's build time on Android, by using the react-native-generated source map file, instead of generating it within our scripts ([#938](https://github.com/Instabug/Instabug-React-Native/pull/938)). +- Improve debug variant's build time on iOS, by disabling automatic source map file uploads ([#942](https://github.com/Instabug/Instabug-React-Native/pull/942)). ### Deprecated -- Deprecate the callback parameter in the aforementioned - methods ([#948](https://github.com/Instabug/Instabug-React-Native/pull/948)). +- Deprecate the callback parameter in the aforementioned methods ([#948](https://github.com/Instabug/Instabug-React-Native/pull/948)). ## [11.9.1](https://github.com/Instabug/Instabug-React-Native/compare/v11.9.0...v11.9.1) (March 01, 2023) ### Changed -- Re-export `NetworkData` type ([#932](https://github.com/Instabug/Instabug-React-Native/pull/932)), - closes [#930](https://github.com/Instabug/Instabug-React-Native/issues/930). +- Re-export `NetworkData` type ([#932](https://github.com/Instabug/Instabug-React-Native/pull/932)), closes [#930](https://github.com/Instabug/Instabug-React-Native/issues/930). ### Fixed -- Fix a TS compilation error due to a broken entry point - path ([#931](https://github.com/Instabug/Instabug-React-Native/pull/931)), - closes [#930](https://github.com/Instabug/Instabug-React-Native/issues/930). +- Fix a TS compilation error due to a broken entry point path ([#931](https://github.com/Instabug/Instabug-React-Native/pull/931)), closes [#930](https://github.com/Instabug/Instabug-React-Native/issues/930). ## 11.9.0 (2023-02-20) @@ -403,13 +298,10 @@ }); ``` - Adds monorepo support for source maps automatic upload scripts. -- Adds gradle and ruby files to integrate native SDKs within exiting native apps. - See [#919](https://github.com/Instabug/Instabug-React-Native/pull/919) for more info. -- Deprecates all module-enums (e.g. `Instabug.invocationEvent`) in favour of standalone-enums (e.g. `InvocationEvent`). - See [#914](https://github.com/Instabug/Instabug-React-Native/pull/914) for more info and the detailed list of Enums. +- Adds gradle and ruby files to integrate native SDKs within exiting native apps. See [#919](https://github.com/Instabug/Instabug-React-Native/pull/919) for more info. +- Deprecates all module-enums (e.g. `Instabug.invocationEvent`) in favour of standalone-enums (e.g. `InvocationEvent`). See [#914](https://github.com/Instabug/Instabug-React-Native/pull/914) for more info and the detailed list of Enums. - Deprecates `Instabug.start` in favour of `Instabug.init`. -- Deprecates `Instabug.setDebugEnabled`, `Instabug.setSdkDebugLogsLevel`, and `APM.setLogLevel` in favour of - `debugLogsLevel` property of `Instabug.init`. +- Deprecates `Instabug.setDebugEnabled`, `Instabug.setSdkDebugLogsLevel`, and `APM.setLogLevel` in favour of `debugLogsLevel` property of `Instabug.init`. - Deprecates `Instabug.isRunningLive` API. - Fixes external global error handlers not being called after initializing Instabug. - Fixes `BugReporting.setDidSelectPromptOptionHandler` on iOS. @@ -437,8 +329,7 @@ - Adds Romanian locale support - Adds BugReporting.setDisclaimerText API - Adds BugReporting.setCommentMinimumCharacterCount API -- Deprecates Instabug.enable and Instabug.disable APIs in favour of a new API Instabug.setEnabled, which works on both - platforms +- Deprecates Instabug.enable and Instabug.disable APIs in favour of a new API Instabug.setEnabled, which works on both platforms - Fixes a compilation error on Android projects without buildToolsVersion property set - Fixes an issue with Hermes source maps generation script on React Native versions prior to 0.65.0 @@ -457,8 +348,7 @@ - Bumps the minimum supported React Native version to 0.60.0 - Drops manual linking support - Adjusts source maps auto upload script on Android to support the bundled Hermes in React Native v0.69 -- Fixes an issue with Hermes source maps generation script causing JS crashes on Android not getting deobfuscated - correctly +- Fixes an issue with Hermes source maps generation script causing JS crashes on Android not getting deobfuscated correctly - Adds support for iOS source maps auto upload when Hermes is enabled ## 11.0.2 (2022-07-20) @@ -483,8 +373,7 @@ - Removes the deprecated APIs. Check the migration guide referenced in our docs - Removes Surveys.setThresholdForReshowingSurveyAfterDismiss - Removes the string keys: surveysCustomThanksTitle and surveysCustomThanksSubtitle -- Renames BugReporting.setAutoScreenRecordingMaxDuration to BugReporting.setAutoScreenRecordingDurationIOS to target iOS - only +- Renames BugReporting.setAutoScreenRecordingMaxDuration to BugReporting.setAutoScreenRecordingDurationIOS to target iOS only - Fixes an issue with the setRequestFilterExpression API not working with Hermes - Fixes an issue with the swipe invocation event not working on Android @@ -536,8 +425,7 @@ - Fixes crashes related to the network request data not being parsed correctly - Fixes issues related to the automatic sourcemap file upload on Android - Adds missing TypeScript definitions -- Deprecates Instabug.setVideoRecordingFloatingButtonPosition in favor of - BugReporting.setVideoRecordingFloatingButtonPosition +- Deprecates Instabug.setVideoRecordingFloatingButtonPosition in favor of BugReporting.setVideoRecordingFloatingButtonPosition - Includes native fix which removes the usage of android:requestLegacyExternalStorage permission - Various other bug fixes and improvements @@ -573,8 +461,7 @@ ## v9.1.6 (2020-07-16) - Fixes an issue that caused XHR Response not to be logged. -- Adds support for Repro Steps. Repro Steps list all of the actions an app user took before reporting a bug or crash, - grouped by the screens they visited in your app. +- Adds support for Repro Steps. Repro Steps list all of the actions an app user took before reporting a bug or crash, grouped by the screens they visited in your app. - Bump Native SDKs to v9.1.6 ## v9.1.1 (2020-04-06) @@ -630,8 +517,7 @@ ## v8.6.4 (2019-09-13) -- Fixes an issue on Android that would result in a build error with the message - `null is not an object (evaluating u.invocationEventNone)` +- Fixes an issue on Android that would result in a build error with the message `null is not an object (evaluating u.invocationEventNone)` ## v8.6.3 (2019-08-29) @@ -660,8 +546,7 @@ ## v8.5.4 (2019-08-10) -- Hot Fixes an issue with `Instabug.setFloatingButtonEdge` and `Instabug.setEnabledAttachmentTypes` causing the app to - crash. +- Hot Fixes an issue with `Instabug.setFloatingButtonEdge` and `Instabug.setEnabledAttachmentTypes` causing the app to crash. ## v8.5.3 (2019-08-08) @@ -681,8 +566,7 @@ ## v8.5.0 (2019-07-11) -**⚠️ If you are using React Native 0.60, please follow our migration -guide [here](https://github.com/Instabug/Instabug-React-Native/blob/master/README.md#updating-to-version-85)** +**⚠️ If you are using React Native 0.60, please follow our migration guide [here](https://github.com/Instabug/Instabug-React-Native/blob/master/README.md#updating-to-version-85)** - Support for React Native 0.60 - Updates native iOS and Android SDKs to version 8.5 From 307821135c1fa4433e6786565998a4999d77d358 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:28:42 +0300 Subject: [PATCH 14/40] feat: export upload utils (#1252) --- .gitignore | 2 + CHANGELOG.md | 2 +- cli/UploadSoFiles.ts | 88 ------------------------ cli/UploadSourcemaps.ts | 89 ------------------------ cli/commands/UploadSoFiles.ts | 38 +++++++++++ cli/commands/UploadSourcemaps.ts | 40 +++++++++++ cli/index.ts | 4 +- cli/upload/index.ts | 2 + cli/upload/uploadSoFiles.ts | 112 +++++++++++++++++++++++++++++++ cli/upload/uploadSourcemaps.ts | 73 ++++++++++++++++++++ rollup.config.js | 39 +++++++---- tsconfig.upload.json | 10 +++ upload/package.json | 5 ++ 13 files changed, 310 insertions(+), 194 deletions(-) delete mode 100755 cli/UploadSoFiles.ts delete mode 100755 cli/UploadSourcemaps.ts create mode 100755 cli/commands/UploadSoFiles.ts create mode 100755 cli/commands/UploadSourcemaps.ts create mode 100644 cli/upload/index.ts create mode 100755 cli/upload/uploadSoFiles.ts create mode 100644 cli/upload/uploadSourcemaps.ts create mode 100644 tsconfig.upload.json create mode 100644 upload/package.json diff --git a/.gitignore b/.gitignore index 50fb3439f9..4033aaa3b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Distribution dist/ bin/ +upload/* +!upload/package.json # NodeJS node_modules/ diff --git a/CHANGELOG.md b/CHANGELOG.md index d2540e03d1..1035a998d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- Enhance the network interceptor to capture some client error messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). +- Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)). ### Fixed diff --git a/cli/UploadSoFiles.ts b/cli/UploadSoFiles.ts deleted file mode 100755 index 6329f4d27f..0000000000 --- a/cli/UploadSoFiles.ts +++ /dev/null @@ -1,88 +0,0 @@ -import axios from 'axios'; -import { Command, Option } from 'commander'; -import FormData from 'form-data'; -import fs from 'fs'; - -interface UploadSoFilesOptions { - arch: 'x86' | 'x86_64' | 'arm64-v8a' | 'armeabi-v7a'; - file: string; - token: string; - name: string; - api_key: string; -} -/** - * This script uploads .so files to the specified endpoint used in NDK crash reporting. - * Usage: node upload-so-files.js --arch --file --api_key --token --name - */ - -export const UploadSoFilesCommand = new Command(); - -UploadSoFilesCommand.name('upload-so-files') - .addOption( - new Option('-arch, --arch ', 'arch') - .choices(['x86', 'x86_64', 'arm64-v8a', 'armeabi-v7a']) - .makeOptionMandatory(), - ) - .addOption( - new Option( - '-f, --file ', - 'The path of the symbol files in Zip format', - ).makeOptionMandatory(), - ) - .addOption(new Option('--api_key ', 'Your App key').makeOptionMandatory()) - .addOption( - new Option('-t, --token ', 'Your App Token') - .env('INSTABUG_APP_TOKEN') - .makeOptionMandatory(), - ) - .addOption( - new Option('-n, --name ', 'The app version name') - .env('INSTABUG_APP_VERSION_NAME') - .makeOptionMandatory(), - ) - .action(function (this: Command) { - const options = this.opts(); - UploadSoFiles(options); - }) - .showHelpAfterError(); - -const UploadSoFiles = async (opts: UploadSoFilesOptions) => { - const fileName = opts.file; - if (fileName == null) { - console.error('Failed to upload So Files: invalid file path'); - process.exit(1); - } - - if (fs.existsSync(fileName) === false) { - console.error('Failed to upload So Files: File not found'); - process.exit(1); - } - var fileExt = fileName.split('.').pop(); - - if (fileExt !== 'zip') { - console.error('Failed to upload So Files: You can only upload ZIP files'); - process.exit(1); - } - - const fileBlob = fs.readFileSync(opts.file); - - const form = new FormData(); - form.append('app_version', opts.name); - form.append('so_file', fileBlob, fileName); - form.append('application_token', opts.token); - form.append('api_key', opts.api_key); - form.append('arch', opts.arch); - - console.log('Uploading So files...'); - const uploadEndpoint = 'https://api.instabug.com/api/web/public/so_files'; - try { - await axios.post(uploadEndpoint, form, { - headers: form.getHeaders(), - }); - - console.log(`Successfully uploaded So Files for version: ${opts.name} with arch ${opts.arch}`); - } catch (err) { - console.error('Failed to upload So Files:', axios.isAxiosError(err) ? err.response?.data : err); - process.exit(1); - } -}; diff --git a/cli/UploadSourcemaps.ts b/cli/UploadSourcemaps.ts deleted file mode 100755 index 939629cb5f..0000000000 --- a/cli/UploadSourcemaps.ts +++ /dev/null @@ -1,89 +0,0 @@ -import axios from 'axios'; -import { Command, Option } from 'commander'; -import FormData from 'form-data'; -import fs from 'fs'; - -interface UploadSourcemapsOptions { - platform: 'android' | 'ios'; - file: string; - token: string; - name: string; - code: string; - label?: string; -} - -export const uploadSourcemapsCommand = new Command(); - -uploadSourcemapsCommand - .name('upload-sourcemaps') - .addOption( - new Option('-p, --platform ', 'Platform') - .choices(['ios', 'android']) - .makeOptionMandatory(), - ) - .addOption( - new Option('-f, --file ', 'The path of the source map file').makeOptionMandatory(), - ) - .addOption( - new Option('-t, --token ', 'Your App Token') - .env('INSTABUG_APP_TOKEN') - .makeOptionMandatory(), - ) - .addOption( - new Option('-n, --name ', 'The app version name') - .env('INSTABUG_APP_VERSION_NAME') - .makeOptionMandatory(), - ) - .addOption( - new Option('-c, --code ', 'The app version code') - .env('INSTABUG_APP_VERSION_CODE') - .makeOptionMandatory(), - ) - .addOption( - new Option('-l, --label ', "The CodePush label if it's a CodePush release").env( - 'INSTABUG_APP_VERSION_LABEL', - ), - ) - .action(function (this: Command) { - const options = this.opts(); - uploadSourcemaps(options); - }) - .showHelpAfterError(); - -const uploadSourcemaps = async (opts: UploadSourcemapsOptions) => { - const fileName = `${opts.platform}-sourcemap.json`; - const fileBlob = fs.readFileSync(opts.file); - - const version = { - code: opts.code, - name: opts.name, - codepush: opts.label, - }; - - const form = new FormData(); - form.append('app_version', JSON.stringify(version)); - form.append('symbols_file', fileBlob, fileName); - form.append('application_token', opts.token); - form.append('platform', 'react_native'); - form.append('os', opts.platform); - - console.log('Uploading Source map file...'); - - try { - const response = await axios.post('https://api.instabug.com/api/sdk/v3/symbols_files', form, { - headers: form.getHeaders(), - }); - - const appVersion = version.codepush - ? `${version.name} (${version.code})+codepush:${version.codepush}` - : `${version.name} (${version.code})`; - - console.log(`Successfully uploaded Source maps for version: ${appVersion}`); - console.log(response.data); - } catch (err) { - console.error( - 'Failed to upload source maps:', - axios.isAxiosError(err) ? err.response?.data : err, - ); - } -}; diff --git a/cli/commands/UploadSoFiles.ts b/cli/commands/UploadSoFiles.ts new file mode 100755 index 0000000000..99b23e3e4c --- /dev/null +++ b/cli/commands/UploadSoFiles.ts @@ -0,0 +1,38 @@ +import { Command, Option } from 'commander'; +import { uploadSoFiles, UploadSoFilesOptions } from '../upload/uploadSoFiles'; + +/** + * This script uploads .so files to the specified endpoint used in NDK crash reporting. + * Usage: node upload-so-files.js --arch --file --api_key --token --name + */ + +export const UploadSoFilesCommand = new Command(); + +UploadSoFilesCommand.name('upload-so-files') + .addOption( + new Option('-arch, --arch ', 'arch') + .choices(['x86', 'x86_64', 'arm64-v8a', 'armeabi-v7a']) + .makeOptionMandatory(), + ) + .addOption( + new Option( + '-f, --file ', + 'The path of the symbol files in Zip format', + ).makeOptionMandatory(), + ) + .addOption(new Option('--api_key ', 'Your App key').makeOptionMandatory()) + .addOption( + new Option('-t, --token ', 'Your App Token') + .env('INSTABUG_APP_TOKEN') + .makeOptionMandatory(), + ) + .addOption( + new Option('-n, --name ', 'The app version name') + .env('INSTABUG_APP_VERSION_NAME') + .makeOptionMandatory(), + ) + .action(function (this: Command) { + const options = this.opts(); + uploadSoFiles(options); + }) + .showHelpAfterError(); diff --git a/cli/commands/UploadSourcemaps.ts b/cli/commands/UploadSourcemaps.ts new file mode 100755 index 0000000000..5199693e77 --- /dev/null +++ b/cli/commands/UploadSourcemaps.ts @@ -0,0 +1,40 @@ +import { Command, Option } from 'commander'; +import { uploadSourcemaps, UploadSourcemapsOptions } from '../upload/uploadSourcemaps'; + +export const uploadSourcemapsCommand = new Command(); + +uploadSourcemapsCommand + .name('upload-sourcemaps') + .addOption( + new Option('-p, --platform ', 'Platform') + .choices(['ios', 'android']) + .makeOptionMandatory(), + ) + .addOption( + new Option('-f, --file ', 'The path of the source map file').makeOptionMandatory(), + ) + .addOption( + new Option('-t, --token ', 'Your App Token') + .env('INSTABUG_APP_TOKEN') + .makeOptionMandatory(), + ) + .addOption( + new Option('-n, --name ', 'The app version name') + .env('INSTABUG_APP_VERSION_NAME') + .makeOptionMandatory(), + ) + .addOption( + new Option('-c, --code ', 'The app version code') + .env('INSTABUG_APP_VERSION_CODE') + .makeOptionMandatory(), + ) + .addOption( + new Option('-l, --label ', "The CodePush label if it's a CodePush release").env( + 'INSTABUG_APP_VERSION_LABEL', + ), + ) + .action(function (this: Command) { + const options = this.opts(); + uploadSourcemaps(options); + }) + .showHelpAfterError(); diff --git a/cli/index.ts b/cli/index.ts index c1731d67a5..8df747e75e 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -1,8 +1,8 @@ #!/usr/bin/env node import { Command } from 'commander'; -import { uploadSourcemapsCommand } from './UploadSourcemaps'; -import { UploadSoFilesCommand } from './UploadSoFiles'; +import { uploadSourcemapsCommand } from './commands/UploadSourcemaps'; +import { UploadSoFilesCommand } from './commands/UploadSoFiles'; const program = new Command(); diff --git a/cli/upload/index.ts b/cli/upload/index.ts new file mode 100644 index 0000000000..b09f4b243b --- /dev/null +++ b/cli/upload/index.ts @@ -0,0 +1,2 @@ +export * from './uploadSourcemaps'; +export * from './uploadSoFiles'; diff --git a/cli/upload/uploadSoFiles.ts b/cli/upload/uploadSoFiles.ts new file mode 100755 index 0000000000..fb25f60632 --- /dev/null +++ b/cli/upload/uploadSoFiles.ts @@ -0,0 +1,112 @@ +import axios from 'axios'; +import FormData from 'form-data'; +import fs from 'fs'; + +export interface UploadSoFilesOptions { + arch: 'x86' | 'x86_64' | 'arm64-v8a' | 'armeabi-v7a'; + file: string; + token: string; + name: string; + api_key: string; + + /** + * Disables logging to the console and prevents process exit on error. + * + * @default false + * */ + silent?: boolean; +} + +/** + * Uploads NDK `.so` files to Instabug. + * + * @param opts Options for the `.so` files upload process. + * @returns A promise that resolves to a boolean indicating whether the upload was successful. + */ +export const uploadSoFiles = async (opts: UploadSoFilesOptions): Promise => { + const fileName = opts.file; + + const validFilePath = assert( + fileName != null, + 'Failed to upload So Files: invalid file path', + opts.silent, + ); + + if (!validFilePath) { + return false; + } + + const fileExists = assert( + fs.existsSync(fileName), + 'Failed to upload So Files: File not found', + opts.silent, + ); + + if (!fileExists) { + return false; + } + + const fileExt = fileName.split('.').pop(); + + const isZipFile = assert( + fileExt === 'zip', + 'Failed to upload So Files: You can only upload ZIP files', + opts.silent, + ); + + if (!isZipFile) { + return false; + } + + const fileBlob = fs.readFileSync(opts.file); + + const form = new FormData(); + form.append('app_version', opts.name); + form.append('so_file', fileBlob, fileName); + form.append('application_token', opts.token); + form.append('api_key', opts.api_key); + form.append('arch', opts.arch); + + if (!opts.silent) { + console.log('Uploading So files...'); + } + + const uploadEndpoint = 'https://api.instabug.com/api/web/public/so_files'; + try { + await axios.post(uploadEndpoint, form, { + headers: form.getHeaders(), + }); + + if (!opts.silent) { + console.log( + `Successfully uploaded So Files for version: ${opts.name} with arch ${opts.arch}`, + ); + } + + return true; + } catch (err) { + if (!opts.silent) { + console.error( + 'Failed to upload So Files:', + axios.isAxiosError(err) ? err.response?.data : err, + ); + + process.exit(1); + } + + return false; + } +}; + +export const assert = (condition: unknown, message: string, silent?: boolean): boolean => { + if (silent) { + return Boolean(condition); + } + + if (!condition) { + console.error(message); + process.exit(1); + } + + return true; +}; diff --git a/cli/upload/uploadSourcemaps.ts b/cli/upload/uploadSourcemaps.ts new file mode 100644 index 0000000000..701ce9ead8 --- /dev/null +++ b/cli/upload/uploadSourcemaps.ts @@ -0,0 +1,73 @@ +import axios from 'axios'; +import FormData from 'form-data'; +import fs from 'fs'; + +export interface UploadSourcemapsOptions { + platform: 'android' | 'ios'; + file: string; + token: string; + name: string; + code: string; + label?: string; + + /** + * Disables logging to the console and prevents process exit on error. + * + * @default false + * */ + silent?: boolean; +} + +/** + * Uploads JavaScript sourcemaps to Instabug. + * + * @param opts Options for the sourcemaps upload process. + * @returns A promise that resolves to a boolean indicating whether the upload was successful. + */ +export const uploadSourcemaps = async (opts: UploadSourcemapsOptions): Promise => { + const fileName = `${opts.platform}-sourcemap.json`; + const fileBlob = fs.readFileSync(opts.file); + + const version = { + code: opts.code, + name: opts.name, + codepush: opts.label, + }; + + const form = new FormData(); + form.append('app_version', JSON.stringify(version)); + form.append('symbols_file', fileBlob, fileName); + form.append('application_token', opts.token); + form.append('platform', 'react_native'); + form.append('os', opts.platform); + + if (!opts.silent) { + console.log('Uploading Source map file...'); + } + + try { + const response = await axios.post('https://api.instabug.com/api/sdk/v3/symbols_files', form, { + headers: form.getHeaders(), + }); + + const appVersion = version.codepush + ? `${version.name} (${version.code})+codepush:${version.codepush}` + : `${version.name} (${version.code})`; + + if (!opts.silent) { + console.log(`Successfully uploaded Source maps for version: ${appVersion}`); + console.log(response.data); + } + + return true; + } catch (err) { + if (!opts.silent) { + console.error( + 'Failed to upload source maps:', + axios.isAxiosError(err) ? err.response?.data : err, + ); + } + + return false; + } +}; diff --git a/rollup.config.js b/rollup.config.js index 9b3068d89e..ae91a89060 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,19 +5,30 @@ import typescript from '@rollup/plugin-typescript'; import cleanup from 'rollup-plugin-cleanup'; import shebang from 'rollup-plugin-preserve-shebang'; +const commonPlugins = [ + shebang(), + json(), + nodeResolve({ preferBuiltins: true }), + commonjs(), + cleanup(), +]; + /** @type import('rollup').RollupOptions */ -export default { - input: ['cli/index.ts'], - output: { - dir: 'bin', - format: 'cjs', +export default [ + { + input: ['cli/index.ts'], + output: { + dir: 'bin', + format: 'cjs', + }, + plugins: [...commonPlugins, typescript({ tsconfig: './tsconfig.cli.json' })], + }, + { + input: ['cli/upload/index.ts'], + output: { + dir: 'upload', + format: 'cjs', + }, + plugins: [...commonPlugins, typescript({ tsconfig: './tsconfig.upload.json' })], }, - plugins: [ - typescript({ tsconfig: './tsconfig.cli.json' }), - shebang(), - json(), - nodeResolve({ preferBuiltins: true }), - commonjs(), - cleanup(), - ], -}; +]; diff --git a/tsconfig.upload.json b/tsconfig.upload.json new file mode 100644 index 0000000000..5ade7ea9a7 --- /dev/null +++ b/tsconfig.upload.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "include": ["cli/upload/**/*"], + "exclude": [], + "compilerOptions": { + "lib": ["dom"], + "outDir": "upload", + "module": "esnext" + } +} diff --git a/upload/package.json b/upload/package.json new file mode 100644 index 0000000000..778c7ebf51 --- /dev/null +++ b/upload/package.json @@ -0,0 +1,5 @@ +{ + "main": "index.js", + "module": "index.mjs", + "types": "index.d.ts" +} From 6eaf49616363ab95577c0b11bb31b8a6108c7e36 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:50:42 +0300 Subject: [PATCH 15/40] chore(example): remove flipper (#1259) --- android/src/main/AndroidManifest.xml | 2 +- examples/default/android/app/build.gradle | 6 - .../react/example/ReactNativeFlipper.java | 75 ------------ .../react/example/MainApplication.java | 1 - .../instabugexample/ReactNativeFlipper.java | 20 ---- examples/default/android/gradle.properties | 3 - examples/default/ios/Podfile | 16 --- examples/default/ios/Podfile.lock | 108 +----------------- 8 files changed, 2 insertions(+), 229 deletions(-) delete mode 100644 examples/default/android/app/src/debug/java/com/instabug/react/example/ReactNativeFlipper.java delete mode 100644 examples/default/android/app/src/release/java/com/instabugexample/ReactNativeFlipper.java diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 44ad85bcd7..9af27fbd31 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - diff --git a/examples/default/android/app/build.gradle b/examples/default/android/app/build.gradle index f556607edc..c3d5374954 100644 --- a/examples/default/android/app/build.gradle +++ b/examples/default/android/app/build.gradle @@ -171,12 +171,6 @@ dependencies { implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") - debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") - debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { - exclude group:'com.squareup.okhttp3', module:'okhttp' - } - - debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { diff --git a/examples/default/android/app/src/debug/java/com/instabug/react/example/ReactNativeFlipper.java b/examples/default/android/app/src/debug/java/com/instabug/react/example/ReactNativeFlipper.java deleted file mode 100644 index a769aa68fc..0000000000 --- a/examples/default/android/app/src/debug/java/com/instabug/react/example/ReactNativeFlipper.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - *

This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. - */ -package com.instabug.react.example; - -import android.content.Context; -import com.facebook.flipper.android.AndroidFlipperClient; -import com.facebook.flipper.android.utils.FlipperUtils; -import com.facebook.flipper.core.FlipperClient; -import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; -import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; -import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; -import com.facebook.flipper.plugins.inspector.DescriptorMapping; -import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; -import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; -import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; -import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; -import com.facebook.react.ReactInstanceEventListener; -import com.facebook.react.ReactInstanceManager; -import com.facebook.react.bridge.ReactContext; -import com.facebook.react.modules.network.NetworkingModule; -import okhttp3.OkHttpClient; - -/** - * Class responsible of loading Flipper inside your React Native application. This is the debug - * flavor of it. Here you can add your own plugins and customize the Flipper setup. - */ -public class ReactNativeFlipper { - public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { - if (FlipperUtils.shouldEnableFlipper(context)) { - final FlipperClient client = AndroidFlipperClient.getInstance(context); - - client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); - client.addPlugin(new DatabasesFlipperPlugin(context)); - client.addPlugin(new SharedPreferencesFlipperPlugin(context)); - client.addPlugin(CrashReporterPlugin.getInstance()); - - NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); - NetworkingModule.setCustomClientBuilder( - new NetworkingModule.CustomClientBuilder() { - @Override - public void apply(OkHttpClient.Builder builder) { - builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); - } - }); - client.addPlugin(networkFlipperPlugin); - client.start(); - - // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized - // Hence we run if after all native modules have been initialized - ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); - if (reactContext == null) { - reactInstanceManager.addReactInstanceEventListener( - new ReactInstanceEventListener() { - @Override - public void onReactContextInitialized(ReactContext reactContext) { - reactInstanceManager.removeReactInstanceEventListener(this); - reactContext.runOnNativeModulesQueueThread( - new Runnable() { - @Override - public void run() { - client.addPlugin(new FrescoFlipperPlugin()); - } - }); - } - }); - } else { - client.addPlugin(new FrescoFlipperPlugin()); - } - } - } -} diff --git a/examples/default/android/app/src/main/java/com/instabug/react/example/MainApplication.java b/examples/default/android/app/src/main/java/com/instabug/react/example/MainApplication.java index a988f0a841..a5b32db53f 100644 --- a/examples/default/android/app/src/main/java/com/instabug/react/example/MainApplication.java +++ b/examples/default/android/app/src/main/java/com/instabug/react/example/MainApplication.java @@ -56,6 +56,5 @@ public void onCreate() { // If you opted-in for the New Architecture, we load the native entry point for this app. DefaultNewArchitectureEntryPoint.load(); } - ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } } diff --git a/examples/default/android/app/src/release/java/com/instabugexample/ReactNativeFlipper.java b/examples/default/android/app/src/release/java/com/instabugexample/ReactNativeFlipper.java deleted file mode 100644 index 34e4708ab0..0000000000 --- a/examples/default/android/app/src/release/java/com/instabugexample/ReactNativeFlipper.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - *

This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. - */ -package com.instabug.react.example; - -import android.content.Context; -import com.facebook.react.ReactInstanceManager; - -/** - * Class responsible of loading Flipper inside your React Native application. This is the release - * flavor of it so it's empty as we don't want to load Flipper. - */ -public class ReactNativeFlipper { - public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { - // Do nothing as we don't want to initialize Flipper on Release. - } -} diff --git a/examples/default/android/gradle.properties b/examples/default/android/gradle.properties index d1a632d51f..6a35482a52 100644 --- a/examples/default/android/gradle.properties +++ b/examples/default/android/gradle.properties @@ -24,9 +24,6 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true -# Version of flipper SDK to use with React Native -FLIPPER_VERSION=0.182.0 - # Use this property to specify which architecture you want to build. # You can also override it from the CLI using # ./gradlew -PreactNativeArchitectures=x86_64 diff --git a/examples/default/ios/Podfile b/examples/default/ios/Podfile index 7fa5129f99..3d0c8ceedb 100644 --- a/examples/default/ios/Podfile +++ b/examples/default/ios/Podfile @@ -5,17 +5,6 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ platform :ios, '13.4' prepare_react_native_project! -# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. -# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded -# -# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` -# ```js -# module.exports = { -# dependencies: { -# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), -# ``` -flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled - linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green @@ -36,11 +25,6 @@ target 'InstabugExample' do # we make it explicit here to aid in the React Native upgrade process. :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], - # Enables Flipper. - # - # Note that if you have use_frameworks! enabled, Flipper will not work and - # you should disable the next line. - :flipper_configuration => flipper_config, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock index dcaa1c6971..543a31b57a 100644 --- a/examples/default/ios/Podfile.lock +++ b/examples/default/ios/Podfile.lock @@ -1,6 +1,5 @@ PODS: - boost (1.76.0) - - CocoaAsyncSocket (7.6.5) - DoubleConversion (1.1.6) - FBLazyVector (0.72.3) - FBReactNativeSpec (0.72.3): @@ -10,64 +9,6 @@ PODS: - React-Core (= 0.72.3) - React-jsi (= 0.72.3) - ReactCommon/turbomodule/core (= 0.72.3) - - Flipper (0.182.0): - - Flipper-Folly (~> 2.6) - - Flipper-Boost-iOSX (1.76.0.1.11) - - Flipper-DoubleConversion (3.2.0.1) - - Flipper-Fmt (7.1.7) - - Flipper-Folly (2.6.10): - - Flipper-Boost-iOSX - - Flipper-DoubleConversion - - Flipper-Fmt (= 7.1.7) - - Flipper-Glog - - libevent (~> 2.1.12) - - OpenSSL-Universal (= 1.1.1100) - - Flipper-Glog (0.5.0.5) - - Flipper-PeerTalk (0.0.4) - - FlipperKit (0.182.0): - - FlipperKit/Core (= 0.182.0) - - FlipperKit/Core (0.182.0): - - Flipper (~> 0.182.0) - - FlipperKit/CppBridge - - FlipperKit/FBCxxFollyDynamicConvert - - FlipperKit/FBDefines - - FlipperKit/FKPortForwarding - - SocketRocket (~> 0.6.0) - - FlipperKit/CppBridge (0.182.0): - - Flipper (~> 0.182.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.182.0): - - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.182.0) - - FlipperKit/FKPortForwarding (0.182.0): - - CocoaAsyncSocket (~> 7.6) - - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.182.0) - - FlipperKit/FlipperKitLayoutHelpers (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay - - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay - - FlipperKit/FlipperKitLayoutHelpers - - YogaKit (~> 1.18) - - FlipperKit/FlipperKitLayoutPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay - - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutIOSDescriptors - - FlipperKit/FlipperKitLayoutTextSearchable - - YogaKit (~> 1.18) - - FlipperKit/FlipperKitLayoutTextSearchable (0.182.0) - - FlipperKit/FlipperKitNetworkPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitNetworkPlugin - fmt (6.2.1) - glog (0.3.5) - Google-Maps-iOS-Utils (4.2.2): @@ -103,7 +44,6 @@ PODS: - React-Core - libevent (2.1.12) - OCMock (3.9.3) - - OpenSSL-Universal (1.1.1100) - RCT-Folly (2021.07.22.00): - boost - DoubleConversion @@ -576,40 +516,17 @@ PODS: - React-Core - SocketRocket (0.6.1) - Yoga (1.14.0) - - YogaKit (1.18.1): - - Yoga (~> 1.14) DEPENDENCIES: - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) - - Flipper (= 0.182.0) - - Flipper-Boost-iOSX (= 1.76.0.1.11) - - Flipper-DoubleConversion (= 3.2.0.1) - - Flipper-Fmt (= 7.1.7) - - Flipper-Folly (= 2.6.10) - - Flipper-Glog (= 0.5.0.5) - - Flipper-PeerTalk (= 0.0.4) - - FlipperKit (= 0.182.0) - - FlipperKit/Core (= 0.182.0) - - FlipperKit/CppBridge (= 0.182.0) - - FlipperKit/FBCxxFollyDynamicConvert (= 0.182.0) - - FlipperKit/FBDefines (= 0.182.0) - - FlipperKit/FKPortForwarding (= 0.182.0) - - FlipperKit/FlipperKitHighlightOverlay (= 0.182.0) - - FlipperKit/FlipperKitLayoutPlugin (= 0.182.0) - - FlipperKit/FlipperKitLayoutTextSearchable (= 0.182.0) - - FlipperKit/FlipperKitNetworkPlugin (= 0.182.0) - - FlipperKit/FlipperKitReactPlugin (= 0.182.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.182.0) - - FlipperKit/SKIOSNetworkPlugin (= 0.182.0) - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) - hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) - instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`) - libevent (~> 2.1.12) - OCMock - - OpenSSL-Universal (= 1.1.1100) - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) @@ -617,7 +534,6 @@ DEPENDENCIES: - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) - React-Codegen (from `build/generated/ios`) - React-Core (from `../node_modules/react-native/`) - - React-Core/DevSupport (from `../node_modules/react-native/`) - React-Core/RCTWebSocket (from `../node_modules/react-native/`) - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) @@ -661,24 +577,13 @@ DEPENDENCIES: SPEC REPOS: trunk: - - CocoaAsyncSocket - - Flipper - - Flipper-Boost-iOSX - - Flipper-DoubleConversion - - Flipper-Fmt - - Flipper-Folly - - Flipper-Glog - - Flipper-PeerTalk - - FlipperKit - fmt - Google-Maps-iOS-Utils - GoogleMaps - Instabug - libevent - OCMock - - OpenSSL-Universal - SocketRocket - - YogaKit EXTERNAL SOURCES: boost: @@ -791,18 +696,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: 7dcd2de282d72e344012f7d6564d024930a6a440 - CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: 4cce221dd782d3ff7c4172167bba09d58af67ccb FBReactNativeSpec: c6bd9e179757b3c0ecf815864fae8032377903ef - Flipper: 6edb735e6c3e332975d1b17956bcc584eccf5818 - Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c - Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 - Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b - Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 - Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 - Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: 2efad7007d6745a3f95e4034d547be637f89d3f6 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a @@ -812,7 +708,6 @@ SPEC CHECKSUMS: instabug-reactnative-ndk: 960119a69380cf4cbe47ccd007c453f757927d17 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OCMock: 300b1b1b9155cb6378660b981c2557448830bdc6 - OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: a2faf4bad4e438ca37b2040cb8f7799baa065c18 RCTTypeSafety: cb09f3e4747b6d18331a15eb05271de7441ca0b3 @@ -860,8 +755,7 @@ SPEC CHECKSUMS: RNVectorIcons: 8b5bb0fa61d54cd2020af4f24a51841ce365c7e9 SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce - YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: ad82a989387dcdb1ce80667f16b998a2644cf0b2 +PODFILE CHECKSUM: 281036e04bd4b9e7c2cc03a503b3245d3f1dd0dd COCOAPODS: 1.12.0 From f2197b8b90ad55b7367b873e565674189874b79c Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Thu, 1 Aug 2024 15:40:53 +0300 Subject: [PATCH 16/40] fix: Pr comments --- src/utils/XhrNetworkInterceptor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index 283c036d2f..1039b59216 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -152,7 +152,7 @@ export default { const _response = this._response; // Detect a more descriptive error message. if (typeof _response === 'string' && _response.length > 0) { - cloneNetwork.errorDomain = _response; + cloneNetwork.errorDomain = _response.replaceAll(' ', '-'); } // @ts-ignore From 79afb4bde6393e35c1b2b3a1c5dc7f34d2308ba8 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:58:56 +0300 Subject: [PATCH 17/40] fix(android): resolve an OOM in network logs (#1244) --- CHANGELOG.md | 5 --- .../reactlibrary/RNInstabugAPMModule.java | 42 +++++++++---------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1035a998d0..7ec9aad5b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,8 @@ ## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...dev) -### Added - -- Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)). - ### Fixed -- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). - Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)). ## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java index 70487f8cc5..7ffaf4de73 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java @@ -14,7 +14,6 @@ import com.instabug.apm.APM; import com.instabug.apm.model.ExecutionTrace; import com.instabug.apm.networking.APMNetworkLogger; -import com.instabug.apm.networkinterception.cp.APMCPNetworkLog; import com.instabug.reactlibrary.utils.MainThreadHandler; import org.json.JSONException; @@ -339,28 +338,27 @@ private void networkLogAndroid(final double requestStartTime, final String errorMessage = hasError ? errorDomain : null; try { - Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class, APMCPNetworkLog.W3CExternalTraceAttributes.class); + Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class); if (method != null) { - method.invoke( - networkLogger, - (long) requestStartTime, - (long) requestDuration, - requestHeaders, - requestBody, - (long) requestBodySize, - requestMethod, - requestUrl, - requestContentType, - responseHeaders, - responseBody, - (long)responseBodySize, - (int) statusCode, - responseContentType, - errorMessage, - gqlQueryName, - serverErrorMessage, - null - ); + method.invoke( + networkLogger, + requestStartTime, + requestDuration, + requestHeaders, + requestBody, + requestBodySize, + requestMethod, + requestUrl, + requestContentType, + responseHeaders, + responseBody, + responseBodySize, + statusCode, + responseContentType, + errorMessage, + gqlQueryName, + serverErrorMessage + ); } else { Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection"); } From 61274de6b91074a4fb27528f27d5c1d2d4f21b8b Mon Sep 17 00:00:00 2001 From: kholood Date: Tue, 23 Jul 2024 10:15:55 +0300 Subject: [PATCH 18/40] fix(android): APM network logging(#1253) * fix(android): add W3C External Trace Attributes placeholder * chore: add CHANGLOG * chore: add CHANGLOG * fix: remove ios sub module --- CHANGELOG.md | 1 + .../reactlibrary/RNInstabugAPMModule.java | 42 ++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ec9aad5b6..4221fa8a26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixed +- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). - Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)). ## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java index 7ffaf4de73..70487f8cc5 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java @@ -14,6 +14,7 @@ import com.instabug.apm.APM; import com.instabug.apm.model.ExecutionTrace; import com.instabug.apm.networking.APMNetworkLogger; +import com.instabug.apm.networkinterception.cp.APMCPNetworkLog; import com.instabug.reactlibrary.utils.MainThreadHandler; import org.json.JSONException; @@ -338,27 +339,28 @@ private void networkLogAndroid(final double requestStartTime, final String errorMessage = hasError ? errorDomain : null; try { - Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class); + Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class, APMCPNetworkLog.W3CExternalTraceAttributes.class); if (method != null) { - method.invoke( - networkLogger, - requestStartTime, - requestDuration, - requestHeaders, - requestBody, - requestBodySize, - requestMethod, - requestUrl, - requestContentType, - responseHeaders, - responseBody, - responseBodySize, - statusCode, - responseContentType, - errorMessage, - gqlQueryName, - serverErrorMessage - ); + method.invoke( + networkLogger, + (long) requestStartTime, + (long) requestDuration, + requestHeaders, + requestBody, + (long) requestBodySize, + requestMethod, + requestUrl, + requestContentType, + responseHeaders, + responseBody, + (long)responseBodySize, + (int) statusCode, + responseContentType, + errorMessage, + gqlQueryName, + serverErrorMessage, + null + ); } else { Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection"); } From 36c9974f17c3f25fc3e3df80b1ac3eb04fc24704 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:28:42 +0300 Subject: [PATCH 19/40] feat: export upload utils (#1252) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4221fa8a26..1035a998d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...dev) +### Added + +- Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)). + ### Fixed - Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). From 8677585488cad06b64cb1cb39ad441574f321f7e Mon Sep 17 00:00:00 2001 From: ahmed alaa <154802748+ahmedAlaaInstabug@users.noreply.github.com> Date: Fri, 2 Aug 2024 10:54:38 +0300 Subject: [PATCH 20/40] fix(android): pass network start time in microseconds (#1260) * fix: network timestamp in android side * fix: PR comments Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> --------- Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> --- .../java/com/instabug/reactlibrary/RNInstabugAPMModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java index 70487f8cc5..e2ff10b991 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java @@ -343,7 +343,7 @@ private void networkLogAndroid(final double requestStartTime, if (method != null) { method.invoke( networkLogger, - (long) requestStartTime, + (long) requestStartTime * 1000, (long) requestDuration, requestHeaders, requestBody, From b638d12db1f9ead92b823a6617d8d9ad04d2c600 Mon Sep 17 00:00:00 2001 From: ahmed alaa <154802748+ahmedAlaaInstabug@users.noreply.github.com> Date: Fri, 2 Aug 2024 19:07:10 +0300 Subject: [PATCH 21/40] feat: support feature flags with variants (#1230) Jira ID: MOB-14684 --------- Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> --- CHANGELOG.md | 5 ++ .../RNInstabugReactnativeModule.java | 66 ++++++++++++++++ .../RNInstabugReactnativeModuleTest.java | 54 ++++++++++++- .../ios/InstabugTests/InstabugSampleTests.m | 45 ++++++++++- .../default/src/screens/SettingsScreen.tsx | 76 +++++++++++++++++++ ios/RNInstabug/InstabugReactBridge.h | 4 +- ios/RNInstabug/InstabugReactBridge.m | 32 ++++++++ src/models/FeatureFlag.ts | 12 +++ src/modules/Instabug.ts | 47 ++++++++++++ src/native/NativeInstabug.ts | 6 ++ test/mocks/mockInstabug.ts | 3 + test/modules/Instabug.spec.ts | 52 +++++++++++++ 12 files changed, 396 insertions(+), 6 deletions(-) create mode 100644 src/models/FeatureFlag.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 1035a998d0..f277b26077 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,13 @@ ### Added +- Add support for Feature Flags APIs `Instabug.addFeatureFlags`, `Instabug.removeFeatureFlags` and `Instabug.clearAllFeatureFlags` ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)). - Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)). +### Deprecated + +- Deprecate Experiments APIs `Instabug.addExperiments`, `Instabug.removeExperiments` and `Instabug.clearAllExperiments` in favor of the new Feature Flags APIs ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)). + ### Fixed - Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 7d14656089..f936eaa12e 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -16,6 +16,7 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeArray; @@ -29,6 +30,7 @@ import com.instabug.library.LogLevel; import com.instabug.library.ReproConfigurations; import com.instabug.library.core.InstabugCore; +import com.instabug.library.featuresflags.model.IBGFeatureFlag; import com.instabug.library.internal.module.InstabugLocale; import com.instabug.library.invocation.InstabugInvocationEvent; import com.instabug.library.logging.InstabugLog; @@ -41,6 +43,7 @@ import com.instabug.reactlibrary.utils.MainThreadHandler; import com.instabug.reactlibrary.utils.RNTouchedViewExtractor; + import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; @@ -50,6 +53,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -1023,6 +1027,9 @@ public void run() { }); } + /** + * @deprecated see {@link #addFeatureFlags(ReadableArray)} + */ @ReactMethod public void addExperiments(final ReadableArray experiments) { MainThreadHandler.runOnMainThread(new Runnable() { @@ -1039,6 +1046,9 @@ public void run() { }); } + /** + * @deprecated see {@link #removeFeatureFlags(ReadableArray)} + */ @ReactMethod public void removeExperiments(final ReadableArray experiments) { MainThreadHandler.runOnMainThread(new Runnable() { @@ -1055,6 +1065,9 @@ public void run() { }); } + /** + * @deprecated see {@link #removeAllFeatureFlags()} + */ @ReactMethod public void clearAllExperiments() { MainThreadHandler.runOnMainThread(new Runnable() { @@ -1069,6 +1082,59 @@ public void run() { }); } + @ReactMethod + public void addFeatureFlags(final ReadableMap featureFlagsMap) { + MainThreadHandler.runOnMainThread(new Runnable() { + @Override + public void run() { + try { + Iterator> iterator = featureFlagsMap.getEntryIterator(); + ArrayList featureFlags = new ArrayList<>(); + while (iterator.hasNext()) { + Map.Entry item = iterator.next(); + String variant = (String) item.getValue(); + String name = item.getKey(); + featureFlags.add(new IBGFeatureFlag(name, variant.isEmpty() ? null : variant)); + } + if (!featureFlags.isEmpty()) { + Instabug.addFeatureFlags(featureFlags); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + @ReactMethod + public void removeFeatureFlags(final ReadableArray featureFlags) { + MainThreadHandler.runOnMainThread(new Runnable() { + @Override + public void run() { + try { + ArrayList stringArray = ArrayUtil.parseReadableArrayOfStrings(featureFlags); + Instabug.removeFeatureFlag(stringArray); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + @ReactMethod + public void removeAllFeatureFlags() { + MainThreadHandler.runOnMainThread(new Runnable() { + @Override + public void run() { + try { + Instabug.removeAllFeatureFlags(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + @ReactMethod public void willRedirectToStore() { MainThreadHandler.runOnMainThread(new Runnable() { diff --git a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java index beee65c4bf..b9bf2308cc 100644 --- a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java +++ b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java @@ -18,6 +18,7 @@ import com.instabug.library.IssueType; import com.instabug.library.ReproConfigurations; import com.instabug.library.ReproMode; +import com.instabug.library.featuresflags.model.IBGFeatureFlag; import com.instabug.library.internal.module.InstabugLocale; import com.instabug.library.ui.onboarding.WelcomeMessage; import com.instabug.reactlibrary.utils.MainThreadHandler; @@ -38,6 +39,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -567,8 +569,6 @@ public void testIdentifyUserWithId() { @Test public void given$clearAllExperiments_whenQuery_thenShouldCallNativeApi() { - // given - // when rnModule.clearAllExperiments(); @@ -577,6 +577,56 @@ public void testIdentifyUserWithId() { Instabug.clearAllExperiments(); } + @Test + public void testAddFeatureFlags() { + // given + JavaOnlyMap map = new JavaOnlyMap(); + map.putString("key1", "value1"); + map.putString("key2", "value2"); + + // when + rnModule.addFeatureFlags(map); + + // then + Iterator> iterator = map.getEntryIterator(); + ArrayList featureFlags = new ArrayList<>(); + while (iterator.hasNext()) { + Map.Entry item = iterator.next(); + featureFlags.add(new IBGFeatureFlag(item.getKey(), (String) item.getValue())); + } + + mockInstabug.verify(() -> Instabug.addFeatureFlags(featureFlags)); + + } + + @Test + public void testRemoveFeatureFlags() { + // given + JavaOnlyArray array = new JavaOnlyArray(); + array.pushString("exp1"); + array.pushString("exp2"); + + // when + rnModule.removeFeatureFlags(array); + + // then + List expectedList = new ArrayList(); + for (Object o : array.toArrayList()) { + expectedList.add((String) o); + } + mockInstabug.verify(() -> Instabug.removeFeatureFlag(expectedList)); + + } + + @Test + public void testRemoveAllFeatureFlags() { + // when + rnModule.removeAllFeatureFlags(); + + // then + mockInstabug.verify(() -> Instabug.removeAllFeatureFlags()); + } + @Test public void testWillRedirectToStore() { // when diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m index 37990b450c..565a21b1a7 100644 --- a/examples/default/ios/InstabugTests/InstabugSampleTests.m +++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m @@ -73,7 +73,7 @@ - (void)testInit { NSArray *invocationEvents = [NSArray arrayWithObjects:[NSNumber numberWithInteger:floatingButtonInvocationEvent], nil]; BOOL useNativeNetworkInterception = YES; IBGSDKDebugLogsLevel sdkDebugLogsLevel = IBGSDKDebugLogsLevelDebug; - + OCMStub([mock setCodePushVersion:codePushVersion]); [self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion]; @@ -85,9 +85,9 @@ - (void)testInit { - (void)testSetCodePushVersion { id mock = OCMClassMock([Instabug class]); NSString *codePushVersion = @"123"; - + [self.instabugBridge setCodePushVersion:codePushVersion]; - + OCMVerify([mock setCodePushVersion:codePushVersion]); } @@ -498,4 +498,43 @@ - (void)testClearAllExperiments { OCMVerify([mock clearAllExperiments]); } +- (void)testAddFeatureFlags { + id mock = OCMClassMock([Instabug class]); + NSDictionary *featureFlagsMap = @{ @"key13" : @"value1", @"key2" : @"value2"}; + + OCMStub([mock addFeatureFlags :[OCMArg any]]); + [self.instabugBridge addFeatureFlags:featureFlagsMap]; + OCMVerify([mock addFeatureFlags: [OCMArg checkWithBlock:^(id value) { + NSArray *featureFlags = value; + NSString* firstFeatureFlagName = [featureFlags objectAtIndex:0 ].name; + NSString* firstFeatureFlagKey = [[featureFlagsMap allKeys] objectAtIndex:0] ; + if([ firstFeatureFlagKey isEqualToString: firstFeatureFlagName]){ + return YES; + } + return NO; + }]]); +} + +- (void)testRemoveFeatureFlags { + id mock = OCMClassMock([Instabug class]); + NSArray *featureFlags = @[@"exp1", @"exp2"]; + [self.instabugBridge removeFeatureFlags:featureFlags]; + OCMVerify([mock removeFeatureFlags: [OCMArg checkWithBlock:^(id value) { + NSArray *featureFlagsObJ = value; + NSString* firstFeatureFlagName = [featureFlagsObJ objectAtIndex:0 ].name; + NSString* firstFeatureFlagKey = [featureFlags firstObject] ; + if([ firstFeatureFlagKey isEqualToString: firstFeatureFlagName]){ + return YES; + } + return NO; + }]]); +} + +- (void)testRemoveAllFeatureFlags { + id mock = OCMClassMock([Instabug class]); + OCMStub([mock removeAllFeatureFlags]); + [self.instabugBridge removeAllFeatureFlags]; + OCMVerify([mock removeAllFeatureFlags]); +} + @end diff --git a/examples/default/src/screens/SettingsScreen.tsx b/examples/default/src/screens/SettingsScreen.tsx index 618de54a22..6390bb7a0a 100644 --- a/examples/default/src/screens/SettingsScreen.tsx +++ b/examples/default/src/screens/SettingsScreen.tsx @@ -17,8 +17,12 @@ export const SettingsScreen: React.FC = () => { const [userID, setUserID] = useState(''); const [userAttributeKey, setUserAttributeKey] = useState(''); const [userAttributeValue, setUserAttributeValue] = useState(''); + const [featureFlagName, setFeatureFlagName] = useState(''); + const [featureFlagVariant, setfeatureFlagVariant] = useState(''); + const toast = useToast(); const [userAttributesFormError, setUserAttributesFormError] = useState({}); + const [featureFlagFormError, setFeatureFlagFormError] = useState({}); const validateUserAttributeForm = () => { const errors: any = {}; @@ -31,6 +35,15 @@ export const SettingsScreen: React.FC = () => { setUserAttributesFormError(errors); return Object.keys(errors).length === 0; }; + const validateFeatureFlagForm = () => { + const errors: any = {}; + if (featureFlagName.length === 0) { + errors.featureFlagName = 'Value is required'; + } + setFeatureFlagFormError(errors); + return Object.keys(errors).length === 0; + }; + const styles = StyleSheet.create({ inputWrapper: { padding: 4, @@ -60,6 +73,37 @@ export const SettingsScreen: React.FC = () => { setUserAttributeValue(''); } }; + const saveFeatureFlags = () => { + if (validateFeatureFlagForm()) { + Instabug.addFeatureFlag({ + name: featureFlagName, + variant: featureFlagVariant, + }); + toast.show({ + description: 'Feature Flag added successfully', + }); + setFeatureFlagName(''); + setfeatureFlagVariant(''); + } + }; + const removeFeatureFlags = () => { + if (validateFeatureFlagForm()) { + Instabug.removeFeatureFlag(featureFlagName); + toast.show({ + description: 'Feature Flag removed successfully', + }); + setFeatureFlagName(''); + setfeatureFlagVariant(''); + } + }; + const removeAllFeatureFlags = () => { + Instabug.removeAllFeatureFlags(); + toast.show({ + description: 'Feature Flags removed successfully', + }); + setFeatureFlagName(''); + setfeatureFlagVariant(''); + }; const logout = () => { Instabug.logOut(); @@ -215,6 +259,38 @@ export const SettingsScreen: React.FC = () => { + + + + + setFeatureFlagName(key)} + value={featureFlagName} + errorText={featureFlagFormError.featureFlagName} + /> + + + setfeatureFlagVariant(value)} + value={featureFlagVariant} + /> + + + + + + + + + ); diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h index 5da9b9cc71..c2accc9955 100644 --- a/ios/RNInstabug/InstabugReactBridge.h +++ b/ios/RNInstabug/InstabugReactBridge.h @@ -133,5 +133,7 @@ - (void)addExperiments:(NSArray *)experiments; - (void)removeExperiments:(NSArray *)experiments; - (void)clearAllExperiments; - +- (void)addFeatureFlags:(NSDictionary *)featureFlagsMap; +- (void)removeFeatureFlags:(NSArray *)featureFlags; +- (void)removeAllFeatureFlags; @end diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index 2f2b24f27a..a6f56109c2 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -355,6 +355,38 @@ - (dispatch_queue_t)methodQueue { [Instabug clearAllExperiments]; } +RCT_EXPORT_METHOD(addFeatureFlags:(NSDictionary *)featureFlagsMap) { + NSMutableArray *featureFlags = [NSMutableArray array]; + for(id key in featureFlagsMap){ + NSString* variant =[featureFlagsMap objectForKey:key]; + if ([variant length]==0) { + [featureFlags addObject:[[IBGFeatureFlag alloc] initWithName:key]]; + } else{ + [featureFlags addObject:[[IBGFeatureFlag alloc] initWithName:key variant:variant]]; + } + } + + [Instabug addFeatureFlags:featureFlags]; +} + +RCT_EXPORT_METHOD(removeFeatureFlags:(NSArray *)featureFlags) { + NSMutableArray *features = [NSMutableArray array]; + for(id item in featureFlags){ + [features addObject:[[IBGFeatureFlag alloc] initWithName:item]]; + } + + @try { + [Instabug removeFeatureFlags:features]; + } + @catch (NSException *exception) { + NSLog(@"%@", exception); + } +} + +RCT_EXPORT_METHOD(removeAllFeatureFlags) { + [Instabug removeAllFeatureFlags]; +} + RCT_EXPORT_METHOD(willRedirectToStore){ [Instabug willRedirectToAppStore]; } diff --git a/src/models/FeatureFlag.ts b/src/models/FeatureFlag.ts new file mode 100644 index 0000000000..d2fd58e0f6 --- /dev/null +++ b/src/models/FeatureFlag.ts @@ -0,0 +1,12 @@ +export interface FeatureFlag { + /** + * the name of feature flag + */ + name: string; + + /** + * The variant of the feature flag. + * Leave it `undefined` for boolean (kill switch) feature flags. + */ + variant?: string; +} diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts index 07b3c079d6..baec7660aa 100644 --- a/src/modules/Instabug.ts +++ b/src/modules/Instabug.ts @@ -21,6 +21,7 @@ import InstabugUtils, { stringifyIfNotString } from '../utils/InstabugUtils'; import * as NetworkLogger from './NetworkLogger'; import { captureUnhandledRejections } from '../utils/UnhandledRejectionTracking'; import type { ReproConfig } from '../models/ReproConfig'; +import type { FeatureFlag } from '../models/FeatureFlag'; let _currentScreen: string | null = null; let _lastScreen: string | null = null; @@ -539,6 +540,8 @@ export const reportScreenChange = (screenName: string) => { /** * Add experiments to next report. * @param experiments An array of experiments to add to the next report. + * + * @deprecated Please migrate to the new Feature Flags APIs: {@link addFeatureFlags}. */ export const addExperiments = (experiments: string[]) => { NativeInstabug.addExperiments(experiments); @@ -547,6 +550,8 @@ export const addExperiments = (experiments: string[]) => { /** * Remove experiments from next report. * @param experiments An array of experiments to remove from the next report. + * + * @deprecated Please migrate to the new Feature Flags APIs: {@link removeFeatureFlags}. */ export const removeExperiments = (experiments: string[]) => { NativeInstabug.removeExperiments(experiments); @@ -554,11 +559,53 @@ export const removeExperiments = (experiments: string[]) => { /** * Clear all experiments + * + * @deprecated Please migrate to the new Feature Flags APIs: {@link removeAllFeatureFlags}. */ export const clearAllExperiments = () => { NativeInstabug.clearAllExperiments(); }; +/** + * Add feature flags to the next report. + * @param featureFlags An array of feature flags to add to the next report. + */ +export const addFeatureFlags = (featureFlags: FeatureFlag[]) => { + const entries = featureFlags.map((item) => [item.name, item.variant || '']); + const flags = Object.fromEntries(entries); + NativeInstabug.addFeatureFlags(flags); +}; + +/** + * Add a feature flag to the to next report. + */ +export const addFeatureFlag = (featureFlag: FeatureFlag) => { + addFeatureFlags([featureFlag]); +}; + +/** + * Remove feature flags from the next report. + * @param featureFlags An array of feature flags to remove from the next report. + */ +export const removeFeatureFlags = (featureFlags: string[]) => { + NativeInstabug.removeFeatureFlags(featureFlags); +}; + +/** + * Remove a feature flag from the next report. + * @param name the name of the feature flag to remove from the next report. + */ +export const removeFeatureFlag = (name: string) => { + removeFeatureFlags([name]); +}; + +/** + * Clear all feature flags + */ +export const removeAllFeatureFlags = () => { + NativeInstabug.removeAllFeatureFlags(); +}; + /** * This API has to be call when using custom app rating prompt */ diff --git a/src/native/NativeInstabug.ts b/src/native/NativeInstabug.ts index 3990da4c8b..3b72f5951f 100644 --- a/src/native/NativeInstabug.ts +++ b/src/native/NativeInstabug.ts @@ -118,6 +118,12 @@ export interface InstabugNativeModule extends NativeModule { removeExperiments(experiments: string[]): void; clearAllExperiments(): void; + addFeatureFlags(featureFlags: Record): void; + + removeFeatureFlags(featureFlags: string[]): void; + + removeAllFeatureFlags(): void; + // Files APIs // setFileAttachment(filePath: string, fileName?: string): void; diff --git a/test/mocks/mockInstabug.ts b/test/mocks/mockInstabug.ts index c2dac12b5a..5139afcde3 100644 --- a/test/mocks/mockInstabug.ts +++ b/test/mocks/mockInstabug.ts @@ -54,6 +54,9 @@ const mockInstabug: InstabugNativeModule = { clearAllExperiments: jest.fn(), networkLogIOS: jest.fn(), networkLogAndroid: jest.fn(), + addFeatureFlags: jest.fn(), + removeFeatureFlags: jest.fn(), + removeAllFeatureFlags: jest.fn(), appendTagToReport: jest.fn(), appendConsoleLogToReport: jest.fn(), setUserAttributeToReport: jest.fn(), diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts index f2e52099f9..fdbdcae64e 100644 --- a/test/modules/Instabug.spec.ts +++ b/test/modules/Instabug.spec.ts @@ -21,6 +21,7 @@ import { WelcomeMessageMode, } from '../../src/utils/Enums'; import InstabugUtils from '../../src/utils/InstabugUtils'; +import type { FeatureFlag } from '../../src/models/FeatureFlag'; describe('Instabug Module', () => { beforeEach(() => { @@ -770,6 +771,57 @@ describe('Instabug Module', () => { expect(NativeInstabug.clearAllExperiments).toBeCalledTimes(1); }); + it('should call native addFeatureFlags method', () => { + const featureFlags: Array = [ + { + name: 'key1', + variant: 'variant1', + }, + { + name: 'key2', + variant: 'variant2', + }, + ]; + const expected: Record = {}; + expected.key1 = 'variant1'; + expected.key2 = 'variant2'; + + Instabug.addFeatureFlags(featureFlags); + expect(NativeInstabug.addFeatureFlags).toBeCalledTimes(1); + expect(NativeInstabug.addFeatureFlags).toBeCalledWith(expected); + }); + + it('should call native addFeatureFlag method', () => { + const featureFlag: FeatureFlag = { + name: 'key1', + variant: 'variant2', + }; + const expected: Record = {}; + expected.key1 = 'variant2'; + + Instabug.addFeatureFlag(featureFlag); + expect(NativeInstabug.addFeatureFlags).toBeCalledTimes(1); + expect(NativeInstabug.addFeatureFlags).toBeCalledWith(expected); + }); + it('should call native removeFeatureFlags method', () => { + const featureFlags = ['exp1', 'exp2']; + Instabug.removeFeatureFlags(featureFlags); + expect(NativeInstabug.removeFeatureFlags).toBeCalledTimes(1); + expect(NativeInstabug.removeFeatureFlags).toBeCalledWith(featureFlags); + }); + + it('should call native removeFeatureFlag method', () => { + const featureFlag = 'exp1'; + Instabug.removeFeatureFlag(featureFlag); + expect(NativeInstabug.removeFeatureFlags).toBeCalledTimes(1); + expect(NativeInstabug.removeFeatureFlags).toBeCalledWith([featureFlag]); + }); + + it('should call native removeAllFeatureFlags method', () => { + Instabug.removeAllFeatureFlags(); + expect(NativeInstabug.removeAllFeatureFlags).toBeCalledTimes(1); + }); + it('should call the native willRedirectToStore method', () => { Instabug.willRedirectToStore(); expect(NativeInstabug.willRedirectToStore).toBeCalledTimes(1); From 27a10e356a55c1d19d15f5b3ea457c8bf1dda496 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Sun, 4 Aug 2024 15:29:53 +0300 Subject: [PATCH 22/40] chore(android): bump android sdk to v13.3.0 (#1261) --- CHANGELOG.md | 4 ++++ android/native.gradle | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f277b26077..21e5ecaea5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ - Add support for Feature Flags APIs `Instabug.addFeatureFlags`, `Instabug.removeFeatureFlags` and `Instabug.clearAllFeatureFlags` ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)). - Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)). +### Changed + +- Bump Instabug Android SDK to v13.3.0 ([#1261](https://github.com/Instabug/Instabug-React-Native/pull/1261)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.3.0). + ### Deprecated - Deprecate Experiments APIs `Instabug.addExperiments`, `Instabug.removeExperiments` and `Instabug.clearAllExperiments` in favor of the new Feature Flags APIs ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)). diff --git a/android/native.gradle b/android/native.gradle index 916c957e59..0e86a4edff 100644 --- a/android/native.gradle +++ b/android/native.gradle @@ -1,5 +1,5 @@ project.ext.instabug = [ - version: '13.2.0' + version: '13.3.0' ] dependencies { From f5f64f8e126a40308cf9ece12254424439e07800 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Sun, 4 Aug 2024 15:31:14 +0300 Subject: [PATCH 23/40] chore(ios): bump sdk to v13.3.0 (#1262) --- CHANGELOG.md | 1 + examples/default/ios/Podfile.lock | 8 ++++---- ios/native.rb | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21e5ecaea5..7301cb18fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Changed - Bump Instabug Android SDK to v13.3.0 ([#1261](https://github.com/Instabug/Instabug-React-Native/pull/1261)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.3.0). +- Bump Instabug iOS SDK to v13.3.0 ([#1262](https://github.com/Instabug/Instabug-React-Native/pull/1262)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.3.0). ### Deprecated diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock index 543a31b57a..d84aab147f 100644 --- a/examples/default/ios/Podfile.lock +++ b/examples/default/ios/Podfile.lock @@ -38,7 +38,7 @@ PODS: - hermes-engine (0.72.3): - hermes-engine/Pre-built (= 0.72.3) - hermes-engine/Pre-built (0.72.3) - - Instabug (13.2.0) + - Instabug (13.3.0) - instabug-reactnative-ndk (0.1.0): - RCT-Folly (= 2021.07.22.00) - React-Core @@ -476,7 +476,7 @@ PODS: - RCT-Folly (= 2021.07.22.00) - React-Core - RNInstabug (13.2.0): - - Instabug (= 13.2.0) + - Instabug (= 13.3.0) - React-Core - RNReanimated (3.5.4): - DoubleConversion @@ -704,7 +704,7 @@ SPEC CHECKSUMS: Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac hermes-engine: 10fbd3f62405c41ea07e71973ea61e1878d07322 - Instabug: aee76898789d17c55b36c7fbaa697e443effe3b1 + Instabug: 4f26295103a330ec0236918359eef7ccaa74e2fa instabug-reactnative-ndk: 960119a69380cf4cbe47ccd007c453f757927d17 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OCMock: 300b1b1b9155cb6378660b981c2557448830bdc6 @@ -748,7 +748,7 @@ SPEC CHECKSUMS: ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9 RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495 RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee - RNInstabug: 6fa68cd181533f83154df2ebba000d0c47ca7ba3 + RNInstabug: 2fbe75c9903c0a7d070d6d6a9b5c2a389f0b6862 RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87 RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7 RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9 diff --git a/ios/native.rb b/ios/native.rb index 0047a90883..c5188a3a73 100644 --- a/ios/native.rb +++ b/ios/native.rb @@ -1,4 +1,4 @@ -$instabug = { :version => '13.2.0' } +$instabug = { :version => '13.3.0' } def use_instabug! (spec = nil) version = $instabug[:version] From 2485faca5aebe69e7225bf1bdc10e4497de55e93 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Sun, 4 Aug 2024 15:56:00 +0300 Subject: [PATCH 24/40] release: v13.3.0 (#1263) --- CHANGELOG.md | 2 +- android/build.gradle | 2 +- examples/default/ios/Podfile.lock | 4 ++-- package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7301cb18fc..026fafd2e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...dev) +## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) ### Added diff --git a/android/build.gradle b/android/build.gradle index 2d3eceb239..ffd71b5f87 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -57,7 +57,7 @@ android { minSdkVersion getExtOrDefault('minSdkVersion').toInteger() targetSdkVersion getExtOrDefault('targetSdkVersion').toInteger() versionCode 1 - versionName "13.2.0" + versionName "13.3.0" multiDexEnabled true ndk { abiFilters "armeabi-v7a", "x86" diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock index d84aab147f..1da6e558ee 100644 --- a/examples/default/ios/Podfile.lock +++ b/examples/default/ios/Podfile.lock @@ -475,7 +475,7 @@ PODS: - RNGestureHandler (2.13.4): - RCT-Folly (= 2021.07.22.00) - React-Core - - RNInstabug (13.2.0): + - RNInstabug (13.3.0): - Instabug (= 13.3.0) - React-Core - RNReanimated (3.5.4): @@ -748,7 +748,7 @@ SPEC CHECKSUMS: ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9 RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495 RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee - RNInstabug: 2fbe75c9903c0a7d070d6d6a9b5c2a389f0b6862 + RNInstabug: a4ac0bd09123f6be7d58be541dc220acbaff8dc3 RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87 RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7 RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9 diff --git a/package.json b/package.json index cd62475f6a..d641ecad65 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "instabug-reactnative", "description": "React Native plugin for integrating the Instabug SDK", - "version": "13.2.0", + "version": "13.3.0", "author": "Instabug (https://instabug.com)", "repository": "github:Instabug/Instabug-React-Native", "homepage": "https://www.instabug.com/platforms/react-native", From f66f3e1e31657a33e1f0aa6ea23b87b0184183af Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Sun, 4 Aug 2024 16:10:45 +0300 Subject: [PATCH 25/40] chore: remove duplicate app flows entries in changelog (#1264) --- CHANGELOG.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 026fafd2e1..96695f29c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,21 +73,16 @@ - Bump Instabug iOS SDK to v13.0.0 ([#1189](https://github.com/Instabug/Instabug-React-Native/pull/1189)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.0). - Bump Instabug Android SDK to v13.0.0 ([#1188](https://github.com/Instabug/Instabug-React-Native/pull/1188)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.0). +### Deprecated + +- 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)). + ## [12.9.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.8.0...12.9.0)(April 2, 2024) ### Added - Adds symbol files upload script ([#1137](https://github.com/Instabug/Instabug-React-Native/pull/1137)) - Support enabling NDK crash capturing on Android ([#1132](https://github.com/Instabug/Instabug-React-Native/pull/1132)). -- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)). - -### Deprecated - -- 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)). - -### Deprecated - -- 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)). ### Changed From efe42408279e3fe6d81584daa4d8dcf2c30d9b22 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Sun, 4 Aug 2024 16:22:29 +0300 Subject: [PATCH 26/40] chore: remove duplicate execution traces deprecation in changelog (#1265) --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96695f29c0..9400332650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -105,10 +105,6 @@ - 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). -### Deprecated - -- 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)). - ## [12.7.1](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.0...v12.7.1) (February 15, 2024) ### Changed From be8daf0bbf61252bff079927beeb624b2bd7dc5a Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Wed, 7 Aug 2024 02:02:03 +0300 Subject: [PATCH 27/40] feat: add axios button to example app --- .../default/src/screens/apm/NetworkScreen.tsx | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/examples/default/src/screens/apm/NetworkScreen.tsx b/examples/default/src/screens/apm/NetworkScreen.tsx index 467a621f21..40ad2b5faf 100644 --- a/examples/default/src/screens/apm/NetworkScreen.tsx +++ b/examples/default/src/screens/apm/NetworkScreen.tsx @@ -7,6 +7,7 @@ import { useQuery } from 'react-query'; import { HStack, VStack } from 'native-base'; import { gql, request } from 'graphql-request'; import { CustomButton } from '../../components/CustomButton'; +import axios from 'axios'; export const NetworkScreen: React.FC = () => { const [endpointUrl, setEndpointUrl] = useState(''); @@ -45,6 +46,32 @@ export const NetworkScreen: React.FC = () => { } } + async function sendRequestToUrlUsingAxios() { + let urlToSend = ''; + + if (endpointUrl.trim() !== '') { + urlToSend = endpointUrl; + console.log('Sending request to: ', endpointUrl); + } else { + // Use json placeholder URL as a default if endpointUrl is empty + console.log('sending request to default json placeholder'); + urlToSend = defaultRequestUrl; + } + + try { + // Perform the request using the urlToSend + const response = await axios.get(urlToSend); + // Format the JSON response for better logging + const formattedData = JSON.stringify(response.data, null, 2); + + // Log the formatted response + console.log('Response:', formattedData); + } catch (error) { + // Handle errors appropriately + console.error('Error:', error); + } + } + const fetchGraphQlData = async () => { const document = gql` query { @@ -75,6 +102,11 @@ export const NetworkScreen: React.FC = () => { value={endpointUrl} /> + + refetch} title="Reload GraphQL" /> {isLoading && Loading...} From 8f0a5c4345fab7e9aa00653775a2c7de00bc466d Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Thu, 22 Aug 2024 12:37:08 +0300 Subject: [PATCH 28/40] fix: change client error code to 9876 --- src/utils/XhrNetworkInterceptor.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index 1039b59216..bd6660a61d 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -72,7 +72,8 @@ export default { originalXHROpen = XMLHttpRequest.prototype.open; originalXHRSend = XMLHttpRequest.prototype.send; originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader; - + // An error code that signifies an issue with the RN client. + const clientErrorCode = 9876; XMLHttpRequest.prototype.open = function (method, url, ...args) { _reset(); network.url = url; @@ -145,7 +146,7 @@ export default { // @ts-ignore if (this._hasError) { - cloneNetwork.errorCode = 0; + cloneNetwork.errorCode = clientErrorCode; cloneNetwork.errorDomain = 'ClientError'; // @ts-ignore @@ -157,7 +158,7 @@ export default { // @ts-ignore } else if (this._timedOut) { - cloneNetwork.errorCode = 0; + cloneNetwork.errorCode = clientErrorCode; cloneNetwork.errorDomain = 'TimeOutError'; } From 398262d5b75c1427356869bc4e2b38bc4e38b1d4 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Thu, 22 Aug 2024 14:41:09 +0300 Subject: [PATCH 29/40] fix: change client error code to 9876 --- test/utils/XhrNetworkInterceptor.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/XhrNetworkInterceptor.spec.ts b/test/utils/XhrNetworkInterceptor.spec.ts index 7ec818278f..10a8f1abb8 100644 --- a/test/utils/XhrNetworkInterceptor.spec.ts +++ b/test/utils/XhrNetworkInterceptor.spec.ts @@ -235,7 +235,7 @@ describe('Network Interceptor', () => { expect(callback).toBeCalledWith( expect.objectContaining({ errorDomain: 'ClientError', - errorCode: 0, + errorCode: 9876, responseBody: '', }), ); From ac2d7e6b38249d8a9ddab04d97fd289ed537f39c Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Thu, 22 Aug 2024 14:43:20 +0300 Subject: [PATCH 30/40] fix: change client error code to 9876 --- examples/default/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/default/package.json b/examples/default/package.json index 529521802d..a618c2811c 100644 --- a/examples/default/package.json +++ b/examples/default/package.json @@ -16,6 +16,7 @@ "@react-navigation/native": "^6.1.6", "@react-navigation/native-stack": "^6.9.12", "graphql": "^16.8.1", + "axios": "^1.7.4", "graphql-request": "^6.1.0", "instabug-reactnative": "link:../..", "instabug-reactnative-ndk": "github:https://github.com/Instabug/Instabug-React-Native-NDK", From 9550ce91a95aaa2abf29e8f05cd5bc8976210481 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Thu, 22 Aug 2024 14:52:14 +0300 Subject: [PATCH 31/40] fix: change client error code to 9876 --- examples/default/yarn.lock | 50 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/examples/default/yarn.lock b/examples/default/yarn.lock index 74f7ce0e3b..10aaed1cd9 100644 --- a/examples/default/yarn.lock +++ b/examples/default/yarn.lock @@ -3239,11 +3239,25 @@ async@^3.2.2: resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c" integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ== +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + at-least-node@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2" integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== +axios@^1.7.4: + version "1.7.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.4.tgz#4c8ded1b43683c8dd362973c393f3ede24052aa2" + integrity sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw== + dependencies: + follow-redirects "^1.15.6" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + babel-core@^7.0.0-bridge.0: version "7.0.0-bridge.0" resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece" @@ -3729,6 +3743,13 @@ colorette@^1.0.7: resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40" integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g== +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + command-exists@^1.2.8: version "1.2.9" resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69" @@ -3941,6 +3962,11 @@ define-data-property@^1.1.1: gopd "^1.0.1" has-property-descriptors "^1.0.0" +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + denodeify@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/denodeify/-/denodeify-1.2.1.tgz#3a36287f5034e699e7577901052c2e6c94251631" @@ -4329,6 +4355,20 @@ flow-parser@^0.206.0: resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.206.0.tgz#f4f794f8026535278393308e01ea72f31000bfef" integrity sha512-HVzoK3r6Vsg+lKvlIZzaWNBVai+FXTX1wdYhz/wVlH13tb/gOdLXmlTqy6odmTBhT5UoWUbq0k8263Qhr9d88w== +follow-redirects@^1.15.6: + version "1.15.6" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" + integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== + +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + fresh@0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" @@ -4650,7 +4690,8 @@ inline-style-prefixer@^6.0.1: resolved "https://codeload.github.com/Instabug/Instabug-React-Native-NDK/tar.gz/3b0bac281253133852d32f52aa50cc805dd0b570" "instabug-reactnative@link:../..": - version "13.0.5" + version "0.0.0" + uid "" intl-messageformat@^10.1.0: version "10.5.0" @@ -6105,7 +6146,7 @@ mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.27, mime-types@~2.1.34: +mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.34: version "2.1.35" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== @@ -6664,6 +6705,11 @@ proper-lockfile@^3.0.2: retry "^0.12.0" signal-exit "^3.0.2" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" From b41ff4f612d2cdd1895dad2566c7da5523ebdd2f Mon Sep 17 00:00:00 2001 From: kholood Date: Mon, 12 Aug 2024 14:10:34 +0300 Subject: [PATCH 32/40] feat: navigation tracking support with expo router (#1270) * feat: add screen tracker on screen change listener and tests * feat (example): add screen change listener --- examples/default/src/App.tsx | 9 +++++++-- src/modules/Instabug.ts | 18 +++++++++++++++++- test/modules/Instabug.spec.ts | 18 ++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx index d92db633c1..ae548f97c5 100644 --- a/examples/default/src/App.tsx +++ b/examples/default/src/App.tsx @@ -2,7 +2,7 @@ import React, { useEffect } from 'react'; import { StyleSheet } from 'react-native'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; -import { NavigationContainer } from '@react-navigation/native'; +import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native'; import Instabug, { CrashReporting, InvocationEvent, @@ -20,6 +20,7 @@ import { QueryClient, QueryClientProvider } from 'react-query'; const queryClient = new QueryClient(); export const App: React.FC = () => { + const navigationRef = useNavigationContainerRef(); useEffect(() => { Instabug.init({ token: 'deb1910a7342814af4e4c9210c786f35', @@ -33,11 +34,15 @@ export const App: React.FC = () => { }); }, []); + useEffect(() => { + Instabug.setNavigationListener(navigationRef); + }, [navigationRef]); + return ( - + diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts index baec7660aa..b0a05032c4 100644 --- a/src/modules/Instabug.ts +++ b/src/modules/Instabug.ts @@ -1,7 +1,10 @@ import type React from 'react'; import { Platform, findNodeHandle, processColor } from 'react-native'; -import type { NavigationState as NavigationStateV5 } from '@react-navigation/native'; +import type { + NavigationContainerRefWithCurrent, + NavigationState as NavigationStateV5, +} from '@react-navigation/native'; import type { ComponentDidAppearEvent } from 'react-native-navigation'; import type { NavigationAction, NavigationState as NavigationStateV4 } from 'react-navigation'; @@ -533,6 +536,19 @@ export const onStateChange = (state?: NavigationStateV5) => { }, 1000); }; +/** + * Sets a listener for screen change + * @param navigationRef a refrence of a navigation container + * + */ +export const setNavigationListener = ( + navigationRef: NavigationContainerRefWithCurrent, +) => { + navigationRef.addListener('state', () => { + onStateChange(navigationRef.getRootState()); + }); +}; + export const reportScreenChange = (screenName: string) => { NativeInstabug.reportScreenChange(screenName); }; diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts index fdbdcae64e..518e53ce93 100644 --- a/test/modules/Instabug.spec.ts +++ b/test/modules/Instabug.spec.ts @@ -2,6 +2,7 @@ import '../mocks/mockInstabugUtils'; import '../mocks/mockNetworkLogger'; import { Platform, findNodeHandle, processColor } from 'react-native'; +import type { NavigationContainerRefWithCurrent } from '@react-navigation/native'; // Import the hook import { mocked } from 'jest-mock'; import waitForExpect from 'wait-for-expect'; @@ -236,6 +237,23 @@ describe('Instabug Module', () => { await waitForExpect(() => expect(NativeInstabug.reportScreenChange).toBeCalledTimes(2)); }); + it('setNavigationListener should call the onStateChange on a screen change', async () => { + const mockNavigationContainerRef = { + current: null, + navigate: jest.fn(), + reset: jest.fn(), + goBack: jest.fn(), + dispatch: jest.fn(), + getRootState: jest.fn(), + canGoBack: jest.fn(), + addListener: jest.fn(), + removeListener: jest.fn(), + } as unknown as NavigationContainerRefWithCurrent; + + Instabug.setNavigationListener(mockNavigationContainerRef); + expect(mockNavigationContainerRef.addListener).toBeCalledTimes(1); + }); + it('should call the native method init', () => { const instabugConfig = { token: 'some-token', From 10286cdeccd19c88dd625639b3d303de5034c17c Mon Sep 17 00:00:00 2001 From: kholood Date: Tue, 13 Aug 2024 17:37:27 +0300 Subject: [PATCH 33/40] chore: enhance expo router tracking support (#1272) --- CHANGELOG.md | 6 ++++++ examples/default/src/App.tsx | 4 +++- src/modules/Instabug.ts | 2 +- test/modules/Instabug.spec.ts | 23 +++++++++++++++++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9400332650..acb003486f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.3.0...dev) + +### Added + +- Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)). + ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) ### Added diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx index ae548f97c5..33a3c34f94 100644 --- a/examples/default/src/App.tsx +++ b/examples/default/src/App.tsx @@ -35,7 +35,9 @@ export const App: React.FC = () => { }, []); useEffect(() => { - Instabug.setNavigationListener(navigationRef); + const unregisterListener = Instabug.setNavigationListener(navigationRef); + + return unregisterListener; }, [navigationRef]); return ( diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts index b0a05032c4..29ff1d27c9 100644 --- a/src/modules/Instabug.ts +++ b/src/modules/Instabug.ts @@ -544,7 +544,7 @@ export const onStateChange = (state?: NavigationStateV5) => { export const setNavigationListener = ( navigationRef: NavigationContainerRefWithCurrent, ) => { - navigationRef.addListener('state', () => { + return navigationRef.addListener('state', () => { onStateChange(navigationRef.getRootState()); }); }; diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts index 518e53ce93..fdc1b91b24 100644 --- a/test/modules/Instabug.spec.ts +++ b/test/modules/Instabug.spec.ts @@ -238,20 +238,39 @@ describe('Instabug Module', () => { }); it('setNavigationListener should call the onStateChange on a screen change', async () => { + const mockedState = { routes: [{ name: 'ScreenName' }], index: 0 }; + const mockNavigationContainerRef = { current: null, navigate: jest.fn(), reset: jest.fn(), goBack: jest.fn(), dispatch: jest.fn(), - getRootState: jest.fn(), + getRootState: () => mockedState, canGoBack: jest.fn(), - addListener: jest.fn(), + + addListener: jest.fn((event, callback) => { + expect(event).toBe('state'); + callback(mockedState); + return jest.fn(); + }), removeListener: jest.fn(), } as unknown as NavigationContainerRefWithCurrent; + const onStateChangeMock = jest.fn(); + + jest.spyOn(Instabug, 'onStateChange').mockImplementation(onStateChangeMock); + Instabug.setNavigationListener(mockNavigationContainerRef); + expect(mockNavigationContainerRef.addListener).toBeCalledTimes(1); + expect(mockNavigationContainerRef.addListener).toHaveBeenCalledWith( + 'state', + expect.any(Function), + ); + + expect(onStateChangeMock).toBeCalledTimes(1); + expect(onStateChangeMock).toHaveBeenCalledWith(mockNavigationContainerRef.getRootState()); }); it('should call the native method init', () => { From ef5a023360cb32294dda7bc4ecdb28cd2ae6ff6e Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:38:04 +0300 Subject: [PATCH 34/40] ci: generalize enterprise releases (#1275) --- .circleci/config.yml | 159 +++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 74 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c218cf7e93..64a6b4013a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,10 +59,67 @@ commands: type: string replace: type: string + working_directory: + type: string + default: ~/project steps: - run: name: Find and Replace in << parameters.files >> command: node ~/project/scripts/replace.js << parameters.search >> << parameters.replace >> << parameters.files >> + working_directory: << parameters.working_directory >> + + prepare_custom_package: + parameters: + npm_package: + type: string + android_package: + type: string + api_endpoint: + type: string + working_directory: + type: string + default: ~/project + steps: + - run: + name: Remove README.md file + command: rm README.md + working_directory: << parameters.working_directory >> + - find_and_replace: + files: package.json android/sourcemaps.gradle ios/sourcemaps.sh + search: instabug-reactnative + replace: << parameters.npm_package >> + working_directory: << parameters.working_directory >> + - find_and_replace: + files: cli/upload/uploadSourcemaps.ts cli/upload/uploadSoFiles.ts + search: api.instabug.com + replace: << parameters.api_endpoint >> + working_directory: << parameters.working_directory >> + - find_and_replace: + files: android/native.gradle + search: 'com.instabug.library:instabug:' + replace: 'com.instabug.library-<< parameters.android_package >>:instabug:' + working_directory: << parameters.working_directory >> + + prepare_dream11: + parameters: + working_directory: + type: string + default: ~/project + steps: + - install_node_modules + - prepare_custom_package: + npm_package: '@instabug/instabug-reactnative-dream11' + android_package: dream11 + api_endpoint: st001012dream11.instabug.com + working_directory: << parameters.working_directory >> + - run: + name: Give execute permission to Dream11 script + command: chmod +x ./scripts/dream-11-delete-unused-features.sh + working_directory: << parameters.working_directory >> + - run: + name: Remove unused features + command: ./scripts/dream-11-delete-unused-features.sh + working_directory: << parameters.working_directory >> notify_github: parameters: @@ -264,33 +321,16 @@ jobs: release_custom_package: parameters: - npm_package: - type: string - android_package: - type: string - api_endpoint: - type: string + prepare_steps: + type: steps + default: [] working_directory: ~/project executor: name: node/default steps: - advanced-checkout/shallow-checkout + - steps: << parameters.prepare_steps >> - install_node_modules - - run: - name: Remove README.md file - command: rm README.md - - find_and_replace: - files: package.json android/sourcemaps.gradle ios/sourcemaps.sh - search: instabug-reactnative - replace: << parameters.npm_package >> - - find_and_replace: - files: cli/UploadSourcemaps.ts cli/UploadSoFiles.ts - search: api.instabug.com - replace: << parameters.api_endpoint >> - - find_and_replace: - files: android/native.gradle - search: 'com.instabug.library:instabug:' - replace: 'com.instabug.library-<< parameters.android_package >>:instabug:' - run: name: Build the SDK command: yarn build @@ -301,45 +341,6 @@ jobs: name: Publish new enterprise version command: npm publish - # Automate the enterprise D11 sdk changes - release_d11: - working_directory: ~/project - executor: - name: node/default - steps: - - advanced-checkout/shallow-checkout - - install_node_modules - - run: - name: Remove README.md file - command: rm README.md - - find_and_replace: - files: package.json ios/sourcemaps.sh android/sourcemaps.gradle - search: instabug-reactnative - replace: '@instabug/instabug-reactnative-dream11' - - find_and_replace: - files: cli/UploadSourcemaps.ts cli/UploadSoFiles.ts - search: api.instabug.com - replace: st001012dream11.instabug.com - - find_and_replace: - files: android/native.gradle - search: com.instabug.library:instabug - replace: 'com.instabug.library-dream11:instabug' - - run: - name: give exec permssion to d11 script - command: chmod +x ./scripts/dream-11-delete-unused-features.sh - - run: - name: remove un-required features - command: ./scripts/dream-11-delete-unused-features.sh - - run: - name: Build the SDK - command: yarn build - - run: - name: Authorize with npm - command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - - run: - name: Publish new enterprise version - command: npm publish - publish: macos: xcode: 13.4.1 @@ -463,12 +464,6 @@ workflows: filters: branches: only: master - - hold_release_d11: - requires: *release_dependencies - type: approval - filters: - branches: - only: dream11 - publish: requires: - hold_publish @@ -481,6 +476,7 @@ workflows: filters: branches: only: master + - hold_release_nn: requires: *release_dependencies type: approval @@ -494,9 +490,12 @@ workflows: filters: branches: only: master - npm_package: '@instabug/react-native-nn' - android_package: nn - api_endpoint: st001009nn.instabug.com + prepare_steps: + - prepare_custom_package: + npm_package: '@instabug/react-native-nn' + android_package: nn + api_endpoint: st001009nn.instabug.com + - hold_release_injazat: requires: *release_dependencies type: approval @@ -510,12 +509,24 @@ workflows: filters: branches: only: master - npm_package: '@instabug/react-native-injazat' - android_package: injazat - api_endpoint: st001013mec1.instabug.com - - release_d11: + prepare_steps: + - prepare_custom_package: + npm_package: '@instabug/react-native-injazat' + android_package: injazat + api_endpoint: st001013mec1.instabug.com + + - hold_release_dream11: + requires: *release_dependencies + type: approval + filters: + branches: + only: dream11 + - release_custom_package: + name: release_dream11 requires: - - hold_release_d11 + - hold_release_dream11 filters: branches: only: dream11 + prepare_steps: + - prepare_dream11 From 253c92ca72cbfb18ee94283eb033c0c7fdf94637 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:02:11 +0300 Subject: [PATCH 35/40] ci: run tests before enterprise releases (#1271) --- .circleci/config.yml | 151 +++++++++++++++--- .../RNInstabugExampleReactnativePackage.java | 8 - .../app/src/main/res/raw/instabug_config.json | 4 + examples/default/android/build.gradle | 8 + .../InstabugExample.xcodeproj/project.pbxproj | 4 + .../ios/InstabugExample/Instabug.plist | Bin 0 -> 157 bytes .../ios/InstabugTests/InstabugSampleTests.m | 1 - .../ios/InstabugTests/RNInstabugTests.m | 1 - ios/RNInstabug/InstabugReactBridge.h | 1 - ios/RNInstabug/InstabugReactBridge.m | 1 - scripts/customize-ios-endpoints.sh | 28 ++++ scripts/dream-11-delete-unused-features.sh | 70 ++++---- scripts/replace.js | 24 ++- 13 files changed, 231 insertions(+), 70 deletions(-) create mode 100644 examples/default/android/app/src/main/res/raw/instabug_config.json create mode 100644 examples/default/ios/InstabugExample/Instabug.plist create mode 100755 scripts/customize-ios-endpoints.sh mode change 100644 => 100755 scripts/dream-11-delete-unused-features.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 64a6b4013a..d8334f0b32 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,6 +17,12 @@ references: - e2e_ios - e2e_android + dream11_prepare_config: &dream11_prepare_config + prepare_steps: + - prepare_dream11 + requires: + - hold_test_dream11 + commands: install_node_modules: parameters: @@ -36,15 +42,28 @@ commands: parameters: working_directory: type: string + deployment: + type: boolean + default: false steps: - restore_cache: name: Restore Pods Cache keys: - v1-pods-{{ checksum "<< parameters.working_directory >>/Podfile.lock" }} - - run: - name: Install Pods - working_directory: << parameters.working_directory >> - command: pod install --deployment + - when: + condition: << parameters.deployment >> + steps: + - run: + name: Install Pods + working_directory: << parameters.working_directory >> + command: pod install --deployment + - unless: + condition: << parameters.deployment >> + steps: + - run: + name: Install Pods + working_directory: << parameters.working_directory >> + command: pod install - save_cache: name: Save Pods Cache key: v1-pods-{{ checksum "<< parameters.working_directory >>/Podfile.lock" }} @@ -120,6 +139,11 @@ commands: name: Remove unused features command: ./scripts/dream-11-delete-unused-features.sh working_directory: << parameters.working_directory >> + # Remove the NDK package to avoid dependency conflicts on Android. + - run: + name: Remove the NDK package + command: yarn remove instabug-reactnative-ndk + working_directory: << parameters.working_directory >>/examples/default notify_github: parameters: @@ -158,20 +182,38 @@ jobs: command: yarn lint:ci test_module: + parameters: + prepare_steps: + type: steps + default: [] + collect_coverage: + type: boolean + default: false executor: name: node/default steps: - advanced-checkout/shallow-checkout + - steps: << parameters.prepare_steps >> - install_node_modules - run: name: Run Tests command: yarn test - - persist_to_workspace: - root: coverage - paths: - - lcov.info + - when: + condition: << parameters.collect_coverage >> + steps: + - persist_to_workspace: + root: coverage + paths: + - lcov.info test_android: + parameters: + prepare_steps: + type: steps + default: [] + collect_coverage: + type: boolean + default: false executor: name: android/android-machine tag: '2024.01.1' @@ -180,15 +222,18 @@ jobs: INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true steps: - advanced-checkout/shallow-checkout - # - node/install-yarn + - steps: << parameters.prepare_steps >> - install_node_modules - android/run-tests: working-directory: android test-command: ./gradlew test - - persist_to_workspace: - root: ~/project/android/build/reports/jacoco/jacocoTestReport - paths: - - jacocoTestReport.xml + - when: + condition: << parameters.collect_coverage >> + steps: + - persist_to_workspace: + root: ~/project/android/build/reports/jacoco/jacocoTestReport + paths: + - jacocoTestReport.xml validate_shell_files: machine: @@ -217,10 +262,18 @@ jobs: app-dir: examples/default - install_pods: working_directory: examples/default/ios + deployment: true - run: git --no-pager diff - run: git diff-index HEAD --exit-code -p -I EXCLUDED_ARCHS # Ignore Arch Changes test_ios: + parameters: + prepare_steps: + type: steps + default: [] + collect_coverage: + type: boolean + default: false macos: xcode: 13.4.1 resource_class: macos.m1.medium.gen1 @@ -229,6 +282,7 @@ jobs: INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true steps: - advanced-checkout/shallow-checkout + - steps: << parameters.prepare_steps >> - install_node_modules - install_pods: working_directory: ios @@ -243,16 +297,23 @@ jobs: -sdk iphonesimulator \ -destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.5' \ test | xcpretty - - run: - name: Convert xcresult into JSON report - working_directory: ios/coverage - command: xcrun xccov view --report --json result.xcresult > xcode.json - - persist_to_workspace: - root: ios/coverage - paths: - - xcode.json + - when: + condition: << parameters.collect_coverage >> + steps: + - run: + name: Convert xcresult into JSON report + working_directory: ios/coverage + command: xcrun xccov view --report --json result.xcresult > xcode.json + - persist_to_workspace: + root: ios/coverage + paths: + - xcode.json e2e_ios: + parameters: + prepare_steps: + type: steps + default: [] macos: xcode: 13.4.1 resource_class: macos.m1.medium.gen1 @@ -260,6 +321,7 @@ jobs: INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true steps: - advanced-checkout/shallow-checkout + - steps: << parameters.prepare_steps >> - install_node_modules - node/install-packages: pkg-manager: yarn @@ -276,6 +338,11 @@ jobs: name: Rebuild Detox.framework Cache working_directory: examples/default command: detox clean-framework-cache && detox build-framework-cache + # This is a workaround until the iOS SDK is updated to prioritize the custom + # Instabug.plist over the internal Config.plist. + - run: + name: Customize API Endpoints + command: ./scripts/customize-ios-endpoints.sh - run: name: Detox - Build Release App working_directory: examples/default @@ -286,6 +353,10 @@ jobs: command: detox test --configuration ios.sim.release --cleanup e2e_android: + parameters: + prepare_steps: + type: steps + default: [] executor: name: android/android-machine tag: '2024.01.1' @@ -294,7 +365,7 @@ jobs: INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true steps: - advanced-checkout/shallow-checkout - # - node/install-yarn + - steps: << parameters.prepare_steps >> - install_node_modules - node/install-packages: pkg-manager: yarn @@ -439,11 +510,14 @@ workflows: - test_android - test_ios - lint - - test_module - - test_android + - test_module: + collect_coverage: true + - test_android: + collect_coverage: true + - test_ios: + collect_coverage: true - validate_shell_files - sync_generated_files - - test_ios - e2e_ios - e2e_android - hold_generate_snapshot: @@ -515,8 +589,33 @@ workflows: android_package: injazat api_endpoint: st001013mec1.instabug.com + # Dream11 tests + - hold_test_dream11: + type: approval + - test_module: + name: test_module_dream11 + <<: *dream11_prepare_config + - test_android: + name: test_android_dream11 + <<: *dream11_prepare_config + - test_ios: + name: test_ios_dream11 + <<: *dream11_prepare_config + - e2e_android: + name: e2e_android_dream11 + <<: *dream11_prepare_config + - e2e_ios: + name: e2e_ios_dream11 + <<: *dream11_prepare_config + + # Dream11 release - hold_release_dream11: - requires: *release_dependencies + requires: + - test_module_dream11 + - test_android_dream11 + - test_ios_dream11 + - e2e_android_dream11 + - e2e_ios_dream11 type: approval filters: branches: diff --git a/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java b/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java index 304ab68704..977afa782e 100644 --- a/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java +++ b/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java @@ -6,14 +6,6 @@ import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; -import com.instabug.reactlibrary.RNInstabugAPMModule; -import com.instabug.reactlibrary.RNInstabugBugReportingModule; -import com.instabug.reactlibrary.RNInstabugCrashReportingModule; -import com.instabug.reactlibrary.RNInstabugFeatureRequestsModule; -import com.instabug.reactlibrary.RNInstabugReactnativeModule; -import com.instabug.reactlibrary.RNInstabugRepliesModule; -import com.instabug.reactlibrary.RNInstabugSessionReplayModule; -import com.instabug.reactlibrary.RNInstabugSurveysModule; import java.util.ArrayList; import java.util.Collections; diff --git a/examples/default/android/app/src/main/res/raw/instabug_config.json b/examples/default/android/app/src/main/res/raw/instabug_config.json new file mode 100644 index 0000000000..86b3a7a225 --- /dev/null +++ b/examples/default/android/app/src/main/res/raw/instabug_config.json @@ -0,0 +1,4 @@ +{ + "instabug-domain": "api.instabug.com", + "apm-domain": "api-apm.instabug.com" +} diff --git a/examples/default/android/build.gradle b/examples/default/android/build.gradle index 0336ff851f..7fa616eb1b 100644 --- a/examples/default/android/build.gradle +++ b/examples/default/android/build.gradle @@ -27,5 +27,13 @@ allprojects { maven { url("$rootDir/../node_modules/detox/Detox-android") } + + maven { + credentials { + username System.getenv("DREAM11_MAVEN_USERNAME") + password System.getenv("DREAM11_MAVEN_PASSWORD") + } + url "https://mvn.instabug.com/nexus/repository/dream-11" + } } } diff --git a/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj b/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj index afe4ffe605..3b05a8f1e0 100644 --- a/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj +++ b/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ CC3DF8932A1DFC9A003E9914 /* InstabugSurveysTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3DF88B2A1DFC99003E9914 /* InstabugSurveysTests.m */; }; CC3DF8942A1DFC9A003E9914 /* InstabugAPMTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3DF88C2A1DFC99003E9914 /* InstabugAPMTests.m */; }; CC3DF8952A1DFC9A003E9914 /* IBGConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3DF88D2A1DFC9A003E9914 /* IBGConstants.m */; }; + CC487A9C2C71FCFC0021F680 /* Instabug.plist in Resources */ = {isa = PBXBuildFile; fileRef = CC487A9B2C71FCFC0021F680 /* Instabug.plist */; }; CCF1E4092B022CF20024802D /* RNInstabugTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CCF1E4082B022CF20024802D /* RNInstabugTests.m */; }; CD36F4707EA1F435D2CC7A15 /* libPods-InstabugExample-InstabugTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF7A6E02D40E0CEEA833CC4 /* libPods-InstabugExample-InstabugTests.a */; }; F7BF47401EF3A435254C97BB /* libPods-InstabugExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BAED0D0441A708AE2390E153 /* libPods-InstabugExample.a */; }; @@ -64,6 +65,7 @@ CC3DF88B2A1DFC99003E9914 /* InstabugSurveysTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstabugSurveysTests.m; sourceTree = ""; }; CC3DF88C2A1DFC99003E9914 /* InstabugAPMTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstabugAPMTests.m; sourceTree = ""; }; CC3DF88D2A1DFC9A003E9914 /* IBGConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IBGConstants.m; sourceTree = ""; }; + CC487A9B2C71FCFC0021F680 /* Instabug.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; name = Instabug.plist; path = InstabugExample/Instabug.plist; sourceTree = ""; }; CCF1E4082B022CF20024802D /* RNInstabugTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNInstabugTests.m; sourceTree = ""; }; DBCB1B1D023646D84146C91E /* Pods-InstabugExample-InstabugTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InstabugExample-InstabugTests.release.xcconfig"; path = "Target Support Files/Pods-InstabugExample-InstabugTests/Pods-InstabugExample-InstabugTests.release.xcconfig"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; @@ -120,6 +122,7 @@ 13B07FAE1A68108700A75B9A /* InstabugExample */ = { isa = PBXGroup; children = ( + CC487A9B2C71FCFC0021F680 /* Instabug.plist */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.mm */, 13B07FB51A68108700A75B9A /* Images.xcassets */, @@ -296,6 +299,7 @@ buildActionMask = 2147483647; files = ( 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, + CC487A9C2C71FCFC0021F680 /* Instabug.plist in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/examples/default/ios/InstabugExample/Instabug.plist b/examples/default/ios/InstabugExample/Instabug.plist new file mode 100644 index 0000000000000000000000000000000000000000..24d035f427616a1490762b3e7c6b8861c863c4a4 GIT binary patch literal 157 zcmYc)$jK}&F)+Bq$i&PN=b2Yrl9*JQ?ik=38srlV;{w_70_qthB?ZM+`ud3lnYxJu vxq6vU#d^v4xgbIP;*@OtGUIpwWh9ljRB`aiXaq5U0V5-XW?+TVFscFo;^Zpb literal 0 HcmV?d00001 diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m index 565a21b1a7..70ef410258 100644 --- a/examples/default/ios/InstabugTests/InstabugSampleTests.m +++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m @@ -8,7 +8,6 @@ #import #import "OCMock/OCMock.h" #import "Instabug/Instabug.h" -#import "Instabug/IBGSurvey.h" #import "InstabugReactBridge.h" #import #import "IBGConstants.h" diff --git a/examples/default/ios/InstabugTests/RNInstabugTests.m b/examples/default/ios/InstabugTests/RNInstabugTests.m index 0df2fd8430..cde248ad30 100644 --- a/examples/default/ios/InstabugTests/RNInstabugTests.m +++ b/examples/default/ios/InstabugTests/RNInstabugTests.m @@ -1,7 +1,6 @@ #import #import "OCMock/OCMock.h" #import "Instabug/Instabug.h" -#import "Instabug/IBGSurvey.h" #import #import "RNInstabug.h" #import "RNInstabug/Instabug+CP.h" diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h index c2accc9955..a3cfc21c13 100644 --- a/ios/RNInstabug/InstabugReactBridge.h +++ b/ios/RNInstabug/InstabugReactBridge.h @@ -12,7 +12,6 @@ #import #import #import -#import #import #import #import "ArgsRegistry.h" diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index a6f56109c2..dd18513163 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -8,7 +8,6 @@ #import #import #import -#import #import #import #import diff --git a/scripts/customize-ios-endpoints.sh b/scripts/customize-ios-endpoints.sh new file mode 100755 index 0000000000..2fecd9d729 --- /dev/null +++ b/scripts/customize-ios-endpoints.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Replaces the internal Config.plist file inside the Instabug iOS SDK with the +# Instabug.plist file in the example app. +# +# This is a workaround until the iOS SDK is updated to prioritize the custom +# Instabug.plist over the internal Config.plist. + +instabug_plist=examples/default/ios/InstabugExample/Instabug.plist + +if [ ! -f $instabug_plist ]; then + echo "Instabug.plist not found" + exit 1 +fi + +for dir in examples/default/ios/Pods/Instabug/Instabug.xcframework/ios-*/ +do + echo "Replacing Config.plist in $dir" + + config_path=$dir/Instabug.framework/InstabugResources.bundle/Config.plist + + if [ ! -f $config_path ]; then + echo "Config.plist not found in $dir" + exit 1 + fi + + cp -f $instabug_plist $config_path +done diff --git a/scripts/dream-11-delete-unused-features.sh b/scripts/dream-11-delete-unused-features.sh old mode 100644 new mode 100755 index 58ab392885..fa10a9181e --- a/scripts/dream-11-delete-unused-features.sh +++ b/scripts/dream-11-delete-unused-features.sh @@ -2,47 +2,61 @@ # remove survey and featureRequest features in JavaScript files deletedFeaturesFilesInJavaScript=("Surveys" "FeatureRequests" "Survey") -for feature in "${deletedFeaturesFilesInJavaScript[@]}"; - do - echo "$feature" -rm -f src/modules/"$feature".ts -rm -f test/mocks/mock"$feature".ts -sed -i "s/import..*$feature';//g" src/index.ts -sed -i "s/$feature,//g" src/index.ts - +for feature in "${deletedFeaturesFilesInJavaScript[@]}"; do + echo "$feature" + + rm -f src/modules/"$feature".ts + rm -f src/native/Native"$feature".ts + rm -f test/mocks/mock"$feature".ts + rm -f test/modules/"$feature".spec.ts + + node scripts/replace.js --pattern "import.+$feature';" "" src/index.ts + node scripts/replace.js --pattern "$feature," "" src/index.ts + node scripts/replace.js --pattern ".*$feature.*" "" src/native/NativePackage.ts + node scripts/replace.js --pattern ".*$feature.*" "" test/mocks/mockNativeModules.ts done -npx eslint src/index.ts --fix + +npx eslint src/index.ts --fix # remove survey and featureRequest features in Android files deletedFeaturesFilesInAndroidApp=("RNInstabugSurveysModule" "RNInstabugFeatureRequestsModule") -for feature in "${deletedFeaturesFilesInAndroidApp[@]}"; - do - echo "$feature" - -rm -f android/src/main/java/com/instabug/reactlibrary/"$feature".java -rm -f android/src/test/java/com/instabug/reactlibrary/"$feature"Test.java -sed -i "s/modules.add(new $feature(reactContext));//g" android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java +for feature in "${deletedFeaturesFilesInAndroidApp[@]}"; do + echo "$feature" + rm -f android/src/main/java/com/instabug/reactlibrary/"$feature".java + rm -f android/src/test/java/com/instabug/reactlibrary/"$feature"Test.java + node scripts/replace.js "modules.add(new $feature(reactContext));" "" android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java done # remove survey and featureRequest features in IOS files deletedFeaturesFilesInIosApp=("InstabugSurveysBridge" "InstabugFeatureRequestsBridge") -for feature in "${deletedFeaturesFilesInIosApp[@]}"; - do - echo "$feature" -rm -f ios/RNInstabug/"$feature".h -rm -f ios/RNInstabug/"$feature".m +for feature in "${deletedFeaturesFilesInIosApp[@]}"; do + echo "$feature" + rm -f ios/RNInstabug/"$feature".h + rm -f ios/RNInstabug/"$feature".m done -sed -i "s/\#import //g" ios/RNInstabug/InstabugReactBridge.m -sed -i "s/\#import //g" ios/RNInstabug/InstabugReactBridge.h +# Remove unused features iOS test files +iosTestFiles=("InstabugSurveysTests.m" "InstabugFeatureRequestsTests.m") +for file in "${iosTestFiles[@]}"; do + echo "Deleting $file" + + rm -f examples/default/ios/InstabugTests/"$file" + node scripts/replace.js --pattern ".*$file.*" "" examples/default/ios/InstabugExample.xcodeproj/project.pbxproj +done -# remove all locales except English locale -sed -i -E '/english/!s/.*constants.locale.*//g' src/utils/Enums.ts -npx eslint src/index.ts --fix src/utils/Enums.ts +node scripts/replace.js "#import " "" ios/RNInstabug/InstabugReactBridge.m +node scripts/replace.js "#import " "" ios/RNInstabug/InstabugReactBridge.h -sed -i "s/return (major == 7 && minor >= 3) || major >= 8/return false/g" android/build.gradle +# Remove all locales except for English +# This ugly regular expression matches all lines not containing "english" and containing "constants.locale" +node scripts/replace.js --pattern "^(?!.*english).+constants\.locale.*" "" src/utils/Enums.ts +npx eslint src/index.ts --fix src/utils/Enums.ts -sed -i "s/static boolean supportsNamespace() {/static boolean supportsNamespace() { \n return false/g" android/build.gradle +node scripts/replace.js "return (major == 7 && minor >= 3) || major >= 8" "return false" android/build.gradle +# Note: printf is used here as the string contains a newline character which would be escaped otherwise. +node scripts/replace.js "static boolean supportsNamespace() {" "$(printf "static boolean supportsNamespace() {\n return false")" android/build.gradle +# Add Dream11 custom iOS build podspec to Podfile +node scripts/replace.js "target 'InstabugExample' do" "$(printf "target 'InstabugExample' do\n pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/dream11/Instabug.podspec'")" examples/default/ios/Podfile diff --git a/scripts/replace.js b/scripts/replace.js index 5682b47265..aeb483ae8f 100644 --- a/scripts/replace.js +++ b/scripts/replace.js @@ -10,10 +10,25 @@ const fs = require('fs'); const path = require('path'); +const { parseArgs } = require('util'); -const [search, replace, ...files] = process.argv.slice(2); +const { values, positionals } = parseArgs({ + allowPositionals: true, + options: { + pattern: { + type: 'boolean', + default: false, + short: 'p', + }, + }, +}); -if (!search || !replace || !files.length) { +const [search, replace, ...files] = positionals; + +/** Whether to replace the search string as a regular expression or as a literal string. */ +const isPattern = values.pattern; + +if (search == null || replace == null || !files.length) { // The path of the script relative to the directory where the user ran the // script to be used in the error message demonstrating the usage. const scriptPath = path.relative(process.cwd(), __filename); @@ -21,7 +36,7 @@ if (!search || !replace || !files.length) { console.error('Missing arguments.'); console.table({ search, replace, files }); - console.error(`Usage: node ${scriptPath} `); + console.error(`Usage: node ${scriptPath} [-p | --pattern] `); process.exit(1); } @@ -31,7 +46,8 @@ for (const file of files) { const fileContent = fs.readFileSync(filePath, 'utf8'); - const newContent = fileContent.replaceAll(search, replace); + const searchPattern = isPattern ? new RegExp(search, 'gm') : search; + const newContent = fileContent.replaceAll(searchPattern, replace); fs.writeFileSync(filePath, newContent); } catch (error) { From 030fa97faa347d9794575a008f342ded77a9011c Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:35:40 +0300 Subject: [PATCH 36/40] ci: publish snapshots to npm (#1274) --- .circleci/config.yml | 35 +++++++++++------------------------ scripts/snapshot-branch.sh | 30 ------------------------------ scripts/snapshot-comment.md | 4 ++-- scripts/snapshot-version.sh | 11 +++++++++++ 4 files changed, 24 insertions(+), 56 deletions(-) delete mode 100755 scripts/snapshot-branch.sh create mode 100755 scripts/snapshot-version.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index d8334f0b32..efca5acab3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -469,35 +469,22 @@ jobs: - run: yarn build - run: yarn remove @instabug/danger-plugin-coverage - run: - name: Remove build files from .gitignore - command: sed -i '/dist/d' .gitignore && sed -i '/bin/d' .gitignore - - run: - name: Get snapshot branch name - command: | - source scripts/snapshot-branch.sh - echo "export SNAPSHOT_BRANCH=$SNAPSHOT_BRANCH" >> "$BASH_ENV" - - run: - name: Setup Git - command: | - git config --global user.name "Instabug-CP-CI" - git config --global user.email github-ci+cp@instabug.com - - run: - name: Create snapshot branch - command: git checkout -b $SNAPSHOT_BRANCH - - run: - name: Commit changes + name: Get snapshot version command: | - git add . - git commit -m "chore: add generate files" + source scripts/snapshot-version.sh + echo "export SNAPSHOT_VERSION=$SNAPSHOT_VERSION" >> "$BASH_ENV" - run: - name: Push snapshot - command: git push --force origin $SNAPSHOT_BRANCH + name: Authorize with NPM + command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + - run: npm version $SNAPSHOT_VERSION --no-git-tag-version + - run: npm publish --tag snapshot - run: name: Install jq command: sudo apt-get update && sudo apt-get install -y jq - - run: - name: Replace snapshot branch in comment template - command: sed -i "s|{BRANCH}|$SNAPSHOT_BRANCH|g" scripts/snapshot-comment.md + - find_and_replace: + files: scripts/snapshot-comment.md + search: '{VERSION}' + replace: $SNAPSHOT_VERSION - notify_github: data: "$(jq -Rcs '{ body: . }' scripts/snapshot-comment.md)" diff --git a/scripts/snapshot-branch.sh b/scripts/snapshot-branch.sh deleted file mode 100755 index 652dd1bb98..0000000000 --- a/scripts/snapshot-branch.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -pr_url="https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open" -pr_response=$(curl --location --request GET "$pr_url" --header "Authorization: Bearer $RELEASE_GITHUB_TOKEN") - -if [ $(echo "$pr_response" | jq length) -eq 0 ]; then - echo "No PR found, proceeding with branch name instead" - - SNAPSHOT_BRANCH="snapshot/$CIRCLE_BRANCH" -else - pr_description=$(echo "$pr_response" | jq -r '.[].body') - - # The `sed "s/\r//g"` is used to remove the carriage return character \r from the end of the string - SNAPSHOT_BRANCH=$(echo -E "$pr_description" | grep 'Snapshot name:' | cut -d ':' -f 2 | xargs echo -n | sed "s/\r//g" || echo -n) - - if [ -z "$SNAPSHOT_BRANCH" ]; then - echo "No custom snapshot name found, proceeding with default snapshot naming convention" - - version=$(jq -r '.version' package.json) - jira_id=$(echo -E "$pr_description" | grep 'Jira ID:' | grep -Eo '[A-Z]+-[0-9]+' || echo -n) - - if [ -z "$jira_id" ]; then - echo "No Jira ID found, proceeding with branch name instead" - - SNAPSHOT_BRANCH="snapshot/$CIRCLE_BRANCH" - else - SNAPSHOT_BRANCH="snapshot/$version-$jira_id" - fi - fi -fi diff --git a/scripts/snapshot-comment.md b/scripts/snapshot-comment.md index 25ee16227b..6acb6d7267 100644 --- a/scripts/snapshot-comment.md +++ b/scripts/snapshot-comment.md @@ -5,11 +5,11 @@ Your snapshot has been generated! :rocket: You can install the snapshot through NPM: ```sh -npm install https://github.com/Instabug/Instabug-React-Native\#{BRANCH} +npm install instabug-reactnative@{VERSION} ``` or Yarn: ```sh -yarn add https://github.com/Instabug/Instabug-React-Native\#{BRANCH} +yarn add instabug-reactnative@{VERSION} ``` diff --git a/scripts/snapshot-version.sh b/scripts/snapshot-version.sh new file mode 100755 index 0000000000..7ba0a0fd58 --- /dev/null +++ b/scripts/snapshot-version.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Generates a snapshot version following the format {version}-{pr}{random-3-digit}-SNAPSHOT +# Example: 13.3.0-502861-SNAPSHOT + +pr=$(basename $CIRCLE_PULL_REQUEST) +random=$(($RANDOM % 900 + 100)) +version=$(jq -r '.version' package.json) +suffix="SNAPSHOT" + +SNAPSHOT_VERSION="$version-$pr$random-$suffix" From ee836a130741b96a68809d2ecf642622a204c564 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Thu, 12 Sep 2024 12:20:52 +0300 Subject: [PATCH 37/40] fix: changelog merge issues --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index acb003486f..80cd1b9fe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)). +- Enhance the network interceptor to capture some client error messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) From 97350b4cc398100f788f736460e80c856fc62251 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Thu, 12 Sep 2024 12:21:28 +0300 Subject: [PATCH 38/40] fix: changelog merge issues --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80cd1b9fe2..3b1ee5e7b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Added - Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)). -- Enhance the network interceptor to capture some client error messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)). +- Enhance the network interceptor to capture some client error messages ([#1257](https://github.com/Instabug/Instabug-React-Native/pull/1257)). ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) From 0a16c77da86b2a2a90ab75559b4ba066fc6a074d Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Thu, 12 Sep 2024 17:03:42 +0300 Subject: [PATCH 39/40] fix: PR comments --- src/utils/XhrNetworkInterceptor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index bd6660a61d..54f4bf5108 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -153,7 +153,7 @@ export default { const _response = this._response; // Detect a more descriptive error message. if (typeof _response === 'string' && _response.length > 0) { - cloneNetwork.errorDomain = _response.replaceAll(' ', '-'); + cloneNetwork.errorDomain = _response; } // @ts-ignore From b1424becfea768de86f5b62c28ee9b45f45f5ff3 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Sun, 15 Sep 2024 18:59:29 +0300 Subject: [PATCH 40/40] fix: merge issues --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b1ee5e7b7..5516848a07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Added - Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)). -- Enhance the network interceptor to capture some client error messages ([#1257](https://github.com/Instabug/Instabug-React-Native/pull/1257)). +- Enhance the network interceptor to capture more client error messages ([#1257](https://github.com/Instabug/Instabug-React-Native/pull/1257)). ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)