Skip to content

Commit

Permalink
#30411 first shot with some addition and name refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Nov 26, 2024
1 parent 7e1ea55 commit 6ba6527
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import com.dotmarketing.business.web.WebAPILocator;
import com.dotmarketing.util.PageMode;
import com.dotmarketing.util.UtilMethods;
import com.liferay.portal.model.User;
import com.liferay.util.StringPool;

import javax.servlet.http.HttpServletRequest;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
Expand Down Expand Up @@ -78,9 +81,23 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
collectorPayloadBean.put(EVENT_SOURCE, EventSource.DOT_CMS.getName());
}

setUserInfo(request, collectorPayloadBean);

return collectorPayloadBean;
}

private void setUserInfo(final HttpServletRequest request, final CollectorPayloadBean collectorPayloadBean) {

final User user = WebAPILocator.getUserWebAPI().getUser(request);
if (Objects.nonNull(user)) {

final HashMap<String, String> userObject = new HashMap<>();
userObject.put(ID, user.getUserId().toString());
userObject.put(EMAIL, user.getEmailAddress());
collectorPayloadBean.put(USER_OBJECT, userObject);
}
}

@Override
public boolean isEventCreator(){
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public interface Collector {
String DETAIL_PAGE_URL = "detail_page_url";
String IS_EXPERIMENT_PAGE = "isexperimentpage";
String IS_TARGET_PAGE = "istargetpage";


String VANITY_QUERY_STRING = "vanity_query_string";

String VANITY_URL_KEY = "vanity_url";
String FORWARD_TO = "forwardTo";

String EMAIL = "email";
String USER_OBJECT = "user";
/**
* Test if the collector should run
* @param collectorContextMap
Expand Down

0 comments on commit 6ba6527

Please sign in to comment.