@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return PropertyUtils.getProperty(event.getProfile(), "properties." + valueAsString); } });
@Override public int execute(Action action, Event event) { String eventType = (String) action.getParameterValues().get("eventType"); @SuppressWarnings("unchecked") Map<String, Object> eventProperties = (Map<String, Object>) action.getParameterValues().get("eventProperties"); Item target = (Item) action.getParameterValues().get("eventTarget"); // String type = (String) target.get("type"); // Item targetItem = new CustomItem(); // BeanUtils.populate(targetItem, target); Event subEvent = new Event(eventType, event.getSession(), event.getProfile(), event.getScope(), event, target, event.getTimeStamp()); subEvent.setProfileId(event.getProfileId()); subEvent.getAttributes().putAll(event.getAttributes()); subEvent.getProperties().putAll(eventProperties); return eventService.send(subEvent); } }
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return PropertyUtils.getProperty(event.getProfile(), "properties." + valueAsString); } });
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return event.getProfile().getProperty(valueAsString); } });
@Override public int execute(Action action, Event event) { sfdcService.createOrUpdateLead(event.getProfile()); return EventService.NO_CHANGE; } }
@Override public int execute(Action action, Event event) { boolean profileUpdated = sfdcService.updateProfileFromLead(event.getProfile()); if (profileUpdated) return EventService.PROFILE_UPDATED; return EventService.NO_CHANGE; } }
@Override public int execute(Action action, Event event) { sfdcService.createOrUpdateLead(event.getProfile()); return EventService.NO_CHANGE; } }
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return event.getProfile().getProperty(valueAsString); } });
@Override public int execute(Action action, Event event) { boolean profileUpdated = sfdcService.updateProfileFromLead(event.getProfile()); if (profileUpdated) return EventService.PROFILE_UPDATED; return EventService.NO_CHANGE; } }
@Override public int execute(Action action, Event event) { MailChimpResult result = mailChimpService.addToMCList(event.getProfile(), action); switch (result) { case UPDATED: logger.info("The visitor has been successfully added in MailChimp list and subscribed"); break; case NO_CHANGE: logger.info("The visitor is already in the MailChimp list and subscribed"); break; default: break; } return EventService.NO_CHANGE; } }
@Override public int execute(Action action, Event event) { MailChimpResult result = mailChimpService.removeFromMCList(event.getProfile(), action); switch (result) { case REMOVED: logger.info("The visitor has been successfully removed from MailChimp list"); break; case NO_CHANGE: logger.info("Visitor was not part of the list"); break; default: break; } return EventService.NO_CHANGE; } }
@Override public int execute(Action action, Event event) { boolean updated = false; if (event.getProfile().getProperty("birthDate") != null) { Integer y = Years.yearsBetween(new DateTime(event.getProfile().getProperty("birthDate")), new DateTime()).getYears(); if (event.getProfile().getProperty("age") == null || event.getProfile().getProperty("age") != y) { updated = true; event.getProfile().setProperty("age", y); } } return updated ? EventService.PROFILE_UPDATED : EventService.NO_CHANGE; } }
@Override public int execute(Action action, Event event) { MailChimpResult result = mailChimpService.unsubscribeFromMCList(event.getProfile(), action); switch (result) { case UPDATED: logger.info("The visitor has been successfully unsubscribed from MailChimp list"); break; case NO_CHANGE: logger.info("Visitor is already unsubscribed"); break; case REMOVED: logger.info("Visitor was not part of the list"); break; default: break; } return EventService.NO_CHANGE; } }
public int execute(Action action, Event event) { String eventPropertyName = (String) action.getParameterValues().get("eventPropertyName"); String profilePropertyName = (String) action.getParameterValues().get("profilePropertyName"); if (event.getProfile().getProperty(profilePropertyName) == null || !event.getProfile().getProperty(profilePropertyName).equals(event.getProperty(eventPropertyName))) { event.getProfile().setProperty(profilePropertyName, event.getProperty(eventPropertyName)); return EventService.PROFILE_UPDATED; } return EventService.NO_CHANGE; } }
@Override public int execute(Action action, Event event) { if (event.getProfile().isAnonymousProfile()) { return EventService.NO_CHANGE; } boolean updated = false; SegmentsAndScores segmentsAndScoringForProfile = segmentService.getSegmentsAndScoresForProfile(event.getProfile()); Set<String> segments = segmentsAndScoringForProfile.getSegments(); if (!segments.equals(event.getProfile().getSegments())) { event.getProfile().setSegments(segments); updated = true; } Map<String, Integer> scores = segmentsAndScoringForProfile.getScores(); if (!scores.equals(event.getProfile().getScores())) { event.getProfile().setScores(scores); updated = true; } return updated ? EventService.PROFILE_UPDATED : EventService.NO_CHANGE; } }
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); if (!mvelExpressions.containsKey(valueAsString)) { ParserConfiguration parserConfiguration = new ParserConfiguration(); parserConfiguration.setClassLoader(getClass().getClassLoader()); mvelExpressions.put(valueAsString, MVEL.compileExpression(valueAsString, new ParserContext(parserConfiguration))); } Map<String, Object> ctx = new HashMap<>(); ctx.put("event", event); ctx.put("session", event.getSession()); ctx.put("profile", event.getProfile()); return MVEL.executeExpression(mvelExpressions.get(valueAsString), ctx); } finally { Thread.currentThread().setContextClassLoader(tccl); } } });
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); if (!mvelExpressions.containsKey(valueAsString)) { ParserConfiguration parserConfiguration = new ParserConfiguration(); parserConfiguration.setClassLoader(getClass().getClassLoader()); mvelExpressions.put(valueAsString, MVEL.compileExpression(valueAsString, new ParserContext(parserConfiguration))); } Map<String, Object> ctx = new HashMap<>(); ctx.put("event", event); ctx.put("session", event.getSession()); ctx.put("profile", event.getProfile()); return MVEL.executeExpression(mvelExpressions.get(valueAsString), ctx); } finally { Thread.currentThread().setContextClassLoader(tccl); } } });
@Override public int execute(Action action, Event event) { Profile profile = event.getProfile(); boolean isProfileUpdated = false; ISO8601DateFormat dateFormat = new ISO8601DateFormat(); Map consentMap = (Map) event.getProperties().get(CONSENT_PROPERTY_NAME); if (consentMap != null) { if (consentMap.containsKey("typeIdentifier") && consentMap.containsKey("status")) { Consent consent = null; try { consent = new Consent(consentMap, dateFormat); isProfileUpdated = profile.setConsent(consent); } catch (ParseException e) { logger.error("Error parsing date format", e); } } else { logger.warn("Event properties for modifyConsent is missing typeIdentifier and grant properties. We will ignore this event."); } } return isProfileUpdated ? EventService.PROFILE_UPDATED : EventService.NO_CHANGE; } }
public int onEvent(Event event) { Set<Rule> rules = getMatchingRules(event); int changes = EventService.NO_CHANGE; for (Rule rule : rules) { logger.debug("Fired rule " + rule.getMetadata().getId() + " for " + event.getEventType() + " - " + event.getItemId()); long actionsStartTime = System.currentTimeMillis(); for (Action action : rule.getActions()) { changes |= actionExecutorDispatcher.execute(action, event); } long totalActionsTime = System.currentTimeMillis() - actionsStartTime; Event ruleFired = new Event("ruleFired", event.getSession(), event.getProfile(), event.getScope(), event, rule, event.getTimeStamp()); ruleFired.getAttributes().putAll(event.getAttributes()); ruleFired.setPersistent(false); changes |= eventService.send(ruleFired); RuleStatistics ruleStatistics = getLocalRuleStatistics(rule); ruleStatistics.setLocalExecutionCount(ruleStatistics.getLocalExecutionCount()+1); ruleStatistics.setLocalActionsTime(ruleStatistics.getLocalActionsTime() + totalActionsTime); this.allRuleStatistics.put(rule.getItemId(), ruleStatistics); } return changes; }
public int onEvent(Event event) { Set<Rule> rules = getMatchingRules(event); int changes = EventService.NO_CHANGE; for (Rule rule : rules) { logger.debug("Fired rule " + rule.getMetadata().getId() + " for " + event.getEventType() + " - " + event.getItemId()); fireExecuteActions(rule, event); long actionsStartTime = System.currentTimeMillis(); for (Action action : rule.getActions()) { changes |= actionExecutorDispatcher.execute(action, event); } long totalActionsTime = System.currentTimeMillis() - actionsStartTime; Event ruleFired = new Event("ruleFired", event.getSession(), event.getProfile(), event.getScope(), event, rule, event.getTimeStamp()); ruleFired.getAttributes().putAll(event.getAttributes()); ruleFired.setPersistent(false); changes |= eventService.send(ruleFired); RuleStatistics ruleStatistics = getLocalRuleStatistics(rule); ruleStatistics.setLocalExecutionCount(ruleStatistics.getLocalExecutionCount()+1); ruleStatistics.setLocalActionsTime(ruleStatistics.getLocalActionsTime() + totalActionsTime); this.allRuleStatistics.put(rule.getItemId(), ruleStatistics); } return changes; }