Class: Event

Event

Use 'Event' to trigger an event on Built.io Backend

new Event(uid){Event}

analyticsEvent.js, line 11
Represents an analytics event
Name Type Description
uid string | object The uid of the event, or initial values of the event
Example
//'blt5d4sample2633b' is a dummy Application API key
var Event = Built.App('blt5d4sample2633b').Analytics().Event;

//Constructor accepting event uid as argument
var event = Event('event1');

// Constructor accepting inital properties as argument
var event = Event({
   username:'ABC';
});
event = event.setUid('event2');

Methods

getProperties(){object}

analyticsEvent.js, line 43
Gets the properties assigned to this event
Example
var event = Built.App('blt5d4sample2633b').Event({
   username:'ABC';
});
event = event.setUid('event2');
console.log(event.getProperties())

getUid(){String}

analyticsEvent.js, line 61
Returns the uid of this event
Example
var event = Built.App('blt5d4sample2633b').Event('event1');
var uid = event.getUid();

setCreatedAt(date){Event}

analyticsEvent.js, line 122
You can assign a created at date to an Event. If this is provided Built.io Backend would consider it as the time the event was triggered else would attach server's timestamp as its created at.
Name Type Description
date Date The custom created at date to be assigned to event
Example
var event = Built.App('blt5d4sample2633b').Event('event1');
event = event.setCreatedAt(new Date());

setProperties(properties){Event}

analyticsEvent.js, line 102
Assigns properties to the event. These are nothing but data you want to send along with the event
Name Type Description
properties object Plain JavaScript object containing custom properties
Example
var event = Built.App('blt5d4sample2633b').Event('event1');
// username data is send along with the event
event = event.setProperties({ 
   username:'ABC'
});

setUid(uid){Event}

analyticsEvent.js, line 76
Assigns a uid to the event
Name Type Description
uid String Uid for the event
Example
var event = Built.App('blt5d4sample2633b').Event({
   username:'ABC'
});
event = event.setUid('event1');

trigger(forceTrigger)

analyticsEvent.js, line 136
Triggers this event on Built.io Backend
Name Type Description
forceTrigger Triggers regardless of the batchSize
Example
var event = Built.App('blt5d4sample2633b').Event('event1');
event.trigger()
.then(function(event){
   // Returns the same event
});