sentry-docs icon indicating copy to clipboard operation
sentry-docs copied to clipboard

spring-boot/record-user page shoud mention that SentryUserProvider works only in web-app mode

Open nixel2007 opened this issue 2 years ago • 7 comments

Core or SDK?

Platform/SDK

Which part? Which one?

Spring boot

Description

https://docs.sentry.io/platforms/java/guides/spring-boot/record-user page states that you could use SentryUserProvider bean for User custimization. But there is no information that this bean condinionaly loads only in web application mode - the only place where SentryUserProvider is used is the SentryWebMvcConfiguration with @ConditionalOnWebApplication. I have a console spring boot app (WebEnvironment.NONE) and spend some time to figure it out :)

Suggested Solution

Add a note about ConditionalOnWebApplication/web app mode and provide a link to general doc https://docs.sentry.io/platforms/java/guides/spring-boot/enriching-events/identify-user/

nixel2007 avatar Jul 14 '22 09:07 nixel2007

Another option is to implement SentryUserProvider registration in all modes, but it is a not "docs" issue, i guess.

nixel2007 avatar Jul 14 '22 09:07 nixel2007

Routing to @getsentry/team-mobile for triage. ⏲️

getsentry-release avatar Jul 14 '22 14:07 getsentry-release

Thanks for opening the issue @nixel2007. @adinauer should be able to help you out during this week.

philipphofmann avatar Jul 18 '22 08:07 philipphofmann

hello @philipphofmann! I've already solved my task with custom bean with "conditional on bean + depends on": https://github.com/1c-syntax/bsl-language-server/blob/develop/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/SentryScopeConfigurer.java#L42-L59

Just want to highlight this problem in docs

nixel2007 avatar Jul 18 '22 09:07 nixel2007

@nixel2007 thank you for reporting this.

Another option is to implement SentryUserProvider registration in all modes, but it is a not "docs" issue, i guess.

There used to be an EventProcessor that attached the user but we changed that to a OncePerRequestFilter based approach as the static utils (SecurityContextHolder, RequestContextHolder) we use no longer contain the user when a transaction is finished (see https://github.com/getsentry/sentry-java/pull/1430#issuecomment-826753354).

We have this note on the docs (see https://docs.sentry.io/platforms/java/guides/spring-boot/record-user/):

Recording user information is available only in the Spring MVC integration.

Maybe we should move the record user page into https://docs.sentry.io/platforms/java/guides/spring-boot/enriching-events/identify-user/

adinauer avatar Jul 19 '22 12:07 adinauer

Recording user information is available only in the Spring MVC integration

This block looks like it applies to "auto" mode. Like "if you use spring mvc, you'll get this shiny thing out of the box. But you always can define custom user info provider with that interface".

My bad, I know, but it is how i've read it for the first time.

nixel2007 avatar Jul 19 '22 17:07 nixel2007

Status changed based on the above. Please let me know if it should be updated to something else!

kerenkhatiwada avatar Jul 19 '22 19:07 kerenkhatiwada

Routing to @getsentry/product-owners-sdks-web-backend for triage ⏲️

getsantry[bot] avatar Feb 27 '24 09:02 getsantry[bot]