Augmenting RequestLog Data
Some pieces of data cannot be easily collected by collectors, invoked from the targeting valve, without compromising the design of the site application. This data may not be needed for targeting, but is for example used in custom analysis. For that scenario, there is an alternative way to store data in a request log entry.
The essence of the matter is captured by the following piece of code:
private void storeValueAtKey(String key, Object value) { TargetingState state = TargetingStateProvider.get(); RequestLogEntry entry = state.getRequestLogEntry(); Map<String, Object> data = entry.getData(); data.put(key, value); }
To prevent collisions with other pieces of code doing collection you need to make sure that the key is sufficiently unique. The object data that you put need to be POJOs that can be mapped from Java to JSON and vice versa via com.fasterxml.jackson.databind.ObjectMapper. Note that the serialized data will be written to the request log that is in turned stored in Request Relevance Data Store, thus make sure to not store large objects as this might severly impact performance and storage.