Skip to content

Commit c9b4850

Browse files
committed
Added Sentry.captureFeedback API
Added Scopes.captureFeedback API Changed the MainActivity sample app to use the new API
1 parent 62e71ff commit c9b4850

File tree

15 files changed

+292
-40
lines changed

15 files changed

+292
-40
lines changed

sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/MainActivity.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import io.sentry.ISpan;
99
import io.sentry.MeasurementUnit;
1010
import io.sentry.Sentry;
11-
import io.sentry.UserFeedback;
1211
import io.sentry.instrumentation.file.SentryFileOutputStream;
13-
import io.sentry.protocol.SentryId;
12+
import io.sentry.protocol.Feedback;
1413
import io.sentry.protocol.User;
1514
import io.sentry.samples.android.compose.ComposeActivity;
1615
import io.sentry.samples.android.databinding.ActivityMainBinding;
@@ -73,13 +72,12 @@ protected void onCreate(Bundle savedInstanceState) {
7372

7473
binding.sendUserFeedback.setOnClickListener(
7574
view -> {
76-
SentryId sentryId = Sentry.captureException(new Exception("I have feedback"));
75+
Feedback feedback =
76+
new Feedback("It broke on Android. I don't know why, but this happens.");
77+
feedback.setContactEmail("john@me.com");
78+
feedback.setName("John Me");
7779

78-
UserFeedback userFeedback = new UserFeedback(sentryId);
79-
userFeedback.setComments("It broke on Android. I don't know why, but this happens.");
80-
userFeedback.setEmail("john@me.com");
81-
userFeedback.setName("John Me");
82-
Sentry.captureUserFeedback(userFeedback);
80+
Sentry.captureFeedback(feedback);
8381
});
8482

8583
binding.addAttachment.setOnClickListener(

sentry/api/sentry.api

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ public final class io/sentry/HubAdapter : io/sentry/IHub {
584584
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
585585
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
586586
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
587+
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
587588
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
588589
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
589590
public fun captureReplay (Lio/sentry/SentryReplayEvent;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
@@ -649,6 +650,7 @@ public final class io/sentry/HubScopesWrapper : io/sentry/IHub {
649650
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
650651
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
651652
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
653+
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
652654
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
653655
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
654656
public fun captureReplay (Lio/sentry/SentryReplayEvent;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
@@ -870,6 +872,9 @@ public abstract interface class io/sentry/IScopes {
870872
public abstract fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
871873
public abstract fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
872874
public fun captureException (Ljava/lang/Throwable;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
875+
public fun captureFeedback (Lio/sentry/protocol/Feedback;)Lio/sentry/protocol/SentryId;
876+
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
877+
public abstract fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
873878
public fun captureMessage (Ljava/lang/String;)Lio/sentry/protocol/SentryId;
874879
public fun captureMessage (Ljava/lang/String;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
875880
public abstract fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
@@ -951,6 +956,7 @@ public abstract interface class io/sentry/ISentryClient {
951956
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
952957
public fun captureException (Ljava/lang/Throwable;Lio/sentry/IScope;)Lio/sentry/protocol/SentryId;
953958
public fun captureException (Ljava/lang/Throwable;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
959+
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/IScope;)Lio/sentry/protocol/SentryId;
954960
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
955961
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/IScope;)Lio/sentry/protocol/SentryId;
956962
public abstract fun captureReplayEvent (Lio/sentry/SentryReplayEvent;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
@@ -1396,6 +1402,7 @@ public final class io/sentry/NoOpHub : io/sentry/IHub {
13961402
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
13971403
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
13981404
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
1405+
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
13991406
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
14001407
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
14011408
public fun captureReplay (Lio/sentry/SentryReplayEvent;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
@@ -1555,6 +1562,7 @@ public final class io/sentry/NoOpScopes : io/sentry/IScopes {
15551562
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
15561563
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
15571564
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
1565+
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
15581566
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
15591567
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
15601568
public fun captureReplay (Lio/sentry/SentryReplayEvent;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
@@ -2158,6 +2166,7 @@ public final class io/sentry/Scopes : io/sentry/IScopes {
21582166
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
21592167
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
21602168
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
2169+
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
21612170
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
21622171
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
21632172
public fun captureReplay (Lio/sentry/SentryReplayEvent;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
@@ -2222,6 +2231,7 @@ public final class io/sentry/ScopesAdapter : io/sentry/IScopes {
22222231
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
22232232
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
22242233
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
2234+
public fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
22252235
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
22262236
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
22272237
public fun captureReplay (Lio/sentry/SentryReplayEvent;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
@@ -2328,6 +2338,9 @@ public final class io/sentry/Sentry {
23282338
public static fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
23292339
public static fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
23302340
public static fun captureException (Ljava/lang/Throwable;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
2341+
public static fun captureFeedback (Lio/sentry/protocol/Feedback;)Lio/sentry/protocol/SentryId;
2342+
public static fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
2343+
public static fun captureFeedback (Lio/sentry/protocol/Feedback;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
23312344
public static fun captureMessage (Ljava/lang/String;)Lio/sentry/protocol/SentryId;
23322345
public static fun captureMessage (Ljava/lang/String;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
23332346
public static fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
@@ -4490,6 +4503,7 @@ public class io/sentry/protocol/Contexts : io/sentry/JsonSerializable {
44904503
public fun getApp ()Lio/sentry/protocol/App;
44914504
public fun getBrowser ()Lio/sentry/protocol/Browser;
44924505
public fun getDevice ()Lio/sentry/protocol/Device;
4506+
public fun getFeedback ()Lio/sentry/protocol/Feedback;
44934507
public fun getGpu ()Lio/sentry/protocol/Gpu;
44944508
public fun getOperatingSystem ()Lio/sentry/protocol/OperatingSystem;
44954509
public fun getResponse ()Lio/sentry/protocol/Response;
@@ -4509,6 +4523,7 @@ public class io/sentry/protocol/Contexts : io/sentry/JsonSerializable {
45094523
public fun setApp (Lio/sentry/protocol/App;)V
45104524
public fun setBrowser (Lio/sentry/protocol/Browser;)V
45114525
public fun setDevice (Lio/sentry/protocol/Device;)V
4526+
public fun setFeedback (Lio/sentry/protocol/Feedback;)V
45124527
public fun setGpu (Lio/sentry/protocol/Gpu;)V
45134528
public fun setOperatingSystem (Lio/sentry/protocol/OperatingSystem;)V
45144529
public fun setResponse (Lio/sentry/protocol/Response;)V
@@ -4728,6 +4743,43 @@ public final class io/sentry/protocol/Device$JsonKeys {
47284743
public fun <init> ()V
47294744
}
47304745

4746+
public final class io/sentry/protocol/Feedback : io/sentry/JsonSerializable, io/sentry/JsonUnknown {
4747+
public static final field TYPE Ljava/lang/String;
4748+
public fun <init> (Lio/sentry/protocol/Feedback;)V
4749+
public fun <init> (Ljava/lang/String;)V
4750+
public fun getAssociatedEventId ()Lio/sentry/protocol/SentryId;
4751+
public fun getContactEmail ()Ljava/lang/String;
4752+
public fun getMessage ()Ljava/lang/String;
4753+
public fun getName ()Ljava/lang/String;
4754+
public fun getReplayId ()Lio/sentry/protocol/SentryId;
4755+
public fun getUnknown ()Ljava/util/Map;
4756+
public fun getUrl ()Ljava/lang/String;
4757+
public fun serialize (Lio/sentry/ObjectWriter;Lio/sentry/ILogger;)V
4758+
public fun setAssociatedEventId (Lio/sentry/protocol/SentryId;)V
4759+
public fun setContactEmail (Ljava/lang/String;)V
4760+
public fun setMessage (Ljava/lang/String;)V
4761+
public fun setName (Ljava/lang/String;)V
4762+
public fun setReplayId (Lio/sentry/protocol/SentryId;)V
4763+
public fun setUnknown (Ljava/util/Map;)V
4764+
public fun setUrl (Ljava/lang/String;)V
4765+
}
4766+
4767+
public final class io/sentry/protocol/Feedback$Deserializer : io/sentry/JsonDeserializer {
4768+
public fun <init> ()V
4769+
public fun deserialize (Lio/sentry/ObjectReader;Lio/sentry/ILogger;)Lio/sentry/protocol/Feedback;
4770+
public synthetic fun deserialize (Lio/sentry/ObjectReader;Lio/sentry/ILogger;)Ljava/lang/Object;
4771+
}
4772+
4773+
public final class io/sentry/protocol/Feedback$JsonKeys {
4774+
public static final field ASSOCIATED_EVENT_ID Ljava/lang/String;
4775+
public static final field CONTACT_EMAIL Ljava/lang/String;
4776+
public static final field MESSAGE Ljava/lang/String;
4777+
public static final field NAME Ljava/lang/String;
4778+
public static final field REPLAY_ID Ljava/lang/String;
4779+
public static final field URL Ljava/lang/String;
4780+
public fun <init> ()V
4781+
}
4782+
47314783
public final class io/sentry/protocol/Geo : io/sentry/JsonSerializable, io/sentry/JsonUnknown {
47324784
public fun <init> ()V
47334785
public fun <init> (Lio/sentry/protocol/Geo;)V

sentry/src/main/java/io/sentry/HubAdapter.java

Lines changed: 7 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.protocol.User;
@@ -50,6 +51,12 @@ public boolean isEnabled() {
5051
return Sentry.captureMessage(message, level, callback);
5152
}
5253

54+
@Override
55+
public @NotNull SentryId captureFeedback(
56+
@NotNull Feedback feedback, @Nullable Hint hint, @Nullable ScopeCallback callback) {
57+
return Sentry.captureFeedback(feedback, hint, callback);
58+
}
59+
5360
@ApiStatus.Internal
5461
@Override
5562
public @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) {

sentry/src/main/java/io/sentry/HubScopesWrapper.java

Lines changed: 7 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.protocol.User;
@@ -46,6 +47,12 @@ public boolean isEnabled() {
4647
return scopes.captureMessage(message, level, callback);
4748
}
4849

50+
@Override
51+
public @NotNull SentryId captureFeedback(
52+
@NotNull Feedback feedback, @Nullable Hint hint, @Nullable ScopeCallback callback) {
53+
return scopes.captureFeedback(feedback, hint, callback);
54+
}
55+
4956
@Override
5057
public @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) {
5158
return scopes.captureEnvelope(envelope, hint);

sentry/src/main/java/io/sentry/IScopes.java

Lines changed: 37 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.protocol.User;
@@ -108,6 +109,42 @@ SentryId captureMessage(
108109
return captureMessage(message, SentryLevel.INFO, callback);
109110
}
110111

112+
/**
113+
* Captures the feedback.
114+
*
115+
* @param feedback The feedback to send.
116+
* @return The Id (SentryId object) of the event
117+
*/
118+
default @NotNull SentryId captureFeedback(final @NotNull Feedback feedback) {
119+
return captureFeedback(feedback, null);
120+
}
121+
122+
/**
123+
* Captures the feedback.
124+
*
125+
* @param feedback The feedback to send.
126+
* @param hint An optional hint to be applied to the event.
127+
* @return The Id (SentryId object) of the event
128+
*/
129+
default @NotNull SentryId captureFeedback(
130+
final @NotNull Feedback feedback, final @Nullable Hint hint) {
131+
return captureFeedback(feedback, hint, null);
132+
}
133+
134+
/**
135+
* Captures the feedback.
136+
*
137+
* @param feedback The feedback to send.
138+
* @param hint An optional hint to be applied to the event.
139+
* @param callback The callback to configure the scope for a single invocation.
140+
* @return The Id (SentryId object) of the event
141+
*/
142+
@NotNull
143+
SentryId captureFeedback(
144+
final @NotNull Feedback feedback,
145+
final @Nullable Hint hint,
146+
final @Nullable ScopeCallback callback);
147+
111148
/**
112149
* Captures an envelope.
113150
*

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

Lines changed: 17 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.Message;
45
import io.sentry.protocol.SentryId;
56
import io.sentry.protocol.SentryTransaction;
@@ -78,6 +79,22 @@ public interface ISentryClient {
7879
return captureEvent(event, null, hint);
7980
}
8081

82+
/**
83+
* Captures the feedback.
84+
*
85+
* @param feedback The feedback to send.
86+
* @param hint An optional hint to be applied to the event.
87+
* @param scope An optional scope to be applied to the event.
88+
* @return The Id (SentryId object) of the event
89+
*/
90+
default @NotNull SentryId captureFeedback(
91+
@NotNull Feedback feedback, @Nullable Hint hint, @Nullable IScope scope) {
92+
SentryEvent event = new SentryEvent();
93+
event.getContexts().setFeedback(feedback);
94+
95+
return captureEvent(event, scope, hint);
96+
}
97+
8198
/**
8299
* Captures the message.
83100
*

sentry/src/main/java/io/sentry/JsonSerializer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.sentry.protocol.DebugImage;
1010
import io.sentry.protocol.DebugMeta;
1111
import io.sentry.protocol.Device;
12+
import io.sentry.protocol.Feedback;
1213
import io.sentry.protocol.Geo;
1314
import io.sentry.protocol.Gpu;
1415
import io.sentry.protocol.MeasurementValue;
@@ -84,6 +85,7 @@ public JsonSerializer(@NotNull SentryOptions options) {
8485
deserializersByClass.put(Device.class, new Device.Deserializer());
8586
deserializersByClass.put(
8687
Device.DeviceOrientation.class, new Device.DeviceOrientation.Deserializer());
88+
deserializersByClass.put(Feedback.class, new Feedback.Deserializer());
8789
deserializersByClass.put(Gpu.class, new Gpu.Deserializer());
8890
deserializersByClass.put(MeasurementValue.class, new MeasurementValue.Deserializer());
8991
deserializersByClass.put(Mechanism.class, new Mechanism.Deserializer());

sentry/src/main/java/io/sentry/NoOpHub.java

Lines changed: 7 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.protocol.User;
@@ -53,6 +54,12 @@ public boolean isEnabled() {
5354
return SentryId.EMPTY_ID;
5455
}
5556

57+
@Override
58+
public @NotNull SentryId captureFeedback(
59+
@NotNull Feedback feedback, @Nullable Hint hint, @Nullable ScopeCallback callback) {
60+
return SentryId.EMPTY_ID;
61+
}
62+
5663
@Override
5764
public @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) {
5865
return SentryId.EMPTY_ID;

sentry/src/main/java/io/sentry/NoOpScopes.java

Lines changed: 7 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.protocol.User;
@@ -48,6 +49,12 @@ public boolean isEnabled() {
4849
return SentryId.EMPTY_ID;
4950
}
5051

52+
@Override
53+
public @NotNull SentryId captureFeedback(
54+
@NotNull Feedback feedback, @Nullable Hint hint, @Nullable ScopeCallback callback) {
55+
return SentryId.EMPTY_ID;
56+
}
57+
5158
@Override
5259
public @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) {
5360
return SentryId.EMPTY_ID;

sentry/src/main/java/io/sentry/Scopes.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.sentry.clientreport.DiscardReason;
44
import io.sentry.hints.SessionEndHint;
55
import io.sentry.hints.SessionStartHint;
6+
import io.sentry.protocol.Feedback;
67
import io.sentry.protocol.SentryId;
78
import io.sentry.protocol.SentryTransaction;
89
import io.sentry.protocol.User;
@@ -230,6 +231,37 @@ private IScope buildLocalScope(
230231
return sentryId;
231232
}
232233

234+
@Override
235+
public @NotNull SentryId captureFeedback(
236+
final @NotNull Feedback feedback,
237+
final @Nullable Hint hint,
238+
final @Nullable ScopeCallback scopeCallback) {
239+
SentryId sentryId = SentryId.EMPTY_ID;
240+
if (!isEnabled()) {
241+
getOptions()
242+
.getLogger()
243+
.log(
244+
SentryLevel.WARNING,
245+
"Instance is disabled and this 'captureFeedback' call is a no-op.");
246+
} else if (feedback.getMessage().isEmpty()) {
247+
getOptions()
248+
.getLogger()
249+
.log(SentryLevel.WARNING, "captureFeedback called with empty message.");
250+
} else {
251+
try {
252+
final IScope localScope = buildLocalScope(getCombinedScopeView(), scopeCallback);
253+
254+
sentryId = getClient().captureFeedback(feedback, hint, localScope);
255+
} catch (Throwable e) {
256+
getOptions()
257+
.getLogger()
258+
.log(SentryLevel.ERROR, "Error while capturing feedback: " + feedback.getMessage(), e);
259+
}
260+
}
261+
updateLastEventId(sentryId);
262+
return sentryId;
263+
}
264+
233265
@ApiStatus.Internal
234266
@Override
235267
public @NotNull SentryId captureEnvelope(

0 commit comments

Comments
 (0)