Skip to content

Commit 173097e

Browse files
Merge remote-tracking branch 'origin/dev' into feat/dev-into-network-spans
# Conflicts: # android/native.gradle # android/src/main/java/com/instabug/reactlibrary/Constants.java # android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java # android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java # examples/default/android/app/build.gradle # examples/default/ios/Podfile # examples/default/ios/Podfile.lock # examples/default/package.json # examples/default/src/App.tsx # examples/default/src/screens/apm/NetworkScreen.tsx # examples/default/yarn.lock # ios/RNInstabug/InstabugAPMBridge.m # ios/RNInstabug/Util/IBGNetworkLogger+CP.h # src/modules/Instabug.ts # src/modules/NetworkLogger.ts # src/native/NativeAPM.ts # src/native/NativeInstabug.ts # src/utils/InstabugConstants.ts # src/utils/InstabugUtils.ts # test/mocks/mockInstabug.ts # test/modules/Instabug.spec.ts # test/modules/NetworkLogger.spec.ts
2 parents 0c06cc0 + 0502d85 commit 173097e

File tree

66 files changed

+1719
-160
lines changed

Some content is hidden

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

66 files changed

+1719
-160
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
# Changelog
22

3+
## [14.1.0](https://github.com/Instabug/Instabug-React-Native/compare/v14.0.0...v14.1.0) (January 2, 2025)
4+
5+
### Added
6+
7+
- Add support for tracing network requests from Instabug to services like Datadog and New Relic ([#1288](https://github.com/Instabug/Instabug-React-Native/pull/1288))
8+
9+
### Changed
10+
11+
- Bump Instabug iOS SDK to v14.1.0 ([#1335](https://github.com/Instabug/Instabug-React-Native/pull/1335)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/14.1.0).
12+
- Bump Instabug Android SDK to v14.1.0 ([#1335](https://github.com/Instabug/Instabug-React-Native/pull/1335)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v14.1.0).
13+
14+
## [14.0.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.4.0...14.0.0) (November 19, 2024)
15+
16+
### Added
17+
18+
- Add support for opting into session syncing ([#1292](https://github.com/Instabug/Instabug-React-Native/pull/1292)).
19+
20+
### Changed
21+
22+
- Bump Instabug iOS SDK to v14.0.0 ([#1312](https://github.com/Instabug/Instabug-React-Native/pull/1312)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/14.0.0).
23+
- Bump Instabug Android SDK to v14.0.0 ([#1312](https://github.com/Instabug/Instabug-React-Native/pull/1312)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v14.0.0).
24+
25+
### Added
26+
27+
- Exclude DEV server from network logs ([#1307](https://github.com/Instabug/Instabug-React-Native/pull/1307)).
28+
29+
### Fixed
30+
31+
- Replace thrown errors with logs ([#1220](https://github.com/Instabug/Instabug-React-Native/pull/1220))
32+
333
## [13.4.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.3.0...v13.4.0) (October 2, 2024)
434

535
### Added

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ android {
5757
minSdkVersion getExtOrDefault('minSdkVersion').toInteger()
5858
targetSdkVersion getExtOrDefault('targetSdkVersion').toInteger()
5959
versionCode 1
60-
versionName "13.4.0"
60+
versionName "14.1.0"
6161
multiDexEnabled true
6262
ndk {
6363
abiFilters "armeabi-v7a", "x86"

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.instabug.library.invocation.InstabugInvocationEvent;
1616
import com.instabug.library.invocation.util.InstabugFloatingButtonEdge;
1717
import com.instabug.library.invocation.util.InstabugVideoRecordingButtonPosition;
18+
import com.instabug.library.sessionreplay.model.SessionMetadata;
1819
import com.instabug.library.ui.onboarding.WelcomeMessage;
1920

2021
import java.util.ArrayList;
@@ -58,6 +59,7 @@ static Map<String, Object> getAll() {
5859
putAll(nonFatalExceptionLevel);
5960
putAll(locales);
6061
putAll(placeholders);
62+
putAll(launchType);
6163
}};
6264
}
6365

@@ -238,4 +240,18 @@ static Map<String, Object> getAll() {
238240
put("team", Key.CHATS_TEAM_STRING_NAME);
239241
put("insufficientContentMessage", Key.COMMENT_FIELD_INSUFFICIENT_CONTENT);
240242
}};
243+
244+
public static ArgsMap<String> launchType = new ArgsMap<String>() {{
245+
put("cold", SessionMetadata.LaunchType.COLD);
246+
put("warm",SessionMetadata.LaunchType.WARM );
247+
put("unknown","unknown");
248+
}};
249+
250+
// Temporary workaround to be removed in future release
251+
// This is used for mapping native `LaunchType` values into React Native enum values.
252+
public static HashMap<String,String> launchTypeReversed = new HashMap<String,String>() {{
253+
put(SessionMetadata.LaunchType.COLD,"cold");
254+
put(SessionMetadata.LaunchType.WARM,"warm" );
255+
}};
256+
241257
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ final class Constants {
1212

1313
final static String IBG_ON_FEATURES_UPDATED_CALLBACK = "IBGOnFeatureUpdatedCallback";
1414
final static String IBG_NETWORK_LOGGER_HANDLER = "IBGNetworkLoggerHandler";
15+
16+
final static String IBG_ON_NEW_W3C_FLAGS_UPDATE_RECEIVED_CALLBACK = "IBGOnNewW3CFlagsUpdateReceivedCallback";
17+
18+
final static String IBG_SESSION_REPLAY_ON_SYNC_CALLBACK_INVOCATION = "IBGSessionReplayOnSyncCallback";
19+
1520
}

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

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@
99

1010
import com.facebook.react.bridge.Promise;
1111
import com.facebook.react.bridge.ReactApplicationContext;
12-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
1312
import com.facebook.react.bridge.ReactMethod;
13+
import com.facebook.react.bridge.ReadableMap;
1414
import com.instabug.apm.APM;
1515
import com.instabug.apm.model.ExecutionTrace;
1616
import com.instabug.apm.networking.APMNetworkLogger;
1717
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
18+
import com.instabug.reactlibrary.utils.EventEmitterModule;
19+
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
1820
import com.instabug.reactlibrary.utils.MainThreadHandler;
1921

20-
import org.json.JSONException;
21-
import org.json.JSONObject;
22-
23-
import java.lang.reflect.InvocationTargetException;
2422
import java.lang.reflect.Method;
2523

2624
import java.util.HashMap;
@@ -29,7 +27,7 @@
2927

3028
import static com.instabug.reactlibrary.utils.InstabugUtil.getMethod;
3129

32-
public class RNInstabugAPMModule extends ReactContextBaseJavaModule {
30+
public class RNInstabugAPMModule extends EventEmitterModule {
3331

3432
public RNInstabugAPMModule(ReactApplicationContext reactApplicationContext) {
3533
super(reactApplicationContext);
@@ -59,7 +57,6 @@ public void run() {
5957

6058
/**
6159
* Enables or disables APM.
62-
*
6360
* @param isEnabled boolean indicating enabled or disabled.
6461
*/
6562
@ReactMethod
@@ -78,7 +75,6 @@ public void run() {
7875

7976
/**
8077
* Enables or disables app launch tracking.
81-
*
8278
* @param isEnabled boolean indicating enabled or disabled.
8379
*/
8480
@ReactMethod
@@ -114,7 +110,6 @@ public void run() {
114110

115111
/**
116112
* Enables or disables auto UI tracing
117-
*
118113
* @param isEnabled boolean indicating enabled or disabled.
119114
*/
120115
@ReactMethod
@@ -213,6 +208,7 @@ public void run() {
213208
* Starts an execution trace
214209
*
215210
* @param name string name of the trace.
211+
*
216212
* @deprecated see {@link #startFlow(String)}
217213
*/
218214
@Deprecated
@@ -243,6 +239,7 @@ public void run() {
243239
* @param id String id of the trace.
244240
* @param key attribute key
245241
* @param value attribute value. Null to remove attribute
242+
*
246243
* @deprecated see {@link #setFlowAttribute}
247244
*/
248245
@Deprecated
@@ -264,6 +261,7 @@ public void run() {
264261
* Ends a trace
265262
*
266263
* @param id string id of the trace.
264+
*
267265
* @deprecated see {@link #endFlow}
268266
*/
269267
@Deprecated
@@ -283,7 +281,6 @@ public void run() {
283281

284282
/**
285283
* Starts a UI trace
286-
*
287284
* @param name string name of the UI trace.
288285
*/
289286
@ReactMethod
@@ -332,44 +329,71 @@ private void networkLogAndroid(final double requestStartTime,
332329
final double statusCode,
333330
final String responseContentType,
334331
@Nullable final String errorDomain,
332+
@Nullable final ReadableMap w3cAttributes,
335333
@Nullable final String gqlQueryName,
336-
@Nullable final String serverErrorMessage) {
334+
@Nullable final String serverErrorMessage
335+
) {
337336
try {
338337
APMNetworkLogger networkLogger = new APMNetworkLogger();
339338

340339
final boolean hasError = errorDomain != null && !errorDomain.isEmpty();
341340
final String errorMessage = hasError ? errorDomain : null;
341+
Boolean isW3cHeaderFound=false;
342+
Long partialId=null;
343+
Long networkStartTimeInSeconds=null;
344+
342345

346+
try {
347+
if (!w3cAttributes.isNull("isW3cHeaderFound")) {
348+
isW3cHeaderFound = w3cAttributes.getBoolean("isW3cHeaderFound");
349+
}
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+
);
343367
try {
344368
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);
345369
if (method != null) {
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-
);
370+
method.invoke(
371+
networkLogger,
372+
(long) requestStartTime * 1000,
373+
(long) requestDuration,
374+
requestHeaders,
375+
requestBody,
376+
(long) requestBodySize,
377+
requestMethod,
378+
requestUrl,
379+
requestContentType,
380+
responseHeaders,
381+
responseBody,
382+
(long)responseBodySize,
383+
(int) statusCode,
384+
responseContentType,
385+
errorMessage,
386+
gqlQueryName,
387+
serverErrorMessage,
388+
w3cExternalTraceAttributes
389+
);
366390
} else {
367391
Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection");
368392
}
369393
} catch (Throwable e) {
370394
e.printStackTrace();
371395
}
372-
} catch (Throwable e) {
396+
} catch(Throwable e) {
373397
e.printStackTrace();
374398
}
375399
}

0 commit comments

Comments
 (0)