src/models/Insight.js
/**
* Model representing a tracker object. Tracker must have an action and section values.
*/
class InsightModel {
/**
* @param {String} action - The action that triggers the track insights event,
* @param {String} section - The section of the application that triggers the
* application,
* @param {String} [value] - The specific element Id for the given section to track,
* @param {String} [label] - The name/text the user sees for the value being tracked,
* @param {String} [triggeredAt] - The event timestamp (default is now).
* @param {String} [brandId] - The brand associated with the section/value,
* @param {Object} [location] - Object including the following location-based fields:
* @param {Float} [location.latitude] - Longitude
* @param {Float} [location.longitude] - Latitude
*/
constructor(action, section, value, label, triggeredAt, brandId, location = {}) {
/** @type {Object} */
this.tracker = {
action,
section,
value,
label,
triggered_at: triggeredAt,
brand_id: brandId,
lat: location.latitude,
lng: location.longitude,
};
}
}
export default InsightModel;