Skip to content

Commit 7d2966c

Browse files
authored
add JS examples (#5)
1 parent 8fb8620 commit 7d2966c

File tree

6 files changed

+82
-0
lines changed

6 files changed

+82
-0
lines changed
File renamed without changes.

js/library/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "va-library",
3+
"version": "0.0.1",
4+
"description": "Vacuum Analytics Library",
5+
"author": "Alexander Surkov <[email protected]>",
6+
"repository": {
7+
"type": "git",
8+
"url": "[email protected]:sourcerer-io/vacuum-analytics.git"
9+
},
10+
"license": "MIT",
11+
"private": false,
12+
"main" : "LogEvent.js",
13+
"dependencies": {
14+
}
15+
}

js/samples/browser/simple.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<html>
2+
<head>
3+
<meta charset="utf-8" />
4+
<meta name="viewport"
5+
content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes" />
6+
<title>Vacuum Analytics Example</title>
7+
8+
<script src="../../library/LogEvent.js"></script>
9+
<script>
10+
const logging_url = 'http://0.0.0.0:8080';
11+
12+
const logger = new LogEvent(
13+
logging_url,
14+
{ 'headers' : { 'set-cookie': 'sessionid=bmomob;' } }
15+
);
16+
17+
logger.error("B'eba-%pBeba").
18+
then(
19+
() => { console.log('done'); document.body.textContent = 'done'; },
20+
(e) => { console.log(e); document.body.textContent = 'error'; }
21+
);
22+
</script>
23+
</head>
24+
25+
<body>
26+
</body>
27+
</html>

js/samples/node/config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(function() {
2+
'use strict';
3+
4+
module.exports.cfg = {
5+
logging_url: 'http://0.0.0.0:8080' // Log stash.
6+
};
7+
8+
}());

js/samples/node/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "va-sample",
3+
"version": "0.0.1",
4+
"description": "Vacuum Analytics Examples",
5+
"author": "Alexander Surkov <[email protected]>",
6+
"license": "MIT",
7+
"private": false,
8+
"scripts": {
9+
"start": "node simple.js"
10+
},
11+
"dependencies": {
12+
"va": "file:../../library",
13+
}
14+
}

js/samples/node/simple.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(function() {
2+
'use strict';
3+
4+
const cfg = require('./config.js');
5+
const LogEvent = require('va').LogEvent;
6+
7+
let logger = new LogEvent(
8+
cfg.logging_url,
9+
{ 'headers' : { 'set-cookie': 'sessionid=bmomob;' } }
10+
);
11+
12+
logger.error("B'eba-%pBeba").
13+
then(
14+
() => { console.log('done'); },
15+
(e) => { console.log(e); }
16+
);
17+
18+
}());

0 commit comments

Comments
 (0)