Skip to content

Commit 75436ce

Browse files
authored
Merge branch 'main' into feat/report-agentless-sdk
2 parents c6f7d1d + dea75aa commit 75436ce

File tree

48 files changed

+1422
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1422
-50
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,37 @@
44

55
### Features
66

7+
- Add `SentryUserFeedbackButton` Composable ([#4559](https://github.com/getsentry/sentry-java/pull/4559))
8+
- Also added `Sentry.showUserFeedbackDialog` static method
79
- Add deadlineTimeout option ([#4555](https://github.com/getsentry/sentry-java/pull/4555))
10+
- Add Ktor client integration ([#4527](https://github.com/getsentry/sentry-java/pull/4527))
11+
- To use the integration, add a dependency on `io.sentry:sentry-ktor-client`, then install the `SentryKtorClientPlugin` on your `HttpClient`,
12+
e.g.:
13+
```kotlin
14+
val client =
15+
HttpClient(Java) {
16+
install(io.sentry.ktorClient.SentryKtorClientPlugin) {
17+
captureFailedRequests = true
18+
failedRequestTargets = listOf(".*")
19+
failedRequestStatusCodes = listOf(HttpStatusCodeRange(500, 599))
20+
}
21+
}
22+
```
823

924
### Fixes
1025

1126
- Allow multiple UncaughtExceptionHandlerIntegrations to be active at the same time ([#4462](https://github.com/getsentry/sentry-java/pull/4462))
1227
- Prevent repeated scroll target determination during a single scroll gesture ([#4557](https://github.com/getsentry/sentry-java/pull/4557))
1328
- This should reduce the number of ANRs seen in `SentryGestureListener`
29+
- Do not use Sentry logging API in JUL if logs are disabled ([#4574](https://github.com/getsentry/sentry-java/pull/4574))
30+
- This was causing Sentry SDK to log warnings: "Sentry Log is disabled and this 'logger' call is a no-op."
31+
- Do not use Sentry logging API in Log4j2 if logs are disabled ([#4573](https://github.com/getsentry/sentry-java/pull/4573))
32+
- This was causing Sentry SDK to log warnings: "Sentry Log is disabled and this 'logger' call is a no-op."
33+
- SDKs send queue is no longer shutdown immediately on re-init ([#4564](https://github.com/getsentry/sentry-java/pull/4564))
34+
- This means we're no longer losing events that have been enqueued right before SDK re-init.
35+
- Reduce scope forking when using OpenTelemetry ([#4565](https://github.com/getsentry/sentry-java/pull/4565))
36+
- `Sentry.withScope` now has the correct current scope passed to the callback. Previously our OpenTelemetry integration forked scopes an additional.
37+
- Overall the SDK is now forking scopes a bit less often.
1438

1539
## 8.17.0
1640

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Sentry SDK for Java and Android
3737
| sentry-apollo-3 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo-3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo-3) | 21 |
3838
| sentry-apollo-4 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo-4/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo-4) | 21 |
3939
| sentry-kotlin-extensions | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-kotlin-extensions/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-kotlin-extensions) | 21 |
40+
| sentry-ktor-client | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-ktor-client/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-ktor-client) | 21 |
4041
| sentry-servlet | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet) | |
4142
| sentry-servlet-jakarta | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet-jakarta/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet-jakarta) | |
4243
| sentry-spring-boot | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot) |

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ apiValidation {
6969
"sentry-samples-spring-boot-jakarta-opentelemetry-noagent",
7070
"sentry-samples-spring-boot-webflux",
7171
"sentry-samples-spring-boot-webflux-jakarta",
72+
"sentry-samples-ktor-client",
7273
"sentry-uitest-android",
7374
"sentry-uitest-android-benchmark",
7475
"sentry-uitest-android-critical",

buildSrc/src/main/java/Config.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ object Config {
7878
val SENTRY_OKHTTP_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.okhttp"
7979
val SENTRY_REACTOR_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.reactor"
8080
val SENTRY_KOTLIN_EXTENSIONS_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.kotlin-extensions"
81+
val SENTRY_KTOR_CLIENT_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.ktor-client"
8182
val group = "io.sentry"
8283
val description = "SDK for sentry.io"
8384
val versionNameProp = "versionName"

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jackson = "2.18.3"
1313
jetbrainsCompose = "1.6.11"
1414
kotlin = "1.9.24"
1515
kotlin-compatible-version = "1.6"
16+
ktorClient = "3.0.0"
1617
logback = "1.2.9"
1718
log4j2 = "2.20.0"
1819
nopen = "1.0.1"
@@ -95,6 +96,8 @@ jetbrains-annotations = { module = "org.jetbrains:annotations", version = "23.0.
9596
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
9697
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
9798
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
99+
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktorClient" }
100+
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktorClient" }
98101
log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j2" }
99102
log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j2" }
100103
leakcanary = { module = "com.squareup.leakcanary:leakcanary-android", version = "2.14" }

sentry-android-core/api/sentry-android-core.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ public class io/sentry/android/core/SentryUserFeedbackDialog$Builder {
404404
public fun <init> (Landroid/content/Context;I)V
405405
public fun <init> (Landroid/content/Context;ILio/sentry/android/core/SentryUserFeedbackDialog$OptionsConfiguration;)V
406406
public fun <init> (Landroid/content/Context;Lio/sentry/android/core/SentryUserFeedbackDialog$OptionsConfiguration;)V
407+
public fun associatedEventId (Lio/sentry/protocol/SentryId;)Lio/sentry/android/core/SentryUserFeedbackDialog$Builder;
408+
public fun configurator (Lio/sentry/SentryFeedbackOptions$OptionsConfigurator;)Lio/sentry/android/core/SentryUserFeedbackDialog$Builder;
407409
public fun create ()Lio/sentry/android/core/SentryUserFeedbackDialog;
408410
}
409411

sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ static void installDefaultIntegrations(
389389
options.addIntegration(replay);
390390
options.setReplayController(replay);
391391
}
392+
options
393+
.getFeedbackOptions()
394+
.setDialogHandler(new SentryAndroidOptions.AndroidUserFeedbackIDialogHandler());
392395
}
393396

394397
/**

sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
package io.sentry.android.core;
22

3+
import android.app.Activity;
34
import android.app.ActivityManager;
45
import android.app.ApplicationExitInfo;
56
import io.sentry.Hint;
67
import io.sentry.IScope;
78
import io.sentry.ISpan;
89
import io.sentry.Sentry;
910
import io.sentry.SentryEvent;
11+
import io.sentry.SentryFeedbackOptions;
12+
import io.sentry.SentryLevel;
1013
import io.sentry.SentryOptions;
1114
import io.sentry.SpanStatus;
1215
import io.sentry.android.core.internal.util.RootChecker;
1316
import io.sentry.android.core.internal.util.SentryFrameMetricsCollector;
1417
import io.sentry.protocol.Mechanism;
1518
import io.sentry.protocol.SdkVersion;
19+
import io.sentry.protocol.SentryId;
1620
import org.jetbrains.annotations.ApiStatus;
1721
import org.jetbrains.annotations.NotNull;
1822
import org.jetbrains.annotations.Nullable;
@@ -609,4 +613,29 @@ public boolean isEnableAutoTraceIdGeneration() {
609613
public void setEnableAutoTraceIdGeneration(final boolean enableAutoTraceIdGeneration) {
610614
this.enableAutoTraceIdGeneration = enableAutoTraceIdGeneration;
611615
}
616+
617+
static class AndroidUserFeedbackIDialogHandler implements SentryFeedbackOptions.IDialogHandler {
618+
@Override
619+
public void showDialog(
620+
final @Nullable SentryId associatedEventId,
621+
final @Nullable SentryFeedbackOptions.OptionsConfigurator configurator) {
622+
final @Nullable Activity activity = CurrentActivityHolder.getInstance().getActivity();
623+
if (activity == null) {
624+
Sentry.getCurrentScopes()
625+
.getOptions()
626+
.getLogger()
627+
.log(
628+
SentryLevel.ERROR,
629+
"Cannot show user feedback dialog, no activity is available. "
630+
+ "Make sure to call SentryAndroid.init() in your Application.onCreate() method.");
631+
return;
632+
}
633+
634+
new SentryUserFeedbackDialog.Builder(activity)
635+
.associatedEventId(associatedEventId)
636+
.configurator(configurator)
637+
.create()
638+
.show();
639+
}
640+
}
612641
}

sentry-android-core/src/main/java/io/sentry/android/core/SentryUserFeedbackDialog.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@ public final class SentryUserFeedbackDialog extends AlertDialog {
2525

2626
private boolean isCancelable = false;
2727
private @Nullable SentryId currentReplayId;
28+
private final @Nullable SentryId associatedEventId;
2829
private @Nullable OnDismissListener delegate;
2930

3031
private final @Nullable OptionsConfiguration configuration;
32+
private final @Nullable SentryFeedbackOptions.OptionsConfigurator configurator;
3133

3234
SentryUserFeedbackDialog(
3335
final @NotNull Context context,
3436
final int themeResId,
35-
final @Nullable OptionsConfiguration configuration) {
37+
final @Nullable SentryId associatedEventId,
38+
final @Nullable OptionsConfiguration configuration,
39+
final @Nullable SentryFeedbackOptions.OptionsConfigurator configurator) {
3640
super(context, themeResId);
41+
this.associatedEventId = associatedEventId;
3742
this.configuration = configuration;
43+
this.configurator = configurator;
3844
SentryIntegrationPackageStorage.getInstance().addIntegration("UserFeedbackWidget");
3945
}
4046

@@ -56,6 +62,9 @@ protected void onCreate(Bundle savedInstanceState) {
5662
if (configuration != null) {
5763
configuration.configure(getContext(), feedbackOptions);
5864
}
65+
if (configurator != null) {
66+
configurator.configure(feedbackOptions);
67+
}
5968
final @NotNull TextView lblTitle = findViewById(R.id.sentry_dialog_user_feedback_title);
6069
final @NotNull ImageView imgLogo = findViewById(R.id.sentry_dialog_user_feedback_logo);
6170
final @NotNull TextView lblName = findViewById(R.id.sentry_dialog_user_feedback_txt_name);
@@ -145,6 +154,9 @@ protected void onCreate(Bundle savedInstanceState) {
145154
final @NotNull Feedback feedback = new Feedback(message);
146155
feedback.setName(name);
147156
feedback.setContactEmail(email);
157+
if (associatedEventId != null) {
158+
feedback.setAssociatedEventId(associatedEventId);
159+
}
148160
if (currentReplayId != null) {
149161
feedback.setReplayId(currentReplayId);
150162
}
@@ -226,6 +238,8 @@ public void show() {
226238
public static class Builder {
227239

228240
@Nullable OptionsConfiguration configuration;
241+
@Nullable SentryFeedbackOptions.OptionsConfigurator configurator;
242+
@Nullable SentryId associatedEventId;
229243
final @NotNull Context context;
230244
final int themeResId;
231245

@@ -317,14 +331,38 @@ public Builder(
317331
this.configuration = configuration;
318332
}
319333

334+
/**
335+
* Sets the configuration for the feedback options.
336+
*
337+
* @param configurator the configuration for the feedback options, can be {@code null} to use
338+
* the global feedback options.
339+
*/
340+
public Builder configurator(
341+
final @Nullable SentryFeedbackOptions.OptionsConfigurator configurator) {
342+
this.configurator = configurator;
343+
return this;
344+
}
345+
346+
/**
347+
* Sets the associated event ID for the feedback.
348+
*
349+
* @param associatedEventId the associated event ID for the feedback, can be {@code null} to
350+
* avoid associating the feedback to an event.
351+
*/
352+
public Builder associatedEventId(final @Nullable SentryId associatedEventId) {
353+
this.associatedEventId = associatedEventId;
354+
return this;
355+
}
356+
320357
/**
321358
* Builds a new {@link SentryUserFeedbackDialog} with the specified context, theme, and
322359
* configuration.
323360
*
324361
* @return a new instance of {@link SentryUserFeedbackDialog}
325362
*/
326363
public SentryUserFeedbackDialog create() {
327-
return new SentryUserFeedbackDialog(context, themeResId, configuration);
364+
return new SentryUserFeedbackDialog(
365+
context, themeResId, associatedEventId, configuration, configurator);
328366
}
329367
}
330368

sentry-android-core/src/main/res/drawable/sentry_user_feedback_button_logo_24.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- Taken from https://cs.android.com/android-studio/platform/tools/adt/idea/+/mirror-goog-studio-main:android/resources/images/material/icons/materialicons/campaign/baseline_campaign_24.xml -->
12
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="?android:attr/colorForeground" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
23

34
<path android:fillColor="?android:attr/colorForeground" android:pathData="M18,11v2h4v-2h-4zM16,17.61c0.96,0.71 2.21,1.65 3.2,2.39 0.4,-0.53 0.8,-1.07 1.2,-1.6 -0.99,-0.74 -2.24,-1.68 -3.2,-2.4 -0.4,0.54 -0.8,1.08 -1.2,1.61zM20.4,5.6c-0.4,-0.53 -0.8,-1.07 -1.2,-1.6 -0.99,0.74 -2.24,1.68 -3.2,2.4 0.4,0.53 0.8,1.07 1.2,1.6 0.96,-0.72 2.21,-1.65 3.2,-2.4zM4,9c-1.1,0 -2,0.9 -2,2v2c0,1.1 0.9,2 2,2h1v4h2v-4h1l5,3L13,6L8,9L4,9zM15.5,12c0,-1.33 -0.58,-2.53 -1.5,-3.35v6.69c0.92,-0.81 1.5,-2.01 1.5,-3.34z"/>

0 commit comments

Comments
 (0)