Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apeeyush/e5c4e94fe1362341f147 to your computer and use it in GitHub Desktop.
Save apeeyush/e5c4e94fe1362341f147 to your computer and use it in GitHub Desktop.

Proposed format for specifying synthetic data

This file should be edited freely.

Scenario: Find an event with a value

In this scenario, we want to see if the event "Score" ever happens with the property "{points_earned: 10}" in the properties hash. If we find one, we want to add a new event, "User scored max points".

{
  rule: {
    type: "match",
    pattern: [
      {
        event: "Score",
        points_earned: 10
      }
    ]
  },
  result: {
    clone: "pattern[0]",
    event: "User scored max points",
    properties: null
  }
}

This example looks a little more complicated than it might otherwise be, because it is doing two things:

  1. Using a generalizable "pattern" field that takes an array, which will be useful for finding multiple events, and
  2. Using a "clone" key, because we would like to create a "complete" event with all the other fields intact, such as session-id, application-id and timestamp.

The above rule would find any event with "event: Score, properties: {value: 10}". Because the Rails application "flattens" the properties column, we can refer to "value: 10" directly.

It then creates a new event which first clones the found event (pattern[0], which refers to the first captured event in the pattern array), then replaces the "event" property with our new event, and removes the "properties" property.

Scenario: Find any combination of properties in a single event

The above pattern searches "event" and "points_earned", but we can search any combination of properties.

{
  rule: {
    type: "match",
    pattern: [
      {
        activity: "Spring and mass",
        action: "exported"
        type: "model"
      }
    ]
  },
  result: {
    clone: "pattern[0]",
    event: "User exported model",
    properties: null
  }
}

Scenario: Find multiple events in a row

Here we want to find n events that happen in sequence. We use the pattern's array to specify multiple events that we want to capture in a row

{
  rule: {
    type: "match",
    pattern: [
      {
        event: "Ended challenge"
      },
      {
        event: "Score",
        points_earned: 10
      },
      {
        event: "Restarted challenge"
      }
    ]
  },
  result: {
    clone: "pattern[2]",
    event: "User scored max points and then restarted",
    properties: null
  }
}

Here when we find the three events in order (for two of them we care only about the event name), we clone the last one (pattern[2]) and create the new event.

Note that, for Geniverse, finding three events in order is a fairly naive search -- events that happen close to each other, like a user finishing a challenge and then earning a score for it, are not guaranteed to arrive in a specified order. For this reason, we might want to use a time-based filter. However, it sounds like this filter would still be useful for IS data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment