Skip to content

Release: v13.1.1 #480

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 10 commits into from
Jun 11, 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
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ commands:
steps:
- run:
name: Install XCUITest Driver
command: appium driver install xcuitest@7.14.0
command: appium driver install xcuitest@4.35.0
- when:
condition:
equal:
Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:
executor:
name: android/android-machine
resource-class: xlarge
tag: default
tag: 2024.01.1
steps:
- advanced-checkout/shallow-checkout
- setup_flutter
Expand All @@ -154,7 +154,7 @@ jobs:
executor:
name: android/android-machine
resource-class: xlarge
tag: default
tag: 2024.01.1
steps:
- advanced-checkout/shallow-checkout
- setup_captain:
Expand Down
205 changes: 140 additions & 65 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.instabug.flutter'
version '13.0.0'
version '13.1.1'

buildscript {
repositories {
Expand Down Expand Up @@ -41,7 +41,7 @@ android {
}

dependencies {
api 'com.instabug.library:instabug:13.0.0'
api 'com.instabug.library:instabug:13.1.1'

testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-inline:3.12.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package com.instabug.flutter.modules;

import android.util.Log;
import static com.instabug.crash.CrashReporting.getFingerprintObject;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.instabug.crash.CrashReporting;
import com.instabug.crash.models.IBGNonFatalException;
import com.instabug.flutter.generated.CrashReportingPigeon;
import com.instabug.flutter.util.ArgsRegistry;
import com.instabug.flutter.util.Reflection;
import com.instabug.library.Feature;

import org.json.JSONObject;

import java.lang.reflect.Method;
import java.util.Map;

import io.flutter.plugin.common.BinaryMessenger;

Expand Down Expand Up @@ -46,4 +50,24 @@ public void send(@NonNull String jsonCrash, @NonNull Boolean isHandled) {
}
}

@Override
public void sendNonFatalError(@NonNull String jsonCrash, @Nullable Map<String, String> userAttributes, @Nullable String fingerprint, @NonNull String nonFatalExceptionLevel) {
try {
Method method = Reflection.getMethod(Class.forName("com.instabug.crash.CrashReporting"), "reportException", JSONObject.class, boolean.class,
Map.class, JSONObject.class, IBGNonFatalException.Level.class);
final JSONObject exceptionObject = new JSONObject(jsonCrash);

JSONObject fingerprintObj = null;
if (fingerprint != null) {
fingerprintObj = getFingerprintObject(fingerprint);
}
IBGNonFatalException.Level nonFatalExceptionLevelType = ArgsRegistry.nonFatalExceptionLevel.get(nonFatalExceptionLevel);
if (method != null) {
method.invoke(null, exceptionObject, true, userAttributes, fingerprintObj, nonFatalExceptionLevelType);
}
} catch (Exception e) {
e.printStackTrace();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import androidx.annotation.NonNull;

import com.instabug.crash.models.IBGNonFatalException;
import com.instabug.library.LogLevel;
import com.instabug.bug.BugReporting;
import com.instabug.bug.invocation.Option;
Expand Down Expand Up @@ -56,7 +57,12 @@ public T get(Object key) {
put("ColorTheme.light", InstabugColorTheme.InstabugColorThemeLight);
put("ColorTheme.dark", InstabugColorTheme.InstabugColorThemeDark);
}};

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);
put("NonFatalExceptionLevel.info", IBGNonFatalException.Level.INFO);
}};
public static final ArgsMap<InstabugFloatingButtonEdge> floatingButtonEdges = new ArgsMap<InstabugFloatingButtonEdge>() {{
put("FloatingButtonEdge.left", InstabugFloatingButtonEdge.LEFT);
put("FloatingButtonEdge.right", InstabugFloatingButtonEdge.RIGHT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.instabug.flutter;

import static com.instabug.crash.CrashReporting.getFingerprintObject;
import static com.instabug.flutter.util.GlobalMocks.reflected;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;

import com.instabug.crash.CrashReporting;
import com.instabug.crash.models.IBGNonFatalException;
import com.instabug.flutter.generated.CrashReportingPigeon;
import com.instabug.flutter.modules.CrashReportingApi;
import com.instabug.flutter.util.ArgsRegistry;
import com.instabug.flutter.util.GlobalMocks;
import com.instabug.flutter.util.MockReflected;
import com.instabug.library.Feature;
Expand All @@ -19,6 +22,9 @@
import org.junit.Test;
import org.mockito.MockedStatic;

import java.util.HashMap;
import java.util.Map;

import io.flutter.plugin.common.BinaryMessenger;


Expand Down Expand Up @@ -77,4 +83,19 @@ public void testSend() {

reflected.verify(() -> MockReflected.crashReportException(any(JSONObject.class), eq(isHandled)));
}

@Test
public void testSendNonFatalError() {
String jsonCrash = "{}";
boolean isHandled = true;
String fingerPrint = "test";

Map<String, String> expectedUserAttributes = new HashMap<>();
String level = ArgsRegistry.nonFatalExceptionLevel.keySet().iterator().next();
JSONObject expectedFingerprint = getFingerprintObject(fingerPrint);
IBGNonFatalException.Level expectedLevel = ArgsRegistry.nonFatalExceptionLevel.get(level);
api.sendNonFatalError(jsonCrash, expectedUserAttributes, fingerPrint, level);

reflected.verify(() -> MockReflected.crashReportException(any(JSONObject.class), eq(isHandled), eq(expectedUserAttributes), eq(expectedFingerprint), eq(expectedLevel)));
}
}
12 changes: 12 additions & 0 deletions android/src/test/java/com/instabug/flutter/util/GlobalMocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
import android.net.Uri;
import android.util.Log;

import com.instabug.crash.models.IBGNonFatalException;

import org.json.JSONObject;
import org.mockito.MockedStatic;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import java.lang.reflect.Method;
import java.util.Map;

public class GlobalMocks {
public static MockedStatic<ThreadManager> threadManager;
Expand Down Expand Up @@ -75,6 +78,15 @@ public static void setUp() throws NoSuchMethodException {
JSONObject.class, boolean.class))
.thenReturn(mCrashReportException);

Method mCrashReportNonFatalException = MockReflected.class.getDeclaredMethod("crashReportException", JSONObject.class, boolean.class,
Map.class, JSONObject.class, IBGNonFatalException.Level.class);
mCrashReportNonFatalException.setAccessible(true);
reflection
.when(() -> Reflection.getMethod(Class.forName("com.instabug.crash.CrashReporting"), "reportException",
JSONObject.class, boolean.class,
Map.class, JSONObject.class, IBGNonFatalException.Level.class))
.thenReturn(mCrashReportNonFatalException);

uri = mockStatic(Uri.class);
uri.when(() -> Uri.fromFile(any())).thenReturn(mock(Uri.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

import androidx.annotation.Nullable;

import com.instabug.crash.models.IBGNonFatalException;

import org.json.JSONObject;

import java.util.Map;

/**
* Includes fake implementations of methods called by reflection.
* Used to verify whether or not a private methods was called.
Expand Down Expand Up @@ -36,4 +40,6 @@ public static void apmNetworkLog(long requestStartTime, long requestDuration, St
* 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) {}

}
9 changes: 3 additions & 6 deletions e2e/BugReportingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void ManualInvocation()
[Fact]
public void MultipleScreenshotsInReproSteps()
{
ScrollDown();
ScrollDownLittle();

captain.FindByText("Enter screen name").Tap();
captain.Type("My Screen");
Expand All @@ -136,12 +136,11 @@ public void MultipleScreenshotsInReproSteps()
[Fact]
public void ChangeReportTypes()
{
ScrollDown();
ScrollUp();
captain.FindByText("Bug", exact: true).Tap();

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

// Shows bug reporting screen
Expand All @@ -153,12 +152,10 @@ public void ChangeReportTypes()

Thread.Sleep(500);

ScrollDown();
}

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

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

// Shows both bug reporting and feature requests in prompt options
Expand Down Expand Up @@ -192,7 +189,7 @@ public void ChangeFloatingButtonEdge()
[Fact]
public void OnDismissCallbackIsCalled()
{
ScrollUp();
ScrollDownLittle();

captain.FindByText("Set On Dismiss Callback").Tap();
captain.FindByText("Invoke").Tap();
Expand Down
9 changes: 9 additions & 0 deletions e2e/Utils/CaptainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ protected void ScrollDown()
);
}


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(
Expand Down
1 change: 1 addition & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
android:label="Instabug - Flutter"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
Expand Down
Loading