Skip to content

Commit 2a3820d

Browse files
committed
Make RequestDetailsResolver public
1 parent 6f23a76 commit 2a3820d

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

sentry/api/sentry.api

+6
Original file line numberDiff line numberDiff line change
@@ -2174,6 +2174,12 @@ public final class io/sentry/RequestDetails {
21742174
public fun getUrl ()Ljava/net/URL;
21752175
}
21762176

2177+
public final class io/sentry/RequestDetailsResolver {
2178+
public fun <init> (Lio/sentry/SentryOptions;)V
2179+
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
2180+
public fun resolve ()Lio/sentry/RequestDetails;
2181+
}
2182+
21772183
public final class io/sentry/SamplingContext {
21782184
public fun <init> (Lio/sentry/TransactionContext;Lio/sentry/CustomSamplingContext;)V
21792185
public fun <init> (Lio/sentry/TransactionContext;Lio/sentry/CustomSamplingContext;Ljava/lang/Double;Ljava/util/Map;)V

sentry/src/main/java/io/sentry/RequestDetailsResolver.java

+23-8
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,40 @@
44
import java.net.URI;
55
import java.util.HashMap;
66
import java.util.Map;
7+
import org.jetbrains.annotations.ApiStatus;
8+
import org.jetbrains.annotations.ApiStatus.Internal;
79
import org.jetbrains.annotations.NotNull;
10+
import org.jetbrains.annotations.Nullable;
811

912
/** Resolves {@link RequestDetails}. */
10-
final class RequestDetailsResolver {
13+
@ApiStatus.Experimental
14+
public final class RequestDetailsResolver {
1115
/** HTTP Header for the user agent. */
1216
private static final String USER_AGENT = "User-Agent";
1317
/** HTTP Header for the authentication to Sentry. */
1418
private static final String SENTRY_AUTH = "X-Sentry-Auth";
1519

16-
private final @NotNull SentryOptions options;
20+
private final @NotNull Dsn dsn;
21+
private final @Nullable String sentryClientName;
1722

23+
public RequestDetailsResolver(
24+
final @NotNull String dsn, final @Nullable String sentryClientName) {
25+
Objects.requireNonNull(dsn, "dsn is required");
26+
27+
this.dsn = new Dsn(dsn);
28+
this.sentryClientName = sentryClientName;
29+
}
30+
31+
@ApiStatus.Internal
1832
public RequestDetailsResolver(final @NotNull SentryOptions options) {
19-
this.options = Objects.requireNonNull(options, "options is required");
33+
Objects.requireNonNull(options, "options is required");
34+
35+
this.dsn = options.retrieveParsedDsn();
36+
this.sentryClientName = options.getSentryClientName();
2037
}
2138

2239
@NotNull
23-
RequestDetails resolve() {
24-
final Dsn dsn = options.retrieveParsedDsn();
40+
public RequestDetails resolve() {
2541
final URI sentryUri = dsn.getSentryUri();
2642
final String envelopeUrl = sentryUri.resolve(sentryUri.getPath() + "/envelope/").toString();
2743

@@ -33,15 +49,14 @@ RequestDetails resolve() {
3349
+ SentryClient.SENTRY_PROTOCOL_VERSION
3450
+ ","
3551
+ "sentry_client="
36-
+ options.getSentryClientName()
52+
+ sentryClientName
3753
+ ","
3854
+ "sentry_key="
3955
+ publicKey
4056
+ (secretKey != null && secretKey.length() > 0 ? (",sentry_secret=" + secretKey) : "");
41-
final String userAgent = options.getSentryClientName();
4257

4358
final Map<String, String> headers = new HashMap<>();
44-
headers.put(USER_AGENT, userAgent);
59+
headers.put(USER_AGENT, sentryClientName);
4560
headers.put(SENTRY_AUTH, authHeader);
4661

4762
return new RequestDetails(envelopeUrl, headers);

0 commit comments

Comments
 (0)