Skip to content

Commit e4ab074

Browse files
Merge pull request #1298 from Instabug/feat/network-spans-feature-flags
feat: add network spans feature flags
2 parents acaaaf2 + de65770 commit e4ab074

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+6031
-4115
lines changed

.circleci/config.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ commands:
4646
type: boolean
4747
default: false
4848
steps:
49+
- run:
50+
name: Uninstall Existing CocoaPods
51+
command: gem uninstall -x cocoapods
52+
- run:
53+
name: Install CocoaPods
54+
command: gem install cocoapods:1.14.0
4955
- restore_cache:
5056
name: Restore Pods Cache
5157
keys:
@@ -252,7 +258,7 @@ jobs:
252258
# ios/upload_sourcemap.sh files respectively.
253259
sync_generated_files:
254260
macos:
255-
xcode: 13.4.1
261+
xcode: 15.4.0
256262
resource_class: macos.m1.medium.gen1
257263
steps:
258264
- advanced-checkout/shallow-checkout
@@ -275,7 +281,7 @@ jobs:
275281
type: boolean
276282
default: false
277283
macos:
278-
xcode: 13.4.1
284+
xcode: 15.4.0
279285
resource_class: macos.m1.medium.gen1
280286
working_directory: ~/project/examples/default
281287
environment:
@@ -295,7 +301,7 @@ jobs:
295301
-scheme InstabugExample \
296302
-resultBundlePath coverage/result.xcresult \
297303
-sdk iphonesimulator \
298-
-destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.5' \
304+
-destination 'platform=iOS Simulator,name=iPhone 15 Pro Max,OS=17.5' \
299305
test | xcpretty
300306
- when:
301307
condition: << parameters.collect_coverage >>
@@ -315,7 +321,7 @@ jobs:
315321
type: steps
316322
default: []
317323
macos:
318-
xcode: 13.4.1
324+
xcode: 15.4.0
319325
resource_class: macos.m1.medium.gen1
320326
environment:
321327
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
@@ -414,7 +420,7 @@ jobs:
414420

415421
publish:
416422
macos:
417-
xcode: 13.4.1
423+
xcode: 15.4.0
418424
resource_class: macos.m1.medium.gen1
419425
working_directory: '~'
420426
steps:

android/build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,17 @@ dependencies {
7979
testImplementation "org.mockito:mockito-android:3.4.0"
8080
testImplementation 'junit:junit:4.13.2'
8181
}
82+
83+
rootProject.allprojects {
84+
repositories {
85+
google()
86+
jcenter()
87+
maven {
88+
url "https://mvn.instabug.com/nexus/repository/instabug-internal/"
89+
credentials {
90+
username "instabug"
91+
password System.getenv('INSTABUG_REPOSITORY_PASSWORD')
92+
}
93+
}
94+
}
95+
}

android/native.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.ext.instabug = [
2-
version: '13.4.1'
2+
version: '14.0.0.6273738-SNAPSHOT'
33
]
44

55
dependencies {

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.json.JSONException;
2121
import org.json.JSONObject;
22+
2223
import java.lang.reflect.InvocationTargetException;
2324
import java.lang.reflect.Method;
2425

@@ -58,6 +59,7 @@ public void run() {
5859

5960
/**
6061
* Enables or disables APM.
62+
*
6163
* @param isEnabled boolean indicating enabled or disabled.
6264
*/
6365
@ReactMethod
@@ -76,6 +78,7 @@ public void run() {
7678

7779
/**
7880
* Enables or disables app launch tracking.
81+
*
7982
* @param isEnabled boolean indicating enabled or disabled.
8083
*/
8184
@ReactMethod
@@ -111,6 +114,7 @@ public void run() {
111114

112115
/**
113116
* Enables or disables auto UI tracing
117+
*
114118
* @param isEnabled boolean indicating enabled or disabled.
115119
*/
116120
@ReactMethod
@@ -209,7 +213,6 @@ public void run() {
209213
* Starts an execution trace
210214
*
211215
* @param name string name of the trace.
212-
*
213216
* @deprecated see {@link #startFlow(String)}
214217
*/
215218
@Deprecated
@@ -240,7 +243,6 @@ public void run() {
240243
* @param id String id of the trace.
241244
* @param key attribute key
242245
* @param value attribute value. Null to remove attribute
243-
*
244246
* @deprecated see {@link #setFlowAttribute}
245247
*/
246248
@Deprecated
@@ -262,7 +264,6 @@ public void run() {
262264
* Ends a trace
263265
*
264266
* @param id string id of the trace.
265-
*
266267
* @deprecated see {@link #endFlow}
267268
*/
268269
@Deprecated
@@ -282,6 +283,7 @@ public void run() {
282283

283284
/**
284285
* Starts a UI trace
286+
*
285287
* @param name string name of the UI trace.
286288
*/
287289
@ReactMethod
@@ -341,33 +343,33 @@ private void networkLogAndroid(final double requestStartTime,
341343
try {
342344
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);
343345
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+
);
364366
} else {
365367
Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection");
366368
}
367369
} catch (Throwable e) {
368370
e.printStackTrace();
369371
}
370-
} catch(Throwable e) {
372+
} catch (Throwable e) {
371373
e.printStackTrace();
372374
}
373375
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package com.instabug.reactlibrary;
2+
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+
8+
import androidx.annotation.NonNull;
9+
10+
import com.facebook.react.bridge.Promise;
11+
import com.facebook.react.bridge.ReactApplicationContext;
12+
import com.facebook.react.bridge.ReactMethod;
13+
import com.instabug.apm.InternalAPM;
14+
import com.instabug.reactlibrary.utils.EventEmitterModule;
15+
import com.instabug.reactlibrary.utils.MainThreadHandler;
16+
17+
18+
public class RNInstabugNetworkLoggerModule extends EventEmitterModule {
19+
20+
public RNInstabugNetworkLoggerModule(ReactApplicationContext reactContext) {
21+
super(reactContext);
22+
}
23+
24+
@NonNull
25+
@Override
26+
public String getName() {
27+
return "IBGNetworkLogger";
28+
}
29+
30+
31+
@ReactMethod
32+
public void addListener(String event) {
33+
super.addListener(event);
34+
}
35+
36+
@ReactMethod
37+
public void removeListeners(Integer count) {
38+
super.removeListeners(count);
39+
}
40+
41+
private boolean getFlagValue(String key) {
42+
return InternalAPM._isFeatureEnabledCP( key , "");
43+
}
44+
45+
/**
46+
* Get first time Value of [cp_native_interception_enabled] flag
47+
*/
48+
@ReactMethod
49+
public void isNativeInterceptionEnabled(Promise promise) {
50+
MainThreadHandler.runOnMainThread(new Runnable() {
51+
@Override
52+
public void run() {
53+
try {
54+
promise.resolve(getFlagValue(CP_NATIVE_INTERCEPTION_ENABLED));
55+
} catch (Exception e) {
56+
e.printStackTrace();
57+
promise.resolve(false); // Will rollback to JS interceptor
58+
}
59+
60+
}
61+
});
62+
}
63+
64+
/**
65+
* Indicate if user added APM Network plugin or not
66+
* [true] means user added the APM plugin
67+
* [false] means not
68+
*/
69+
@ReactMethod
70+
public void hasAPMNetworkPlugin(Promise promise) {
71+
MainThreadHandler.runOnMainThread(new Runnable() {
72+
@Override
73+
public void run() {
74+
try {
75+
promise.resolve(getFlagValue(APM_NETWORK_PLUGIN_INSTALLED));
76+
} catch (Exception e) {
77+
e.printStackTrace();
78+
promise.resolve(false); // Will rollback to JS interceptor
79+
}
80+
81+
}
82+
});
83+
}
84+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext r
2929
modules.add(new RNInstabugRepliesModule(reactContext));
3030
modules.add(new RNInstabugAPMModule(reactContext));
3131
modules.add(new RNInstabugSessionReplayModule(reactContext));
32+
modules.add(new RNInstabugNetworkLoggerModule(reactContext));
3233
return modules;
3334
}
3435

0 commit comments

Comments
 (0)