You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@unomi.apache.org by sh...@apache.org on 2018/11/05 14:08:37 UTC

svn commit: r1845794 [6/19] - in /incubator/unomi/website/manual: 1_1_x/ 1_1_x/images/ 1_2_x/ 1_2_x/connectors/ 1_2_x/images/ 1_2_x/samples/ 1_3_x/ 1_3_x/asciidoc/ 1_3_x/connectors/ 1_3_x/images/ 1_3_x/samples/ latest/ latest/connectors/ latest/images/...

Added: incubator/unomi/website/manual/1_2_x/getting-started.html
URL: http://svn.apache.org/viewvc/incubator/unomi/website/manual/1_2_x/getting-started.html?rev=1845794&view=auto
==============================================================================
--- incubator/unomi/website/manual/1_2_x/getting-started.html (added)
+++ incubator/unomi/website/manual/1_2_x/getting-started.html Mon Nov  5 14:08:37 2018
@@ -0,0 +1,175 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="generator" content="Asciidoctor 1.5.6.1">
+<title>Getting started with Unomi</title>
+<link rel="stylesheet" href="./apache.css">
+</head>
+<body class="article">
+<div id="header">
+<div id="toc" class="toc">
+<div id="toctitle">Table of Contents</div>
+<ul class="sectlevel2">
+<li><a href="#_getting_started_with_unomi">Getting started with Unomi</a></li>
+</ul>
+</div>
+</div>
+<div id="content">
+<div class="sect2">
+<h3 id="_getting_started_with_unomi">Getting started with Unomi</h3>
+<div class="paragraph">
+<p>We will first get you up and running with an example. We will then lift the corner of the cover somewhat and explain in greater details what just happened.</p>
+</div>
+<div class="sect3">
+<h4 id="_prerequisites">Prerequisites</h4>
+<div class="paragraph">
+<p>This document assumes that you are already familiar with Unomi&#8217;s <a href="concepts.html">concepts</a>. On the technical side, we also assume working knowledge of <a href="https://git-scm.com/">git</a> to be able to retrieve the code for Unomi and the example. Additionnally, you will require a working Java 7 or above install. Refer to <a href="http://www.oracle.com/technetwork/java/javase/">http://www.oracle.com/technetwork/java/javase/</a> for details on how to download and install Java SE 7 or greater.</p>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_running_unomi">Running Unomi</h4>
+<div class="sect4">
+<h5 id="_building_unomi">Building Unomi</h5>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Get the code: <code>git clone <a href="https://git-wip-us.apache.org/repos/asf/incubator-unomi.git" class="bare">https://git-wip-us.apache.org/repos/asf/incubator-unomi.git</a></code></p>
+</li>
+<li>
+<p>Build and install according to the <a href="building-and-deploying.html">instructions</a> and install Unomi.</p>
+</li>
+</ol>
+</div>
+</div>
+<div class="sect4">
+<h5 id="_start_unomi">Start Unomi</h5>
+<div class="paragraph">
+<p>Start Unomi according to the <a href="building-and-deploying.html#Deploying_the_generated_package">instructions</a>. Once you have Karaf running,
+ you should wait until you see the following messages on the Karaf console:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>Initializing user list service endpoint...
+Initializing geonames service endpoint...
+Initializing segment service endpoint...
+Initializing scoring service endpoint...
+Initializing campaigns service endpoint...
+Initializing rule service endpoint...
+Initializing profile service endpoint...
+Initializing cluster service endpoint...</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This indicates that all the Unomi services are started and ready to react to requests. You can then open a browser and go to <code><a href="http://localhost:8181/cxs" class="bare">http://localhost:8181/cxs</a></code> to see the list of
+available RESTful services or retrieve an initial context at <code><a href="http://localhost:8181/context.json" class="bare">http://localhost:8181/context.json</a></code> (which isn&#8217;t very useful at this point).</p>
+</div>
+</div>
+<div class="sect4">
+<h5 id="_request_examples">Request examples</h5>
+<div class="sect5">
+<h6 id="_retrieving_your_first_context">Retrieving your first context</h6>
+<div class="paragraph">
+<p>You can retrieve a context using curl like this :</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>curl http://localhost:8181/context.js?sessionId=1234</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This will retrieve a JavaScript script that contains a <code>cxs</code> object that contains the context with the current user
+profile, segments, scores as well as functions that makes it easier to perform further requests (such as collecting
+events using the cxs.collectEvents() function).</p>
+</div>
+</div>
+<div class="sect5">
+<h6 id="_retrieving_a_context_as_a_json_object">Retrieving a context as a JSON object.</h6>
+<div class="paragraph">
+<p>If you prefer to retrieve a pure JSON object, you can simply use a request formed like this:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>curl http://localhost:8181/context.json?sessionId=1234</code></pre>
+</div>
+</div>
+</div>
+<div class="sect5">
+<h6 id="_accessing_profile_properties_in_a_context">Accessing profile properties in a context</h6>
+<div class="paragraph">
+<p>By default, in order to optimize the amount of data sent over the network, Apache Unomi will not send the content of
+the profile or session properties. If you need this data, you must send a JSON object to configure the resulting output
+of the context.js(on) servlet.</p>
+</div>
+<div class="paragraph">
+<p>Here is an example that will retrieve all the session and profile properties.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>curl -H "Content-Type: application/json" -X POST -d '{"source":{"itemId":"homepage","itemType":"page","scope":"example"},"requiredProfileProperties":["*"],"requiredSessionProperties":["*"],"requireSegments":true}' http://localhost:8181/context.json?sessionId=1234</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The <code>requiredProfileProperties</code> and <code>requiredSessionProperties</code> are properties that take an array of property names
+that should be retrieved. In this case we use the wildcard character '*' to say we want to retrieve all the available
+properties. The structure of the JSON object that you should send is a JSON-serialized version of the <a href="http://unomi.incubator.apache.org/unomi-api/apidocs/org/apache/unomi/api/ContextRequest.html">ContextRequest</a>
+Java class.</p>
+</div>
+</div>
+<div class="sect5">
+<h6 id="_sending_events_using_the_context_servlet">Sending events using the context servlet</h6>
+<div class="paragraph">
+<p>At the same time as you are retrieving the context, you can also directly send events in the ContextRequest object as
+illustrated in the following example:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>curl -H "Content-Type: application/json" -X POST -d '{"source":{"itemId":"homepage","itemType":"page","scope":"example"},"events":[{"eventType":"view","scope": "example","source":{"itemType": "site","scope":"example","itemId": "mysite"},"target":{"itemType":"page","scope":"example","itemId":"homepage","properties":{"pageInfo":{"referringURL":""}}}}]}' http://localhost:8181/context.json?sessionId=1234</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Upon received events, Apache Unomi will execute all the rules that match the current context, and return an updated context.
+This way of sending events is usually used upon first loading of a page. If you want to send events after the page has
+finished loading you could either do a second call and get an updating context, or if you don&#8217;t need the context and want
+to send events in a network optimal way you can use the eventcollector servlet (see below).</p>
+</div>
+</div>
+<div class="sect5">
+<h6 id="_sending_events_using_the_eventcollector_servlet">Sending events using the eventcollector servlet</h6>
+<div class="paragraph">
+<p>If you only need to send events without retrieving a context, you should use the eventcollector servlet that is optimized
+respond quickly and minimize network traffic. Here is an example of using this servlet:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>curl -H "Content-Type: application/json" -X POST -d '{"events":[{"eventType":"view","scope": "example","source":{"itemType": "site","scope":"example","itemId": "mysite"},"target":{"itemType":"page","scope":"example","itemId":"homepage","properties":{"pageInfo":{"referringURL":""}}}}]}' http://localhost:8181/eventcollector?sessionId=1234</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Note that the eventcollector executes the rules but does not return a context. If is generally used after a page is loaded
+to send additional events.</p>
+</div>
+</div>
+</div>
+<div class="sect4">
+<h5 id="_where_to_go_from_here">Where to go from here</h5>
+<div class="ulist">
+<ul>
+<li>
+<p>Read the <a href="twitter-sample.html">Twitter sample</a> documentation that contains a detailed example of how to integrate with Apache Unomi.</p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2018-09-10 11:30:03 CEST
+</div>
+</div>
+</body>
+</html>
\ No newline at end of file

Added: incubator/unomi/website/manual/1_2_x/images/asf_logo_url.png
URL: http://svn.apache.org/viewvc/incubator/unomi/website/manual/1_2_x/images/asf_logo_url.png?rev=1845794&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/unomi/website/manual/1_2_x/images/asf_logo_url.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/unomi/website/manual/1_2_x/images/incubator-logo.png
URL: http://svn.apache.org/viewvc/incubator/unomi/website/manual/1_2_x/images/incubator-logo.png?rev=1845794&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/unomi/website/manual/1_2_x/images/incubator-logo.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/unomi/website/manual/1_2_x/images/unomi-request.png
URL: http://svn.apache.org/viewvc/incubator/unomi/website/manual/1_2_x/images/unomi-request.png?rev=1845794&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/unomi/website/manual/1_2_x/images/unomi-request.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream