Transformation Methods in the Event Class
The Event
object contains the properties and metadata of each Event ingested by the Pipeline from the Source.
The two main components of this object are:
-
event_name
: The name of the Event in the corresponding Event Type. -
properties
: The properties of the Event, received as key-value pairs.
For example:
{
"event_name": "users",
"properties": {
"id":56712434,
"first_name": "John",
"last_name": "Doe",
"age": 42,
"is_active": true,
"last_logged_in": 1507893200464
}
}
You can manipulate the properties of an Event using the methods provided by Hevo and transform it as per your requirement.
If you want Hevo to load the Event properties modified by your Transformation script to the Destination, you need to specifically add them to the transformed Event.
Refer to the pages in this section for a description of the methods available to the Event
object and a sample Transformation script demonstrating its use.
For each Event
object method, the following table is provided that describes the method, the type of parameter(s) that the method takes as argument(s), and the data type of the object returned by the method:
Definition: | Contains the method definition. The definiton consists of: - The method name. - The arguments that the method takes along with their data types. - The data type of the return value. <Method name>(<arg 1>: <data type1> , <arg2>: <data type2> ,…) → <return value data type> |
Description: | Describes what the method does. |
Parameters: | The variables that the method accepts as arguments. For example, the rename(new_name: str) method takes the parameter, new_name , of type string. |
Returns: | The data type of the variable(s) created or acted upon by the method. |
You can further transform your Event
object and its properties with the utilities provided by Hevo in the TimeUtils and Utils classes. For example, converting a millisecond value to a datetime object or creating an array from a property.
List of Methods in the Event Class
Hevo provides the following Transformation methods in the Event class. You can use them in your Transformation script to transform the Event
object, and test your script on sample Events before deploying it:
Definition | Description |
---|---|
Event(newEventName, properties) | Creates an Event |
getEventName() | Retrieves the Event name |
rename(newName) | Renames an Event |
getProperties() | Retrieves the properties of an Event |
setProperties(props) | Modifies the properties for an Event |
getPrimaryKeyFields() | Fetches the primary keys of an Event |
setPrimaryKeyFields([‘fieldname1’, ‘fieldname2’,…]) | Modifies the primary keys of an Event |
getType(fieldname) | Fetches the data type of a field |
isString(fieldname) | Checks if the Field is a string |
isNumber(fieldname) | Checks if the field is a number |
isBoolean(fieldname) | Checks if the field is boolean |
isDate(fieldname) | Checks if the field is a date |
isTime(fieldname) | Checks if the field is a time value |
isTimestamp(fieldname) | Checks if the field is a timestamp |