Skip to content

Commit 2944c2a

Browse files
chore: pull changes from remove_deprecate_apis branch using rebase
1 parent 432295e commit 2944c2a

File tree

3 files changed

+117
-100
lines changed

3 files changed

+117
-100
lines changed

android/native.gradle

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

55
dependencies {

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

Lines changed: 115 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
package com.instabug.reactlibrary;
33

4+
import static com.instabug.reactlibrary.utils.InstabugUtil.getMethod;
5+
46
import android.os.SystemClock;
57
import android.util.Log;
68

@@ -15,17 +17,13 @@
1517
import com.instabug.apm.networking.APMNetworkLogger;
1618
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
1719
import com.instabug.reactlibrary.utils.EventEmitterModule;
18-
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
1920
import com.instabug.reactlibrary.utils.MainThreadHandler;
2021

2122
import java.lang.reflect.Method;
22-
2323
import java.util.HashMap;
2424

2525
import javax.annotation.Nonnull;
2626

27-
import static com.instabug.reactlibrary.utils.InstabugUtil.getMethod;
28-
2927
public class RNInstabugAPMModule extends EventEmitterModule {
3028

3129
public RNInstabugAPMModule(ReactApplicationContext reactApplicationContext) {
@@ -240,73 +238,73 @@ public void run() {
240238
});
241239
}
242240

243-
/**
244-
* The `networkLogAndroid` function logs network-related information using APMNetworkLogger in a React
245-
* Native module.
246-
*
247-
* @param requestStartTime The `requestStartTime` parameter in the `networkLogAndroid` method
248-
* represents the timestamp when the network request started. It is of type `double` and is passed as
249-
* a parameter to log network-related information.
250-
* @param requestDuration The `requestDuration` parameter in the `networkLogAndroid` method represents
251-
* the duration of the network request in milliseconds. It indicates the time taken for the request to
252-
* complete from the moment it was initiated until the response was received. This parameter helps in
253-
* measuring the performance of network requests and identifying any potential
254-
* @param requestHeaders requestHeaders is a string parameter that contains the headers of the network
255-
* request. It typically includes information such as the content type, authorization token, and any
256-
* other headers that were sent with the request.
257-
* @param requestBody The `requestBody` parameter in the `networkLogAndroid` method represents the
258-
* body of the HTTP request being logged. It contains the data that is sent as part of the request to
259-
* the server. This could include form data, JSON payload, XML data, or any other content that is
260-
* being transmitted
261-
* @param requestBodySize The `requestBodySize` parameter in the `networkLogAndroid` method represents
262-
* the size of the request body in bytes. It is a double value that indicates the size of the request
263-
* body being sent in the network request. This parameter is used to log information related to the
264-
* network request, including details
265-
* @param requestMethod The `requestMethod` parameter in the `networkLogAndroid` method represents the
266-
* HTTP method used in the network request, such as GET, POST, PUT, DELETE, etc. It indicates the type
267-
* of operation that the client is requesting from the server.
268-
* @param requestUrl The `requestUrl` parameter in the `networkLogAndroid` method represents the URL
269-
* of the network request being logged. It typically contains the address of the server to which the
270-
* request is being made, along with any additional path or query parameters required for the request.
271-
* This URL is essential for identifying the
272-
* @param requestContentType The `requestContentType` parameter in the `networkLogAndroid` method
273-
* represents the content type of the request being made. This could be values like
274-
* "application/json", "application/xml", "text/plain", etc., indicating the format of the data being
275-
* sent in the request body. It helps in specifying
276-
* @param responseHeaders The `responseHeaders` parameter in the `networkLogAndroid` method represents
277-
* the headers of the response received from a network request. These headers typically include
278-
* information such as content type, content length, server information, and any other metadata
279-
* related to the response. The `responseHeaders` parameter is expected to
280-
* @param responseBody The `responseBody` parameter in the `networkLogAndroid` method represents the
281-
* body of the response received from a network request. It contains the data or content sent back by
282-
* the server in response to the request made by the client. This could be in various formats such as
283-
* JSON, XML, HTML
284-
* @param responseBodySize The `responseBodySize` parameter in the `networkLogAndroid` method
285-
* represents the size of the response body in bytes. It is a double value that indicates the size of
286-
* the response body received from the network request. This parameter is used to log information
287-
* related to the network request and response, including
288-
* @param statusCode The `statusCode` parameter in the `networkLogAndroid` method represents the HTTP
289-
* status code of the network request/response. It indicates the status of the HTTP response, such as
290-
* success (200), redirection (3xx), client errors (4xx), or server errors (5xx). This parameter is
291-
* @param responseContentType The `responseContentType` parameter in the `networkLogAndroid` method
292-
* represents the content type of the response received from the network request. It indicates the
293-
* format of the data in the response, such as JSON, XML, HTML, etc. This information is useful for
294-
* understanding how to parse and handle the
295-
* @param errorDomain The `errorDomain` parameter in the `networkLogAndroid` method is used to specify
296-
* the domain of an error, if any occurred during the network request. If there was no error, this
297-
* parameter will be `null`.
298-
* @param w3cAttributes The `w3cAttributes` parameter in the `networkLogAndroid` method is a
299-
* ReadableMap object that contains additional attributes related to W3C external trace. It may
300-
* include the following key-value pairs:
301-
* @param gqlQueryName The `gqlQueryName` parameter in the `networkLogAndroid` method represents the
302-
* name of the GraphQL query being executed. It is a nullable parameter, meaning it can be null if no
303-
* GraphQL query name is provided. This parameter is used to log information related to GraphQL
304-
* queries in the network logging
305-
* @param serverErrorMessage The `serverErrorMessage` parameter in the `networkLogAndroid` method is
306-
* used to pass any error message received from the server during network communication. This message
307-
* can provide additional details about any errors that occurred on the server side, helping in
308-
* debugging and troubleshooting network-related issues.
309-
*/
241+
/**
242+
* The `networkLogAndroid` function logs network-related information using APMNetworkLogger in a React
243+
* Native module.
244+
*
245+
* @param requestStartTime The `requestStartTime` parameter in the `networkLogAndroid` method
246+
* represents the timestamp when the network request started. It is of type `double` and is passed as
247+
* a parameter to log network-related information.
248+
* @param requestDuration The `requestDuration` parameter in the `networkLogAndroid` method represents
249+
* the duration of the network request in milliseconds. It indicates the time taken for the request to
250+
* complete from the moment it was initiated until the response was received. This parameter helps in
251+
* measuring the performance of network requests and identifying any potential
252+
* @param requestHeaders requestHeaders is a string parameter that contains the headers of the network
253+
* request. It typically includes information such as the content type, authorization token, and any
254+
* other headers that were sent with the request.
255+
* @param requestBody The `requestBody` parameter in the `networkLogAndroid` method represents the
256+
* body of the HTTP request being logged. It contains the data that is sent as part of the request to
257+
* the server. This could include form data, JSON payload, XML data, or any other content that is
258+
* being transmitted
259+
* @param requestBodySize The `requestBodySize` parameter in the `networkLogAndroid` method represents
260+
* the size of the request body in bytes. It is a double value that indicates the size of the request
261+
* body being sent in the network request. This parameter is used to log information related to the
262+
* network request, including details
263+
* @param requestMethod The `requestMethod` parameter in the `networkLogAndroid` method represents the
264+
* HTTP method used in the network request, such as GET, POST, PUT, DELETE, etc. It indicates the type
265+
* of operation that the client is requesting from the server.
266+
* @param requestUrl The `requestUrl` parameter in the `networkLogAndroid` method represents the URL
267+
* of the network request being logged. It typically contains the address of the server to which the
268+
* request is being made, along with any additional path or query parameters required for the request.
269+
* This URL is essential for identifying the
270+
* @param requestContentType The `requestContentType` parameter in the `networkLogAndroid` method
271+
* represents the content type of the request being made. This could be values like
272+
* "application/json", "application/xml", "text/plain", etc., indicating the format of the data being
273+
* sent in the request body. It helps in specifying
274+
* @param responseHeaders The `responseHeaders` parameter in the `networkLogAndroid` method represents
275+
* the headers of the response received from a network request. These headers typically include
276+
* information such as content type, content length, server information, and any other metadata
277+
* related to the response. The `responseHeaders` parameter is expected to
278+
* @param responseBody The `responseBody` parameter in the `networkLogAndroid` method represents the
279+
* body of the response received from a network request. It contains the data or content sent back by
280+
* the server in response to the request made by the client. This could be in various formats such as
281+
* JSON, XML, HTML
282+
* @param responseBodySize The `responseBodySize` parameter in the `networkLogAndroid` method
283+
* represents the size of the response body in bytes. It is a double value that indicates the size of
284+
* the response body received from the network request. This parameter is used to log information
285+
* related to the network request and response, including
286+
* @param statusCode The `statusCode` parameter in the `networkLogAndroid` method represents the HTTP
287+
* status code of the network request/response. It indicates the status of the HTTP response, such as
288+
* success (200), redirection (3xx), client errors (4xx), or server errors (5xx). This parameter is
289+
* @param responseContentType The `responseContentType` parameter in the `networkLogAndroid` method
290+
* represents the content type of the response received from the network request. It indicates the
291+
* format of the data in the response, such as JSON, XML, HTML, etc. This information is useful for
292+
* understanding how to parse and handle the
293+
* @param errorDomain The `errorDomain` parameter in the `networkLogAndroid` method is used to specify
294+
* the domain of an error, if any occurred during the network request. If there was no error, this
295+
* parameter will be `null`.
296+
* @param w3cAttributes The `w3cAttributes` parameter in the `networkLogAndroid` method is a
297+
* ReadableMap object that contains additional attributes related to W3C external trace. It may
298+
* include the following key-value pairs:
299+
* @param gqlQueryName The `gqlQueryName` parameter in the `networkLogAndroid` method represents the
300+
* name of the GraphQL query being executed. It is a nullable parameter, meaning it can be null if no
301+
* GraphQL query name is provided. This parameter is used to log information related to GraphQL
302+
* queries in the network logging
303+
* @param serverErrorMessage The `serverErrorMessage` parameter in the `networkLogAndroid` method is
304+
* used to pass any error message received from the server during network communication. This message
305+
* can provide additional details about any errors that occurred on the server side, helping in
306+
* debugging and troubleshooting network-related issues.
307+
*/
310308
@ReactMethod
311309
private void networkLogAndroid(final double requestStartTime,
312310
final double requestDuration,
@@ -325,15 +323,15 @@ private void networkLogAndroid(final double requestStartTime,
325323
@Nullable final ReadableMap w3cAttributes,
326324
@Nullable final String gqlQueryName,
327325
@Nullable final String serverErrorMessage
328-
) {
326+
) {
329327
try {
330328
APMNetworkLogger networkLogger = new APMNetworkLogger();
331329

332330
final boolean hasError = errorDomain != null && !errorDomain.isEmpty();
333331
final String errorMessage = hasError ? errorDomain : null;
334-
Boolean isW3cHeaderFound=false;
335-
Long partialId=null;
336-
Long networkStartTimeInSeconds=null;
332+
Boolean isW3cHeaderFound = false;
333+
Long partialId = null;
334+
Long networkStartTimeInSeconds = null;
337335

338336

339337
try {
@@ -342,7 +340,7 @@ private void networkLogAndroid(final double requestStartTime,
342340
}
343341

344342
if (!w3cAttributes.isNull("partialId")) {
345-
partialId =(long) w3cAttributes.getDouble("partialId");
343+
partialId = (long) w3cAttributes.getDouble("partialId");
346344
networkStartTimeInSeconds = (long) w3cAttributes.getDouble("networkStartTimeInSeconds");
347345
}
348346

@@ -360,34 +358,54 @@ private void networkLogAndroid(final double requestStartTime,
360358
try {
361359
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);
362360
if (method != null) {
363-
method.invoke(
364-
networkLogger,
365-
(long) requestStartTime * 1000,
366-
(long) requestDuration,
367-
requestHeaders,
368-
requestBody,
369-
(long) requestBodySize,
370-
requestMethod,
371-
requestUrl,
372-
requestContentType,
373-
responseHeaders,
374-
responseBody,
375-
(long)responseBodySize,
376-
(int) statusCode,
377-
responseContentType,
378-
errorMessage,
379-
gqlQueryName,
380-
serverErrorMessage,
381-
w3cExternalTraceAttributes
382-
);
361+
method.invoke(
362+
networkLogger,
363+
(long) requestStartTime * 1000,
364+
(long) requestDuration,
365+
requestHeaders,
366+
requestBody,
367+
(long) requestBodySize,
368+
requestMethod,
369+
requestUrl,
370+
requestContentType,
371+
responseHeaders,
372+
responseBody,
373+
(long) responseBodySize,
374+
(int) statusCode,
375+
responseContentType,
376+
errorMessage,
377+
gqlQueryName,
378+
serverErrorMessage,
379+
w3cExternalTraceAttributes
380+
);
383381
} else {
384382
Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection");
385383
}
386384
} catch (Throwable e) {
387385
e.printStackTrace();
388386
}
389-
} catch(Throwable e) {
387+
} catch (Throwable e) {
390388
e.printStackTrace();
391389
}
392390
}
391+
392+
393+
/**
394+
* Enables or disables screen rendering
395+
*
396+
* @param isEnabled boolean indicating enabled or disabled.
397+
*/
398+
@ReactMethod
399+
public void setScreenRenderEnabled(boolean isEnabled) {
400+
MainThreadHandler.runOnMainThread(new Runnable() {
401+
@Override
402+
public void run() {
403+
try {
404+
APM.setScreenRenderingEnabled(isEnabled);
405+
} catch (Exception e) {
406+
e.printStackTrace();
407+
}
408+
}
409+
});
410+
}
393411
}

examples/default/src/App.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
55
import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
66
import type { SessionMetadata } from 'instabug-reactnative';
77
import Instabug, {
8-
APM,
98
CrashReporting,
109
InvocationEvent,
1110
LaunchType,
@@ -70,7 +69,7 @@ export const App: React.FC = () => {
7069
networkData.url = `${networkData.url}/JS/Obfuscated`;
7170
return networkData;
7271
});
73-
APM.setScreenRenderEnabled(false);
72+
// APM.setScreenRenderEnabled(true);
7473
});
7574
});
7675

0 commit comments

Comments
 (0)