# # #

#

Usage

Initialization

Initialize the TrackZeroClient instance by passing in your API key before using any of the methods.

var instance = new TrackZeroClient("API-KEY");

Getting Started

TrackZero Instance

After initializing the TrackZero instance, you could get the instance anywhere in your project

var instance = TrackZeroClient.getInstance();

Entity

Entities are objects that contain data. It can represent any object in the real world. Each entity is defined by it’s Type and Id.

Create an Entity object

///Initializes the Entity object
///
///[type] - Entity's type
///[id] - {String | int} - Entity's id

Entity entity = new Entity("type", "id");

Add Attributes

///Adds custom attributes to the entity
///
///[attribute] - Entity's attribute name
///[value] - Entity's attribute value

entity.addAttribute("attribute", "value");

Add Attributes Referencing Other Entities

///Adds custom attributes to the entity that are related to another entity
///
///[attribute] - Entity's attribute name
///[referenceType] - Related to entity type
///[referenceId] - {String | int} - Related to entity id

entity.addEntityReferencedAttribute(
  "attribute",
  "referenceType",
  "referenceId"
);

Track Entity

///Creates/Updates the Entity
await instance.upsertEntity(entity);

Note: Upsert (Update/Insert) is applied when sending the entity. So, if the the entity of type X with id Y already exists, then it gets updated, else a new entity is created. This also applies to the entity's referenced attributes in addEntityReferencedAttribute.

Complete Entity Example

Entity user = new Entity("User", "USER_ID")
  .addAttribute("Name", "Sam Smith")
  .addAttribute("Date Of Birth", DateTime.utc(1990, 12, 23).toIso8601String()) //Make sure dates are in ISO8601 String
  .addEntityReferencedAttribute("Location", "Country", "US");

await instance.upsertEntity(user);

Delete Entity

:exclamation:   Deletion is permanent and cannot be undone.

///Deletes the Entity
///
///[type] - type of entity to be deleted
///[id] - {String | int} - id of the entity to be deleted

await instance.deleteEntity("type", "id");

Analytics Spaces

Each analytics space represents a separate database storing analytical data relevant to a specific subject/entity user defined.

Each analytics space is able to build reports and dahsboards in TrackZero's space portal.

Get a Space Portal Session

///Creates a space portal session
///
///[analyticsSpaceId] - the analytics space id
///
///[ttl] - (in seconds) - default set to 3600 - time to live, when the session expires

await instance.getSession(analyticsSpaceId, ttl);

Resources

Changelog

License

MIT

Libraries

leiratech_trackzero