This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/master by this push:
new bc80aba UNOMI-300 Fix npm dependencies for web tracker - Fix problem
when specifying no initial page properties - Add release guide - Upgrade
uglify-js to latest version & fix source map generation - Update Javascript
project README
bc80aba is described below
commit bc80aba4e383953faea7f6c6f786f191ce6ab9e1
Author: Serge Huber <[email protected]>
AuthorDate: Mon May 4 17:43:25 2020 +0200
UNOMI-300 Fix npm dependencies for web tracker
- Fix problem when specifying no initial page properties
- Add release guide
- Upgrade uglify-js to latest version & fix source map generation
- Update Javascript project README
---
.../javascript/{README.md => NPM-RELEASE-GUIDE.md} | 36 ++--------------------
extensions/web-tracker/javascript/README.md | 16 ++++++++--
extensions/web-tracker/javascript/package.json | 6 ++--
.../src/analytics.js-integration-apache-unomi.js | 22 +++++++++----
extensions/web-tracker/javascript/yarn.lock | 14 +++------
.../wab/src/main/webapp/basic_test.html | 33 ++++++++++++++++++++
6 files changed, 73 insertions(+), 54 deletions(-)
diff --git a/extensions/web-tracker/javascript/README.md
b/extensions/web-tracker/javascript/NPM-RELEASE-GUIDE.md
similarity index 51%
copy from extensions/web-tracker/javascript/README.md
copy to extensions/web-tracker/javascript/NPM-RELEASE-GUIDE.md
index d16a01a..8f30071 100644
--- a/extensions/web-tracker/javascript/README.md
+++ b/extensions/web-tracker/javascript/NPM-RELEASE-GUIDE.md
@@ -15,38 +15,8 @@
~ limitations under the License.
-->
+Guide for releasing the Javascript project to the Node Package Manage central
repository
-Apache Unomi Web Tracker
-=================================
+1. mvn clean install
+2. yarn publish
-This is the web tracker for apache-unomi ( http://unomi.apache.org/ )
-
-It's included in unomi server, and can be served directly by unomi :
https://github.com/apache/incubator-unomi/tree/master/extensions/web-tracker
-
-This package can be used in a JS app to interact with unomi.
-
-## Getting started
-
-Adds tracker to your app :
-
-`npm add unomi-analytics`
-
-Then
-
-```javascript
-unomiTracker.initialize({
- 'Apache Unomi': {
- scope: 'my-app',
- url: 'http://unomi:8181'
- }
- });
-
-unomiTracker.ready(function() {
- console.log("Unomi context loaded - profile id : "+window.cxs.profileId +
", sessionId="+window.cxs.sessionId);
-});
-```
-
-Then send events :
-```javascript
-unomiTracker.page()
-```
diff --git a/extensions/web-tracker/javascript/README.md
b/extensions/web-tracker/javascript/README.md
index d16a01a..06b6ffe 100644
--- a/extensions/web-tracker/javascript/README.md
+++ b/extensions/web-tracker/javascript/README.md
@@ -37,7 +37,7 @@ Then
unomiTracker.initialize({
'Apache Unomi': {
scope: 'my-app',
- url: 'http://unomi:8181'
+ url: 'http://unomi:8181',
}
});
@@ -48,5 +48,17 @@ unomiTracker.ready(function() {
Then send events :
```javascript
-unomiTracker.page()
+unomiTracker.page() // first call will be ignored as the initial page load is
done in the initialize method
+
+unomiTracker.identify({
+ nickname: 'Amazing Grace',
+ favoriteCompiler: 'A-0',
+ industry: 'Computer Science'
+});
+
+unomiTracker.track('articleCompleted', {
+ title: 'How to Create a Tracking Plan',
+ course: 'Intro to Analytics'
+});
+
```
diff --git a/extensions/web-tracker/javascript/package.json
b/extensions/web-tracker/javascript/package.json
index 9be5155..ff15de0 100644
--- a/extensions/web-tracker/javascript/package.json
+++ b/extensions/web-tracker/javascript/package.json
@@ -14,8 +14,8 @@
"build": "yarn browserify && yarn replace && yarn minify && yarn
snippet:minify",
"browserify": "browserify src/index.js -p [ browserify-header --file
src/license.js ] -s unomiTracker -o dist/unomi-tracker.js",
"replace": "replace-in-file 'analytics.require = require'
'//analytics.require = require' dist/unomi-tracker.js",
- "minify": "uglifyjs -c -m --comments '/@license/' -o
dist/unomi-tracker.min.js --source-map -- dist/unomi-tracker.js",
- "snippet:minify": "uglifyjs -c -m -o snippet.min.js --source-map --
snippet.js",
+ "minify": "cd dist && uglifyjs -c -m --comments '/@license/' -o
unomi-tracker.min.js --source-map url=unomi-tracker.min.js.map --
unomi-tracker.js",
+ "snippet:minify": "uglifyjs -c -m -o snippet.min.js --source-map
url=snipper.min.js.map -- snippet.js",
"clean": "rimraf *.log dist/unomi-tracker.js dist/unomi-tracker.min.js",
"clean:all": "yarn clean && rimraf node_modules"
},
@@ -33,7 +33,7 @@
"eslint-plugin-require-path-exists": "^1.1.5",
"replace-in-file": "^3.4.2",
"rimraf": "^2.6.2",
- "uglify-js": "^3.8.1",
+ "uglify-js": "^3.9.2",
"yarn": "^1.22.4"
}
}
diff --git
a/extensions/web-tracker/javascript/src/analytics.js-integration-apache-unomi.js
b/extensions/web-tracker/javascript/src/analytics.js-integration-apache-unomi.js
index b365ab6..8a4f587 100644
---
a/extensions/web-tracker/javascript/src/analytics.js-integration-apache-unomi.js
+++
b/extensions/web-tracker/javascript/src/analytics.js-integration-apache-unomi.js
@@ -61,16 +61,26 @@ Unomi.prototype.initialize = function() {
scope: self.options.scope
};
+ window.digitalData.page = window.digitalData.page || {
+ path: location.pathname + location.hash,
+ pageInfo: {
+ pageName: document.title,
+ pageID : location.pathname + location.hash,
+ pagePath : location.pathname + location.hash,
+ destinationURL: location.href
+ }
+ }
+
+ var unomiPage = window.digitalData.page;
+ if (!unomiPage) {
+ unomiPage = window.digitalData.page = { pageInfo:{} }
+ }
if (self.options.initialPageProperties) {
var props = self.options.initialPageProperties;
- var unomiPage = window.digitalData.page;
- if (!unomiPage) {
- unomiPage = window.digitalData.page = { pageInfo:{} }
- }
this.fillPageData(unomiPage, props);
- window.digitalData.events = window.digitalData.events || [];
- window.digitalData.events.push(this.buildEvent('view',
this.buildPage(unomiPage), this.buildSource(this.options.scope, 'site')))
}
+ window.digitalData.events = window.digitalData.events || [];
+ window.digitalData.events.push(this.buildEvent('view',
this.buildPage(unomiPage), this.buildSource(this.options.scope, 'site')))
if (!self.options.sessionId) {
var cookie = require('component-cookie');
diff --git a/extensions/web-tracker/javascript/yarn.lock
b/extensions/web-tracker/javascript/yarn.lock
index 856c18a..d0d1154 100644
--- a/extensions/web-tracker/javascript/yarn.lock
+++ b/extensions/web-tracker/javascript/yarn.lock
@@ -2094,11 +2094,6 @@ source-map@~0.5.3:
resolved
"https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=
-source-map@~0.6.1:
- version "0.6.1"
- resolved
"https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
- integrity
sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
-
spark-md5@^2.0.2:
version "2.0.2"
resolved
"https://registry.yarnpkg.com/spark-md5/-/spark-md5-2.0.2.tgz#37b763847763ae7e7acef2ca5233d01e649a78b7"
@@ -2328,13 +2323,12 @@ typedarray@^0.0.6:
resolved
"https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
-uglify-js@^3.8.1:
- version "3.8.1"
- resolved
"https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.8.1.tgz#43bb15ce6f545eaa0a64c49fd29375ea09fa0f93"
- integrity
sha512-W7KxyzeaQmZvUFbGj4+YFshhVrMBGSg2IbcYAjGWGvx8DHvJMclbTDMpffdxFUGPBHjIytk7KJUR/KUXstUGDw==
+uglify-js@^3.9.2:
+ version "3.9.2"
+ resolved
"https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.9.2.tgz#012b74fb6a2e440d9ba1f79110a479d3b1f2d48d"
+ integrity
sha512-zGVwKslUAD/EeqOrD1nQaBmXIHl1Vw371we8cvS8I6mYK9rmgX5tv8AAeJdfsQ3Kk5mGax2SVV/AizxdNGhl7Q==
dependencies:
commander "~2.20.3"
- source-map "~0.6.1"
umd@^3.0.0:
version "3.0.3"
diff --git a/extensions/web-tracker/wab/src/main/webapp/basic_test.html
b/extensions/web-tracker/wab/src/main/webapp/basic_test.html
new file mode 100644
index 0000000..944c59c
--- /dev/null
+++ b/extensions/web-tracker/wab/src/main/webapp/basic_test.html
@@ -0,0 +1,33 @@
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one or more
+~ contributor license agreements. See the NOTICE file distributed with
+~ this work for additional information regarding copyright ownership.
+~ The ASF licenses this file to You under the Apache License, Version 2.0
+~ (the "License"); you may not use this file except in compliance with
+~ the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<!doctype html>
+<html lang="en">
+ <head>
+ <title>Basic Tracker test page</title>
+ <script type="text/javascript">
+ var unomiOption = {
+ scope: 'realEstateManager',
+ url: 'http://localhost:8181'
+ };
+
+ window.unomiTracker||(window.unomiTracker={}),function(){function
e(e){for(unomiTracker.initialize({"Apache Unomi":unomiOption});n.length>0;){var
r=n.shift(),t=r.shift();unomiTracker[t]&&unomiTracker[t].apply(unomiTracker,r)}}for(var
n=[],r=["trackSubmit","trackClick","trackLink","trackForm","initialize","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","personalize"],t=0;t<r.length;t++){var
i=r[t];window.unomiTracker[i]=function(e){ [...]
+ </script>
+ </head>
+<body>
+ Please check that there are no errors in Javascript console.
+</body>
+</html>
\ No newline at end of file