Implement event history insert and insertIfNotExists consequence support #1121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements support for the new
insert
andinsertIfNotExists
consequence support in the Core RulesEngine, leveraging the existing rules condition evaluation logic to trigger these consequences.The consequence handling has been updated to handle the new
schema
consequence type, andhttps://ns.adobe.com/personalization/eventHistoryOperation
schema value.At a high level, the consequence object has three high level properties:
Determines the type of database operation to be performed on Event History by the SDK.
- Insert: Inserts a record in the Event History Database.
- Insert if not exists: Inserts a record in the Event History Database only if there is not already a matching record with a matching hash value.
Provided key-value pairs will be added to the string used to generate the event history hash.
If the value represents a token that the SDK knows how to resolve, the resolved value will be used (such as shared state values, ~timestampu, etc.).
An array of strings that designate which keys in the event will be used for generating the event history hash.
The primary logic for this new support is handled in the new
LaunchRulesEngine
processEventHistoryOperation
method:operation
exists (which could be eitherinsert
orinsertIfNotExists
, but does not strictly require these two values for future expansion)keys
are separated into two groups - event data keys and token keys: -~
(ex:~sdkver
)["~sdkver": "{%~sdkver%}"]
2 This dictionary is resolved using the
TokenFinder
used to resolve the original rules conditioncontent
key value pairs are merged in (thecontent
key value pairs' tokens were already replaced by the overall consequence resolution)keys
(that is, event data keys and token keys) andcontent
insertIfNotExists
, first check that the hash for the event does not already existeventExists
has been created in inEventHistory
to support easily checking for the hash value instead of having to extract all the key value pairs from the flattened map as is required by the existinggetEvents
API'sEventHistoryRequest
input format requirementRelated Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: