Package org.matomo.java.tracking
Class MatomoTracker
java.lang.Object
org.matomo.java.tracking.MatomoTracker
- Direct Known Subclasses:
PiwikTracker
A class that sends
MatomoRequests to a specified Matomo server.- Author:
- brettcsorba
-
Constructor Summary
ConstructorsConstructorDescriptionMatomoTracker(@NonNull String hostUrl) Creates a tracker that will sendMatomoRequests to the specified Tracking HTTP API endpoint.MatomoTracker(@NonNull String hostUrl, int timeout) Creates a tracker that will sendMatomoRequests to the specified Tracking HTTP API endpoint.MatomoTracker(@NonNull String hostUrl, String proxyHost, int proxyPort) Creates a tracker that will sendMatomoRequests to the specified Tracking HTTP API endpoint via the provided proxyMatomoTracker(@NonNull String hostUrl, String proxyHost, int proxyPort, int timeout) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.http.impl.nio.client.CloseableHttpAsyncClientGet an async HTTP client.protected org.apache.http.client.HttpClientGet a HTTP client.org.apache.http.HttpResponsesendBulkRequest(@NonNull Iterable<? extends MatomoRequest> requests) Deprecated.use sendBulkRequestAsync insteadorg.apache.http.HttpResponsesendBulkRequest(@NonNull Iterable<? extends MatomoRequest> requests, String authToken) Deprecated.use sendBulkRequestAsync insteadFuture<org.apache.http.HttpResponse>sendBulkRequestAsync(@NonNull Iterable<? extends MatomoRequest> requests) Send multiple requests in a single HTTP call.Future<org.apache.http.HttpResponse>sendBulkRequestAsync(@NonNull Iterable<? extends MatomoRequest> requests, String authToken) Send multiple requests in a single HTTP call.Future<org.apache.http.HttpResponse>sendBulkRequestAsync(@NonNull Iterable<? extends MatomoRequest> requests, String authToken, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback) Send multiple requests in a single HTTP call.Future<org.apache.http.HttpResponse>sendBulkRequestAsync(@NonNull Iterable<? extends MatomoRequest> requests, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback) Send multiple requests in a single HTTP call.org.apache.http.HttpResponsesendRequest(@NonNull MatomoRequest request) Deprecated.use sendRequestAsync insteadFuture<org.apache.http.HttpResponse>sendRequestAsync(@NonNull MatomoRequest request) Send a request.Future<org.apache.http.HttpResponse>sendRequestAsync(@NonNull MatomoRequest request, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback) Send a request.
-
Constructor Details
-
MatomoTracker
Creates a tracker that will sendMatomoRequests to the specified Tracking HTTP API endpoint.- Parameters:
hostUrl- url endpoint to send requests to. Usually in the format http://your-matomo-domain.tld/matomo.php. Must not be null
-
MatomoTracker
Creates a tracker that will sendMatomoRequests to the specified Tracking HTTP API endpoint.- Parameters:
hostUrl- url endpoint to send requests to. Usually in the format http://your-matomo-domain.tld/matomo.php.timeout- the timeout of the sent request in milliseconds
-
MatomoTracker
-
MatomoTracker
Creates a tracker that will sendMatomoRequests to the specified Tracking HTTP API endpoint via the provided proxy- Parameters:
hostUrl- url endpoint to send requests to. Usually in the format http://your-matomo-domain.tld/matomo.php.proxyHost- url endpoint for the proxyproxyPort- proxy server port number
-
-
Method Details
-
sendRequest
@Deprecated public org.apache.http.HttpResponse sendRequest(@NonNull @NonNull MatomoRequest request) Deprecated.use sendRequestAsync insteadSends a tracking request to Matomo- Parameters:
request- request to send. must not be null- Returns:
- the response from this request
-
getHttpClient
protected org.apache.http.client.HttpClient getHttpClient()Get a HTTP client. With proxy if a proxy is provided in the constructor.- Returns:
- a HTTP client
-
sendRequestAsync
public Future<org.apache.http.HttpResponse> sendRequestAsync(@NonNull @NonNull MatomoRequest request) Send a request.- Parameters:
request- request to send- Returns:
- future with response from this request
-
sendRequestAsync
public Future<org.apache.http.HttpResponse> sendRequestAsync(@NonNull @NonNull MatomoRequest request, @Nullable org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback) Send a request.- Parameters:
request- request to sendcallback- callback that gets executed when response arrives- Returns:
- future with response from this request
-
getHttpAsyncClient
protected org.apache.http.impl.nio.client.CloseableHttpAsyncClient getHttpAsyncClient()Get an async HTTP client. With proxy if a proxy is provided in the constructor.- Returns:
- an async HTTP client
-
sendBulkRequest
@Deprecated public org.apache.http.HttpResponse sendBulkRequest(@NonNull @NonNull Iterable<? extends MatomoRequest> requests) Deprecated.use sendBulkRequestAsync insteadSend multiple requests in a single HTTP call. More efficient than sending several individual requests.- Parameters:
requests- the requests to send- Returns:
- the response from these requests
-
sendBulkRequest
@Deprecated public org.apache.http.HttpResponse sendBulkRequest(@NonNull @NonNull Iterable<? extends MatomoRequest> requests, @Nullable String authToken) Deprecated.use sendBulkRequestAsync insteadSend multiple requests in a single HTTP call. More efficient than sending several individual requests. Specify the AuthToken if parameters that require an auth token is used.- Parameters:
requests- the requests to sendauthToken- specify if any of the parameters use require AuthToken- Returns:
- the response from these requests
-
sendBulkRequestAsync
public Future<org.apache.http.HttpResponse> sendBulkRequestAsync(@NonNull @NonNull Iterable<? extends MatomoRequest> requests) Send multiple requests in a single HTTP call. More efficient than sending several individual requests.- Parameters:
requests- the requests to send- Returns:
- future with response from these requests
-
sendBulkRequestAsync
public Future<org.apache.http.HttpResponse> sendBulkRequestAsync(@NonNull @NonNull Iterable<? extends MatomoRequest> requests, @Nullable String authToken, @Nullable org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback) Send multiple requests in a single HTTP call. More efficient than sending several individual requests. Specify the AuthToken if parameters that require an auth token is used.- Parameters:
requests- the requests to sendauthToken- specify if any of the parameters use require AuthTokencallback- callback that gets executed when response arrives- Returns:
- the response from these requests
-
sendBulkRequestAsync
public Future<org.apache.http.HttpResponse> sendBulkRequestAsync(@NonNull @NonNull Iterable<? extends MatomoRequest> requests, @Nullable org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback) Send multiple requests in a single HTTP call. More efficient than sending several individual requests.- Parameters:
requests- the requests to sendcallback- callback that gets executed when response arrives- Returns:
- future with response from these requests
-
sendBulkRequestAsync
public Future<org.apache.http.HttpResponse> sendBulkRequestAsync(@NonNull @NonNull Iterable<? extends MatomoRequest> requests, @Nullable String authToken) Send multiple requests in a single HTTP call. More efficient than sending several individual requests. Specify the AuthToken if parameters that require an auth token is used.- Parameters:
requests- the requests to sendauthToken- specify if any of the parameters use require AuthToken- Returns:
- the response from these requests
-