Skip to content

Commit 144bcca

Browse files
committed
added feedback as DataCategory for rate limit and client report
added SentryOptions.beforeSendFeedback implemented SentryClient.captureFeedback
1 parent 6428dfa commit 144bcca

File tree

9 files changed

+262
-66
lines changed

9 files changed

+262
-66
lines changed

sentry/api/sentry.api

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public final class io/sentry/Baggage {
3535
public fun <init> (Ljava/util/Map;Ljava/lang/String;ZZLio/sentry/ILogger;)V
3636
public fun forceSetSampleRate (Ljava/lang/String;)V
3737
public fun freeze ()V
38-
public static fun fromEvent (Lio/sentry/SentryEvent;Lio/sentry/SentryOptions;)Lio/sentry/Baggage;
38+
public static fun fromEvent (Lio/sentry/SentryBaseEvent;Ljava/lang/String;Lio/sentry/SentryOptions;)Lio/sentry/Baggage;
3939
public static fun fromHeader (Ljava/lang/String;)Lio/sentry/Baggage;
4040
public static fun fromHeader (Ljava/lang/String;Lio/sentry/ILogger;)Lio/sentry/Baggage;
4141
public static fun fromHeader (Ljava/lang/String;ZLio/sentry/ILogger;)Lio/sentry/Baggage;
@@ -342,6 +342,7 @@ public final class io/sentry/DataCategory : java/lang/Enum {
342342
public static final field Attachment Lio/sentry/DataCategory;
343343
public static final field Default Lio/sentry/DataCategory;
344344
public static final field Error Lio/sentry/DataCategory;
345+
public static final field Feedback Lio/sentry/DataCategory;
345346
public static final field Monitor Lio/sentry/DataCategory;
346347
public static final field Profile Lio/sentry/DataCategory;
347348
public static final field Replay Lio/sentry/DataCategory;
@@ -958,7 +959,7 @@ public abstract interface class io/sentry/ISentryClient {
958959
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
959960
public fun captureException (Ljava/lang/Throwable;Lio/sentry/IScope;)Lio/sentry/protocol/SentryId;
960961
public fun captureException (Ljava/lang/Throwable;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
961-
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/IScope;)Lio/sentry/protocol/SentryId;
962+
public abstract fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/IScope;)Lio/sentry/protocol/SentryId;
962963
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
963964
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/IScope;)Lio/sentry/protocol/SentryId;
964965
public abstract fun captureReplayEvent (Lio/sentry/SentryReplayEvent;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
@@ -2526,6 +2527,7 @@ public final class io/sentry/SentryClient : io/sentry/ISentryClient {
25262527
public fun captureCheckIn (Lio/sentry/CheckIn;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
25272528
public fun captureEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
25282529
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
2530+
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/IScope;)Lio/sentry/protocol/SentryId;
25292531
public fun captureReplayEvent (Lio/sentry/SentryReplayEvent;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
25302532
public fun captureSession (Lio/sentry/Session;Lio/sentry/Hint;)V
25312533
public fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/TraceContext;Lio/sentry/IScope;Lio/sentry/Hint;Lio/sentry/ProfilingTraceData;)Lio/sentry/protocol/SentryId;
@@ -2868,6 +2870,7 @@ public class io/sentry/SentryOptions {
28682870
public fun getBeforeBreadcrumb ()Lio/sentry/SentryOptions$BeforeBreadcrumbCallback;
28692871
public fun getBeforeEnvelopeCallback ()Lio/sentry/SentryOptions$BeforeEnvelopeCallback;
28702872
public fun getBeforeSend ()Lio/sentry/SentryOptions$BeforeSendCallback;
2873+
public fun getBeforeSendFeedback ()Lio/sentry/SentryOptions$BeforeSendCallback;
28712874
public fun getBeforeSendReplay ()Lio/sentry/SentryOptions$BeforeSendReplayCallback;
28722875
public fun getBeforeSendTransaction ()Lio/sentry/SentryOptions$BeforeSendTransactionCallback;
28732876
public fun getBundleIds ()Ljava/util/Set;
@@ -2989,6 +2992,7 @@ public class io/sentry/SentryOptions {
29892992
public fun setBeforeBreadcrumb (Lio/sentry/SentryOptions$BeforeBreadcrumbCallback;)V
29902993
public fun setBeforeEnvelopeCallback (Lio/sentry/SentryOptions$BeforeEnvelopeCallback;)V
29912994
public fun setBeforeSend (Lio/sentry/SentryOptions$BeforeSendCallback;)V
2995+
public fun setBeforeSendFeedback (Lio/sentry/SentryOptions$BeforeSendCallback;)V
29922996
public fun setBeforeSendReplay (Lio/sentry/SentryOptions$BeforeSendReplayCallback;)V
29932997
public fun setBeforeSendTransaction (Lio/sentry/SentryOptions$BeforeSendTransactionCallback;)V
29942998
public fun setCacheDirPath (Ljava/lang/String;)V

sentry/src/main/java/io/sentry/Baggage.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,16 @@ public static Baggage fromHeader(
148148
@ApiStatus.Internal
149149
@NotNull
150150
public static Baggage fromEvent(
151-
final @NotNull SentryEvent event, final @NotNull SentryOptions options) {
151+
final @NotNull SentryBaseEvent event,
152+
final @Nullable String transaction,
153+
final @NotNull SentryOptions options) {
152154
final Baggage baggage = new Baggage(options.getLogger());
153155
final SpanContext trace = event.getContexts().getTrace();
154156
baggage.setTraceId(trace != null ? trace.getTraceId().toString() : null);
155157
baggage.setPublicKey(options.retrieveParsedDsn().getPublicKey());
156158
baggage.setRelease(event.getRelease());
157159
baggage.setEnvironment(event.getEnvironment());
158-
baggage.setTransaction(event.getTransaction());
160+
baggage.setTransaction(transaction);
159161
// we don't persist sample rate
160162
baggage.setSampleRate(null);
161163
baggage.setSampled(null);

sentry/src/main/java/io/sentry/DataCategory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public enum DataCategory {
88
All("__all__"),
99
Default("default"), // same as Error
1010
Error("error"),
11+
Feedback("feedback"),
1112
Session("session"),
1213
Attachment("attachment"),
1314
Monitor("monitor"),

sentry/src/main/java/io/sentry/ISentryClient.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,8 @@ public interface ISentryClient {
8787
* @param scope An optional scope to be applied to the event.
8888
* @return The Id (SentryId object) of the event
8989
*/
90-
default @NotNull SentryId captureFeedback(
91-
@NotNull Feedback feedback, @Nullable Hint hint, @NotNull IScope scope) {
92-
SentryEvent event = new SentryEvent();
93-
event.getContexts().setFeedback(feedback);
94-
95-
if (feedback.getReplayId() == null) {
96-
final @NotNull SentryId replayId = scope.getReplayId();
97-
if (!replayId.equals(SentryId.EMPTY_ID)) {
98-
feedback.setReplayId(replayId);
99-
}
100-
}
101-
if (feedback.getUrl() == null) {
102-
feedback.setUrl(scope.getScreen());
103-
}
104-
105-
return captureEvent(event, scope, hint);
106-
}
90+
@NotNull
91+
SentryId captureFeedback(@NotNull Feedback feedback, @Nullable Hint hint, @NotNull IScope scope);
10792

10893
/**
10994
* Captures the message.

sentry/src/main/java/io/sentry/NoOpSentryClient.java

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

3+
import io.sentry.protocol.Feedback;
34
import io.sentry.protocol.SentryId;
45
import io.sentry.protocol.SentryTransaction;
56
import io.sentry.transport.RateLimiter;
@@ -37,6 +38,11 @@ public void close() {}
3738
@Override
3839
public void flush(long timeoutMillis) {}
3940

41+
@Override
42+
public @NotNull SentryId captureFeedback(@NotNull Feedback feedback, @Nullable Hint hint, @NotNull IScope scope) {
43+
return SentryId.EMPTY_ID;
44+
}
45+
4046
@Override
4147
public void captureUserFeedback(@NotNull UserFeedback userFeedback) {}
4248

0 commit comments

Comments
 (0)