com.vaadin.flow.server.dau.

Class DAUUtils

java.lang.Object
com.vaadin.flow.server.dau.DAUUtils
public final class DAUUtils extends Object

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

  • Field Details

    • ENFORCEMENT_EXCEPTION_KEY

      public static final String ENFORCEMENT_EXCEPTION_KEY
    • STATUS_CODE_KEY

      public static final String STATUS_CODE_KEY

      See Also:

  • Method Details

    • isDauEnabled

      public static boolean isDauEnabled(VaadinService service)

      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

      public 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.

      Parameters:

      request - Vaadin request

      Returns:

      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.

      Enforcement messages are get from the registered DAUCustomizer, if available. Otherwise, the default messages are returned.

      Parameters:

      vaadinRequest - The current request

      Returns:

      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.

      Method checks if the current request should be considered for DAU tracking by using isDauEnabled(VaadinService).

      Parameters:

      defaultVaadinService - the default VaadinService to use if the current service is not available

      request - the request. Cannot be null.

      response - the response

      Returns:

      the enforcement result. Never null.