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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
### Dependencies

- Bump JavaScript SDKs from v9.0.0 to v9.11.0 ([#872](https://github.com/getsentry/sentry-capacitor/pull/872))

- [changelog](https://github.com/getsentry/sentry-javascript/blob/9.11.0/CHANGELOG.md)
- [diff](https://github.com/getsentry/sentry-javascript/compare/9.0.0...9.11.0)
- Bump Android SDK from v7.16.0 to v8.11.1 ([#889](https://github.com/getsentry/sentry-capacitor/pull/889))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8111)
- [diff](https://github.com/getsentry/sentry-java/compare/7.16.0...8.11.1)

## 2.0.0-beta.1

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ repositories {

dependencies {
implementation project(':capacitor-android')
implementation 'io.sentry:sentry-android:7.16.0'
implementation 'io.sentry:sentry-android:8.11.1'
}
44 changes: 18 additions & 26 deletions android/src/main/java/io/sentry/capacitor/SentryCapacitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
import com.getcapacitor.annotation.CapacitorPlugin;

import io.sentry.Breadcrumb;
import io.sentry.HubAdapter;
import io.sentry.IScope;
import io.sentry.Integration;
import io.sentry.ScopesAdapter;
import io.sentry.Sentry;
import io.sentry.SentryEvent;
import io.sentry.SentryLevel;
Expand All @@ -25,7 +26,7 @@
import io.sentry.protocol.User;
import java.io.File;
import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -62,9 +63,9 @@ public void load() {

@PluginMethod
public void initNativeSdk(final PluginCall call) {
JSObject capOptions = call.getObject("options");
JSObject capOptions = call.getObject("options");

SentryAndroid.init(
SentryAndroid.init(
this.getContext(),
options -> {
SdkVersion sdkVersion = options.getSdkVersion();
Expand All @@ -74,7 +75,7 @@ public void initNativeSdk(final PluginCall call) {
sdkVersion.setName(ANDROID_SDK_NAME);
}

if (capOptions.has("debug") && capOptions.getBool("debug")) {
if (capOptions.has("debug") && capOptions.getBool("debug")) {
options.setDebug(true);
logger.setLevel(Level.INFO);
}
Expand All @@ -83,7 +84,7 @@ public void initNativeSdk(final PluginCall call) {
options.setNativeSdkName(NATIVE_SDK_NAME);
options.setSdkVersion(sdkVersion);

String dsn = capOptions.getString("dsn") != null ? capOptions.getString("dsn") : "";
String dsn = capOptions.getString("dsn") != null ? capOptions.getString("dsn") : "";
logger.info(String.format("Starting with DSN: '%s'", dsn));
options.setDsn(dsn);

Expand Down Expand Up @@ -212,9 +213,9 @@ public void crash(PluginCall call) {
@PluginMethod
public void fetchNativeRelease(PluginCall call) {
JSObject release = new JSObject();
release.put("id", this.packageInfo.packageName);
release.put("version", this.packageInfo.versionName);
release.put("build", String.valueOf(this.packageInfo.versionCode)); // Requires API 28
release.put("id", packageInfo.packageName);
release.put("version", packageInfo.versionName);
release.put("build", String.valueOf(packageInfo.versionCode)); // Requires API 28
call.resolve(release);
}

Expand All @@ -227,7 +228,7 @@ public void captureEnvelope(PluginCall call) {
bytes[i] = (byte) rawIntegers.getInt(i);
}

final String outboxPath = HubAdapter.getInstance().getOptions().getOutboxPath();
final String outboxPath = ScopesAdapter.getInstance().getOptions().getOutboxPath();

if (outboxPath == null || outboxPath.isEmpty()) {
logger.info("Error when writing envelope, no outbox path is present.");
Expand Down Expand Up @@ -259,9 +260,9 @@ public void getStringBytesLength(PluginCall call) {
String payload = call.getString("string");
try {
JSObject resp = new JSObject();
resp.put("value", payload.getBytes("UTF-8").length);
resp.put("value", payload.getBytes(StandardCharsets.UTF_8).length);
call.resolve(resp);
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
call.reject(String.valueOf(e));
}
} else {
Expand Down Expand Up @@ -300,9 +301,6 @@ public void addBreadcrumb(final PluginCall breadcrumb) {
case "debug":
breadcrumbInstance.setLevel(SentryLevel.DEBUG);
break;
case "error":
breadcrumbInstance.setLevel(SentryLevel.ERROR);
break;
default:
breadcrumbInstance.setLevel(SentryLevel.ERROR);
break;
Expand All @@ -328,9 +326,7 @@ public void addBreadcrumb(final PluginCall breadcrumb) {

@PluginMethod
public void clearBreadcrumbs(PluginCall call) {
Sentry.configureScope(scope -> {
scope.clearBreadcrumbs();
});
Sentry.configureScope(IScope::clearBreadcrumbs);
}

@PluginMethod
Expand Down Expand Up @@ -399,17 +395,13 @@ public void addPackages(SentryEvent event, SdkVersion sdk) {
SdkVersion eventSdk = event.getSdk();
if (eventSdk != null && eventSdk.getName().equals("sentry.javascript.capacitor") && sdk != null) {
Set<SentryPackage> sentryPackages = sdk.getPackageSet();
if (sentryPackages != null) {
for (SentryPackage sentryPackage : sentryPackages) {
eventSdk.addPackage(sentryPackage.getName(), sentryPackage.getVersion());
}
for (SentryPackage sentryPackage : sentryPackages) {
eventSdk.addPackage(sentryPackage.getName(), sentryPackage.getVersion());
}

Set<String> integrations = sdk.getIntegrationSet();
if (integrations != null) {
for (String integration : integrations) {
eventSdk.addIntegration(integration);
}
for (String integration : integrations) {
eventSdk.addIntegration(integration);
}

event.setSdk(eventSdk);
Expand Down
Loading