I am new to Unomi,
I had installed unomi-1.2.0-incubating and started the karaf server it is running successfully.
I have elastic search install and working under cluster name contextElasticSearch.
I had integrated the context.js in my Front End website to load it from the unomi, and also triggered the page visit event as home page, by making the successful call to unomi context.json, with contectParams like below:
Code:
function contextRequest(successCallback, errorCallback, payload) {
var data = JSON.stringify(payload);
// if we don't already have a session id, generate one
var sessionId = cxs.sessionId || generateUUID();
var url = 'http://localhost:8181/context.json?sessionId=' + sessionId;
var xhr = new XMLHttpRequest();
var isGet = data.length < 100;
if (isGet) {
xhr.withCredentials = true;
xhr.open("GET", url + "&payload=" + encodeURIComponent(data), true);
} else if ("withCredentials" in xhr) {
xhr.open("POST", url, true);
xhr.withCredentials = true;
} else if (typeof XDomainRequest != "undefined") {
xhr = new XDomainRequest();
xhr.open("POST", url);
}
xhr.onreadystatechange = function () {
if (xhr.readyState != 4) {
return;
}
if (xhr.status == 200) {
var response = xhr.responseText ? JSON.parse(xhr.responseText) : undefined;
if (response) {
cxs.sessionId = response.sessionId;
successCallback(response);
}
} else {
console.log("contextserver: " + xhr.status + " ERROR: " + xhr.statusText);
if (errorCallback) {
errorCallback(xhr);
}
}
};
}
var scope = 'unomipages';
var itemId = btoa(window.location.href);
var source = {
itemType: 'page',
scope: scope,
itemId: itemId,
properties: {
url: window.location.href
}
};
var contextPayload: any = {
source: source,
events: [
{
eventType: 'pageVisitEvent',
scope: scope,
source: source
}
],
requiredProfileProperties: [
]
};
contextRequest(function (response: any) {
console.log(JSON.stringify(response));
}, function(){}, contextPayload);
My Question is:
- How to track events in unomi server, and access its rest api?
Let me know if you want any more info from me, or if I am missing any thing.