unomi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Schiefer <benschie...@gmail.com>
Subject Proper usage of pastEventCondition
Date Wed, 29 Apr 2020 13:04:21 GMT
Hello, and thanks for Unomi, its awesome.

I've been wading through the unomi code for the last few days trying to
figure out how to properly use the pastEventCondition type in a segment.  I
am able to register the segment just fine and have it execute against
elastic correctly, but when the "setEventOccurenceCountAction" picks up the
Auto Generated rule to try to increment the count of this event on the
"pastEvents" map on a profile, the action fails with an error because the
eventCondition is null on this line (
https://github.com/apache/unomi/blob/ea1b788ec82b2ad8e404236e21d974a11e68429a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetEventOccurenceCountAction.java#L53
)

Here is my segment definition
```
{
  "metadata": {
    "id": "10viewstoday",
    "name": "At least 10 views in last day",
    "scope": "systemscope",
    "description": "Profile with at least 10 views in last 1 day",
    "readOnly": true,
    "enabled": true
  },
  "condition": {
    "type": "pastEventCondition",
    "parameterValues": {
      "eventCondition": {
        "type": "booleanCondition",
        "parameterValues": {
          "operator": "and",
          "subConditions": [
            {
              "type": "eventTypeCondition",
              "parameterValues": {
                "eventTypeId": "view"
              }
            },
            {
              "type": "eventPropertyCondition",
              "parameterValues": {
                "propertyName": "target.itemType",
                "propertyValue": "flow",
                "comparisonOperator": "equals"
              }
            }
          ]
        }
      },
      "numberOfDays": 1,
      "minimumEventCount": 10
    }
  }
}
```


Here is the auto generated rule for that segment
```
{
    "_index": "context",
    "_type": "rule",
    "_id": "eventTriggered47062c82c5a374d5ab2d2178b9cba16a",
    "_version": 1,
    "_score": 1,
    "_source": {
        "itemId": "eventTriggered47062c82c5a374d5ab2d2178b9cba16a",
        "itemType": "rule",
        "condition": {
            "parameterValues": {
                "eventTypeId": "view"
            },
            "type": "eventTypeCondition"
        },
        "actions": [
            {
                "parameterValues": {
                    "pastEventCondition": {
                        "parameterValues": {
                            "operator": "and",
                            "subConditions": [
                                {
                                    "parameterValues": {
                                        "eventTypeId": "view"
                                    },
                                    "type": "eventTypeCondition"
                                },
                                {
                                    "parameterValues": {
                                        "propertyName": "target.itemType",
                                        "propertyValue": "flow",
                                        "comparisonOperator": "equals"
                                    },
                                    "type": "eventPropertyCondition"
                                }
                            ],
                            "generatedPropertyKey":
"eventTriggered62e083f24cb05e41a2c046c5c4be2086"
                        },
                        "type": "booleanCondition"
                    }
                },
                "type": "setEventOccurenceCountAction"
            }
        ],
        "linkedItems": [
            "10viewstoday"
        ],
        "raiseEventOnlyOnceForProfile": false,
        "raiseEventOnlyOnceForSession": false,
        "priority": 0,
        "metadata": {
            "id": "eventTriggered47062c82c5a374d5ab2d2178b9cba16a",
            "name": "Auto generated rule for At least 10 views in last day",
            "description": "",
            "scope": "systemscope",
            "tags": [],
            "systemTags": [],
            "enabled": true,
            "missingPlugins": false,
            "hidden": true,
            "readOnly": false
        }
    }
}
```



Any help you could provide would be greatly appreciated.  I'm not sure if
i'm using the pastEventCondition improperly in my segment, or if there is a
bug when generating the rule in the segment service (
https://github.com/apache/unomi/blob/27859f99d3b33640b6e6cf62f9b878e56994039d/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java#L728
)


Thanks in advance,
Ben

Mime
View raw message