Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release:v14.1.0 #1338

Merged
merged 19 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [14.1.0](https://github.com/Instabug/Instabug-React-Native/compare/v14.0.0...v14.1.0) (January 2, 2025)

### Added

- 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))

### Changed

- 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).
- 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).

## [14.0.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.4.0...14.0.0) (November 19, 2024)

### Added
Expand All @@ -11,6 +22,10 @@
- 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).
- 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).

### Added

- Exclude DEV server from network logs ([#1307](https://github.com/Instabug/Instabug-React-Native/pull/1307)).

### Fixed

- Replace thrown errors with logs ([#1220](https://github.com/Instabug/Instabug-React-Native/pull/1220))
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ android {
minSdkVersion getExtOrDefault('minSdkVersion').toInteger()
targetSdkVersion getExtOrDefault('targetSdkVersion').toInteger()
versionCode 1
versionName "13.4.0"
versionName "14.1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
Expand Down
2 changes: 1 addition & 1 deletion android/native.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project.ext.instabug = [
version: '14.0.0'
version: '14.1.0'
]

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ final class Constants {

final static String IBG_ON_NEW_MESSAGE_HANDLER = "IBGonNewMessageHandler";
final static String IBG_ON_NEW_REPLY_RECEIVED_CALLBACK = "IBGOnNewReplyReceivedCallback";

final static String IBG_ON_NEW_W3C_FLAGS_UPDATE_RECEIVED_CALLBACK = "IBGOnNewW3CFlagsUpdateReceivedCallback";

final static String IBG_SESSION_REPLAY_ON_SYNC_CALLBACK_INVOCATION = "IBGSessionReplayOnSyncCallback";

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.instabug.apm.APM;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
import com.instabug.reactlibrary.utils.EventEmitterModule;
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
import com.instabug.reactlibrary.utils.MainThreadHandler;

import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import java.util.HashMap;
Expand All @@ -28,7 +27,7 @@

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

public class RNInstabugAPMModule extends ReactContextBaseJavaModule {
public class RNInstabugAPMModule extends EventEmitterModule {

public RNInstabugAPMModule(ReactApplicationContext reactApplicationContext) {
super(reactApplicationContext);
Expand Down Expand Up @@ -330,14 +329,41 @@ private void networkLogAndroid(final double requestStartTime,
final double statusCode,
final String responseContentType,
@Nullable final String errorDomain,
@Nullable final ReadableMap w3cAttributes,
@Nullable final String gqlQueryName,
@Nullable final String serverErrorMessage) {
@Nullable final String serverErrorMessage
) {
try {
APMNetworkLogger networkLogger = new APMNetworkLogger();

final boolean hasError = errorDomain != null && !errorDomain.isEmpty();
final String errorMessage = hasError ? errorDomain : null;
Boolean isW3cHeaderFound=false;
Long partialId=null;
Long networkStartTimeInSeconds=null;


try {
if (!w3cAttributes.isNull("isW3cHeaderFound")) {
isW3cHeaderFound = w3cAttributes.getBoolean("isW3cHeaderFound");
}

if (!w3cAttributes.isNull("partialId")) {
partialId =(long) w3cAttributes.getDouble("partialId");
networkStartTimeInSeconds = (long) w3cAttributes.getDouble("networkStartTimeInSeconds");
}

} catch (Exception e) {
e.printStackTrace();
}
APMCPNetworkLog.W3CExternalTraceAttributes w3cExternalTraceAttributes =
new APMCPNetworkLog.W3CExternalTraceAttributes(
isW3cHeaderFound,
partialId,
networkStartTimeInSeconds,
w3cAttributes.getString("w3cGeneratedHeader"),
w3cAttributes.getString("w3cCaughtHeader")
);
try {
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);
if (method != null) {
Expand All @@ -359,7 +385,7 @@ private void networkLogAndroid(final double requestStartTime,
errorMessage,
gqlQueryName,
serverErrorMessage,
null
w3cExternalTraceAttributes
);
} else {
Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.UiThread;

import com.facebook.react.bridge.Arguments;
Expand All @@ -22,6 +23,8 @@
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.uimanager.UIManagerModule;
import com.instabug.apm.InternalAPM;
import com.instabug.apm.configuration.cp.APMFeature;
import com.instabug.library.Feature;
import com.instabug.library.Instabug;
import com.instabug.library.InstabugColorTheme;
Expand All @@ -30,6 +33,11 @@
import com.instabug.library.LogLevel;
import com.instabug.library.ReproConfigurations;
import com.instabug.library.core.InstabugCore;
import com.instabug.library.internal.crossplatform.CoreFeature;
import com.instabug.library.internal.crossplatform.CoreFeaturesState;
import com.instabug.library.internal.crossplatform.FeaturesStateListener;
import com.instabug.library.internal.crossplatform.InternalCore;
import com.instabug.library.featuresflags.model.IBGFeatureFlag;
import com.instabug.library.featuresflags.model.IBGFeatureFlag;
import com.instabug.library.internal.module.InstabugLocale;
import com.instabug.library.invocation.InstabugInvocationEvent;
Expand Down Expand Up @@ -1148,6 +1156,105 @@ public void run() {
}
});
}
/**
* Register a listener for W3C flags value change
*/
@ReactMethod
public void registerW3CFlagsChangeListener(){

MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
InternalCore.INSTANCE._setFeaturesStateListener(new FeaturesStateListener() {
@Override
public void invoke(@NonNull CoreFeaturesState featuresState) {
WritableMap params = Arguments.createMap();
params.putBoolean("isW3ExternalTraceIDEnabled", featuresState.isW3CExternalTraceIdEnabled());
params.putBoolean("isW3ExternalGeneratedHeaderEnabled", featuresState.isAttachingGeneratedHeaderEnabled());
params.putBoolean("isW3CaughtHeaderEnabled", featuresState.isAttachingCapturedHeaderEnabled());

sendEvent(Constants.IBG_ON_NEW_W3C_FLAGS_UPDATE_RECEIVED_CALLBACK, params);
}
});
}
catch (Exception e) {
e.printStackTrace();
}

}

});
}


/**
* Get first time Value of W3ExternalTraceID flag
*/
@ReactMethod
public void isW3ExternalTraceIDEnabled(Promise promise){

MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
promise.resolve(InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_EXTERNAL_TRACE_ID));
}
catch (Exception e) {
e.printStackTrace();
promise.resolve(false);
}

}

});
}


/**
* Get first time Value of W3ExternalGeneratedHeader flag
*/
@ReactMethod
public void isW3ExternalGeneratedHeaderEnabled(Promise promise){

MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
promise.resolve(InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_ATTACHING_GENERATED_HEADER));
}
catch (Exception e) {
e.printStackTrace();
promise.resolve(false);
}

}

});
}

/**
* Get first time Value of W3CaughtHeader flag
*/
@ReactMethod
public void isW3CaughtHeaderEnabled(Promise promise){

MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
promise.resolve(InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_ATTACHING_CAPTURED_HEADER));
}
catch (Exception e) {
e.printStackTrace();
promise.resolve(false);
}

}

});
}


/**
* Map between the exported JS constant and the arg key in {@link ArgsRegistry}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,6 @@ public void testSetFlowAttribute() {
verify(APM.class, times(1));
APM.endUITrace();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import com.instabug.library.IssueType;
import com.instabug.library.ReproConfigurations;
import com.instabug.library.ReproMode;
import com.instabug.library.internal.crossplatform.CoreFeature;
import com.instabug.library.internal.crossplatform.InternalCore;
import com.instabug.library.featuresflags.model.IBGFeatureFlag;
import com.instabug.library.featuresflags.model.IBGFeatureFlag;
import com.instabug.library.internal.module.InstabugLocale;
import com.instabug.library.ui.onboarding.WelcomeMessage;
Expand Down Expand Up @@ -635,4 +638,28 @@ public void testWillRedirectToStore() {
// then
mockInstabug.verify(() -> Instabug.willRedirectToStore());
}
@Test
public void testW3CExternalTraceIDFlag(){
Promise promise = mock(Promise.class);
InternalCore internalAPM = mock(InternalCore.class);
rnModule.isW3ExternalTraceIDEnabled(promise);
boolean expected=internalAPM._isFeatureEnabled(CoreFeature.W3C_EXTERNAL_TRACE_ID);
verify(promise).resolve(expected);
}
@Test
public void testW3CExternalGeneratedHeaderFlag(){
Promise promise = mock(Promise.class);
InternalCore internalAPM = mock(InternalCore.class);
rnModule.isW3ExternalGeneratedHeaderEnabled(promise);
boolean expected=internalAPM._isFeatureEnabled(CoreFeature.W3C_ATTACHING_GENERATED_HEADER);
verify(promise).resolve(expected);
}
@Test
public void testW3CCaughtHeaderFlag(){
Promise promise = mock(Promise.class);
InternalCore internalAPM = mock(InternalCore.class);
rnModule.isW3CaughtHeaderEnabled(promise);
boolean expected=internalAPM._isFeatureEnabled(CoreFeature.W3C_ATTACHING_CAPTURED_HEADER);
verify(promise).resolve(expected);
}
}
3 changes: 3 additions & 0 deletions examples/default/ios/InstabugTests/InstabugAPMTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import <Instabug/IBGAPM.h>
#import "Instabug/Instabug.h"
#import "IBGConstants.h"
#import "RNInstabug/IBGAPM+PrivateAPIs.h"

@interface InstabugAPMTests : XCTestCase
@property (nonatomic, retain) InstabugAPMBridge *instabugBridge;
Expand Down Expand Up @@ -176,4 +177,6 @@ - (void) testEndUITrace {
OCMVerify([mock endUITrace]);
}



@end
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ - (void)setUp {
}

- (void)testSetEnabled {

[self.bridge setEnabled:NO];
XCTAssertFalse(IBGCrashReporting.enabled);

[self.bridge setEnabled:YES];
XCTAssertTrue(IBGCrashReporting.enabled);

[self.bridge setEnabled:NO];
XCTAssertFalse(IBGCrashReporting.enabled);
}

- (void)testSendJSCrash {
Expand Down
Loading