19
19
20
20
import org .json .JSONException ;
21
21
import org .json .JSONObject ;
22
+
22
23
import java .lang .reflect .InvocationTargetException ;
23
24
import java .lang .reflect .Method ;
24
25
@@ -58,6 +59,7 @@ public void run() {
58
59
59
60
/**
60
61
* Enables or disables APM.
62
+ *
61
63
* @param isEnabled boolean indicating enabled or disabled.
62
64
*/
63
65
@ ReactMethod
@@ -76,6 +78,7 @@ public void run() {
76
78
77
79
/**
78
80
* Enables or disables app launch tracking.
81
+ *
79
82
* @param isEnabled boolean indicating enabled or disabled.
80
83
*/
81
84
@ ReactMethod
@@ -111,6 +114,7 @@ public void run() {
111
114
112
115
/**
113
116
* Enables or disables auto UI tracing
117
+ *
114
118
* @param isEnabled boolean indicating enabled or disabled.
115
119
*/
116
120
@ ReactMethod
@@ -209,7 +213,6 @@ public void run() {
209
213
* Starts an execution trace
210
214
*
211
215
* @param name string name of the trace.
212
- *
213
216
* @deprecated see {@link #startFlow(String)}
214
217
*/
215
218
@ Deprecated
@@ -240,7 +243,6 @@ public void run() {
240
243
* @param id String id of the trace.
241
244
* @param key attribute key
242
245
* @param value attribute value. Null to remove attribute
243
- *
244
246
* @deprecated see {@link #setFlowAttribute}
245
247
*/
246
248
@ Deprecated
@@ -262,7 +264,6 @@ public void run() {
262
264
* Ends a trace
263
265
*
264
266
* @param id string id of the trace.
265
- *
266
267
* @deprecated see {@link #endFlow}
267
268
*/
268
269
@ Deprecated
@@ -282,6 +283,7 @@ public void run() {
282
283
283
284
/**
284
285
* Starts a UI trace
286
+ *
285
287
* @param name string name of the UI trace.
286
288
*/
287
289
@ ReactMethod
@@ -341,34 +343,95 @@ private void networkLogAndroid(final double requestStartTime,
341
343
try {
342
344
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 );
343
345
if (method != null ) {
344
- method .invoke (
345
- networkLogger ,
346
- (long ) requestStartTime * 1000 ,
347
- (long ) requestDuration ,
348
- requestHeaders ,
349
- requestBody ,
350
- (long ) requestBodySize ,
351
- requestMethod ,
352
- requestUrl ,
353
- requestContentType ,
354
- responseHeaders ,
355
- responseBody ,
356
- (long )responseBodySize ,
357
- (int ) statusCode ,
358
- responseContentType ,
359
- errorMessage ,
360
- gqlQueryName ,
361
- serverErrorMessage ,
362
- null
363
- );
346
+ method .invoke (
347
+ networkLogger ,
348
+ (long ) requestStartTime * 1000 ,
349
+ (long ) requestDuration ,
350
+ requestHeaders ,
351
+ requestBody ,
352
+ (long ) requestBodySize ,
353
+ requestMethod ,
354
+ requestUrl ,
355
+ requestContentType ,
356
+ responseHeaders ,
357
+ responseBody ,
358
+ (long ) responseBodySize ,
359
+ (int ) statusCode ,
360
+ responseContentType ,
361
+ errorMessage ,
362
+ gqlQueryName ,
363
+ serverErrorMessage ,
364
+ null
365
+ );
364
366
} else {
365
367
Log .e ("IB-CP-Bridge" , "APMNetworkLogger.log was not found by reflection" );
366
368
}
367
369
} catch (Throwable e ) {
368
370
e .printStackTrace ();
369
371
}
370
- } catch (Throwable e ) {
372
+ } catch (Throwable e ) {
371
373
e .printStackTrace ();
372
374
}
373
375
}
376
+
377
+ /**
378
+ * Get first time Value of [cp_native_interception_enabled] flag
379
+ */
380
+ @ ReactMethod
381
+ public void isNativeInterceptionEnabled (Promise promise ) {
382
+ MainThreadHandler .runOnMainThread (new Runnable () {
383
+ @ Override
384
+ public void run () {
385
+ try {
386
+ promise .resolve (true );
387
+ } catch (Exception e ) {
388
+ e .printStackTrace ();
389
+ promise .resolve (false );
390
+ }
391
+
392
+ }
393
+ });
394
+ }
395
+
396
+ /**
397
+ * Indicate if user added APM Network plugin or not
398
+ * [true] means user added the APM plugin
399
+ * [false] means not
400
+ */
401
+ @ ReactMethod
402
+ public void hasAPMNetworkPlugin (Promise promise ) {
403
+ MainThreadHandler .runOnMainThread (new Runnable () {
404
+ @ Override
405
+ public void run () {
406
+ try {
407
+ promise .resolve (false );
408
+ } catch (Exception e ) {
409
+ e .printStackTrace ();
410
+ promise .resolve (false );
411
+ }
412
+
413
+ }
414
+ });
415
+ }
416
+
417
+ /**
418
+ * Indicate APM is enabled & Network logging is enabled
419
+ * [true] ApmEnabled && NetworkEnabled
420
+ * [false] otherwise
421
+ */
422
+ @ ReactMethod
423
+ public void isAPMNetworkEnabled (Promise promise ) {
424
+ MainThreadHandler .runOnMainThread (new Runnable () {
425
+ @ Override
426
+ public void run () {
427
+ try {
428
+ promise .resolve (false );
429
+ } catch (Exception e ) {
430
+ e .printStackTrace ();
431
+ promise .resolve (false );
432
+ }
433
+
434
+ }
435
+ });
436
+ }
374
437
}
0 commit comments