import "../../thrift/analytics_types";
/** CustomEvent */
export default class CustomEvent {
/**
* Creates a CustomEvent
* @param {Object} args - Event arguments.
* @param {string} args.name - Event name.
* @param {Object<string, string>} [args.customProperties={}] - Event Properties.
* @param {number} [args.deviceTime] - UNIX timestamp
*/
constructor(args) {
this.name = args.name || null;
this.customProperties = args.customProperties || {};
}
/**
* Parse event to get instance of THAnalyticsBaseEvent
* @ignore
* @return {THAnalyticsBaseEvent}
*/
getBaseEvent () {
if (this.custom_data) {
this.customProperties = {
...(this.customProperties || {}),
...this.custom_data
};
}
if (!this.deviceTime) {
this.deviceTime = (new Date()).getTime();
}
return new THAnalyticsBaseEvent({
...this,
deviceTimeType: THDeviceTimeType.LOCAL_TIME,
isCustom: true
});
}
}