Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: rules engine can't retrieve the right version of the lifecycle shared state #296

Closed
yangyansong-adbe opened this issue Sep 11, 2020 · 2 comments · Fixed by #299
Closed

Comments

@yangyansong-adbe
Copy link
Contributor

yangyansong-adbe commented Sep 11, 2020

When the rules engine evaluates the rule to check if the incoming event is a lifecycle response event and the lifecycle shared state contains install event key, it failed to find the right version of the lifecycle shared state. Let's see what happened inside the Eventhub:

Event Flow
E1 E2 E3 E4 ... En

Event Handling
E1: lifecycle start event => create lifecycle shared state version 1 (with install event data)
..
E4: registering lifecycle extension => create lifecycle shared state version 4 (without install event data)
..
En: response event for E1
..

Then, the rules engine gets lifecycle shared state V4 which doesn't have install event data and will not trigger expected consequence events.

Json Rule

{
      "condition": {
        "type": "group",
        "definition": {
          "logic": "and",
          "conditions": [
            {
              "type": "group",
              "definition": {
                "logic": "or",
                "conditions": [
                  {
                    "type": "group",
                    "definition": {
                      "logic": "and",
                      "conditions": [
                        {
                          "type": "matcher",
                          "definition": {
                            "key": "~type",
                            "matcher": "eq",
                            "values": [
                              "com.adobe.eventType.lifecycle"
                            ]
                          }
                        },
                        {
                          "type": "matcher",
                          "definition": {
                            "key": "~source",
                            "matcher": "eq",
                            "values": [
                              "com.adobe.eventSource.responseContent"
                            ]
                          }
                        },
                        {
                          "type": "matcher",
                          "definition": {
                            "key": "lifecyclecontextdata.launchevent",
                            "matcher": "ex",
                            "values": []
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            },
            {
              "type": "group",
              "definition": {
                "logic": "and",
                "conditions": [
                  {
                    "type": "matcher",
                    "definition": {
                      "key": "~state.com.adobe.module.lifecycle/lifecyclecontextdata.installevent",
                      "matcher": "ex",
                      "values": []
                    }
                  }
                ]
              }
            }
          ]
        }
      },
      "consequences": [
        {
          "id": "RC9a96ebad279642d49f59c6fbe2154d5e",
          "type": "url",
          "detail": {
            "url": "http://www.adobex.com"
          }
        }
      ]
    }

Console Log

Shared state is created for com.adobe.module.lifecycle with data Optional(["lifecyclecontextdata": ["devicename": x86_64, "resolution": 1242x2688, "launchevent": LaunchEvent, "appid": AEPSampleApp 1.0 (1), "hourofday": 15, "dayofweek": 5, "locale": en-US, "runmode": Application, "osversion": iOS]]) and version 4
...

Shared state is created for com.adobe.module.lifecycle with data Optional(["lifecyclecontextdata": ["osversion": iOS, "monthlyenguserevent": MonthlyEngUserEvent, "dailyenguserevent": DailyEngUserEvent, "resolution": 1242x2688, "locale": en-US, "dayofweek": 5, "hourofday": 15, "installevent": InstallEvent, "installdate": 9/10/2020, "launchevent": LaunchEvent, "launches": 1, "runmode": Application, "devicename": x86_64, "appid": AEPSampleApp 1.0 (1)]]) and version 1

@shalehaha
Copy link
Contributor

The cause of this behavior:

Lifecycle set the initial shared state in the OnRegister method using code createSharedState(data: sharedStateData as [String: Any], event: nil). When event is nil, eventhub uses the latest event number. So if eventhub have already received events before the lifecycle createSharedState call, this createSharedState will use a event number larger than 0.

@nporter-adbe
Copy link
Contributor

To solve this we are going to modify the behavior when event is nil when setting shared state. Currently, when nil is used it is versioned at the latest, instead, we will version at 0 when event is nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants