Skip to content

Commit 16050df

Browse files
Merge pull request #1349 from Instabug/chore/enhance-apm-code-docs
chore: enhance inline code documentation for APM module.
2 parents f194e79 + 215eddf commit 16050df

File tree

3 files changed

+106
-16
lines changed

3 files changed

+106
-16
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,

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)