diff --git a/CHANGELOG.md b/CHANGELOG.md index e1f28a933..0e37add3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [14.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v14.1.0...14.3.0) + +### Added + +- Add support for enable/disable capturing network body. ([#1362](https://github.com/Instabug/Instabug-React-Native/pull/1362)) + +### Changed + +- Bump Instabug iOS SDK to v14.3.0 ([#1367](https://github.com/Instabug/Instabug-React-Native/pull/1367)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/14.3.0). + +- Bump Instabug Android SDK to v14.3.0 ([#1375](https://github.com/Instabug/Instabug-React-Native/pull/1375)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v14.3.0). + ## [14.1.0](https://github.com/Instabug/Instabug-React-Native/compare/v14.0.0...v14.1.0) (January 2, 2025) ### Added diff --git a/RNInstabug.podspec b/RNInstabug.podspec index 40c480f4c..843865b5b 100644 --- a/RNInstabug.podspec +++ b/RNInstabug.podspec @@ -17,4 +17,5 @@ Pod::Spec.new do |s| s.dependency 'React-Core' use_instabug!(s) + end diff --git a/android/build.gradle b/android/build.gradle index 8a312ccb3..1093a8f1d 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 "14.1.0" + versionName "14.3.0" multiDexEnabled true ndk { abiFilters "armeabi-v7a", "x86" diff --git a/android/native.gradle b/android/native.gradle index 652733c4f..3241dc5f2 100644 --- a/android/native.gradle +++ b/android/native.gradle @@ -1,5 +1,5 @@ project.ext.instabug = [ - version: '14.1.0' + version: '14.3.0' ] dependencies { diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java index 8b3c3206e..d75b4f75b 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java @@ -43,7 +43,7 @@ public String getName() { } /** - * Sets the printed logs priority. Filter to one of the following levels. + * Pauses the current thread for 3 seconds. */ @ReactMethod public void ibgSleep() { @@ -57,6 +57,7 @@ public void run() { /** * Enables or disables APM. + * * @param isEnabled boolean indicating enabled or disabled. */ @ReactMethod @@ -75,6 +76,7 @@ public void run() { /** * Enables or disables app launch tracking. + * * @param isEnabled boolean indicating enabled or disabled. */ @ReactMethod @@ -92,7 +94,7 @@ public void run() { } /** - * Ends app launch + * This method is used to signal the end of the app launch process. */ @ReactMethod public void endAppLaunch() { @@ -110,6 +112,7 @@ public void run() { /** * Enables or disables auto UI tracing + * * @param isEnabled boolean indicating enabled or disabled. */ @ReactMethod @@ -281,6 +284,7 @@ public void run() { /** * Starts a UI trace + * * @param name string name of the UI trace. */ @ReactMethod @@ -298,7 +302,7 @@ public void run() { } /** - * Ends the current running UI trace + * This method is used to terminate the currently active UI trace. */ @ReactMethod public void endUITrace() { @@ -314,6 +318,73 @@ public void run() { }); } + /** + * The `networkLogAndroid` function logs network-related information using APMNetworkLogger in a React + * Native module. + * + * @param requestStartTime The `requestStartTime` parameter in the `networkLogAndroid` method + * represents the timestamp when the network request started. It is of type `double` and is passed as + * a parameter to log network-related information. + * @param requestDuration The `requestDuration` parameter in the `networkLogAndroid` method represents + * the duration of the network request in milliseconds. It indicates the time taken for the request to + * complete from the moment it was initiated until the response was received. This parameter helps in + * measuring the performance of network requests and identifying any potential + * @param requestHeaders requestHeaders is a string parameter that contains the headers of the network + * request. It typically includes information such as the content type, authorization token, and any + * other headers that were sent with the request. + * @param requestBody The `requestBody` parameter in the `networkLogAndroid` method represents the + * body of the HTTP request being logged. It contains the data that is sent as part of the request to + * the server. This could include form data, JSON payload, XML data, or any other content that is + * being transmitted + * @param requestBodySize The `requestBodySize` parameter in the `networkLogAndroid` method represents + * the size of the request body in bytes. It is a double value that indicates the size of the request + * body being sent in the network request. This parameter is used to log information related to the + * network request, including details + * @param requestMethod The `requestMethod` parameter in the `networkLogAndroid` method represents the + * HTTP method used in the network request, such as GET, POST, PUT, DELETE, etc. It indicates the type + * of operation that the client is requesting from the server. + * @param requestUrl The `requestUrl` parameter in the `networkLogAndroid` method represents the URL + * of the network request being logged. It typically contains the address of the server to which the + * request is being made, along with any additional path or query parameters required for the request. + * This URL is essential for identifying the + * @param requestContentType The `requestContentType` parameter in the `networkLogAndroid` method + * represents the content type of the request being made. This could be values like + * "application/json", "application/xml", "text/plain", etc., indicating the format of the data being + * sent in the request body. It helps in specifying + * @param responseHeaders The `responseHeaders` parameter in the `networkLogAndroid` method represents + * the headers of the response received from a network request. These headers typically include + * information such as content type, content length, server information, and any other metadata + * related to the response. The `responseHeaders` parameter is expected to + * @param responseBody The `responseBody` parameter in the `networkLogAndroid` method represents the + * body of the response received from a network request. It contains the data or content sent back by + * the server in response to the request made by the client. This could be in various formats such as + * JSON, XML, HTML + * @param responseBodySize The `responseBodySize` parameter in the `networkLogAndroid` method + * represents the size of the response body in bytes. It is a double value that indicates the size of + * the response body received from the network request. This parameter is used to log information + * related to the network request and response, including + * @param statusCode The `statusCode` parameter in the `networkLogAndroid` method represents the HTTP + * status code of the network request/response. It indicates the status of the HTTP response, such as + * success (200), redirection (3xx), client errors (4xx), or server errors (5xx). This parameter is + * @param responseContentType The `responseContentType` parameter in the `networkLogAndroid` method + * represents the content type of the response received from the network request. It indicates the + * format of the data in the response, such as JSON, XML, HTML, etc. This information is useful for + * understanding how to parse and handle the + * @param errorDomain The `errorDomain` parameter in the `networkLogAndroid` method is used to specify + * the domain of an error, if any occurred during the network request. If there was no error, this + * parameter will be `null`. + * @param w3cAttributes The `w3cAttributes` parameter in the `networkLogAndroid` method is a + * ReadableMap object that contains additional attributes related to W3C external trace. It may + * include the following key-value pairs: + * @param gqlQueryName The `gqlQueryName` parameter in the `networkLogAndroid` method represents the + * name of the GraphQL query being executed. It is a nullable parameter, meaning it can be null if no + * GraphQL query name is provided. This parameter is used to log information related to GraphQL + * queries in the network logging + * @param serverErrorMessage The `serverErrorMessage` parameter in the `networkLogAndroid` method is + * used to pass any error message received from the server during network communication. This message + * can provide additional details about any errors that occurred on the server side, helping in + * debugging and troubleshooting network-related issues. + */ @ReactMethod private void networkLogAndroid(final double requestStartTime, final double requestDuration, diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 9c901cb7a..72872fac8 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -1274,4 +1274,22 @@ public Map getConstants() { return constants; } + + /** + * Enables or disables capturing network body. + * @param isEnabled A boolean to enable/disable capturing network body. + */ + @ReactMethod + public void setNetworkLogBodyEnabled(final boolean isEnabled) { + MainThreadHandler.runOnMainThread(new Runnable() { + @Override + public void run() { + try { + Instabug.setNetworkLogBodyEnabled(isEnabled); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } } diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m index 8744ce4eb..281fc35d6 100644 --- a/examples/default/ios/InstabugTests/InstabugSampleTests.m +++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m @@ -609,4 +609,13 @@ - (void) testIsW3CaughtHeaderEnabled { } +- (void)testSetNetworkLogBodyEnabled { + id mock = OCMClassMock([IBGNetworkLogger class]); + BOOL isEnabled = YES; + + OCMStub([mock setLogBodyEnabled:isEnabled]); + [self.instabugBridge setNetworkLogBodyEnabled:isEnabled]; + OCMVerify([mock setLogBodyEnabled:isEnabled]); +} + @end diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock index 6572db607..2062dad75 100644 --- a/examples/default/ios/Podfile.lock +++ b/examples/default/ios/Podfile.lock @@ -31,7 +31,7 @@ PODS: - hermes-engine (0.75.4): - hermes-engine/Pre-built (= 0.75.4) - hermes-engine/Pre-built (0.75.4) - - Instabug (14.1.0) + - Instabug (14.3.0) - instabug-reactnative-ndk (0.1.0): - DoubleConversion - glog @@ -1319,7 +1319,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - react-native-webview (13.12.3): + - react-native-webview (13.13.2): - DoubleConversion - glog - hermes-engine @@ -1623,8 +1623,8 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNInstabug (14.1.0): - - Instabug (= 14.1.0) + - RNInstabug (14.3.0): + - Instabug (= 14.3.0) - React-Core - RNReanimated (3.16.1): - DoubleConversion @@ -2017,7 +2017,7 @@ SPEC CHECKSUMS: Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0 - Instabug: 8cbca8974168c815658133e2813f5ac3a36f8e20 + Instabug: 97a4e694731f46bbc02dbe49ab29cc552c5e2f41 instabug-reactnative-ndk: d765ac289d56e8896398d02760d9abf2562fc641 OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74 RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740 @@ -2055,7 +2055,7 @@ SPEC CHECKSUMS: react-native-maps: 72a8a903f8a1b53e2c777ba79102078ab502e0bf react-native-safe-area-context: 142fade490cbebbe428640b8cbdb09daf17e8191 react-native-slider: 4a0f3386a38fc3d2d955efc515aef7096f7d1ee4 - react-native-webview: 926d2665cf3196e39c4449a72d136d0a53b9df8a + react-native-webview: c0b91a4598bd54e9fbc70353aebf1e9bab2e5bb9 React-nativeconfig: 8c83d992b9cc7d75b5abe262069eaeea4349f794 React-NativeModulesApple: 9f7920224a3b0c7d04d77990067ded14cee3c614 React-perflogger: 59e1a3182dca2cee7b9f1f7aab204018d46d1914 @@ -2084,7 +2084,7 @@ SPEC CHECKSUMS: ReactCommon: 6a952e50c2a4b694731d7682aaa6c79bc156e4ad RNCClipboard: 2821ac938ef46f736a8de0c8814845dde2dcbdfb RNGestureHandler: 511250b190a284388f9dd0d2e56c1df76f14cfb8 - RNInstabug: 96e629f47c0af2e9455fbcf800d12049f980d873 + RNInstabug: c55b6c697b39d3cbe51b1ab9b729f0b55ed619f1 RNReanimated: f42a5044d121d68e91680caacb0293f4274228eb RNScreens: c7ceced6a8384cb9be5e7a5e88e9e714401fd958 RNSVG: 8b1a777d54096b8c2a0fd38fc9d5a454332bbb4d diff --git a/examples/default/package.json b/examples/default/package.json index 26959bb0b..ab70e536b 100644 --- a/examples/default/package.json +++ b/examples/default/package.json @@ -32,7 +32,7 @@ "react-native-screens": "^3.35.0", "react-native-svg": "^15.8.0", "react-native-vector-icons": "^10.2.0", - "react-native-webview": "^13.12.3", + "react-native-webview": "^13.13.2", "react-query": "^3.39.3" }, "devDependencies": { diff --git a/examples/default/src/components/CustomGap.tsx b/examples/default/src/components/CustomGap.tsx new file mode 100644 index 000000000..bf43eb9d4 --- /dev/null +++ b/examples/default/src/components/CustomGap.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { type DimensionValue, View } from 'react-native'; + +// Define the component type with static properties +interface CustomGapComponent extends React.FC<{ height?: DimensionValue; width?: DimensionValue }> { + small: JSX.Element; + smallV: JSX.Element; + smallH: JSX.Element; + large: JSX.Element; + largeV: JSX.Element; + largeH: JSX.Element; +} + +const defaultDimensionValue = 16; + +// Define the CustomGap component +const CustomGap: CustomGapComponent = ({ height, width }) => { + return ( + + ); +}; + +// Assign static properties for predefined gaps +CustomGap.small = ; +CustomGap.large = ; +CustomGap.smallV = ; +CustomGap.largeV = ; +CustomGap.smallH = ; +CustomGap.largeH = ; + +export default CustomGap; diff --git a/examples/default/src/screens/apm/APMScreen.tsx b/examples/default/src/screens/apm/APMScreen.tsx index d63ee65f4..3652a95c5 100644 --- a/examples/default/src/screens/apm/APMScreen.tsx +++ b/examples/default/src/screens/apm/APMScreen.tsx @@ -3,9 +3,10 @@ import type { HomeStackParamList } from '../../navigation/HomeStack'; import React, { useState } from 'react'; import { ListTile } from '../../components/ListTile'; import { Screen } from '../../components/Screen'; -import { Text, Switch } from 'react-native'; +import { StyleSheet, Switch, Text, View } from 'react-native'; import { APM } from 'instabug-reactnative'; import { showNotification } from '../../utils/showNotification'; +import CustomGap from '../../components/CustomGap'; export const APMScreen: React.FC> = ({ navigation, @@ -17,16 +18,26 @@ export const APMScreen: React.FC - Enable APM: - + + Enable APM: + + + {CustomGap.smallV} APM.endAppLaunch()} /> navigation.navigate('NetworkTraces')} /> navigation.navigate('ExecutionTraces')} /> navigation.navigate('AppFlows')} /> navigation.navigate('WebViews')} /> + navigation.navigate('ComplexViews')} /> ); }; diff --git a/examples/default/yarn.lock b/examples/default/yarn.lock index 3e1f047c3..c484688ce 100644 --- a/examples/default/yarn.lock +++ b/examples/default/yarn.lock @@ -6329,10 +6329,10 @@ react-native-vector-icons@^10.2.0: prop-types "^15.7.2" yargs "^16.1.1" -react-native-webview@^13.12.3: - version "13.12.3" - resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-13.12.3.tgz#3aa9d2fc982ba2681e56d3e96e22b63a0d929270" - integrity sha512-Y1I5YyDYyE7NC96RHLhd2nxh7ymLYOYLTefgx5ixxw2OToQK0ow3OJ+o77QcI1Tuevj5PCxwqC/14ceS/7yPJQ== +react-native-webview@^13.13.2: + version "13.13.2" + resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-13.13.2.tgz#6d72fd8492f11accbcf3be4d1386fa961e424357" + integrity sha512-zACPDTF0WnaEnKZ9mA/r/UpcOpV2gQM06AAIrOOexnO8UJvXL8Pjso0b/wTqKFxUZZnmjKuwd8gHVUosVOdVrw== dependencies: escape-string-regexp "^4.0.0" invariant "2.2.4" diff --git a/ios/RNInstabug/InstabugAPMBridge.m b/ios/RNInstabug/InstabugAPMBridge.m index daea8b4c1..dd77bf130 100644 --- a/ios/RNInstabug/InstabugAPMBridge.m +++ b/ios/RNInstabug/InstabugAPMBridge.m @@ -36,33 +36,34 @@ - (id) init return self; } +// Pauses the current thread for 3 seconds. RCT_EXPORT_METHOD(ibgSleep) { [NSThread sleepForTimeInterval:3.0f]; - // for (int i = 1; i <= 1000000; i++) - // { - // double value = sqrt(i); - - // printf("%@", [NSNumber numberWithDouble:value]); - // } - // [NSThread sleepForTimeInterval:3.0f]; } +// Enables or disables APM. RCT_EXPORT_METHOD(setEnabled:(BOOL)isEnabled) { IBGAPM.enabled = isEnabled; } +// Determines either coldAppLaunch is enabled or not. RCT_EXPORT_METHOD(setAppLaunchEnabled:(BOOL)isEnabled) { IBGAPM.coldAppLaunchEnabled = isEnabled; } +// This method is used to signal the end of the app launch process. RCT_EXPORT_METHOD(endAppLaunch) { [IBGAPM endAppLaunch]; } +// Controls whether automatic tracing of UI interactions is enabled or disabled within the SDK. RCT_EXPORT_METHOD(setAutoUITraceEnabled:(BOOL)isEnabled) { IBGAPM.autoUITraceEnabled = isEnabled; } +// Starts new execution trace with the specified `name`. +// +// Deprecated see [startFlow: (NSString *)name] RCT_EXPORT_METHOD(startExecutionTrace:(NSString *)name :(NSString *)id :(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject) { @@ -75,6 +76,9 @@ - (id) init } } +// Sets a user defined attribute for the execution trace. +// +// Deprecated see [setFlowAttribute:(NSString *)name :(NSString *)key :(NSString *_Nullable)value] RCT_EXPORT_METHOD(setExecutionTraceAttribute:(NSString *)id :(NSString *)key :(NSString *)value) { IBGExecutionTrace *trace = [traces objectForKey:id]; if (trace != nil) { @@ -82,6 +86,9 @@ - (id) init } } +// Ends execution trace with the specified `name`. +// +// Deprecated see [endFlow: (NSString *)name] RCT_EXPORT_METHOD(endExecutionTrace:(NSString *)id) { IBGExecutionTrace *trace = [traces objectForKey:id]; if (trace != nil) { @@ -89,23 +96,30 @@ - (id) init } } +// Starts a flow trace with the specified `name`, +// allowing the SDK to capture and analyze the flow of execution within the application. RCT_EXPORT_METHOD(startFlow: (NSString *)name) { [IBGAPM startFlowWithName:name]; } +// Ends a flow with the specified `name`. RCT_EXPORT_METHOD(endFlow: (NSString *)name) { [IBGAPM endFlowWithName:name]; } +// Sets a user defined attribute for the currently active flow. RCT_EXPORT_METHOD(setFlowAttribute:(NSString *)name :(NSString *)key :(NSString *_Nullable)value) { [IBGAPM setAttributeForFlowWithName:name key:key value:value]; } +// Starts a new `UITrace` with the provided `name` parameter, +// allowing the SDK to capture and analyze the UI components within the application. RCT_EXPORT_METHOD(startUITrace:(NSString *)name) { [IBGAPM startUITraceWithName:name]; } +// Terminates the currently active UI trace. RCT_EXPORT_METHOD(endUITrace) { [IBGAPM endUITrace]; } diff --git a/ios/RNInstabug/InstabugCrashReportingBridge.m b/ios/RNInstabug/InstabugCrashReportingBridge.m index c73a85d5b..9f4cdab55 100644 --- a/ios/RNInstabug/InstabugCrashReportingBridge.m +++ b/ios/RNInstabug/InstabugCrashReportingBridge.m @@ -29,6 +29,7 @@ + (BOOL)requiresMainQueueSetup RCT_EXPORT_METHOD(sendJSCrash:(NSDictionary *)stackTrace resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul); dispatch_async(queue, ^{ [IBGCrashReporting cp_reportFatalCrashWithStackTrace:stackTrace]; @@ -40,6 +41,14 @@ + (BOOL)requiresMainQueueSetup userAttributes:(nullable NSDictionary *)userAttributes fingerprint:(nullable NSString *)fingerprint nonFatalExceptionLevel:(IBGNonFatalLevel)nonFatalExceptionLevel resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { + + if([fingerprint isKindOfClass:NSNull.class]){ + fingerprint = nil; + } + + if([userAttributes isKindOfClass:NSNull.class]){ + userAttributes = nil; + } dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); dispatch_async(queue, ^{ [IBGCrashReporting cp_reportNonFatalCrashWithStackTrace:stackTrace level:nonFatalExceptionLevel groupingString:fingerprint userAttributes:userAttributes]; diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h index bca04ddfd..1498da336 100644 --- a/ios/RNInstabug/InstabugReactBridge.h +++ b/ios/RNInstabug/InstabugReactBridge.h @@ -138,4 +138,6 @@ w3cExternalTraceAttributes:(NSDictionary * _Nullable)w3cExternalTraceAttributes; - (void)addFeatureFlags:(NSDictionary *)featureFlagsMap; - (void)removeFeatureFlags:(NSArray *)featureFlags; - (void)removeAllFeatureFlags; +- (void)setNetworkLogBodyEnabled:(BOOL)isEnabled; + @end diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index e7ca15600..f5237e1b7 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -440,4 +440,7 @@ + (BOOL)iOSVersionIsLessThan:(NSString *)iOSVersion { return [iOSVersion compare:[UIDevice currentDevice].systemVersion options:NSNumericSearch] == NSOrderedDescending; }; +RCT_EXPORT_METHOD(setNetworkLogBodyEnabled:(BOOL)isEnabled) { + IBGNetworkLogger.logBodyEnabled = isEnabled; +} @end diff --git a/ios/native.rb b/ios/native.rb index 4fc710cbe..539131528 100644 --- a/ios/native.rb +++ b/ios/native.rb @@ -1,4 +1,4 @@ -$instabug = { :version => '14.1.0' } +$instabug = { :version => '14.3.0' } def use_instabug! (spec = nil) version = $instabug[:version] diff --git a/package.json b/package.json index e065cb993..a93da7dd3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "instabug-reactnative", "description": "React Native plugin for integrating the Instabug SDK", - "version": "14.1.0", + "version": "14.3.0", "author": "Instabug (https://instabug.com)", "repository": "github:Instabug/Instabug-React-Native", "homepage": "https://www.instabug.com/platforms/react-native", diff --git a/src/modules/APM.ts b/src/modules/APM.ts index 664f4473c..92d401389 100644 --- a/src/modules/APM.ts +++ b/src/modules/APM.ts @@ -13,7 +13,8 @@ export const setEnabled = (isEnabled: boolean) => { }; /** - * Enables or disables APM App Launch + * If APM is enabled, Instabug SDK starts collecting data about the app launch time by default. + * This API is used to give user more control over this behavior. * @param isEnabled */ export const setAppLaunchEnabled = (isEnabled: boolean) => { @@ -21,7 +22,9 @@ export const setAppLaunchEnabled = (isEnabled: boolean) => { }; /** - * Ends app launch + * To define when an app launch is complete, + * such as when it's intractable, use the end app launch API. + * You can then view this data with the automatic cold app launch. */ export const endAppLaunch = () => { NativeAPM.endAppLaunch(); @@ -29,7 +32,7 @@ export const endAppLaunch = () => { /** * Enables or disables APM Network Metric - * @param isEnabled + * @param isEnabled - a boolean indicates either iOS monitoring is enabled or disabled. */ export const setNetworkEnabledIOS = (isEnabled: boolean) => { if (Platform.OS === 'ios') { @@ -114,15 +117,17 @@ export const setFlowAttribute = (name: string, key: string, value?: string | nul }; /** - * Starts a custom trace - * @param name + * Initiates a UI trace with the specified name using a native module. + * @param {string} name - The `name` parameter in the `startUITrace` function is a string that + * represents the name of the UI trace that you want to start. This name is used to identify and track + * the specific UI trace within the application. */ export const startUITrace = (name: string) => { NativeAPM.startUITrace(name); }; /** - * Ends a custom trace + * Ends the currently running custom trace. */ export const endUITrace = () => { NativeAPM.endUITrace(); diff --git a/src/modules/NetworkLogger.ts b/src/modules/NetworkLogger.ts index 1e40b9fa9..4e6b6d379 100644 --- a/src/modules/NetworkLogger.ts +++ b/src/modules/NetworkLogger.ts @@ -5,6 +5,7 @@ import xhr, { NetworkData, ProgressCallback } from '../utils/XhrNetworkIntercept import { isContentTypeNotAllowed, reportNetworkLog } from '../utils/InstabugUtils'; import { InstabugRNConfig } from '../utils/config'; import { Logger } from '../utils/logger'; +import { NativeInstabug } from '../native/NativeInstabug'; export type { NetworkData }; @@ -114,3 +115,11 @@ export const apolloLinkRequestHandler: RequestHandler = (operation, forward) => return forward(operation); }; + +/** + * Sets whether network body logs will be captured or not. + * @param isEnabled + */ +export const setNetworkLogBodyEnabled = (isEnabled: boolean) => { + NativeInstabug.setNetworkLogBodyEnabled(isEnabled); +}; diff --git a/src/native/NativeInstabug.ts b/src/native/NativeInstabug.ts index 5f0628ef7..7fca0bea2 100644 --- a/src/native/NativeInstabug.ts +++ b/src/native/NativeInstabug.ts @@ -72,6 +72,7 @@ export interface InstabugNativeModule extends NativeModule { ): void; setNetworkLoggingEnabled(isEnabled: boolean): void; + setNetworkLogBodyEnabled(isEnabled: boolean): void; // Repro Steps APIs // setReproStepsConfig( diff --git a/test/mocks/mockInstabug.ts b/test/mocks/mockInstabug.ts index 7b3cf2e69..eb02f16f1 100644 --- a/test/mocks/mockInstabug.ts +++ b/test/mocks/mockInstabug.ts @@ -73,6 +73,7 @@ const mockInstabug: InstabugNativeModule = { isW3ExternalGeneratedHeaderEnabled: jest.fn(), isW3CaughtHeaderEnabled: jest.fn(), registerW3CFlagsChangeListener: jest.fn(), + setNetworkLogBodyEnabled: jest.fn(), }; export default mockInstabug; diff --git a/test/modules/NetworkLogger.spec.ts b/test/modules/NetworkLogger.spec.ts index dbf35eddb..d46b10aff 100644 --- a/test/modules/NetworkLogger.spec.ts +++ b/test/modules/NetworkLogger.spec.ts @@ -8,6 +8,7 @@ import Interceptor from '../../src/utils/XhrNetworkInterceptor'; import { isContentTypeNotAllowed, reportNetworkLog } from '../../src/utils/InstabugUtils'; import InstabugConstants from '../../src/utils/InstabugConstants'; import { Logger } from '../../src/utils/logger'; +import { NativeInstabug } from '../../src/native/NativeInstabug'; const clone = (obj: T): T => { return JSON.parse(JSON.stringify(obj)); @@ -282,4 +283,11 @@ describe('NetworkLogger Module', () => { expect(reportNetworkLog).toHaveBeenCalledWith(networkData); }); + + it('should call the native method setNetworkLogBodyEnabled', () => { + NetworkLogger.setNetworkLogBodyEnabled(true); + + expect(NativeInstabug.setNetworkLogBodyEnabled).toBeCalledTimes(1); + expect(NativeInstabug.setNetworkLogBodyEnabled).toBeCalledWith(true); + }); });