Skip to content

Revert "feat: add w3c header" #1287

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

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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: '13.4.0'
version: '13.3.0'
]

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ 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";

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

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 @@ -27,7 +28,7 @@

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

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

public RNInstabugAPMModule(ReactApplicationContext reactApplicationContext) {
super(reactApplicationContext);
Expand Down Expand Up @@ -329,41 +330,14 @@ 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.hasKey("isW3cHeaderFound")) {
isW3cHeaderFound = w3cAttributes.getBoolean("isW3cHeaderFound");
}

if (w3cAttributes.hasKey("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 @@ -385,7 +359,7 @@ private void networkLogAndroid(final double requestStartTime,
errorMessage,
gqlQueryName,
serverErrorMessage,
w3cExternalTraceAttributes
null
);
} 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,7 +8,6 @@
import android.util.Log;
import android.view.View;

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

import com.facebook.react.bridge.Arguments;
Expand All @@ -23,8 +22,6 @@
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 @@ -33,11 +30,6 @@
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 @@ -1156,105 +1148,6 @@ 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,6 +204,4 @@ public void testSetFlowAttribute() {
verify(APM.class, times(1));
APM.endUITrace();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
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 @@ -638,28 +635,4 @@ 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);
}
}
5 changes: 2 additions & 3 deletions examples/default/e2e/reportBug.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ it('reports a bug', async () => {
const floatingButton = getElement('floatingButton');
await waitFor(floatingButton).toBeVisible().withTimeout(30000);
await floatingButton.tap();
const reportBugMenuItemButton = getElement('reportBugMenuItem');
await waitFor(reportBugMenuItemButton).toBeVisible().withTimeout(30000);
await reportBugMenuItemButton.tap();

await getElement('reportBugMenuItem').tap();

await getElement('emailField').typeText(mockData.email);
await getElement('commentField').typeText(mockData.bugComment);
Expand Down
3 changes: 0 additions & 3 deletions examples/default/ios/InstabugTests/InstabugAPMTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#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 @@ -177,6 +176,4 @@ - (void) testEndUITrace {
OCMVerify([mock endUITrace]);
}



@end
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ - (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)testSendNonFatalErrorJsonCrash {
Expand Down
Loading