com.vaadin.flow.server.dau.
Class DAUUtils
A utility class for various daily active users collecting methods.
For internal use only. May be renamed or removed in a future release.
Since:
24.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Record to hold the DAU enforcement check result with the messages and the action to be run at the end of the request.
static enum
A helper to mark operations that might be eligible for DAU tracking
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetEnforcementNotificationMessages
(VaadinRequest vaadinRequest) Gets the enforcement messages for the given request.
static Optional<jakarta.servlet.http.Cookie>
getTrackingCookie
(VaadinRequest request) Looks up for a daily active user tracking cookie in a given http request from browser.
static boolean
isDauEnabled
(VaadinService service) Checks if Daily Active User integration is enabled for the application.
static String
jsonEnforcementResponse
(VaadinRequest vaadinRequest, DauEnforcementException enforcementException) Creates a JSON message which, when sent to client as-is, will cause a critical error to be shown with the given details.
static DAUUtils.EnforcementResult
trackDAU
(VaadinService defaultVaadinService, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Track DAU and check if enforcement should apply to the given request.
-
Field Details
-
ENFORCEMENT_EXCEPTION_KEY
-
STATUS_CODE_KEY
See Also:
-
-
Method Details
-
isDauEnabled
Checks if Daily Active User integration is enabled for the application.
Parameters:
service
- the VaadinService instance.Returns:
true if DAU integration is enabled, otherwise false.
-
getTrackingCookie
Looks up for a daily active user tracking cookie in a given http request from browser.
Parameters:
request
- Vaadin requestReturns:
optional cookie object, may be missing, if users tracking is disabled or if this request is an initial request from client.
-
jsonEnforcementResponse
public static String jsonEnforcementResponse(VaadinRequest vaadinRequest, DauEnforcementException enforcementException) Creates a JSON message which, when sent to client as-is, will cause a critical error to be shown with the given details.
Parameters:
vaadinRequest
- the current Vaadin request.enforcementException
- the enforcement exception raised by license checker.Returns:
an error messages in JSON format to be sent to the client.
-
getEnforcementNotificationMessages
public static EnforcementNotificationMessages getEnforcementNotificationMessages(VaadinRequest vaadinRequest) Gets the enforcement messages for the given request.
DAUCustomizer
, if available. Otherwise, the default messages are returned.Parameters:
vaadinRequest
- The current requestReturns:
enforcement messages for the request.
See Also:
-
trackDAU
public static DAUUtils.EnforcementResult trackDAU(VaadinService defaultVaadinService, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Track DAU and check if enforcement should apply to the given request. If enforcement is needed, the enforcement messages are returned.
isDauEnabled(VaadinService)
.Parameters:
defaultVaadinService
- the default VaadinService to use if the current service is not availablerequest
- the request. Cannot be null.response
- the responseReturns:
the enforcement result. Never null.
-