Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BXC-4356 update to matomo tracker version 3 #1655

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
<dependency>
<groupId>org.piwik.java.tracking</groupId>
<artifactId>matomo-java-tracker</artifactId>
<version>2.0</version>
<version>3.2.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package edu.unc.lib.boxc.web.common.utils;

import java.io.UnsupportedEncodingException;
import java.net.URI;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

import org.matomo.java.tracking.MatomoTracker;
import org.matomo.java.tracking.TrackerConfiguration;
import org.matomo.java.tracking.parameters.VisitorId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.matomo.java.tracking.MatomoRequest;
Expand Down Expand Up @@ -62,9 +65,9 @@ public void trackEvent(HttpServletRequest request, String action, PID pid, Acces
}

private MatomoRequest buildMatomoRequest(String url, AnalyticsUserData userData, String parentCollection, String label) throws UnsupportedEncodingException {
return MatomoRequest.builder()
return MatomoRequest.request()
.siteId(matomoSiteID)
.visitorId(userData.uid)
.visitorId(VisitorId.fromHex(userData.uid))
.actionUrl(url)
.actionName(parentCollection + " / " + MATOMO_ACTION)
.eventCategory(parentCollection)
Expand All @@ -77,7 +80,10 @@ private MatomoRequest buildMatomoRequest(String url, AnalyticsUserData userData,
}

private void sendMatomoRequest(MatomoRequest matomoRequest) {
var tracker = new MatomoTracker(matomoApiURL);
var tracker = new MatomoTracker(TrackerConfiguration
.builder()
.apiEndpoint(URI.create(matomoApiURL))
.build());

try {
tracker.sendRequestAsync(matomoRequest);
Expand Down
Loading