Transformation Methods in the Event Class

Last updated on Feb 13, 2023

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": {
	     "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

Revision History

Refer to the following table for the list of key updates made to this page:

Date Release Description of Change
Feb-14-2023 NA Created as a new document, and moved the information for each method to a new page.

Tell us what went wrong