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

fix(native): Add interface for clearing a tab #582

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 4.15.x

* Fix crash when calling `NativeInterface.clearTab()` (from an integration
library)
[#582](https://github.com/bugsnag/bugsnag-android/pull/582)
* Fix abort() in native code when storing breadcrumbs with null values in
metadata
[#510](https://github.com/bugsnag/bugsnag-android/pull/510)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.bugsnag.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;

import org.junit.Test;

import java.util.Map;

public class NativeInterfaceTest {

@Test
Expand All @@ -13,4 +16,19 @@ public void getMetaData() {
assertNotSame(client.config.getMetaData().store, NativeInterface.getMetaData());
}

@Test
public void testClearTabClearsTheTab() {
// Creates a client object with the test context and no-op delivery
Client client = BugsnagTestUtils.generateClient();
NativeInterface.setClient(client);

client.addToTab("foo", "bar", "baz");
Map<String, Object> tab = client.getMetaData().getTab("foo");
assertEquals(1, tab.size());
assertEquals("baz", tab.get("bar"));

NativeInterface.clearTab("foo");
tab = client.getMetaData().getTab("foo");
assertEquals(0, tab.size());
}
}
9 changes: 9 additions & 0 deletions sdk/src/main/java/com/bugsnag/android/NativeInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ public static void setBinaryArch(@NonNull final String binaryArch) {
getClient().setBinaryArch(binaryArch);
}

/**
* Remove a tab of app-wide diagnostic information
*
* @param tab the dashboard tab to remove diagnostic data from
*/
public static void clearTab(@NonNull final String tab) {
getClient().clearTab(tab);
}

/**
* Return the client report app version
*/
Expand Down