Class TrackerConfiguration.TrackerConfigurationBuilder

java.lang.Object
org.matomo.java.tracking.TrackerConfiguration.TrackerConfigurationBuilder
Enclosing class:
TrackerConfiguration

public static class TrackerConfiguration.TrackerConfigurationBuilder extends Object
  • Method Details

    • apiEndpoint

      public TrackerConfiguration.TrackerConfigurationBuilder apiEndpoint(URI apiEndpoint)
      The Matomo Tracking HTTP API endpoint, for example https://your-matomo-domain.example/matomo.php
      Returns:
      this.
    • defaultSiteId

      public TrackerConfiguration.TrackerConfigurationBuilder defaultSiteId(Integer defaultSiteId)
      The default ID of the website that will be used if not specified explicitly.
      Returns:
      this.
    • defaultAuthToken

      public TrackerConfiguration.TrackerConfigurationBuilder defaultAuthToken(String defaultAuthToken)
      The authorization token (parameter token_auth) to use if not specified explicitly.
      Returns:
      this.
    • enabled

      public TrackerConfiguration.TrackerConfigurationBuilder enabled(boolean enabled)
      Allows to stop the tracker to send requests to the Matomo endpoint.
      Returns:
      this.
    • connectTimeout

      public TrackerConfiguration.TrackerConfigurationBuilder connectTimeout(Duration connectTimeout)
      The timeout until a connection is established.

      A timeout value of zero is interpreted as an infinite timeout. A `null` value is interpreted as undefined (system default if applicable).

      Default: 5 seconds

      Returns:
      this.
    • socketTimeout

      public TrackerConfiguration.TrackerConfigurationBuilder socketTimeout(Duration socketTimeout)
      The socket timeout (SO_TIMEOUT), which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets.

      A timeout value of zero is interpreted as an infinite timeout. A `null value is interpreted as undefined (system default if applicable).

      Default: 5 seconds

      Returns:
      this.
    • proxyHost

      public TrackerConfiguration.TrackerConfigurationBuilder proxyHost(@Nullable String proxyHost)
      The hostname or IP address of an optional HTTP proxy. proxyPort must be configured as well
      Returns:
      this.
    • proxyPort

      public TrackerConfiguration.TrackerConfigurationBuilder proxyPort(int proxyPort)
      The port of an HTTP proxy. proxyHost must be configured as well.
      Returns:
      this.
    • proxyUsername

      public TrackerConfiguration.TrackerConfigurationBuilder proxyUsername(@Nullable String proxyUsername)
      If the HTTP proxy requires a username for basic authentication, it can be configured here. Proxy host, port and password must also be set.
      Returns:
      this.
    • proxyPassword

      public TrackerConfiguration.TrackerConfigurationBuilder proxyPassword(@Nullable String proxyPassword)
      The corresponding password for the basic auth proxy user. The proxy host, port and username must be set as well.
      Returns:
      this.
    • userAgent

      A custom user agent to be set. Defaults to "MatomoJavaClient"
      Returns:
      this.
    • logFailedTracking

      public TrackerConfiguration.TrackerConfigurationBuilder logFailedTracking(boolean logFailedTracking)
      Logs if the Matomo Tracking API endpoint responds with an erroneous HTTP code. Defaults to false.
      Returns:
      this.
    • disableSslCertValidation

      public TrackerConfiguration.TrackerConfigurationBuilder disableSslCertValidation(boolean disableSslCertValidation)
      Disables SSL certificate validation. This is useful for testing with self-signed certificates. Do not use in production environments. Defaults to false.

      Attention: This slows down performance

      Returns:
      this.
      See Also:
      • disableSslHostVerification
    • disableSslHostVerification

      public TrackerConfiguration.TrackerConfigurationBuilder disableSslHostVerification(boolean disableSslHostVerification)
      Disables SSL host verification. This is useful for testing with self-signed certificates. Do not use in production environments. Defaults to false.

      If you use the Java 11 of the Matomo Java Tracker, this setting is ignored. Instead, you have to set the system property jdk.internal.httpclient.disableHostnameVerification as described in the Module java.net.http.

      Returns:
      this.
      See Also:
      • disableSslCertValidation
    • threadPoolSize

      public TrackerConfiguration.TrackerConfigurationBuilder threadPoolSize(int threadPoolSize)
      The thread pool size for the async sender. Defaults to 2.

      Attention: If you use this library in a web application, make sure that this thread pool does not exceed the thread pool of the web application. Otherwise, you might run into problems.

      Returns:
      this.
    • build

      public TrackerConfiguration build()
    • toString

      public String toString()
      Overrides:
      toString in class Object