44import java .net .URI ;
55import java .util .HashMap ;
66import java .util .Map ;
7+ import org .jetbrains .annotations .ApiStatus ;
78import org .jetbrains .annotations .NotNull ;
9+ import org .jetbrains .annotations .Nullable ;
810
911/** Resolves {@link RequestDetails}. */
10- final class RequestDetailsResolver {
12+ @ ApiStatus .Experimental
13+ public final class RequestDetailsResolver {
1114 /** HTTP Header for the user agent. */
1215 private static final String USER_AGENT = "User-Agent" ;
1316 /** HTTP Header for the authentication to Sentry. */
1417 private static final String SENTRY_AUTH = "X-Sentry-Auth" ;
1518
16- private final @ NotNull SentryOptions options ;
19+ private final @ NotNull Dsn dsn ;
20+ private final @ Nullable String sentryClientName ;
21+
22+ public RequestDetailsResolver (
23+ final @ NotNull String dsn , final @ Nullable String sentryClientName ) {
24+ Objects .requireNonNull (dsn , "dsn is required" );
25+
26+ this .dsn = new Dsn (dsn );
27+ this .sentryClientName = sentryClientName ;
28+ }
1729
1830 public RequestDetailsResolver (final @ NotNull SentryOptions options ) {
19- this .options = Objects .requireNonNull (options , "options is required" );
31+ Objects .requireNonNull (options , "options is required" );
32+
33+ this .dsn = options .retrieveParsedDsn ();
34+ this .sentryClientName = options .getSentryClientName ();
2035 }
2136
2237 @ NotNull
23- RequestDetails resolve () {
24- final Dsn dsn = options .retrieveParsedDsn ();
38+ public RequestDetails resolve () {
2539 final URI sentryUri = dsn .getSentryUri ();
2640 final String envelopeUrl = sentryUri .resolve (sentryUri .getPath () + "/envelope/" ).toString ();
2741
@@ -33,15 +47,14 @@ RequestDetails resolve() {
3347 + SentryClient .SENTRY_PROTOCOL_VERSION
3448 + ","
3549 + "sentry_client="
36- + options . getSentryClientName ()
50+ + sentryClientName
3751 + ","
3852 + "sentry_key="
3953 + publicKey
4054 + (secretKey != null && secretKey .length () > 0 ? (",sentry_secret=" + secretKey ) : "" );
41- final String userAgent = options .getSentryClientName ();
4255
4356 final Map <String , String > headers = new HashMap <>();
44- headers .put (USER_AGENT , userAgent );
57+ headers .put (USER_AGENT , sentryClientName );
4558 headers .put (SENTRY_AUTH , authHeader );
4659
4760 return new RequestDetails (envelopeUrl , headers );
0 commit comments