Skip to content
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
### Added

- Add support for Advanced UI customization with comprehensive theming capabilities ([#599](https://github.com/Instabug/Instabug-Flutter/pull/599))
-
- Add support for App variant. ([#585](https://github.com/Instabug/Instabug-Flutter/pull/585))

### Changed

- **BREAKING** Remove deprecated APIs ([#614](https://github.com/Instabug/Instabug-Flutter/pull/614)). See migration guide for more details.


## [15.0.2](https://github.com/Instabug/Instabug-Flutter/compare/v14.3.0...15.0.2) (Jul 7, 2025)

### Added

- Add support for App variant. ([#585](https://github.com/Instabug/Instabug-Flutter/pull/585))

- Add support for xCode 16. ([#574](https://github.com/Instabug/Instabug-Flutter/pull/574))

Expand Down
74 changes: 1 addition & 73 deletions android/src/main/java/com/instabug/flutter/modules/ApmApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.instabug.apm.InternalAPM;
import com.instabug.apm.configuration.cp.APMFeature;
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
import com.instabug.flutter.generated.ApmPigeon;
Expand All @@ -26,7 +25,6 @@

public class ApmApi implements ApmPigeon.ApmHostApi {
private final String TAG = ApmApi.class.getName();
private final HashMap<String, ExecutionTrace> traces = new HashMap<>();

public static void init(BinaryMessenger messenger) {
final ApmApi api = new ApmApi();
Expand Down Expand Up @@ -98,45 +96,7 @@ public void setAutoUITraceEnabled(@NonNull Boolean isEnabled) {
*
* @deprecated see {@link #startFlow}
*/
@Override
public void startExecutionTrace(@NonNull String id, @NonNull String name, ApmPigeon.Result<String> result) {
ThreadManager.runOnBackground(
new Runnable() {
@Override
public void run() {
try {
ExecutionTrace trace = APM.startExecutionTrace(name);
if (trace != null) {
traces.put(id, trace);

ThreadManager.runOnMainThread(new Runnable() {
@Override
public void run() {
result.success(id);
}
});
} else {
ThreadManager.runOnMainThread(new Runnable() {
@Override
public void run() {
result.success(null);
}
});
}
} catch (Exception e) {
e.printStackTrace();

ThreadManager.runOnMainThread(new Runnable() {
@Override
public void run() {
result.success(null);
}
});
}
}
}
);
}


/**
* Starts an AppFlow with the specified name.
Expand Down Expand Up @@ -201,39 +161,7 @@ public void endFlow(@NonNull String name) {
}
}

/**
* Adds a new attribute to trace
*
* @param id String id of the trace.
* @param key attribute key
* @param value attribute value. Null to remove attribute
*
* @deprecated see {@link #setFlowAttribute}
*/
@Override
public void setExecutionTraceAttribute(@NonNull String id, @NonNull String key, @NonNull String value) {
try {
traces.get(id).setAttribute(key, value);
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Ends a trace
*
* @param id string id of the trace.
*
* @deprecated see {@link #endFlow}
*/
@Override
public void endExecutionTrace(@NonNull String id) {
try {
traces.get(id).end();
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Starts a UI trace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void setCommentMinimumCharacterCount(@NonNull Long limit, @Nullable List<
reportTypesArray[i] = ArgsRegistry.reportTypes.get(key);
}
}
BugReporting.setCommentMinimumCharacterCount(limit.intValue(), reportTypesArray);
BugReporting.setCommentMinimumCharacterCountForBugReportType(limit.intValue(), reportTypesArray);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ public void setWelcomeMessageMode(@NonNull String mode) {

@Override
public void setPrimaryColor(@NonNull Long color) {
Instabug.setPrimaryColor(color.intValue());
}

@Override
Expand Down Expand Up @@ -249,20 +248,7 @@ public void run() {
);
}

@Override
public void addExperiments(@NonNull List<String> experiments) {
Instabug.addExperiments(experiments);
}

@Override
public void removeExperiments(@NonNull List<String> experiments) {
Instabug.removeExperiments(experiments);
}

@Override
public void clearAllExperiments() {
Instabug.clearAllExperiments();
}

@Override
public void addFeatureFlags(@NonNull Map<String, String> featureFlags) {
Expand Down Expand Up @@ -535,7 +521,7 @@ public void setNetworkLogBodyEnabled(@NonNull Boolean isEnabled) {
public void setTheme(@NonNull Map<String, Object> themeConfig) {
try {
Log.d(TAG, "setTheme called with config: " + themeConfig.toString());

com.instabug.library.model.IBGTheme.Builder builder = new com.instabug.library.model.IBGTheme.Builder();

if (themeConfig.containsKey("primaryColor")) {
Expand Down Expand Up @@ -582,7 +568,7 @@ public void setTheme(@NonNull Map<String, Object> themeConfig) {

/**
* Retrieves a color value from the Map.
*
*
* @param map The Map object.
* @param key The key to look for.
* @return The parsed color as an integer, or black if missing or invalid.
Expand All @@ -601,7 +587,7 @@ private int getColor(Map<String, Object> map, String key) {

/**
* Retrieves a text style from the Map.
*
*
* @param map The Map object.
* @param key The key to look for.
* @return The corresponding Typeface style, or Typeface.NORMAL if missing or invalid.
Expand Down Expand Up @@ -630,7 +616,7 @@ private int getTextStyle(Map<String, Object> map, String key) {

/**
* Sets a font on the theme builder if the font configuration is present in the theme config.
*
*
* @param themeConfig The theme configuration map
* @param builder The theme builder
* @param fileKey The key for font file path
Expand Down Expand Up @@ -659,17 +645,17 @@ private void setFontIfPresent(Map<String, Object> themeConfig, com.instabug.libr

private Typeface getTypeface(Map<String, Object> map, String fileKey, String assetKey) {
String fontName = null;

if (assetKey != null && map.containsKey(assetKey) && map.get(assetKey) != null) {
fontName = (String) map.get(assetKey);
} else if (fileKey != null && map.containsKey(fileKey) && map.get(fileKey) != null) {
fontName = (String) map.get(fileKey);
}

if (fontName == null) {
return Typeface.DEFAULT;
}

try {
String assetPath = "fonts/" + fontName;
return Typeface.createFromAsset(context.getAssets(), assetPath);
Expand Down
57 changes: 0 additions & 57 deletions android/src/test/java/com/instabug/flutter/ApmApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.instabug.apm.InternalAPM;
import com.instabug.apm.configuration.cp.APMFeature;
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.flutter.generated.ApmPigeon;
import com.instabug.flutter.modules.ApmApi;
Expand Down Expand Up @@ -68,16 +67,6 @@ public void cleanUp() {
GlobalMocks.close();
}

private ExecutionTrace mockTrace(String id) {
String name = "trace-name";
ExecutionTrace mTrace = mock(ExecutionTrace.class);

mAPM.when(() -> APM.startExecutionTrace(name)).thenReturn(mTrace);

api.startExecutionTrace(id, name, makeResult());

return mTrace;
}

@Test
public void testInit() {
Expand Down Expand Up @@ -115,53 +104,7 @@ public void testSetAutoUITraceEnabled() {
mAPM.verify(() -> APM.setAutoUITraceEnabled(isEnabled));
}

@Test
public void testStartExecutionTraceWhenTraceNotNull() {
String expectedId = "trace-id";
String name = "trace-name";
ApmPigeon.Result<String> result = makeResult((String actualId) -> assertEquals(expectedId, actualId));

mAPM.when(() -> APM.startExecutionTrace(name)).thenReturn(new ExecutionTrace(name));

api.startExecutionTrace(expectedId, name, result);

mAPM.verify(() -> APM.startExecutionTrace(name));
}

@Test
public void testStartExecutionTraceWhenTraceIsNull() {
String id = "trace-id";
String name = "trace-name";
ApmPigeon.Result<String> result = makeResult(Assert::assertNull);

mAPM.when(() -> APM.startExecutionTrace(name)).thenReturn(null);

api.startExecutionTrace(id, name, result);

mAPM.verify(() -> APM.startExecutionTrace(name));
}

@Test
public void testSetExecutionTraceAttribute() {
String id = "trace-id";
String key = "is_premium";
String value = "true";
ExecutionTrace mTrace = mockTrace(id);

api.setExecutionTraceAttribute(id, key, value);

verify(mTrace).setAttribute(key, value);
}

@Test
public void testEndExecutionTrace() {
String id = "trace-id";
ExecutionTrace mTrace = mockTrace(id);

api.endExecutionTrace(id);

verify(mTrace).end();
}

@Test
public void testStartFlow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void testSetCommentMinimumCharacterCount() {

api.setCommentMinimumCharacterCount(limit, reportTypes);

mBugReporting.verify(() -> BugReporting.setCommentMinimumCharacterCount(limit.intValue(), BugReporting.ReportType.BUG, BugReporting.ReportType.QUESTION));
mBugReporting.verify(() -> BugReporting.setCommentMinimumCharacterCountForBugReportType(limit.intValue(), BugReporting.ReportType.BUG, BugReporting.ReportType.QUESTION));
}

@Test
Expand Down
35 changes: 3 additions & 32 deletions android/src/test/java/com/instabug/flutter/InstabugApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,7 @@ public void testSetWelcomeMessageMode() {

@Test
public void testSetPrimaryColor() {
Long color = 0xFF0000L;

api.setPrimaryColor(color);

mInstabug.verify(() -> Instabug.setPrimaryColor(0xFF0000));
}

@Test
public void testSetSessionProfilerEnabledGivenTrue() {
Boolean isEnabled = true;
Expand Down Expand Up @@ -352,30 +346,7 @@ public void testGetTags() {
mInstabug.verify(Instabug::getTags);
}

@Test
public void testAddExperiments() {
List<String> experiments = Arrays.asList("premium", "star");

api.addExperiments(experiments);

mInstabug.verify(() -> Instabug.addExperiments(experiments));
}

@Test
public void testRemoveExperiments() {
List<String> experiments = Arrays.asList("premium", "star");

api.removeExperiments(experiments);

mInstabug.verify(() -> Instabug.removeExperiments(experiments));
}

@Test
public void testClearAllExperiments() {
api.clearAllExperiments();

mInstabug.verify(Instabug::clearAllExperiments);
}

@Test
public void testAddFeatureFlags() {
Expand Down Expand Up @@ -688,7 +659,7 @@ public void testSetThemeWithAllProperties() {
themeConfig.put("secondaryFontAsset", "assets/fonts/CustomFont-Bold.ttf");
themeConfig.put("ctaFontAsset", "assets/fonts/CustomFont-Italic.ttf");

MockedConstruction<com.instabug.library.model.IBGTheme.Builder> mThemeBuilder =
MockedConstruction<com.instabug.library.model.IBGTheme.Builder> mThemeBuilder =
mockConstruction(com.instabug.library.model.IBGTheme.Builder.class, (mock, context) -> {
when(mock.setPrimaryColor(anyInt())).thenReturn(mock);
when(mock.setBackgroundColor(anyInt())).thenReturn(mock);
Expand All @@ -707,7 +678,7 @@ public void testSetThemeWithAllProperties() {
api.setTheme(themeConfig);

com.instabug.library.model.IBGTheme.Builder builder = mThemeBuilder.constructed().get(0);

verify(builder).setPrimaryColor(anyInt());
verify(builder).setBackgroundColor(anyInt());
verify(builder).setTitleTextColor(anyInt());
Expand All @@ -716,7 +687,7 @@ public void testSetThemeWithAllProperties() {
verify(builder).setPrimaryTextStyle(Typeface.BOLD);
verify(builder).setSecondaryTextStyle(Typeface.ITALIC);
verify(builder).setCtaTextStyle(Typeface.BOLD_ITALIC);

mInstabug.verify(() -> Instabug.setTheme(any(com.instabug.library.model.IBGTheme.class)));
}

Expand Down
Loading