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

feat: user steps #540

Open
wants to merge 58 commits into
base: refactor/monorepo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ jobs:
- setup_flutter
- android/start-emulator-and-run-tests:
run-tests-working-directory: e2e
additional-avd-args: --device 3
additional-avd-args: --device 25
system-image: system-images;android-33;default;x86_64
post-emulator-launch-assemble-command: cd packages/instabug_flutter/example && flutter build apk --debug
test-command: dotnet test
Expand Down 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
82 changes: 59 additions & 23 deletions e2e/BugReportingTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Drawing;
using E2E.Utils;
using Xunit;
using Instabug.Captain;

using NoSuchElementException = OpenQA.Selenium.NoSuchElementException;
using System.Drawing;

namespace E2E;

Expand Down Expand Up @@ -46,6 +46,9 @@ public void ReportABug()
[Fact]
public void FloatingButtonInvocationEvent()
{

Console.WriteLine("FloatingButtonInvocationEvent");

captain.FindById(
android: "instabug_floating_button",
ios: "IBGFloatingButtonAccessibilityIdentifier"
Expand All @@ -57,9 +60,13 @@ public void FloatingButtonInvocationEvent()
[Fact]
public void ShakeInvocationEvent()
{

Console.WriteLine("ShakeInvocationEvent");

if (!Platform.IsIOS) return;

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

captain.FindByTextScroll("Shake").Tap();

captain.Shake();

Expand All @@ -69,8 +76,12 @@ public void ShakeInvocationEvent()
[Fact]
public void TwoFingersSwipeLeftInvocationEvent()
{
ScrollUp();
captain.FindByText("Two Fingers Swipe Left").Tap();

Console.WriteLine("TwoFingersSwipeLeftInvocationEvent");



captain.FindByTextScroll("Two Fingers Swipe Left").Tap();

Thread.Sleep(500);

Expand All @@ -89,7 +100,11 @@ public void TwoFingersSwipeLeftInvocationEvent()
[Fact]
public void NoneInvocationEvent()
{
captain.FindByText("None").Tap();

Console.WriteLine("NoneInvocationEvent");


captain.FindByTextScroll("None").Tap();

captain.WaitForAssertion(() =>
Assert.Throws<NoSuchElementException>(() =>
Expand All @@ -105,22 +120,38 @@ public void NoneInvocationEvent()
[Fact]
public void ManualInvocation()
{
captain.FindByText("Invoke").Tap();


Console.WriteLine("ManualInvocation");



captain.FindByTextScroll("Invoke").Tap();

AssertOptionsPromptIsDisplayed();
}

[Fact]
public void MultipleScreenshotsInReproSteps()
{
ScrollDownLittle();

captain.FindByText("Enter screen name").Tap();

Console.WriteLine("MultipleScreenshotsInReproSteps");




captain.FindByTextScroll("Enter screen name").Tap();
captain.Type("My Screen");
captain.HideKeyboard();

captain.FindByText("Report Screen Change").Tap();
captain.FindByText("Send Bug Report").Tap();
captain.HideKeyboard();
Thread.Sleep(500);

captain.FindByTextScroll("Report Screen Change")?.Tap();
Thread.Sleep(500);
captain.FindByTextScroll("Send Bug Report")?.Tap();

captain.FindById(
android: "instabug_text_view_repro_steps_disclaimer",
ios: "IBGBugVCReproStepsDisclaimerAccessibilityIdentifier"
Expand All @@ -136,27 +167,30 @@ public void MultipleScreenshotsInReproSteps()
[Fact(Skip = "The test is flaky on iOS so we're skipping it to unblock the v13.2.0 release")]
public void ChangeReportTypes()
{
ScrollUp();
captain.FindByText("Bug", exact: true).Tap();

Console.WriteLine("ChangeReportTypes");


captain.FindByTextScroll("Bug", exact: true).Tap();

if (Platform.IsAndroid)
{
captain.FindByText("Invoke").Tap();
captain.FindByTextScroll("Invoke").Tap();

// Shows bug reporting screen
Assert.True(captain.FindById("ib_bug_scroll_view").Displayed);

// Close bug reporting screen
captain.GoBack();
captain.FindByText("DISCARD").Tap();
captain.FindByTextScroll("DISCARD").Tap();

Thread.Sleep(500);

}

captain.FindByText("Feedback").Tap();
captain.FindByTextScroll("Feedback").Tap();

captain.FindByText("Invoke").Tap();
captain.FindByTextScroll("Invoke").Tap();

// Shows both bug reporting and feature requests in prompt options
AssertOptionsPromptIsDisplayed();
Expand All @@ -169,10 +203,12 @@ public void ChangeReportTypes()
[Fact]
public void ChangeFloatingButtonEdge()
{
ScrollDown();
captain.FindByText("Move Floating Button to Left").Tap();

Thread.Sleep(500);
Console.WriteLine("ChangeFloatingButtonEdge");


captain.FindByTextScroll("Move Floating Button to Left",false,false)?.Tap();


captain.WaitForAssertion(() =>
{
Expand All @@ -189,16 +225,16 @@ public void ChangeFloatingButtonEdge()
[Fact]
public void OnDismissCallbackIsCalled()
{
ScrollDownLittle();

captain.FindByText("Set On Dismiss Callback").Tap();
captain.FindByText("Invoke").Tap();
captain.FindByTextScroll("Set On Dismiss Callback",false,false).Tap();
captain.FindByTextScroll("Invoke",false,false).Tap();

AssertOptionsPromptIsDisplayed();

captain.FindByText("Cancel").Tap();
captain.FindByTextScroll("Cancel").Tap();

var popUpText = captain.FindByText("onDismiss callback called with DismissType.cancel and ReportType.other");
Assert.True(popUpText.Displayed);

}
}
6 changes: 3 additions & 3 deletions e2e/FeatureRequestsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public class FeatureRequestsTests : CaptainTest
[Fact]
public void ShowFeatureRequetsScreen()
{
ScrollDown();
ScrollDown();

captain.FindByText("Show Feature Requests").Tap();
Console.WriteLine("ShowFeatureRequetsScreen");

captain.FindByTextScroll("Show Feature Requests",false,false).Tap();

var screenTitle = captain.FindById(
android: "ib_fr_toolbar_main",
Expand Down
6 changes: 4 additions & 2 deletions e2e/InstabugTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ public class InstabugTests : CaptainTest
[Fact]
public void ChangePrimaryColor()
{
Console.WriteLine("ChangePrimaryColor");

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

captain.FindByText("Enter primary color").Tap();
captain.FindByTextScroll("Enter primary color").Tap();
captain.Type(color);
captain.HideKeyboard();

captain.FindByText("Change Primary Color").Tap();
captain.FindByTextScroll("Change Primary Color").Tap();

captain.WaitForAssertion(() =>
{
Expand Down
5 changes: 3 additions & 2 deletions e2e/SurveysTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ public class SurveysTests : CaptainTest
[Fact]
public void ShowManualSurvey()
{
ScrollDownLittle();
captain.FindByText("Show Manual Survey").Tap();
Console.WriteLine("ShowManualSurvey");

captain.FindByTextScroll("Show Manual Survey",false,false).Tap();

captain.WaitForAssertion(() =>
{
Expand Down
26 changes: 3 additions & 23 deletions e2e/Utils/CaptainTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Drawing;
using Instabug.Captain;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.MultiTouch;

namespace E2E.Utils;

Expand All @@ -10,6 +12,7 @@ public class CaptainTest : IDisposable
AndroidApp = Path.GetFullPath("../../../../packages/instabug_flutter/example/build/app/outputs/flutter-apk/app-debug.apk"),
AndroidAppId = "com.instabug.flutter.example",
AndroidVersion = "13",

IosApp = Path.GetFullPath("../../../../packages/instabug_flutter/example/build/ios/iphonesimulator/Runner.app"),
IosAppId = "com.instabug.InstabugSample",
IosVersion = "17.2",
Expand All @@ -28,28 +31,5 @@ public void Dispose()
captain.RestartApp();
}

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


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

protected void ScrollUp()
{
captain.Swipe(
start: new Point(captain.Window.Size.Width / 2, 250),
end: new Point(captain.Window.Size.Width / 2, captain.Window.Size.Height - 200)
);
}
}
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.6611870-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
Loading