Skip to content

Commit

Permalink
BXC-4356 update to matomo tracker version 3 (#1655)
Browse files Browse the repository at this point in the history
Co-authored-by: Sharon Luong <[email protected]>
  • Loading branch information
sharonluong and Sharon Luong authored Jan 23, 2024
1 parent 8d0ea58 commit a3ebe0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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

0 comments on commit a3ebe0b

Please sign in to comment.