Skip to content

Commit

Permalink
Merge branch 'release-candidate/3.7.8' into feature/integration-verif…
Browse files Browse the repository at this point in the history
…ication-tests
  • Loading branch information
Bartosz Litwiniuk committed Aug 2, 2023
2 parents 1c9e023 + f522114 commit 555ae9e
Show file tree
Hide file tree
Showing 17 changed files with 218 additions and 45 deletions.
49 changes: 43 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# Backtrace Android Release Notes

## Version 3.7.7

- Added a new attribute to native reports - `breadcrumbs.lastId`
- Fixed invalid `BacktraceCredentials` behavior when the user passed an invalid Backtrace URL
- Capture invalid native crash reporting handler path in the initialize method
- Replaced androidx's ContextCompat with Context when checking for self permissions and handled permissions for versions prior to Android 6.0
- Replaced deprecated BluetoothAdapter with BluetoothManager
- Added missing ACCESS_WIFI_STATE and BLUETOOTH permissions to example app and Tests
- Replaced androidx NonNull with jetbrains NotNull annotation
- Use "Unhandled Exception" error type in the unhnadled exception handler callback

## Version 3.7.6

- Maintenance: Update various components to latest versions
- Maintenance: Update gradle
- Bugfix: Fix enabling breadcrumbs when not available
- Add breadcrumb when ANR is detected

## Version 3.7.5

- Maintenance: Update various components to latest versions
- Bugfix: Managed and native reports generated by the same user now have the same `guid`
- Backtrace metrics support - now the interface doesn't require to use `BacktraceCredentials` anymore
Expand All @@ -15,27 +28,33 @@
- Bugfix: Handle corrupt or empty database records

## Version 3.7.4

- Feature: migrated to AndroidX
- Improvement: removed READ_EXTERNAL_STORAGE permission from library AndroidManifest.xml

## Version 3.7.3

- Bug: Crashpad attachment syntax changed

## Version 3.7.2

- Bug: Fix issue rolling over Breadcrumb file
- Feature: update gradle to latest
- Feature: integrate crashpad via cmake
- Improvement: Make local.properties optional
- Improvement: Cleanup build scripts for speed

## Version 3.7.1 - 14.06.2022

- Error type "crash" only on unhandled exceptions from main thread for other threads - error type will be "unhandled exception"

## Version 3.7.0 - 28.04.2022

- Added error.type attribute that shows type of the report
- Added backtrace.version attribute that shows Backtrace agent version

## Version 3.6.0 - 29.1.2022

- Added error-free metrics
- Added method to disable native crash reporting
- Fixed Crashpad initialization failure in Samsung A20
Expand All @@ -44,57 +63,69 @@
- GitHub actions CICD support

## Version 3.5.0 - 14.09.2021

- Added support for native crash reporting in NDK 16b
- Bug fixes and expanded supported NDK versions for client side unwinding

## Version 3.4.0 - 07.09.2021

- Added support for NDK 22

## Version 3.3.0 - 15.07.2021

- Added support for client side unwinding of native crashes

## Version 3.2.2 - 10.03.2021

- Hotfix for crash when user enables native integration without file attachments

## Version 3.2.1 - 09.03.2021

- Native crashes now support custom attributes
- Improved file attachment support for managed and native crashes
- Fixed file attachments bug in BacktraceDatabaseRecord

## Version 3.2.0 - 02.03.2021

- Added Breadcrumbs feature to give Backtrace users context leading up to a `BacktraceReport`
- Improved support for Proguard

## Version 3.1.0 - 29.09.2020

- Backtrace Android allows to capture native crashes from Android NDK code. To enable NDK crashes exception handler use `setupNativeIntegration` method and pass backtraceClient with credentials.

```java
database.setupNativeIntegration(backtraceClient, credentials);
```

## Version 3.0.2 - 23.01.2020

- Fixed checking internal path during filtering attachments

## Version 3.0.1 - 15.01.2020

- Fixed setting custom global attributes on BacktraceClient
- Added support for custom attributes to BacktraceExceptionHandler

## Version 3.0.0 - 03.12.2019

- Added support for `submit.backtrace.io` urls
- Moved generating a server url from BacktraceApi to BacktraceCredentials
- Refactored name of below libraries interfaces:
* IBacktraceApi -> Api
* IBacktraceClient -> Client
* IBacktraceDatabase -> Database
* IBacktraceDatabaseRecordWriter -> DatabaseRecordWriter
* IBacktraceDatabaseFileContext -> DatabaseFileContext
* IBacktraceDatabaseContext -> DatabaseContext
- IBacktraceApi -> Api
- IBacktraceClient -> Client
- IBacktraceDatabase -> Database
- IBacktraceDatabaseRecordWriter -> DatabaseRecordWriter
- IBacktraceDatabaseFileContext -> DatabaseFileContext
- IBacktraceDatabaseContext -> DatabaseContext

## Version 2.1.0 - 16.06.2019

- Added support for detecting ANR (Application Not Responding)
- Added methods and structures to detecting blocked custom threads

## Version 2.0.0 - 06.05.2019

- Removed `sendAsync` method
- Removed event `OnAfterSendEventListener`
- Moved event `OnServerResponseEventListener` to parameter of `send` method
Expand All @@ -103,20 +134,25 @@ database.setupNativeIntegration(backtraceClient, credentials);
- Removed deprecated and unused code

## Version 1.2.1 - 12.04.2019

- Added check is temperature file is empty and remove print stacktrace
- Changed attribute name `app.version_name` to `version`

## Version 1.2.0 - 07.04.2019

- `BacktraceDatabase` - offline error report storage and auto re-submission support in the event of network outage and server unavailability,

## Version 1.1.2 - 07.03.2019

- Added class name to function name in exception StackFrame
- Added exception message to annotations

## Version 1.1.1 - 26.02.2019

- Fixed exception on filter out Backtrace files from StackTraceElements when file name is null

## Version 1.1.0 - 25.02.2019

- Added support for file attachments and annotations
- Added battery level and status attributes
- Added screen brightness attribute
Expand All @@ -127,4 +163,5 @@ database.setupNativeIntegration(backtraceClient, credentials);
- Replaced spaces with underscore in all enums strings

## Version 1.0 - 27.01.2019

- First release.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
package="backtraceio.library">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application/>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static org.junit.Assert.assertNull;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

Expand All @@ -30,6 +31,7 @@
import backtraceio.library.breadcrumbs.BacktraceBreadcrumbs;
import backtraceio.library.events.OnServerResponseEventListener;
import backtraceio.library.events.RequestHandler;
import backtraceio.library.interfaces.Breadcrumbs;
import backtraceio.library.models.BacktraceData;
import backtraceio.library.models.BacktraceResult;
import backtraceio.library.models.types.BacktraceResultStatus;
Expand Down Expand Up @@ -308,6 +310,19 @@ public void onEvent(BacktraceResult backtraceResult) {
}
}

@Test
public void verifyBreadcrumbCallbackInvocation() {
backtraceClient.enableBreadcrumbs(context);
Breadcrumbs breadcrumbs = backtraceClient.database.getBreadcrumbs();

breadcrumbs.setOnSuccessfulBreadcrumbAddEventListener(breadcrumbId -> {
assertEquals(breadcrumbs.getCurrentBreadcrumbId(), breadcrumbId);
return;
});

breadcrumbs.addBreadcrumb("test");
}

public List<String> readBreadcrumbLogFile() throws IOException {
BacktraceBreadcrumbs breadcrumbs = new BacktraceBreadcrumbs(context.getFilesDir().getAbsolutePath());
File breadcrumbLogFile = new File(breadcrumbs.getBreadcrumbLogPath());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package backtraceio.library;

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

import android.net.Uri;

import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
Expand Down Expand Up @@ -76,4 +78,16 @@ public void createBacktraceCredentialsWithLegacyUriAndGetSubmissionToken() {
BacktraceCredentials backtraceCredentials = new BacktraceCredentials(Uri.parse(legacyUrl));
assertEquals(fakeToken, backtraceCredentials.getSubmissionToken());
}

@Test
public void generateEmptyTokenForInvalidSubmissionUrl() {
BacktraceCredentials backtraceCredentials = new BacktraceCredentials("https://submit.backtrace.io/");
assertNull(backtraceCredentials.getSubmissionToken());
}

@Test
public void generateEmptyTokenForInvalidLegacyUrl() {
BacktraceCredentials backtraceCredentials = new BacktraceCredentials("https://universe.sp.backtrace.io/");
assertNull(backtraceCredentials.getSubmissionToken());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,19 @@ public String getSubmissionToken() {
final int tokenLength = 64;
final String tokenQueryParam = "token=";
String submissionUrl = getSubmissionUrl().toString();
final int tokenEndIndex = submissionUrl.lastIndexOf("/");
if (submissionUrl.contains("submit.backtrace.io")) {
return submissionUrl.substring(submissionUrl.lastIndexOf("/") - tokenLength, submissionUrl.lastIndexOf("/"));
if (tokenEndIndex - tokenLength < 0) {
return null;
}
return submissionUrl.substring(tokenEndIndex - tokenLength, tokenEndIndex);
}
final int tokenQueryParamStartIndex = submissionUrl.indexOf(tokenQueryParam);
if (tokenQueryParamStartIndex == -1) {
return null;
}
final int tokenQueryParamStartIndex = submissionUrl.indexOf(tokenQueryParam) + tokenQueryParam.length();
return submissionUrl.substring(tokenQueryParamStartIndex, tokenQueryParamStartIndex + tokenLength);

final int tokenParamStartIndex = tokenQueryParamStartIndex + tokenQueryParam.length();
return submissionUrl.substring(tokenParamStartIndex, tokenParamStartIndex + tokenLength);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ public Boolean setupNativeIntegration(BacktraceBase client, BacktraceCredentials
}
// Path to Crashpad native handler
String handlerPath = _applicationContext.getApplicationInfo().nativeLibraryDir + _crashpadHandlerName;
if (!FileHelper.isFileExists(handlerPath)) {
return false;
}

// setup default native attribtues
// setup default native attributes
BacktraceAttributes crashpadAttributes = new BacktraceAttributes(_applicationContext, client.attributes);
crashpadAttributes.attributes.put(BacktraceAttributeConsts.ErrorType, BacktraceAttributeConsts.CrashAttributeType);
String[] keys = crashpadAttributes.attributes.keySet().toArray(new String[0]);
Expand Down Expand Up @@ -210,6 +213,12 @@ public Boolean setupNativeIntegration(BacktraceBase client, BacktraceCredentials
enableClientSideUnwinding,
unwindingMode
);

if (initialized && this.breadcrumbs.isEnabled()) {
this.breadcrumbs.setOnSuccessfulBreadcrumbAddEventListener(breadcrumbId -> {
this.addAttribute("breadcrumbs.lastId", Long.toString((breadcrumbId)));
});
}
return initialized;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,16 @@ private OnServerResponseEventListener getDatabaseCallback(final BacktraceDatabas
return new OnServerResponseEventListener() {
@Override
public void onEvent(BacktraceResult backtraceResult) {
if (customCallback != null) {
customCallback.onEvent(backtraceResult);
}
if (record != null) {
record.close();
}
if (backtraceResult != null && backtraceResult.status == BacktraceResultStatus.Ok) {
database.delete(record);
}

if (customCallback != null) {
customCallback.onEvent(backtraceResult);
}
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import backtraceio.library.enums.BacktraceBreadcrumbLevel;
import backtraceio.library.enums.BacktraceBreadcrumbType;
import backtraceio.library.events.OnSuccessfulBreadcrumbAddEventListener;
import backtraceio.library.interfaces.Breadcrumbs;
import backtraceio.library.logger.BacktraceLogger;
import backtraceio.library.models.json.BacktraceReport;
Expand All @@ -17,6 +18,11 @@ public class BacktraceBreadcrumbs implements Breadcrumbs {

private static final transient String LOG_TAG = BacktraceBreadcrumbs.class.getSimpleName();

/**
* Event which will be executed after storing successfully breadcurmbs
*/
private OnSuccessfulBreadcrumbAddEventListener onSuccessfulBreadcrumbAddEventListener = null;

/**
* Which breadcrumb types are enabled?
*/
Expand Down Expand Up @@ -54,6 +60,15 @@ public BacktraceBreadcrumbs(String breadcrumbLogDirectory) {
this.breadcrumbLogDirectory = breadcrumbLogDirectory;
}

/**
* Set event executed after adding a breadcrumb to the file
*
* @param eventListener object with method which will be executed
*/
public void setOnSuccessfulBreadcrumbAddEventListener(OnSuccessfulBreadcrumbAddEventListener eventListener) {
this.onSuccessfulBreadcrumbAddEventListener = eventListener;
}

private void unregisterAutomaticBreadcrumbReceivers() {
// Unregister old receivers
if (backtraceBroadcastReceiver != null) {
Expand Down Expand Up @@ -272,10 +287,15 @@ public boolean addBreadcrumb(String message, Map<String, Object> attributes, Bac
*/
@Override
public boolean addBreadcrumb(String message, Map<String, Object> attributes, BacktraceBreadcrumbType type, BacktraceBreadcrumbLevel level) {
if (this.isBreadcrumbsEnabled() && backtraceBreadcrumbsLogManager != null) {
return backtraceBreadcrumbsLogManager.addBreadcrumb(message, attributes, type, level);
if (!this.isEnabled() || backtraceBreadcrumbsLogManager == null) {
return false;
}
boolean addResult = backtraceBreadcrumbsLogManager.addBreadcrumb(message, attributes, type, level);
if (addResult && this.onSuccessfulBreadcrumbAddEventListener != null) {
this.onSuccessfulBreadcrumbAddEventListener.onSuccessfulAdd(this.getCurrentBreadcrumbId());
}
return false;

return addResult;
}

/**
Expand All @@ -285,7 +305,7 @@ public boolean addBreadcrumb(String message, Map<String, Object> attributes, Bac
*/
@Override
public void processReportBreadcrumbs(BacktraceReport backtraceReport) {
if (!this.isBreadcrumbsEnabled()) {
if (!this.isEnabled()) {
return;
}

Expand Down Expand Up @@ -325,7 +345,11 @@ private boolean addConfigurationBreadcrumb() {
BacktraceBreadcrumbLevel.INFO);
}

private boolean isBreadcrumbsEnabled() {
/**
* Determinate if Breadcrumbs are enabled.
* @return true if breadcrumbs are enabled.
*/
public boolean isEnabled() {
return enabledBreadcrumbTypes != null && !enabledBreadcrumbTypes.isEmpty();
}

Expand Down
Loading

0 comments on commit 555ae9e

Please sign in to comment.