Skip to content

Comments

Use new event history format needed for AJO disqualification feature.#31

Merged
dompuiu merged 5 commits intomainfrom
use_new_event_history_format
Apr 7, 2025
Merged

Use new event history format needed for AJO disqualification feature.#31
dompuiu merged 5 commits intomainfrom
use_new_event_history_format

Conversation

@dompuiu
Copy link
Member

@dompuiu dompuiu commented Apr 4, 2025

Description

The event history in Web SDK was not able to handle all scenarios for the AJO disqualification feature. Previously, the event history was having the format:

{
  "trigger": {
    "2caf53e5-734a-46ab-886a-9a5d2411c451#c4b27388-db85-46b7-9436-f52bd76984a3": {
      "event": {
        "iam.id": "2caf53e5-734a-46ab-886a-9a5d2411c451#c4b27388-db85-46b7-9436-f52bd76984a3",
        "iam.eventType": "trigger"
      },
      "firstTimestamp": 1743714729108,
      "timestamp": 1743714732686,
      "count": 3
    }
  }
}

The new event history format looks like this:

{
  "70e6b8ce": {
    "timestamps": [
      1743716866010,
      1743775001300,
      1743775003207
    ]
  }
}

Main differences are that we hash now the activityId and the eventType. On the hash we store all the events timestamps.

Now related to the changes in this PR.

  • We need to provide a hash function to the historical condition.
  • Main changes are in the 'queryAndCountAnyEvent' and 'queryAndCountOrderedEvent' methods.
    • I made some changes to their logic so that this code will match what Mobile SDK does.
    • We also need to normalize the events that the historical condition uses so that it can retrieve it from the event history registry. Web SDK for generating the hashes is using the keys eventId and eventType. The rules engine events have the keys iam.id and iam.eventType.

I also changed the testing framework from jest to vitest. When I was trying to debug some tests failures, jest was throwing errors because babel typescript transformation was not happening for an unknown reason. With vitest, it worked beautifully.

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@dompuiu dompuiu requested a review from carterworks April 4, 2025 16:19
@dompuiu dompuiu self-assigned this Apr 4, 2025
@dompuiu
Copy link
Member Author

dompuiu commented Apr 4, 2025

@aenascut If you have time, could you take a look at this PR to see if I don't break anything on your side?

While we touched just the historical condition, which from my understanding you are not using, I added a rulesEngineOptions parameter, because we need to provide the rules engine a hashing method.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 14271199212

Details

  • 102 of 106 (96.23%) changed or added relevant lines in 7 files are covered.
  • 8 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-2.7%) to 87.934%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/historical.ts 55 57 96.49%
src/index.ts 8 10 80.0%
Files with Coverage Reduction New Missed Lines %
src/parser.ts 1 96.59%
src/utils/hashing.ts 1 84.44%
src/executors/target/target-rules-executor.ts 3 77.05%
src/model.ts 3 94.34%
Totals Coverage Status
Change from base Build 13408133325: -2.7%
Covered Lines: 764
Relevant Lines: 888

💛 - Coveralls

@dompuiu dompuiu merged commit 370cda6 into main Apr 7, 2025
3 checks passed
@dompuiu dompuiu deleted the use_new_event_history_format branch April 7, 2025 19:33
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 this pull request may close these issues.

3 participants