9
9
10
10
import com .facebook .react .bridge .Promise ;
11
11
import com .facebook .react .bridge .ReactApplicationContext ;
12
- import com .facebook .react .bridge .ReactContextBaseJavaModule ;
13
12
import com .facebook .react .bridge .ReactMethod ;
13
+ import com .facebook .react .bridge .ReadableMap ;
14
14
import com .instabug .apm .APM ;
15
15
import com .instabug .apm .model .ExecutionTrace ;
16
16
import com .instabug .apm .networking .APMNetworkLogger ;
17
17
import com .instabug .apm .networkinterception .cp .APMCPNetworkLog ;
18
+ import com .instabug .reactlibrary .utils .EventEmitterModule ;
19
+ import com .instabug .apm .networkinterception .cp .APMCPNetworkLog ;
18
20
import com .instabug .reactlibrary .utils .MainThreadHandler ;
19
21
20
- import org .json .JSONException ;
21
- import org .json .JSONObject ;
22
- import java .lang .reflect .InvocationTargetException ;
23
22
import java .lang .reflect .Method ;
24
23
25
24
import java .util .HashMap ;
28
27
29
28
import static com .instabug .reactlibrary .utils .InstabugUtil .getMethod ;
30
29
31
- public class RNInstabugAPMModule extends ReactContextBaseJavaModule {
30
+ public class RNInstabugAPMModule extends EventEmitterModule {
32
31
33
32
public RNInstabugAPMModule (ReactApplicationContext reactApplicationContext ) {
34
33
super (reactApplicationContext );
@@ -330,14 +329,41 @@ private void networkLogAndroid(final double requestStartTime,
330
329
final double statusCode ,
331
330
final String responseContentType ,
332
331
@ Nullable final String errorDomain ,
332
+ @ Nullable final ReadableMap w3cAttributes ,
333
333
@ Nullable final String gqlQueryName ,
334
- @ Nullable final String serverErrorMessage ) {
334
+ @ Nullable final String serverErrorMessage
335
+ ) {
335
336
try {
336
337
APMNetworkLogger networkLogger = new APMNetworkLogger ();
337
338
338
339
final boolean hasError = errorDomain != null && !errorDomain .isEmpty ();
339
340
final String errorMessage = hasError ? errorDomain : null ;
341
+ Boolean isW3cHeaderFound =false ;
342
+ Long partialId =null ;
343
+ Long networkStartTimeInSeconds =null ;
344
+
345
+
346
+ try {
347
+ if (!w3cAttributes .isNull ("isW3cHeaderFound" )) {
348
+ isW3cHeaderFound = w3cAttributes .getBoolean ("isW3cHeaderFound" );
349
+ }
340
350
351
+ if (!w3cAttributes .isNull ("partialId" )) {
352
+ partialId =(long ) w3cAttributes .getDouble ("partialId" );
353
+ networkStartTimeInSeconds = (long ) w3cAttributes .getDouble ("networkStartTimeInSeconds" );
354
+ }
355
+
356
+ } catch (Exception e ) {
357
+ e .printStackTrace ();
358
+ }
359
+ APMCPNetworkLog .W3CExternalTraceAttributes w3cExternalTraceAttributes =
360
+ new APMCPNetworkLog .W3CExternalTraceAttributes (
361
+ isW3cHeaderFound ,
362
+ partialId ,
363
+ networkStartTimeInSeconds ,
364
+ w3cAttributes .getString ("w3cGeneratedHeader" ),
365
+ w3cAttributes .getString ("w3cCaughtHeader" )
366
+ );
341
367
try {
342
368
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
369
if (method != null ) {
@@ -359,7 +385,7 @@ private void networkLogAndroid(final double requestStartTime,
359
385
errorMessage ,
360
386
gqlQueryName ,
361
387
serverErrorMessage ,
362
- null
388
+ w3cExternalTraceAttributes
363
389
);
364
390
} else {
365
391
Log .e ("IB-CP-Bridge" , "APMNetworkLogger.log was not found by reflection" );
0 commit comments