1
1
package com .instabug .reactlibrary ;
2
2
3
3
4
+ import static com .instabug .apm .configuration .cp .APMFeature .APM_NETWORK_PLUGIN_INSTALLED ;
5
+ import static com .instabug .apm .configuration .cp .APMFeature .CP_NATIVE_INTERCEPTION_ENABLED ;
6
+ import static com .instabug .apm .configuration .cp .APMFeature .NETWORK_INTERCEPTION_ENABLED ;
7
+
4
8
import androidx .annotation .NonNull ;
5
9
6
10
//import com.facebook.react.bridge.Arguments;
12
16
//import com.instabug.apm.sanitization.OnCompleteCallback;
13
17
//import com.instabug.apm.sanitization.VoidSanitizer;
14
18
//import com.instabug.library.logging.listeners.networklogs.NetworkLogSnapshot;
19
+ import com .instabug .apm .InternalAPM ;
15
20
import com .instabug .reactlibrary .utils .EventEmitterModule ;
16
21
import com .instabug .reactlibrary .utils .MainThreadHandler ;
17
22
//
@@ -46,6 +51,10 @@ public void removeListeners(Integer count) {
46
51
super .removeListeners (count );
47
52
}
48
53
54
+ private boolean getFlagValue (String key ) {
55
+ return InternalAPM ._isFeatureEnabledCP ( key , "" );
56
+ }
57
+
49
58
/**
50
59
* Get first time Value of [cp_native_interception_enabled] flag
51
60
*/
@@ -55,7 +64,7 @@ public void isNativeInterceptionEnabled(Promise promise) {
55
64
@ Override
56
65
public void run () {
57
66
try {
58
- promise .resolve (true );
67
+ promise .resolve (getFlagValue ( CP_NATIVE_INTERCEPTION_ENABLED ) );
59
68
} catch (Exception e ) {
60
69
e .printStackTrace ();
61
70
promise .resolve (false );
@@ -76,7 +85,7 @@ public void hasAPMNetworkPlugin(Promise promise) {
76
85
@ Override
77
86
public void run () {
78
87
try {
79
- promise .resolve (true );
88
+ promise .resolve (getFlagValue ( APM_NETWORK_PLUGIN_INSTALLED ) );
80
89
} catch (Exception e ) {
81
90
e .printStackTrace ();
82
91
promise .resolve (false );
@@ -97,7 +106,7 @@ public void isAPMNetworkEnabled(Promise promise) {
97
106
@ Override
98
107
public void run () {
99
108
try {
100
- promise .resolve (true );
109
+ promise .resolve (getFlagValue ( NETWORK_INTERCEPTION_ENABLED ) );
101
110
} catch (Exception e ) {
102
111
e .printStackTrace ();
103
112
promise .resolve (false );
@@ -108,55 +117,54 @@ public void run() {
108
117
}
109
118
110
119
111
-
112
- @ ReactMethod
113
- public void registerNetworkLogsListener () {
114
- MainThreadHandler .runOnMainThread (new Runnable () {
115
- @ Override
116
- public void run () {
117
- InternalAPM ._registerNetworkLogSanitizer (new VoidSanitizer <NetworkLogSnapshot >() {
118
- @ Override
119
- public void sanitize (NetworkLogSnapshot networkLogSnapshot , @ NonNull OnCompleteCallback <NetworkLogSnapshot > onCompleteCallback ) {
120
- final int id = onCompleteCallback .hashCode ();
121
- callbackMap .put (id , onCompleteCallback );
122
-
123
- WritableMap networkSnapshotParams = Arguments .createMap ();
124
- networkSnapshotParams .putInt ("id" , id );
125
- networkSnapshotParams .putString ("url" , networkLogSnapshot .getUrl ());
126
- networkSnapshotParams .putInt ("responseCode" , networkLogSnapshot .getResponseCode ());
127
-
128
- sendEvent ("IBGNetworkLoggerHandler" , networkSnapshotParams );
129
-
130
- }
131
- });
132
- }
133
- });
134
- }
135
-
136
- @ ReactMethod
137
- protected void updateNetworkLogSnapshot (String jsonString ) {
138
-
139
- JSONObject newJSONObject = null ;
140
- try {
141
- newJSONObject = new JSONObject (jsonString );
142
- } catch (JSONException e ) {
143
- throw new RuntimeException (e );
144
- }
145
- final Integer ID = newJSONObject .optInt ("id" );
146
- final NetworkLogSnapshot modifiedSnapshot = new NetworkLogSnapshot (
147
- newJSONObject .optString ("url" ),
148
- null ,
149
- null ,
150
- null ,
151
- null ,
152
- newJSONObject .optInt ("responseCode" )
153
- );
154
-
155
- final OnCompleteCallback <NetworkLogSnapshot > callback = callbackMap .get (ID );
156
- if (callback != null ) {
157
- callback .onComplete (null );
158
- }
159
- callbackMap .remove (ID );
160
-
161
- }
120
+ // @ReactMethod
121
+ // public void registerNetworkLogsListener() {
122
+ // MainThreadHandler.runOnMainThread(new Runnable() {
123
+ // @Override
124
+ // public void run() {
125
+ // InternalAPM._registerNetworkLogSanitizer(new VoidSanitizer<NetworkLogSnapshot>() {
126
+ // @Override
127
+ // public void sanitize(NetworkLogSnapshot networkLogSnapshot, @NonNull OnCompleteCallback<NetworkLogSnapshot> onCompleteCallback) {
128
+ // final int id = onCompleteCallback.hashCode();
129
+ // callbackMap.put(id, onCompleteCallback);
130
+ //
131
+ // WritableMap networkSnapshotParams = Arguments.createMap();
132
+ // networkSnapshotParams.putInt("id", id);
133
+ // networkSnapshotParams.putString("url", networkLogSnapshot.getUrl());
134
+ // networkSnapshotParams.putInt("responseCode", networkLogSnapshot.getResponseCode());
135
+ //
136
+ // sendEvent("IBGNetworkLoggerHandler", networkSnapshotParams);
137
+ //
138
+ // }
139
+ // });
140
+ // }
141
+ // });
142
+ // }
143
+ //
144
+ // @ReactMethod
145
+ // protected void updateNetworkLogSnapshot(String jsonString) {
146
+ //
147
+ // JSONObject newJSONObject = null;
148
+ // try {
149
+ // newJSONObject = new JSONObject(jsonString);
150
+ // } catch (JSONException e) {
151
+ // throw new RuntimeException(e);
152
+ // }
153
+ // final Integer ID = newJSONObject.optInt("id");
154
+ // final NetworkLogSnapshot modifiedSnapshot = new NetworkLogSnapshot(
155
+ // newJSONObject.optString("url"),
156
+ // null,
157
+ // null,
158
+ // null,
159
+ // null,
160
+ // newJSONObject.optInt("responseCode")
161
+ // );
162
+ //
163
+ // final OnCompleteCallback<NetworkLogSnapshot> callback = callbackMap.get(ID);
164
+ // if (callback != null) {
165
+ // callback.onComplete(null);
166
+ // }
167
+ // callbackMap.remove(ID);
168
+ //
169
+ // }
162
170
}
0 commit comments