From 453c9b6f81f8e83e84265b7b5b191862359c258b Mon Sep 17 00:00:00 2001 From: Philipp Meisen Date: Wed, 12 Apr 2017 14:28:37 -0700 Subject: [PATCH] docs --- README.md | 4 +- documentation/snippets/language-config.md | 10 ++-- documentation/snippets/language-example.md | 13 ++--- documentation/snippets/language-integrate.md | 51 ++----------------- .../snippets/language-login-activity.md | 14 +++-- .../snippets/language-pagevisit-activity.md | 8 +-- .../snippets/language-purchase-activity.md | 7 ++- 7 files changed, 40 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 3058ae6..dc023a4 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ The example shows, how to send a login activity, reading the data from an reques ```javascript // the req object may be passed, e.g., using express: -// app.post('/login', function(req, res) +// app.post('/login', function(req, res) { ... }); var user = { 'sessionId': req.sessionID, @@ -77,7 +77,7 @@ It is also possible to send additional information with an activity, e.g., which ```javascript // the req object may be passed, e.g., using express: -// app.post('/addItem', function(req, res) +// app.post('/login', function(req, res) { ... }); var user = { 'sessionId': req.sessionID diff --git a/documentation/snippets/language-config.md b/documentation/snippets/language-config.md index 5a2b0e4..ff69d72 100644 --- a/documentation/snippets/language-config.md +++ b/documentation/snippets/language-config.md @@ -1,11 +1,15 @@

It is recommended to use the Node.js library with a signature (i.e., -the Verification Signature in the UI should be enabled and the secret is needed). +the Verification Signature in the UI +should be enabled and the secret is needed).

+

Whenever a Breinify instance is created, +the configuration has to be specified.

> -```javascript--browser -Breinify.setConfig({ +```javascript--node +var Breinify = require('breinify-node'); +var breinify = new Breinify({ 'apiKey': '938D-3120-64DD-413F-BB55-6573-90CE-473A', 'secret': 'utakxp7sm6weo5gvk7cytw==' }); diff --git a/documentation/snippets/language-example.md b/documentation/snippets/language-example.md index c823e94..5900e60 100644 --- a/documentation/snippets/language-example.md +++ b/documentation/snippets/language-example.md @@ -1,16 +1,17 @@ -
-

You selected the documentation for the JavaScript language utilizing the JavaScript Browser library. -The library is deployed under the MIT License and is available as open-source project +

+

You selected the documentation for Node.js library. +The library is deployed under the MIT License and is +available as open-source project on GitHub.

> -```javascript--browser +```javascript--node /* - * I'm an example snippet of the JavaScript library. The following + * I'm an example snippet of the Node.js library. The following * documentation should help you to get started with the library. * Even more examples and documentation can be found at: * - * https://github.com/Breinify/brein-api-library-javascript-browser + * https://github.com/Breinify/brein-api-library-node */ ``` \ No newline at end of file diff --git a/documentation/snippets/language-integrate.md b/documentation/snippets/language-integrate.md index 75bfa45..775a959 100644 --- a/documentation/snippets/language-integrate.md +++ b/documentation/snippets/language-integrate.md @@ -1,52 +1,9 @@ -
-

There are multiple ways on how to integrate the library within your project. -The library is available on bower, jsdelivr (CDN), npm, or as download from GitHub.

-
- -
-

Using Bower

-

The library can be installed via bower, further information about bower can be found -here.

-
- -> -```javascript--browser -bower install breinify-api --save -``` - -
-

jsdelivr (CDN)

-

The library can be loaded directly within the html code from . -jsdelivr. Please replace -the {version} placeholder with the version you would like to use. -To see a list of all available version have a look -here

-
- -> -```javascript--browser - -``` - -
-

To use the most current SNAPSHOT version, you can also use the following URL. -This URL should only be used for developing purposes (see also rawgit.com).

-
- -> -```javascript--browser - -``` - -
-

Using npm

-

The library can be installed via npm, further information about npm can be found -here. It should be mentioned that it is -not recommended to use this library with Node.js, instead use the -Node.js Library

+
+

The library is distributed through Node.js package manager +(npm).

> ```javascript--browser -npm install breinify-api --save +npm install breinify-node --save ``` \ No newline at end of file diff --git a/documentation/snippets/language-login-activity.md b/documentation/snippets/language-login-activity.md index bd33e04..9e705f2 100644 --- a/documentation/snippets/language-login-activity.md +++ b/documentation/snippets/language-login-activity.md @@ -1,6 +1,12 @@ > -```javascript--browser -var sId = Breinify.UTL.cookie.get('JSESSIONID'); -var email = 'max@sample.com'; // typically read from an input field -Breinify.activity({ 'sessionId': sId, 'email': email }, 'login'); +```javascript--node +// the req object may be passed, e.g., using express: +// app.post('/login', function(req, res) { ... }); + +var user = { + 'sessionId': req.sessionID, + 'email': req.body.email +}; + +breinify.activity(user, 'login'); ``` \ No newline at end of file diff --git a/documentation/snippets/language-pagevisit-activity.md b/documentation/snippets/language-pagevisit-activity.md index 8eb4d1e..19c2850 100644 --- a/documentation/snippets/language-pagevisit-activity.md +++ b/documentation/snippets/language-pagevisit-activity.md @@ -1,5 +1,7 @@ > -```javascript--browser -var sId = Breinify.UTL.cookie.get('JSESSIONID'); -Breinify.activity({ 'sessionId': sId }, 'pageVisit'); +```javascript--node +// the req object may be passed, e.g., using express: +// app.post('/login', function(req, res) { ... }); + +breinify.activity({ 'sessionId': req.sessionID }, 'pageVisit'); ``` \ No newline at end of file diff --git a/documentation/snippets/language-purchase-activity.md b/documentation/snippets/language-purchase-activity.md index 15359c4..a733106 100644 --- a/documentation/snippets/language-purchase-activity.md +++ b/documentation/snippets/language-purchase-activity.md @@ -4,11 +4,14 @@ of the temporalData method.

> -```javascript--browser +```javascript--node +// the req object may be passed, e.g., using express: +// app.post('/login', function(req, res) { ... }); + var sId = Breinify.UTL.cookie.get('JSESSIONID'); var tags = { 'productIds': [ '125689', '982361', '157029' ], 'productPrices': [ 134.23, 15.13, 12.99 ] }; -Breinify.activity({ 'sessionId': sId }, 'checkOut', tags); +Breinify.activity({ 'sessionId': req.sessionID }, 'checkOut', tags); ``` \ No newline at end of file