Skip to content

Commit

Permalink
Add new logging for page views including user viewing the page
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrdoherty committed Sep 27, 2024
1 parent 7eff2de commit 190bdb9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Service/src/main/java/org/gusdb/wdk/service/PageViewLogger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.gusdb.wdk.service;

import static org.gusdb.fgputil.FormatUtil.TAB;

import org.apache.log4j.Logger;
import org.gusdb.wdk.model.user.User;

public class PageViewLogger {

private static final Logger LOG = Logger.getLogger(PageViewLogger.class);

public static void logPageView(String projectId, User user, String pagePath) {
LOG.info(
TAB + user.getUserId() +
TAB + (user.isGuest() ? "guest" : "reg") +
TAB + projectId +
TAB + pagePath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.gusdb.wdk.cache.CacheMgr;
import org.gusdb.wdk.model.WdkCacheSeeder;
import org.gusdb.wdk.model.WdkModelException;
import org.gusdb.wdk.service.PageViewLogger;
import org.json.JSONArray;
import org.json.JSONObject;

Expand Down Expand Up @@ -129,6 +130,7 @@ public StreamingOutput getMetrics() {
@Produces(MediaType.APPLICATION_JSON)
public Response registerVisit(@PathParam("clientPath") String clientPath) {
LOG.trace("Registered visit to /" + clientPath);
PageViewLogger.logPageView(getWdkModel().getProjectId(), getRequestingUser(), clientPath);
return Response.noContent().build();
}

Expand Down

0 comments on commit 190bdb9

Please sign in to comment.