Skip to content

Commit

Permalink
fix: Add togglz to track PAPI events
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Palafox committed Apr 5, 2024
1 parent 738da00 commit a50e2b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public enum Features implements Feature {

@Label("Registration 2.1: Add affiliations on registration")
REGISTRATION_2_1,


@Label("Registration 2.0")
REGISTRATION_2_0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.orcid.core.manager.read_only.ResearcherUrlManagerReadOnly;
import org.orcid.core.manager.read_only.WorkManagerReadOnly;
import org.orcid.core.oauth.openid.OpenIDConnectKeyService;
import org.orcid.core.togglz.Features;
import org.orcid.core.utils.ContributorUtils;
import org.orcid.core.utils.OrcidRequestUtil;
import org.orcid.core.utils.SourceUtils;
Expand Down Expand Up @@ -638,10 +639,12 @@ public Response viewClient(String clientId) {

@Override
public void trackEvents(HttpServletRequest httpRequest) {
String clientId = orcidSecurityManager.getClientIdFromAPIRequest();
String ip = OrcidRequestUtil.getIpAddress(httpRequest);
if (Features.PAPI_EVENTS.isActive()) {
String clientId = orcidSecurityManager.getClientIdFromAPIRequest();
String ip = OrcidRequestUtil.getIpAddress(httpRequest);

eventManager.createPapiEvent(clientId, ip, clientId == null ? true : false);
eventManager.createPapiEvent(clientId, ip, clientId == null ? true : false);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.orcid.core.manager.v3.read_only.ResearcherUrlManagerReadOnly;
import org.orcid.core.manager.v3.read_only.WorkManagerReadOnly;
import org.orcid.core.oauth.openid.OpenIDConnectKeyService;
import org.orcid.core.togglz.Features;
import org.orcid.core.utils.OrcidRequestUtil;
import org.orcid.core.utils.v3.ContributorUtils;
import org.orcid.core.utils.v3.SourceUtils;
Expand Down Expand Up @@ -969,10 +970,12 @@ public Response viewResearchResourceSummary(String orcid, Long putCode) {

@Override
public void trackEvents(HttpServletRequest httpRequest) {
String clientId = orcidSecurityManager.getClientIdFromAPIRequest();
String ip = OrcidRequestUtil.getIpAddress(httpRequest);
if (Features.PAPI_EVENTS.isActive()) {
String clientId = orcidSecurityManager.getClientIdFromAPIRequest();
String ip = OrcidRequestUtil.getIpAddress(httpRequest);

eventManager.createPapiEvent(clientId, ip, clientId == null ? true : false);
eventManager.createPapiEvent(clientId, ip, clientId == null ? true : false);
}
}

}

0 comments on commit a50e2b1

Please sign in to comment.