Skip to content

Commit dc89917

Browse files
Merge remote-tracking branch 'origin/dev' into feat/dev-into-network-spans
2 parents 150477a + a9863bb commit dc89917

File tree

8 files changed

+160
-26
lines changed

8 files changed

+160
-26
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public String getName() {
4343
}
4444

4545
/**
46-
* Sets the printed logs priority. Filter to one of the following levels.
46+
* Pauses the current thread for 3 seconds.
4747
*/
4848
@ReactMethod
4949
public void ibgSleep() {
@@ -57,6 +57,7 @@ public void run() {
5757

5858
/**
5959
* Enables or disables APM.
60+
*
6061
* @param isEnabled boolean indicating enabled or disabled.
6162
*/
6263
@ReactMethod
@@ -75,6 +76,7 @@ public void run() {
7576

7677
/**
7778
* Enables or disables app launch tracking.
79+
*
7880
* @param isEnabled boolean indicating enabled or disabled.
7981
*/
8082
@ReactMethod
@@ -92,7 +94,7 @@ public void run() {
9294
}
9395

9496
/**
95-
* Ends app launch
97+
* This method is used to signal the end of the app launch process.
9698
*/
9799
@ReactMethod
98100
public void endAppLaunch() {
@@ -110,6 +112,7 @@ public void run() {
110112

111113
/**
112114
* Enables or disables auto UI tracing
115+
*
113116
* @param isEnabled boolean indicating enabled or disabled.
114117
*/
115118
@ReactMethod
@@ -281,6 +284,7 @@ public void run() {
281284

282285
/**
283286
* Starts a UI trace
287+
*
284288
* @param name string name of the UI trace.
285289
*/
286290
@ReactMethod
@@ -298,7 +302,7 @@ public void run() {
298302
}
299303

300304
/**
301-
* Ends the current running UI trace
305+
* This method is used to terminate the currently active UI trace.
302306
*/
303307
@ReactMethod
304308
public void endUITrace() {
@@ -314,6 +318,73 @@ public void run() {
314318
});
315319
}
316320

321+
/**
322+
* The `networkLogAndroid` function logs network-related information using APMNetworkLogger in a React
323+
* Native module.
324+
*
325+
* @param requestStartTime The `requestStartTime` parameter in the `networkLogAndroid` method
326+
* represents the timestamp when the network request started. It is of type `double` and is passed as
327+
* a parameter to log network-related information.
328+
* @param requestDuration The `requestDuration` parameter in the `networkLogAndroid` method represents
329+
* the duration of the network request in milliseconds. It indicates the time taken for the request to
330+
* complete from the moment it was initiated until the response was received. This parameter helps in
331+
* measuring the performance of network requests and identifying any potential
332+
* @param requestHeaders requestHeaders is a string parameter that contains the headers of the network
333+
* request. It typically includes information such as the content type, authorization token, and any
334+
* other headers that were sent with the request.
335+
* @param requestBody The `requestBody` parameter in the `networkLogAndroid` method represents the
336+
* body of the HTTP request being logged. It contains the data that is sent as part of the request to
337+
* the server. This could include form data, JSON payload, XML data, or any other content that is
338+
* being transmitted
339+
* @param requestBodySize The `requestBodySize` parameter in the `networkLogAndroid` method represents
340+
* the size of the request body in bytes. It is a double value that indicates the size of the request
341+
* body being sent in the network request. This parameter is used to log information related to the
342+
* network request, including details
343+
* @param requestMethod The `requestMethod` parameter in the `networkLogAndroid` method represents the
344+
* HTTP method used in the network request, such as GET, POST, PUT, DELETE, etc. It indicates the type
345+
* of operation that the client is requesting from the server.
346+
* @param requestUrl The `requestUrl` parameter in the `networkLogAndroid` method represents the URL
347+
* of the network request being logged. It typically contains the address of the server to which the
348+
* request is being made, along with any additional path or query parameters required for the request.
349+
* This URL is essential for identifying the
350+
* @param requestContentType The `requestContentType` parameter in the `networkLogAndroid` method
351+
* represents the content type of the request being made. This could be values like
352+
* "application/json", "application/xml", "text/plain", etc., indicating the format of the data being
353+
* sent in the request body. It helps in specifying
354+
* @param responseHeaders The `responseHeaders` parameter in the `networkLogAndroid` method represents
355+
* the headers of the response received from a network request. These headers typically include
356+
* information such as content type, content length, server information, and any other metadata
357+
* related to the response. The `responseHeaders` parameter is expected to
358+
* @param responseBody The `responseBody` parameter in the `networkLogAndroid` method represents the
359+
* body of the response received from a network request. It contains the data or content sent back by
360+
* the server in response to the request made by the client. This could be in various formats such as
361+
* JSON, XML, HTML
362+
* @param responseBodySize The `responseBodySize` parameter in the `networkLogAndroid` method
363+
* represents the size of the response body in bytes. It is a double value that indicates the size of
364+
* the response body received from the network request. This parameter is used to log information
365+
* related to the network request and response, including
366+
* @param statusCode The `statusCode` parameter in the `networkLogAndroid` method represents the HTTP
367+
* status code of the network request/response. It indicates the status of the HTTP response, such as
368+
* success (200), redirection (3xx), client errors (4xx), or server errors (5xx). This parameter is
369+
* @param responseContentType The `responseContentType` parameter in the `networkLogAndroid` method
370+
* represents the content type of the response received from the network request. It indicates the
371+
* format of the data in the response, such as JSON, XML, HTML, etc. This information is useful for
372+
* understanding how to parse and handle the
373+
* @param errorDomain The `errorDomain` parameter in the `networkLogAndroid` method is used to specify
374+
* the domain of an error, if any occurred during the network request. If there was no error, this
375+
* parameter will be `null`.
376+
* @param w3cAttributes The `w3cAttributes` parameter in the `networkLogAndroid` method is a
377+
* ReadableMap object that contains additional attributes related to W3C external trace. It may
378+
* include the following key-value pairs:
379+
* @param gqlQueryName The `gqlQueryName` parameter in the `networkLogAndroid` method represents the
380+
* name of the GraphQL query being executed. It is a nullable parameter, meaning it can be null if no
381+
* GraphQL query name is provided. This parameter is used to log information related to GraphQL
382+
* queries in the network logging
383+
* @param serverErrorMessage The `serverErrorMessage` parameter in the `networkLogAndroid` method is
384+
* used to pass any error message received from the server during network communication. This message
385+
* can provide additional details about any errors that occurred on the server side, helping in
386+
* debugging and troubleshooting network-related issues.
387+
*/
317388
@ReactMethod
318389
private void networkLogAndroid(final double requestStartTime,
319390
final double requestDuration,

examples/default/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ PODS:
13191319
- ReactCommon/turbomodule/bridging
13201320
- ReactCommon/turbomodule/core
13211321
- Yoga
1322-
- react-native-webview (13.12.3):
1322+
- react-native-webview (13.13.2):
13231323
- DoubleConversion
13241324
- glog
13251325
- hermes-engine
@@ -2057,7 +2057,7 @@ SPEC CHECKSUMS:
20572057
react-native-maps: 72a8a903f8a1b53e2c777ba79102078ab502e0bf
20582058
react-native-safe-area-context: 142fade490cbebbe428640b8cbdb09daf17e8191
20592059
react-native-slider: 4a0f3386a38fc3d2d955efc515aef7096f7d1ee4
2060-
react-native-webview: 926d2665cf3196e39c4449a72d136d0a53b9df8a
2060+
react-native-webview: c0b91a4598bd54e9fbc70353aebf1e9bab2e5bb9
20612061
React-nativeconfig: 8c83d992b9cc7d75b5abe262069eaeea4349f794
20622062
React-NativeModulesApple: 9f7920224a3b0c7d04d77990067ded14cee3c614
20632063
React-perflogger: 59e1a3182dca2cee7b9f1f7aab204018d46d1914

examples/default/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"react-native-screens": "^3.35.0",
3333
"react-native-svg": "^15.8.0",
3434
"react-native-vector-icons": "^10.2.0",
35-
"react-native-webview": "^13.12.3",
35+
"react-native-webview": "^13.13.2",
3636
"react-query": "^3.39.3"
3737
},
3838
"devDependencies": {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import { type DimensionValue, View } from 'react-native';
3+
4+
// Define the component type with static properties
5+
interface CustomGapComponent extends React.FC<{ height?: DimensionValue; width?: DimensionValue }> {
6+
small: JSX.Element;
7+
smallV: JSX.Element;
8+
smallH: JSX.Element;
9+
large: JSX.Element;
10+
largeV: JSX.Element;
11+
largeH: JSX.Element;
12+
}
13+
14+
const defaultDimensionValue = 16;
15+
16+
// Define the CustomGap component
17+
const CustomGap: CustomGapComponent = ({ height, width }) => {
18+
return (
19+
<View
20+
style={{ width: width ?? defaultDimensionValue, height: height ?? defaultDimensionValue }}
21+
/>
22+
);
23+
};
24+
25+
// Assign static properties for predefined gaps
26+
CustomGap.small = <CustomGap height={8} width={8} />;
27+
CustomGap.large = <CustomGap height={32} width={32} />;
28+
CustomGap.smallV = <CustomGap height={8} />;
29+
CustomGap.largeV = <CustomGap height={32} />;
30+
CustomGap.smallH = <CustomGap width={8} />;
31+
CustomGap.largeH = <CustomGap width={32} />;
32+
33+
export default CustomGap;

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import type { HomeStackParamList } from '../../navigation/HomeStack';
33
import React, { useState } from 'react';
44
import { ListTile } from '../../components/ListTile';
55
import { Screen } from '../../components/Screen';
6-
import { Text, Switch } from 'react-native';
6+
import { StyleSheet, Switch, Text, View } from 'react-native';
77
import { APM } from 'instabug-reactnative';
88
import { showNotification } from '../../utils/showNotification';
9+
import CustomGap from '../../components/CustomGap';
910

1011
export const APMScreen: React.FC<NativeStackScreenProps<HomeStackParamList, 'APM'>> = ({
1112
navigation,
@@ -17,16 +18,26 @@ export const APMScreen: React.FC<NativeStackScreenProps<HomeStackParamList, 'APM
1718
APM.setEnabled(value);
1819
showNotification('APM status', 'APM enabled set to ' + value);
1920
};
21+
const styles = StyleSheet.create({
22+
switch: {
23+
flexDirection: 'row',
24+
justifyContent: 'space-between',
25+
},
26+
});
2027

2128
return (
2229
<Screen>
23-
<Text>Enable APM:</Text>
24-
<Switch onValueChange={toggleSwitch} value={isEnabled} />
30+
<View style={styles.switch}>
31+
<Text>Enable APM:</Text>
32+
<Switch onValueChange={toggleSwitch} value={isEnabled} />
33+
</View>
34+
{CustomGap.smallV}
2535
<ListTile title="End App launch" onPress={() => APM.endAppLaunch()} />
2636
<ListTile title="Network Screen" onPress={() => navigation.navigate('NetworkTraces')} />
2737
<ListTile title="Traces" onPress={() => navigation.navigate('ExecutionTraces')} />
2838
<ListTile title="Flows" onPress={() => navigation.navigate('AppFlows')} />
2939
<ListTile title="WebViews" onPress={() => navigation.navigate('WebViews')} />
40+
<ListTile title="Complex Views" onPress={() => navigation.navigate('ComplexViews')} />
3041
</Screen>
3142
);
3243
};

examples/default/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6329,10 +6329,10 @@ react-native-vector-icons@^10.2.0:
63296329
prop-types "^15.7.2"
63306330
yargs "^16.1.1"
63316331

6332-
react-native-webview@^13.12.3:
6333-
version "13.12.3"
6334-
resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-13.12.3.tgz#3aa9d2fc982ba2681e56d3e96e22b63a0d929270"
6335-
integrity sha512-Y1I5YyDYyE7NC96RHLhd2nxh7ymLYOYLTefgx5ixxw2OToQK0ow3OJ+o77QcI1Tuevj5PCxwqC/14ceS/7yPJQ==
6332+
react-native-webview@^13.13.2:
6333+
version "13.13.2"
6334+
resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-13.13.2.tgz#6d72fd8492f11accbcf3be4d1386fa961e424357"
6335+
integrity sha512-zACPDTF0WnaEnKZ9mA/r/UpcOpV2gQM06AAIrOOexnO8UJvXL8Pjso0b/wTqKFxUZZnmjKuwd8gHVUosVOdVrw==
63366336
dependencies:
63376337
escape-string-regexp "^4.0.0"
63386338
invariant "2.2.4"

ios/RNInstabug/InstabugAPMBridge.m

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,34 @@ - (id) init
3636
return self;
3737
}
3838

39+
// Pauses the current thread for 3 seconds.
3940
RCT_EXPORT_METHOD(ibgSleep) {
4041
[NSThread sleepForTimeInterval:3.0f];
41-
// for (int i = 1; i <= 1000000; i++)
42-
// {
43-
// double value = sqrt(i);
44-
45-
// printf("%@", [NSNumber numberWithDouble:value]);
46-
// }
47-
// [NSThread sleepForTimeInterval:3.0f];
4842
}
4943

44+
// Enables or disables APM.
5045
RCT_EXPORT_METHOD(setEnabled:(BOOL)isEnabled) {
5146
IBGAPM.enabled = isEnabled;
5247
}
5348

49+
// Determines either coldAppLaunch is enabled or not.
5450
RCT_EXPORT_METHOD(setAppLaunchEnabled:(BOOL)isEnabled) {
5551
IBGAPM.coldAppLaunchEnabled = isEnabled;
5652
}
5753

54+
// This method is used to signal the end of the app launch process.
5855
RCT_EXPORT_METHOD(endAppLaunch) {
5956
[IBGAPM endAppLaunch];
6057
}
6158

59+
// Controls whether automatic tracing of UI interactions is enabled or disabled within the SDK.
6260
RCT_EXPORT_METHOD(setAutoUITraceEnabled:(BOOL)isEnabled) {
6361
IBGAPM.autoUITraceEnabled = isEnabled;
6462
}
6563

64+
// Starts new execution trace with the specified `name`.
65+
//
66+
// Deprecated see [startFlow: (NSString *)name]
6667
RCT_EXPORT_METHOD(startExecutionTrace:(NSString *)name :(NSString *)id
6768
:(RCTPromiseResolveBlock)resolve
6869
:(RCTPromiseRejectBlock)reject) {
@@ -75,37 +76,50 @@ - (id) init
7576
}
7677
}
7778

79+
// Sets a user defined attribute for the execution trace.
80+
//
81+
// Deprecated see [setFlowAttribute:(NSString *)name :(NSString *)key :(NSString *_Nullable)value]
7882
RCT_EXPORT_METHOD(setExecutionTraceAttribute:(NSString *)id :(NSString *)key :(NSString *)value) {
7983
IBGExecutionTrace *trace = [traces objectForKey:id];
8084
if (trace != nil) {
8185
[trace setAttributeWithKey:key value:value];
8286
}
8387
}
8488

89+
// Ends execution trace with the specified `name`.
90+
//
91+
// Deprecated see [endFlow: (NSString *)name]
8592
RCT_EXPORT_METHOD(endExecutionTrace:(NSString *)id) {
8693
IBGExecutionTrace *trace = [traces objectForKey:id];
8794
if (trace != nil) {
8895
[trace end];
8996
}
9097
}
9198

99+
// Starts a flow trace with the specified `name`,
100+
// allowing the SDK to capture and analyze the flow of execution within the application.
92101
RCT_EXPORT_METHOD(startFlow: (NSString *)name) {
93102
[IBGAPM startFlowWithName:name];
94103
}
95104

105+
// Ends a flow with the specified `name`.
96106
RCT_EXPORT_METHOD(endFlow: (NSString *)name) {
97107
[IBGAPM endFlowWithName:name];
98108
}
99109

100110

111+
// Sets a user defined attribute for the currently active flow.
101112
RCT_EXPORT_METHOD(setFlowAttribute:(NSString *)name :(NSString *)key :(NSString *_Nullable)value) {
102113
[IBGAPM setAttributeForFlowWithName:name key:key value:value];
103114
}
104115

116+
// Starts a new `UITrace` with the provided `name` parameter,
117+
// allowing the SDK to capture and analyze the UI components within the application.
105118
RCT_EXPORT_METHOD(startUITrace:(NSString *)name) {
106119
[IBGAPM startUITraceWithName:name];
107120
}
108121

122+
// Terminates the currently active UI trace.
109123
RCT_EXPORT_METHOD(endUITrace) {
110124
[IBGAPM endUITrace];
111125
}

src/modules/APM.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,26 @@ export const setEnabled = (isEnabled: boolean) => {
1313
};
1414

1515
/**
16-
* Enables or disables APM App Launch
16+
* If APM is enabled, Instabug SDK starts collecting data about the app launch time by default.
17+
* This API is used to give user more control over this behavior.
1718
* @param isEnabled
1819
*/
1920
export const setAppLaunchEnabled = (isEnabled: boolean) => {
2021
NativeAPM.setAppLaunchEnabled(isEnabled);
2122
};
2223

2324
/**
24-
* Ends app launch
25+
* To define when an app launch is complete,
26+
* such as when it's intractable, use the end app launch API.
27+
* You can then view this data with the automatic cold app launch.
2528
*/
2629
export const endAppLaunch = () => {
2730
NativeAPM.endAppLaunch();
2831
};
2932

3033
/**
3134
* Enables or disables APM Network Metric
32-
* @param isEnabled
35+
* @param isEnabled - a boolean indicates either iOS monitoring is enabled or disabled.
3336
*/
3437
export const setNetworkEnabledIOS = (isEnabled: boolean) => {
3538
if (Platform.OS === 'ios') {
@@ -114,15 +117,17 @@ export const setFlowAttribute = (name: string, key: string, value?: string | nul
114117
};
115118

116119
/**
117-
* Starts a custom trace
118-
* @param name
120+
* Initiates a UI trace with the specified name using a native module.
121+
* @param {string} name - The `name` parameter in the `startUITrace` function is a string that
122+
* represents the name of the UI trace that you want to start. This name is used to identify and track
123+
* the specific UI trace within the application.
119124
*/
120125
export const startUITrace = (name: string) => {
121126
NativeAPM.startUITrace(name);
122127
};
123128

124129
/**
125-
* Ends a custom trace
130+
* Ends the currently running custom trace.
126131
*/
127132
export const endUITrace = () => {
128133
NativeAPM.endUITrace();

0 commit comments

Comments
 (0)