Skip to content

feat: [RN][Android] call setTrackUserSteps in android to enable/disable user steps tracking #1341

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -1274,4 +1274,21 @@ public Map<String, Object> getConstants() {

return constants;
}
/**
* Enables or disables user steps tracking.
* @param isEnabled A boolean to enable/disable Instabug.
*/
@ReactMethod
public void setTrackUserSteps(final boolean isEnabled) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
Instabug.setTrackingUserStepsState(isEnabled ? Feature.State.ENABLED : Feature.State.DISABLED);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,18 @@ public void testW3CCaughtHeaderFlag(){
boolean expected=internalAPM._isFeatureEnabled(CoreFeature.W3C_ATTACHING_CAPTURED_HEADER);
verify(promise).resolve(expected);
}
@Test
public void TestEnablingSetTrackerUserSteps() {
rnModule.setTrackUserSteps(true);
verify(Instabug.class, times(1));
Instabug.setTrackingUserStepsState(Feature.State.ENABLED);
}

@Test
public void TestDesablingSetTrackerUserSteps() {

rnModule.setTrackUserSteps(false);
verify(Instabug.class, times(1));
Instabug.setTrackingUserStepsState(Feature.State.DISABLED);
}
}
4 changes: 1 addition & 3 deletions src/modules/Instabug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ export const setUserData = (data: string) => {
* @param isEnabled A boolean to set user steps tracking to being enabled or disabled.
*/
export const setTrackUserSteps = (isEnabled: boolean) => {
if (Platform.OS === 'ios') {
NativeInstabug.setTrackUserSteps(isEnabled);
}
NativeInstabug.setTrackUserSteps(isEnabled);
};

/**
Expand Down
8 changes: 0 additions & 8 deletions test/modules/Instabug.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,20 +375,12 @@ describe('Instabug Module', () => {
});

it('should call the native method setTrackUserSteps', () => {
Platform.OS = 'ios';
Instabug.setTrackUserSteps(true);

expect(NativeInstabug.setTrackUserSteps).toBeCalledTimes(1);
expect(NativeInstabug.setTrackUserSteps).toBeCalledWith(true);
});

it('should not call the native method setTrackUserSteps when platform is android', () => {
Platform.OS = 'android';
Instabug.setTrackUserSteps(true);

expect(NativeInstabug.setTrackUserSteps).not.toBeCalled();
});

it('should call the native method setIBGLogPrintsToConsole', () => {
Platform.OS = 'ios';
Instabug.setIBGLogPrintsToConsole(true);
Expand Down