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

Checking all possible sequence matches #15

Open
korhner opened this issue Dec 25, 2016 · 4 comments
Open

Checking all possible sequence matches #15

korhner opened this issue Dec 25, 2016 · 4 comments

Comments

@korhner
Copy link

korhner commented Dec 25, 2016

Hi,

Lets say this is my event stream:

(User1, event1)
(User1, event2)
(User1, event1)
(User2, event2)

I want to check that any user that has event1 has also event2 (any user can have many such groups). Also, I don't want to specify a specific user, I want to check them all. I tried creating a sequence that matches this:

{
    "comment": "First tdl",
	
	
	
    "sequences": [{
        "type": "CONTAINER",
        "name": "BattleStarted has BattleEnded",
        "sequenceMaxTime": "PT3M",
        "checkPoints": [
        {
            "eventType": "1",
            "set": ["BS_userId=userId", "BS_battleId=p_battleId", "BS_timestamp=timestamp"]
        }, 
        {
            "eventType": "2",
            "match": "userId==BS_userId && p_battleId==BS_battleId",
            "validate": "timestamp > BS_timestamp"
        }]
    }]
}

The problem is checkpoint only matches first event it finds, so in this case, only first 2 events will be checked, failing to report that User1 does not have event2 for all event1. Is it possible for a sequence to search through all possible matches?

@alexander-poulikakos
Copy link
Member

Sorry, that is not currently supported.

If I understand you correctly you want to:
Create a segment for each user, then apply a Sequence (repeatedly? in order?) on that segment?

@korhner
Copy link
Author

korhner commented Dec 28, 2016

Exactly, where segments will most often, if not always, be all users found in data source. I was able to make a quick prototype by adding cardinality to sequence (something regex like, *, +, ?, 1). To do this I had to:

  • make the system add special "poison pill" events for each iterator when consumed
  • alter completion strategy to wait for iterators.size() poison pills and then check again if cardinality of a sequence is broken
  • alter container sequence behavior to not "die" after 1 cycle

This works correctly but the next feature that I miss is, I want to detect if there is any uncomplete funnels, ie I want to match event1 -> event2 -> event3, but also if there is partial funnel like event2 -> event3 in data source which is invalid.

I am very interested to see your exact use case at King. Do you use this with automated tests? Do you use this with exploratory testing (this was my idea, getting data from a bunch of testers and checking if there are any invalid event patterns)? It looks to me I am trying to adapt this to use cases that were not intended to be covered.

Thanks

@alexander-poulikakos
Copy link
Member

The current use case is to verify that a certain action is generating an expected Event.
For example, verify that when a player starts a new level (on real device) the correct Event with correct data is triggered. This is tested whenever a new commit is made to the game, in a CI environment.
This allow us to trust the data when analyzing it later in production.

In the early days of Tratt, it was used for funnel analysis (See Story Of The Tratt). There used to be a way to specify something called "SequenceInvariants" where you could specify event fields. All events containing these fields with the same data would be placed in a segment. Perhaps something similar could be added?

In current implementation there is a CONTAINER sequence type (which accepts events in an un-ordered way). Internally at King we also have a sequence type named FUNNEL, which takes event order into account. The current plan is to add FUNNEL to tratt-api sometimes next year (during first half).

Ps. I'm on xmas leave. Let's talk more in early/mid Januray.

@alexander-poulikakos
Copy link
Member

Hi @korhner

I've been giving this some thoughts. How about

  • Adding this into the TDL: "SequenceInvariants". Something like below. This will allow for making segments, where there will be one SequenceProcessor instance per segment.
{
    "comment": "Comment describing the purpose of this TDL",
    "sequenceInvariants": ["userId"],    
    "sequences": [{
        "type": "CONTAINER",
        "name": "SequenceA",
        "sequenceMaxTime": "PT60S",
        "checkPoints": [{
            "eventType": "GameStart",
            "validate": "level==2 && timestamp>=0",
            "set": ["GS_level=level", "GS_timestamp=timestamp"]
        }, {
            "eventType": "GameEnd",
            "validate": "level==GS_level && timestamp>=GS_timestamp && score==123 && endReason=='some-reason'"
        }]
    }]
}
  • Make the CompletionStrategy interface public and make it possible to register a custom implementation through the EventProcessorBuilder

  • Add another SequenceProcessor type that takes event order into consideration. Possibly making SequenceProcessor public with the possibility to register custom implementations through the EventProcessorBuilder.

/Alex

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

No branches or pull requests

2 participants