Record User Information

Record user information from an HTTP request or by registering a Spring bean for custom user information capture.

Recording User Information From HTTP Request

To record the user's IP address and Principal#name as the username, set the personal information flag to true.

Copied
import org.springframework.context.annotation.Configuration;
import io.sentry.spring.EnableSentry;

@EnableSentry(dsn = "https://examplePublicKey@o0.ingest.sentry.io/0", sendDefaultPii = true)
@Configuration
class SentryConfiguration {
}

Recording Custom User Information

To record custom user information, you can register a bean that implements SentryUserProvider interface.

Copied
import org.springframework.stereotype.Component;
import io.sentry.core.protocol.User;
import io.sentry.spring.SentryUserProvider;

@Component
class CustomSentryUserProvider implements SentryUserProvider {
  public User provideUser() {
    User user = User();
    // ... set user information
    return user
  }
}
You can edit this page on GitHub.