Skip to content

feat: user steps #540

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 58 commits into
base: refactor/monorepo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
773d1ae
feat: gestures & UI elements detection
kholood-ea Dec 2, 2024
76a0b47
testing
ahmedAlaaInstabug Dec 19, 2024
5bc5444
testing
ahmedAlaaInstabug Dec 22, 2024
911497b
testing
ahmedAlaaInstabug Dec 22, 2024
0c62f92
chore: update ios snapshot
ahmedAlaaInstabug Dec 24, 2024
b2a9659
Merge branch 'refs/heads/refactor/monorepo-private-view-package' into…
ahmedAlaaInstabug Dec 24, 2024
dac3899
format
ahmedAlaaInstabug Dec 24, 2024
a56c39f
format
ahmedAlaaInstabug Dec 26, 2024
8322d24
format
ahmedAlaaInstabug Dec 26, 2024
69e233f
chore(android): integrate with android snapshot
kholood-ea Jan 19, 2025
fce0c5e
chore(ios): integrate with ios custom build
kholood-ea Jan 19, 2025
34c5907
fix(android): passed required params to log user steps
kholood-ea Jan 19, 2025
3f7269c
fix(ios): add double tap event
kholood-ea Jan 19, 2025
59eca4b
feat(ios): add native user steps switch
kholood-ea Jan 19, 2025
41b8031
fix(ios): pass flutter view name
kholood-ea Jan 19, 2025
e22199c
feat(example): add private view test
kholood-ea Jan 19, 2025
a3a3e0e
fix: user steps parameters
kholood-ea Jan 19, 2025
be6a07c
chore(android): integrate private views snapshot
kholood-ea Feb 4, 2025
c40b304
chore: cleanup unused params
kholood-ea Feb 4, 2025
f7f6a47
Merge remote-tracking branch 'origin/refactor/monorepo' into feat/use…
kholood-ea Feb 4, 2025
6cf5876
fix(example): clean up imports
kholood-ea Feb 4, 2025
b264f73
fix: update test cases
kholood-ea Feb 4, 2025
cbebbf8
chore: update deps
kholood-ea Feb 4, 2025
f48c1e8
fix(ios): update log user steps test case
kholood-ea Feb 4, 2025
2394241
fix: linters issues
kholood-ea Feb 4, 2025
df65353
fix(android): update test case
kholood-ea Feb 4, 2025
30306cb
chore(android): activate commented code
kholood-ea Feb 5, 2025
877573d
chore(android): activate android test case
kholood-ea Feb 5, 2025
88d5bb7
fix(ios): add double tap to test case
kholood-ea Feb 5, 2025
5c23138
chore(ios): restore cocoapods version
kholood-ea Feb 5, 2025
8dabcdb
chore(example): revert old app token
kholood-ea Feb 5, 2025
4e89b3f
test
ahmedAlaaInstabug Feb 5, 2025
d74dc65
Merge remote-tracking branch 'origin/feat/user-step' into feat/user-step
ahmedAlaaInstabug Feb 5, 2025
d425b52
test
ahmedAlaaInstabug Feb 6, 2025
d4b49d4
test
ahmedAlaaInstabug Feb 6, 2025
ca50dc2
test
ahmedAlaaInstabug Feb 6, 2025
da04866
test
ahmedAlaaInstabug Feb 6, 2025
028f846
test
ahmedAlaaInstabug Feb 6, 2025
a9f7500
chore(android): add descriptive comment
kholood-ea Feb 10, 2025
d9886d1
chore(android): update snapshot
kholood-ea Feb 11, 2025
b5b2744
fix: PR comments
ahmedAlaaInstabug Feb 17, 2025
02e968a
fix: PR comments
ahmedAlaaInstabug Feb 17, 2025
8b2f003
fix: ios CI
ahmedAlaaInstabug Feb 17, 2025
586013b
fix: ios CI
ahmedAlaaInstabug Feb 17, 2025
0aeeb93
fix: ios CI
ahmedAlaaInstabug Feb 17, 2025
502d030
fix: ios CI
ahmedAlaaInstabug Feb 18, 2025
2f26610
fix: ios CI
ahmedAlaaInstabug Feb 18, 2025
43ee727
fix: android CI
ahmedAlaaInstabug Feb 18, 2025
b07202f
fix: android CI
ahmedAlaaInstabug Feb 18, 2025
80c7bcd
Update config.yml
ahmedAlaaInstabug Feb 18, 2025
5c4652a
fix: android CI
ahmedAlaaInstabug Feb 19, 2025
3b7071a
Merge remote-tracking branch 'origin/ci/fix-user-step' into ci/fix-us…
ahmedAlaaInstabug Feb 19, 2025
11405ea
fix: android CI
ahmedAlaaInstabug Feb 19, 2025
9d2f01f
Merge pull request #549 from Instabug/ci/fix-user-step
ahmedAlaaInstabug Feb 19, 2025
8f20790
fix: fix private view app
ahmedAlaaInstabug Feb 23, 2025
5ac4306
fix: extra space in message
ahmedAlaaInstabug Feb 23, 2025
cfc6f6b
chore(android): upgrade to latest snapshot
ahmedAlaaInstabug Feb 24, 2025
47caf61
fix: trim message
ahmedAlaaInstabug Feb 24, 2025
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 .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ jobs:
command: flutter build ios --simulator
- run:
name: Run E2E Tests
no_output_timeout: 30m
no_output_timeout: 20m
working_directory: e2e
command: dotnet test

Expand Down
6 changes: 5 additions & 1 deletion e2e/BugReportingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public void ShakeInvocationEvent()
{
if (!Platform.IsIOS) return;


ScrollUp();
captain.FindByText("Shake").Tap();

captain.Shake();
Expand All @@ -69,7 +71,9 @@ public void ShakeInvocationEvent()
[Fact]
public void TwoFingersSwipeLeftInvocationEvent()
{
if (!Platform.IsIOS){
ScrollUp();
}
captain.FindByText("Two Fingers Swipe Left").Tap();

Thread.Sleep(500);
Expand Down Expand Up @@ -113,8 +117,8 @@ public void ManualInvocation()
[Fact]
public void MultipleScreenshotsInReproSteps()
{
Dispose();
ScrollDownLittle();

captain.FindByText("Enter screen name").Tap();
captain.Type("My Screen");
captain.HideKeyboard();
Expand Down
7 changes: 7 additions & 0 deletions e2e/InstabugTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ public class InstabugTests : CaptainTest
[Fact]
public void ChangePrimaryColor()
{
ScrollUp();
ScrollUp();
ScrollUp();
ScrollUp();
ScrollUp();
ScrollUp();

var color = "#FF0000";
var expected = Color.FromArgb(255, 0, 0);

Expand Down
6 changes: 3 additions & 3 deletions e2e/Utils/CaptainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected void ScrollDown()
{
captain.Swipe(
start: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 200),
end: new Point(captain.Window.Size.Width / 2, 250)
end: new Point(captain.Window.Size.Width / 2, 300)
);
}

Expand All @@ -41,14 +41,14 @@ protected void ScrollDownLittle()
{
captain.Swipe(
start: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 200),
end: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 220)
end: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 250)
);
}

protected void ScrollUp()
{
captain.Swipe(
start: new Point(captain.Window.Size.Width / 2, 250),
start: new Point(captain.Window.Size.Width / 2, 300),
end: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 200)
);
}
Expand Down
10 changes: 9 additions & 1 deletion packages/instabug_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ rootProject.allprojects {
repositories {
google()
mavenCentral()
maven {
url "https://mvn.instabug.com/nexus/repository/instabug-internal/"
credentials {
username "instabug"
password System.getenv('INSTABUG_REPOSITORY_PASSWORD')
}
}
}
}

Expand Down Expand Up @@ -44,7 +51,8 @@ android {
}

dependencies {
api 'com.instabug.library:instabug:14.1.0'
api 'com.instabug.library:instabug:14.2.0.6611053-SNAPSHOT'

testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-inline:3.12.1"
testImplementation "io.mockk:mockk:1.13.13"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -126,6 +127,16 @@ public void init(@NonNull String token, @NonNull List<String> invocationEvents,
.build();

Instabug.setScreenshotProvider(screenshotProvider);

try{
Class<?> myClass = Class.forName("com.instabug.library.Instabug");
// Enable/Disable native user steps capturing
Method method = myClass.getDeclaredMethod("shouldDisableNativeUserStepsCapturing", boolean.class);
method.setAccessible(true);
method.invoke(null,true);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
Expand Down Expand Up @@ -159,6 +170,33 @@ public void logOut() {
Instabug.logoutUser();
}

@Override
public void setEnableUserSteps(@NonNull Boolean isEnabled) {
Instabug.setTrackingUserStepsState(isEnabled ? Feature.State.ENABLED : Feature.State.DISABLED);
}

@Override

public void logUserSteps(@NonNull String gestureType, @NonNull String message,@Nullable String viewName) {
try {
final String stepType = ArgsRegistry.gestureStepType.get(gestureType);
final long timeStamp = System.currentTimeMillis();
String view = "";

Method method = Reflection.getMethod(Class.forName("com.instabug.library.Instabug"), "addUserStep",
long.class, String.class, String.class, String.class, String.class);
if (method != null) {
if (viewName != null){
view = viewName;
}

method.invoke(null, timeStamp, stepType, message, null, view);
}
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void setLocale(@NonNull String locale) {
final InstabugLocale resolvedLocale = ArgsRegistry.locales.get(locale);
Expand Down Expand Up @@ -362,6 +400,13 @@ public void reportScreenChange(@NonNull String screenName) {
if (method != null) {
method.invoke(null, null, screenName);
}

Method reportViewChange = Reflection.getMethod(Class.forName("com.instabug.library.Instabug"), "reportCurrentViewChange",
String.class);
if (reportViewChange != null) {
reportViewChange.invoke(null,screenName);
}

} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -497,7 +542,7 @@ public void willRedirectToStore() {
Instabug.willRedirectToStore();
}

public static void setScreenshotCaptor(ScreenshotCaptor screenshotCaptor,InternalCore internalCore) {
public static void setScreenshotCaptor(ScreenshotCaptor screenshotCaptor, InternalCore internalCore) {
internalCore._setScreenshotCaptor(new com.instabug.library.screenshot.ScreenshotCaptor() {
@Override
public void capture(@NonNull ScreenshotRequest screenshotRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.instabug.library.invocation.InstabugInvocationEvent;
import com.instabug.library.invocation.util.InstabugFloatingButtonEdge;
import com.instabug.library.invocation.util.InstabugVideoRecordingButtonPosition;
import com.instabug.library.model.StepType;
import com.instabug.library.ui.onboarding.WelcomeMessage;

import java.util.HashMap;
Expand Down Expand Up @@ -53,11 +54,12 @@ public T get(Object key) {
put("InvocationOption.disablePostSendingDialog", Option.DISABLE_POST_SENDING_DIALOG);
}};


public static final ArgsMap<InstabugColorTheme> colorThemes = new ArgsMap<InstabugColorTheme>() {{
put("ColorTheme.light", InstabugColorTheme.InstabugColorThemeLight);
put("ColorTheme.dark", InstabugColorTheme.InstabugColorThemeDark);
}};
public static ArgsMap<IBGNonFatalException.Level> nonFatalExceptionLevel = new ArgsMap<IBGNonFatalException.Level>() {{
public static ArgsMap<IBGNonFatalException.Level> nonFatalExceptionLevel = new ArgsMap<IBGNonFatalException.Level>() {{
put("NonFatalExceptionLevel.critical", IBGNonFatalException.Level.CRITICAL);
put("NonFatalExceptionLevel.error", IBGNonFatalException.Level.ERROR);
put("NonFatalExceptionLevel.warning", IBGNonFatalException.Level.WARNING);
Expand Down Expand Up @@ -206,4 +208,13 @@ public T get(Object key) {
put("CustomTextPlaceHolderKey.messagesNotificationAndOthers", Key.CHATS_MULTIPLE_MESSAGE_NOTIFICATION);
put("CustomTextPlaceHolderKey.insufficientContentMessage", Key.COMMENT_FIELD_INSUFFICIENT_CONTENT);
}};

public static final ArgsMap<String> gestureStepType = new ArgsMap<String>() {{
put("GestureType.swipe", StepType.SWIPE);
put("GestureType.scroll", StepType.SCROLL);
put("GestureType.tap", StepType.TAP);
put("GestureType.pinch", StepType.PINCH);
put("GestureType.longPress", StepType.LONG_PRESS);
put("GestureType.doubleTap", StepType.DOUBLE_TAP);
}};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
Expand All @@ -30,6 +32,7 @@
import com.instabug.bug.BugReporting;
import com.instabug.flutter.generated.InstabugPigeon;
import com.instabug.flutter.modules.InstabugApi;
import com.instabug.flutter.util.ArgsRegistry;
import com.instabug.flutter.util.GlobalMocks;
import com.instabug.flutter.util.MockReflected;
import com.instabug.library.Feature;
Expand Down Expand Up @@ -654,4 +657,36 @@ public void testSetScreenshotCaptor() {
InstabugApi.setScreenshotCaptor(any(), internalCore);
verify(internalCore)._setScreenshotCaptor(any(ScreenshotCaptor.class));
}

@Test
public void testSetUserStepsEnabledGivenTrue() {
boolean isEnabled = true;

api.setEnableUserSteps(isEnabled);

mInstabug.verify(() -> Instabug.setTrackingUserStepsState(Feature.State.ENABLED));
}

@Test
public void testSetUserStepsEnabledGivenFalse() {
boolean isEnabled = false;

api.setEnableUserSteps(isEnabled);

mInstabug.verify(() -> Instabug.setTrackingUserStepsState(Feature.State.DISABLED));
}

@Test
public void testLogUserSteps() {

final String gestureType = "GestureType.tap";
final String message = "message";
final String view = "view";

api.logUserSteps(gestureType, message,view);

reflected.verify(() -> MockReflected.addUserStep(anyLong(), eq(ArgsRegistry.gestureStepType.get(gestureType)), eq(message), isNull(), eq(view)));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ public static void setUp() throws NoSuchMethodException {
Method mEndScreenLoadingCP = MockReflected.class.getDeclaredMethod("endScreenLoadingCP", Long.class, Long.class);
mEndScreenLoadingCP.setAccessible(true);
reflection.when(() -> Reflection.getMethod(Class.forName("com.instabug.apm.APM"), "endScreenLoadingCP", Long.class, Long.class)).thenReturn(mEndScreenLoadingCP);


Method mAddUserStepCp = MockReflected.class.getDeclaredMethod("addUserStep",
long.class, String.class, String.class, String.class, String.class);
mAddUserStepCp.setAccessible(true);
reflection.when(() -> Reflection.getMethod(Class.forName("com.instabug.library.Instabug"), "addUserStep",
long.class, String.class, String.class, String.class, String.class)).thenReturn(mAddUserStepCp);;

}

public static void close() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.instabug.flutter.util;

import android.graphics.Bitmap;

import androidx.annotation.Nullable;

import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
import com.instabug.crash.models.IBGNonFatalException;
import com.instabug.library.model.StepType;

import org.json.JSONObject;

Expand All @@ -19,33 +21,46 @@ public class MockReflected {
/**
* Instabug.reportScreenChange
*/
public static void reportScreenChange(Bitmap screenshot, String name) {}
public static void reportScreenChange(Bitmap screenshot, String name) {
}

/**
* Instabug.setCustomBrandingImage
*/
public static void setCustomBrandingImage(Bitmap light, Bitmap dark) {}
public static void setCustomBrandingImage(Bitmap light, Bitmap dark) {
}

/**
* Instabug.setCurrentPlatform
*/
public static void setCurrentPlatform(int platform) {}
public static void setCurrentPlatform(int platform) {
}

/**
* APMNetworkLogger.log
*/
public static void apmNetworkLog(long requestStartTime, long requestDuration, String requestHeaders, String requestBody, long requestBodySize, String requestMethod, String requestUrl, String responseHeaders, String responseBody, String responseBodySize, long statusCode, int responseContentType, String errorMessage, String var18, @Nullable String gqlQueryName, @Nullable String serverErrorMessage, @Nullable APMCPNetworkLog.W3CExternalTraceAttributes w3CExternalTraceAttributes) {}
public static void apmNetworkLog(long requestStartTime, long requestDuration, String requestHeaders, String requestBody, long requestBodySize, String requestMethod, String requestUrl, String responseHeaders, String responseBody, String responseBodySize, long statusCode, int responseContentType, String errorMessage, String var18, @Nullable String gqlQueryName, @Nullable String serverErrorMessage, @Nullable APMCPNetworkLog.W3CExternalTraceAttributes w3CExternalTraceAttributes) {
}

/**
* CrashReporting.reportException
*/
public static void crashReportException(JSONObject exception, boolean isHandled) {}
public static void crashReportException(JSONObject exception, boolean isHandled, Map<String,String> userAttributes, JSONObject fingerPrint, IBGNonFatalException.Level level) {}
public static void crashReportException(JSONObject exception, boolean isHandled) {
}

public static void crashReportException(JSONObject exception, boolean isHandled, Map<String, String> userAttributes, JSONObject fingerPrint, IBGNonFatalException.Level level) {
}


public static void startUiTraceCP(String screenName, Long microTimeStamp, Long traceId) {
}

public static void startUiTraceCP(String screenName, Long microTimeStamp, Long traceId) {}
public static void reportScreenLoadingCP(Long startTimeStampMicro, Long durationMicro, Long uiTraceId) {
}

public static void reportScreenLoadingCP(Long startTimeStampMicro, Long durationMicro, Long uiTraceId) {}
public static void endScreenLoadingCP(Long timeStampMicro, Long uiTraceId) {
}

public static void endScreenLoadingCP(Long timeStampMicro, Long uiTraceId) {}
public static void addUserStep(long timestamp, @StepType String stepType, String message, String label, String viewType) {
}
}
1 change: 1 addition & 0 deletions packages/instabug_flutter/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ allprojects {
repositories {
google()
mavenCentral()

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@ - (void)testLocales {
}
}

- (void)testUserStepsGesture {
NSArray *values = @[
@(IBGUIEventTypeSwipe),
@(IBGUIEventTypeScroll),
@(IBGUIEventTypeTap),
@(IBGUIEventTypePinch),
@(IBGUIEventTypeLongPress),
@(IBGUIEventTypeDoubleTap),
];

for (NSNumber *value in values) {
XCTAssertTrue([[ArgsRegistry.userStepsGesture allValues] containsObject:value]);
}
}

- (void)testPlaceholders {
NSArray *values = @[
kIBGShakeStartAlertTextStringName,
Expand Down
Loading