Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f9bf571

Browse files
AndrewAminInstabugAyaMahmoud148
authored andcommitted
chore: enhance inline code documentation for APM module.
1 parent d1f0150 commit f9bf571

File tree

3 files changed

+174
-16
lines changed

3 files changed

+174
-16
lines changed

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

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

4545
/**
46-
* Sets the printed logs priority. Filter to one of the following levels.
46+
* This method is exporting a method
47+
* named `ibgSleep` to be accessible from JavaScript side. When this method is
48+
* called from JavaScript, it (sleeps) the current thread for 3 seconds.
4749
*/
4850
@ReactMethod
4951
public void ibgSleep() {
@@ -57,6 +59,14 @@ public void run() {
5759

5860
/**
5961
* Enables or disables APM.
62+
*
63+
* This function is exporting a method named
64+
* [setEnabled] to be accessible from JavaScript side. When this method is
65+
* called from JavaScript, it will set the `enabled` property of the [APM] class provided by the
66+
* Instabug SDK to the value passed as the `isEnabled` parameter. This property controls whether the
67+
* APM (Application Performance Monitoring) feature of Instabug is enabled or disabled based on the
68+
* boolean value passed to it.
69+
*
6070
* @param isEnabled boolean indicating enabled or disabled.
6171
*/
6272
@ReactMethod
@@ -75,6 +85,12 @@ public void run() {
7585

7686
/**
7787
* Enables or disables app launch tracking.
88+
*
89+
* This function is exporting a method named
90+
* `setAppLaunchEnabled` to be accessible from JavaScript side. When this
91+
* method is called from JavaScript, it will set the `coldAppLaunchEnabled` property of the `IBGAPM`
92+
* class provided by the Instabug SDK to the value passed as the `isEnabled` parameter.
93+
*
7894
* @param isEnabled boolean indicating enabled or disabled.
7995
*/
8096
@ReactMethod
@@ -92,7 +108,10 @@ public void run() {
92108
}
93109

94110
/**
95-
* Ends app launch
111+
* This function is exporting a method named `endAppLaunch` to be
112+
* accessible from JavaScript side. When this method is called from
113+
* JavaScript, it will invoke the `endAppLaunch` method from the [APM] class provided by the
114+
* Instabug SDK. This method is used to signal the end of the app launch process.
96115
*/
97116
@ReactMethod
98117
public void endAppLaunch() {
@@ -110,6 +129,15 @@ public void run() {
110129

111130
/**
112131
* Enables or disables auto UI tracing
132+
*
133+
* This function is exporting a method named
134+
* [setAutoUITraceEnabled] to be accessible from JavaScript side. When this
135+
* method is called from JavaScript, it will set the `autoUITraceEnabled` property of the [APM]
136+
* class provided by the Instabug SDK to the value passed as the `isEnabled` parameter. This property
137+
* controls whether automatic tracing of UI interactions is enabled or disabled within the SDK. By
138+
* toggling this property, you can control whether the SDK captures data related to user interface
139+
* performance and behavior automatically.
140+
*
113141
* @param isEnabled boolean indicating enabled or disabled.
114142
*/
115143
@ReactMethod
@@ -281,6 +309,12 @@ public void run() {
281309

282310
/**
283311
* Starts a UI trace
312+
*
313+
* This function is exporting a method named
314+
* [startUITrace] to be accessible from JavaScript side. When this method is
315+
* called from JavaScript, it will invoke the [startUITrace] method from the [APM] class
316+
* provided by the Instabug SDK to start a new UI trace.
317+
*
284318
* @param name string name of the UI trace.
285319
*/
286320
@ReactMethod
@@ -298,7 +332,10 @@ public void run() {
298332
}
299333

300334
/**
301-
* Ends the current running UI trace
335+
* This function is exporting a method named [endUITrace] to be
336+
* accessible from JavaScript side. When this method is called from
337+
* JavaScript, it will invoke the `endUITrace` method from the []APM] class provided by the Instabug
338+
* SDK. This method is used to terminate the currently active UI trace.
302339
*/
303340
@ReactMethod
304341
public void endUITrace() {
@@ -314,6 +351,73 @@ public void run() {
314351
});
315352
}
316353

354+
/**
355+
* The `networkLogAndroid` function logs network-related information using APMNetworkLogger in a React
356+
* Native module.
357+
*
358+
* @param requestStartTime The `requestStartTime` parameter in the `networkLogAndroid` method
359+
* represents the timestamp when the network request started. It is of type `double` and is passed as
360+
* a parameter to log network-related information.
361+
* @param requestDuration The `requestDuration` parameter in the `networkLogAndroid` method represents
362+
* the duration of the network request in milliseconds. It indicates the time taken for the request to
363+
* complete from the moment it was initiated until the response was received. This parameter helps in
364+
* measuring the performance of network requests and identifying any potential
365+
* @param requestHeaders requestHeaders is a string parameter that contains the headers of the network
366+
* request. It typically includes information such as the content type, authorization token, and any
367+
* other headers that were sent with the request.
368+
* @param requestBody The `requestBody` parameter in the `networkLogAndroid` method represents the
369+
* body of the HTTP request being logged. It contains the data that is sent as part of the request to
370+
* the server. This could include form data, JSON payload, XML data, or any other content that is
371+
* being transmitted
372+
* @param requestBodySize The `requestBodySize` parameter in the `networkLogAndroid` method represents
373+
* the size of the request body in bytes. It is a double value that indicates the size of the request
374+
* body being sent in the network request. This parameter is used to log information related to the
375+
* network request, including details
376+
* @param requestMethod The `requestMethod` parameter in the `networkLogAndroid` method represents the
377+
* HTTP method used in the network request, such as GET, POST, PUT, DELETE, etc. It indicates the type
378+
* of operation that the client is requesting from the server.
379+
* @param requestUrl The `requestUrl` parameter in the `networkLogAndroid` method represents the URL
380+
* of the network request being logged. It typically contains the address of the server to which the
381+
* request is being made, along with any additional path or query parameters required for the request.
382+
* This URL is essential for identifying the
383+
* @param requestContentType The `requestContentType` parameter in the `networkLogAndroid` method
384+
* represents the content type of the request being made. This could be values like
385+
* "application/json", "application/xml", "text/plain", etc., indicating the format of the data being
386+
* sent in the request body. It helps in specifying
387+
* @param responseHeaders The `responseHeaders` parameter in the `networkLogAndroid` method represents
388+
* the headers of the response received from a network request. These headers typically include
389+
* information such as content type, content length, server information, and any other metadata
390+
* related to the response. The `responseHeaders` parameter is expected to
391+
* @param responseBody The `responseBody` parameter in the `networkLogAndroid` method represents the
392+
* body of the response received from a network request. It contains the data or content sent back by
393+
* the server in response to the request made by the client. This could be in various formats such as
394+
* JSON, XML, HTML
395+
* @param responseBodySize The `responseBodySize` parameter in the `networkLogAndroid` method
396+
* represents the size of the response body in bytes. It is a double value that indicates the size of
397+
* the response body received from the network request. This parameter is used to log information
398+
* related to the network request and response, including
399+
* @param statusCode The `statusCode` parameter in the `networkLogAndroid` method represents the HTTP
400+
* status code of the network request/response. It indicates the status of the HTTP response, such as
401+
* success (200), redirection (3xx), client errors (4xx), or server errors (5xx). This parameter is
402+
* @param responseContentType The `responseContentType` parameter in the `networkLogAndroid` method
403+
* represents the content type of the response received from the network request. It indicates the
404+
* format of the data in the response, such as JSON, XML, HTML, etc. This information is useful for
405+
* understanding how to parse and handle the
406+
* @param errorDomain The `errorDomain` parameter in the `networkLogAndroid` method is used to specify
407+
* the domain of an error, if any occurred during the network request. If there was no error, this
408+
* parameter will be `null`.
409+
* @param w3cAttributes The `w3cAttributes` parameter in the `networkLogAndroid` method is a
410+
* ReadableMap object that contains additional attributes related to W3C external trace. It may
411+
* include the following key-value pairs:
412+
* @param gqlQueryName The `gqlQueryName` parameter in the `networkLogAndroid` method represents the
413+
* name of the GraphQL query being executed. It is a nullable parameter, meaning it can be null if no
414+
* GraphQL query name is provided. This parameter is used to log information related to GraphQL
415+
* queries in the network logging
416+
* @param serverErrorMessage The `serverErrorMessage` parameter in the `networkLogAndroid` method is
417+
* used to pass any error message received from the server during network communication. This message
418+
* can provide additional details about any errors that occurred on the server side, helping in
419+
* debugging and troubleshooting network-related issues.
420+
*/
317421
@ReactMethod
318422
private void networkLogAndroid(final double requestStartTime,
319423
final double requestDuration,

ios/RNInstabug/InstabugAPMBridge.m

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

39+
// This method is exporting a method
40+
// named `ibgSleep` to be accessible from JavaScript side. When this method is
41+
// called from JavaScript, it (sleeps) the current thread for 3 seconds.
3942
RCT_EXPORT_METHOD(ibgSleep) {
4043
[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];
4844
}
4945

46+
// Enables or disables APM.
47+
//
48+
// This function is exporting a method named
49+
// `setEnabled` to be accessible from JavaScript side. When this method is
50+
// called from JavaScript, it will set the `enabled` property of the `IBGAPM` class provided by the
51+
// Instabug SDK to the value passed as the `isEnabled` parameter. This property controls whether the
52+
// APM (Application Performance Monitoring) feature of Instabug is enabled or disabled based on the
53+
// boolean value passed to it.
5054
RCT_EXPORT_METHOD(setEnabled:(BOOL)isEnabled) {
5155
IBGAPM.enabled = isEnabled;
5256
}
5357

58+
// This function is exporting a method named
59+
// `setAppLaunchEnabled` to be accessible from JavaScript side. When this
60+
// method is called from JavaScript, it will set the `coldAppLaunchEnabled` property of the `IBGAPM`
61+
// class provided by the Instabug SDK to the value passed as the `isEnabled` parameter.
5462
RCT_EXPORT_METHOD(setAppLaunchEnabled:(BOOL)isEnabled) {
5563
IBGAPM.coldAppLaunchEnabled = isEnabled;
5664
}
5765

66+
// This function is exporting a method named `endAppLaunch` to be
67+
// accessible from JavaScript side. When this method is called from
68+
// JavaScript, it will invoke the `endAppLaunch` method from the `IBGAPM` class provided by the
69+
// Instabug SDK. This method is used to signal the end of the app launch process.
5870
RCT_EXPORT_METHOD(endAppLaunch) {
5971
[IBGAPM endAppLaunch];
6072
}
6173

74+
// This function is exporting a method named
75+
// `setAutoUITraceEnabled` to be accessible from JavaScript side. When this
76+
// method is called from JavaScript, it will set the `autoUITraceEnabled` property of the `IBGAPM`
77+
// class provided by the Instabug SDK to the value passed as the `isEnabled` parameter. This property
78+
// controls whether automatic tracing of UI interactions is enabled or disabled within the SDK. By
79+
// toggling this property, you can control whether the SDK captures data related to user interface
80+
// performance and behavior automatically.
6281
RCT_EXPORT_METHOD(setAutoUITraceEnabled:(BOOL)isEnabled) {
6382
IBGAPM.autoUITraceEnabled = isEnabled;
6483
}
6584

85+
// This method `startExecutionTrace` is exporting a function to be accessible from JavaScript in a
86+
// React Native application.
87+
// Deprecated see [startFlow: (NSString *)name]
6688
RCT_EXPORT_METHOD(startExecutionTrace:(NSString *)name :(NSString *)id
6789
:(RCTPromiseResolveBlock)resolve
6890
:(RCTPromiseRejectBlock)reject) {
@@ -75,37 +97,64 @@ - (id) init
7597
}
7698
}
7799

100+
// This method is exporting a function to be accessible from JavaScript side.
101+
// Deprecated see [setFlowAttribute:(NSString *)name :(NSString *)key :(NSString *_Nullable)value]
78102
RCT_EXPORT_METHOD(setExecutionTraceAttribute:(NSString *)id :(NSString *)key :(NSString *)value) {
79103
IBGExecutionTrace *trace = [traces objectForKey:id];
80104
if (trace != nil) {
81105
[trace setAttributeWithKey:key value:value];
82106
}
83107
}
84108

109+
// This function is exporting a method named
110+
// `endExecutionTrace` to be accessible from JavaScript side.
111+
// Deprecated see [endFlow: (NSString *)name]
85112
RCT_EXPORT_METHOD(endExecutionTrace:(NSString *)id) {
86113
IBGExecutionTrace *trace = [traces objectForKey:id];
87114
if (trace != nil) {
88115
[trace end];
89116
}
90117
}
91118

119+
// This function is exporting a method named
120+
// `startFlow` to be accessible from JavaScript side. When this method is
121+
// called from JavaScript, it will invoke the `startFlowWithName:` method from the `IBGAPM` class
122+
// provided by the Instabug SDK. This method is used to start a flow trace with the specified name,
123+
// allowing the SDK to capture and analyze the flow of execution within the application.
92124
RCT_EXPORT_METHOD(startFlow: (NSString *)name) {
93125
[IBGAPM startFlowWithName:name];
94126
}
95127

128+
// This function is exporting a method named `endFlow` to
129+
// be accessible from JavaScript side. When this method is called from
130+
// JavaScript, it will invoke the `endFlowWithName:` method from the `IBGAPM` class provided by the
131+
// Instabug SDK. This method is used to end a flow trace with the specified name, allowing the SDK to
132+
// capture and analyze the flow of execution within the application.
96133
RCT_EXPORT_METHOD(endFlow: (NSString *)name) {
97134
[IBGAPM endFlowWithName:name];
98135
}
99136

100137

138+
// The function is exporting a method named `setFlowAttribute` to be accessible from
139+
// JavaScript side. When this method is
140+
// called from JavaScript, it will invoke the `setAttributeForFlowWithName:` method from the `IBGAPM` class
141+
// provided by the Instabug SDK to set a user defined attribute for the currently active flow.
101142
RCT_EXPORT_METHOD(setFlowAttribute:(NSString *)name :(NSString *)key :(NSString *_Nullable)value) {
102143
[IBGAPM setAttributeForFlowWithName:name key:key value:value];
103144
}
104145

146+
// This function is exporting a method named
147+
// `startUITrace` to be accessible from JavaScript side. When this method is
148+
// called from JavaScript, it will invoke the `startUITraceWithName:` method from the `IBGAPM` class
149+
// provided by the Instabug SDK to start a new UI trace.
105150
RCT_EXPORT_METHOD(startUITrace:(NSString *)name) {
106151
[IBGAPM startUITraceWithName:name];
107152
}
108153

154+
// This function is exporting a method named `endUITrace` to be
155+
// accessible from JavaScript side. When this method is called from
156+
// JavaScript, it will invoke the `endUITrace` method from the `IBGAPM` class provided by the Instabug
157+
// SDK. This method is used to terminate the currently active UI trace.
109158
RCT_EXPORT_METHOD(endUITrace) {
110159
[IBGAPM endUITrace];
111160
}

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 and hot app launches.
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)