From 965392527b4296abb4ae9fc4fbed09fadd5e3290 Mon Sep 17 00:00:00 2001 From: Ellis Gray Date: Fri, 17 Mar 2017 09:45:04 +1000 Subject: [PATCH 1/3] changes page view event tracking to include segment properties --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 72f8290..e1c7f52 100644 --- a/lib/index.js +++ b/lib/index.js @@ -56,8 +56,8 @@ Vero.prototype.loaded = function() { * @param {Page} page */ -Vero.prototype.page = function() { - push('trackPageview'); +Vero.prototype.page = function(page) { + push('track', 'viewed_page', page.properties(), { source: 'segment' }); }; /** From 65e2f018319d48ee6a2e54bace077f17c4378fec Mon Sep 17 00:00:00 2001 From: Ellis Gray Date: Fri, 17 Mar 2017 10:40:32 +1000 Subject: [PATCH 2/3] wip havent found how to mock the properties passed to _vero.push from analytics.page --- test/index.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/index.test.js b/test/index.test.js index 141335e..6c21180 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -72,9 +72,9 @@ describe('Vero', function() { analytics.stub(window._veroq, 'push'); }); - it('should push "trackPageview"', function() { + it('should push "viewed_page"', function() { analytics.page(); - analytics.called(window._veroq.push, ['trackPageview']); + analytics.called(window._veroq.push, ['track', 'viewed_page', {}, { source: 'segment' }]); }); }); From 8e0e857196e9693ae99628e406417b803d2d21f6 Mon Sep 17 00:00:00 2001 From: Ellis Gray Date: Mon, 3 Apr 2017 12:22:00 +1000 Subject: [PATCH 3/3] fixes testpage example - referrer gets a static value --- test/index.test.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/index.test.js b/test/index.test.js index 6c21180..5fdef1d 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -73,8 +73,14 @@ describe('Vero', function() { }); it('should push "viewed_page"', function() { - analytics.page(); - analytics.called(window._veroq.push, ['track', 'viewed_page', {}, { source: 'segment' }]); + analytics.page({ referrer: 'http://localhost:9876/?id=42' }); + analytics.called(window._veroq.push, ['track', 'viewed_page', { + referrer: 'http://localhost:9876/?id=42', + path: '/context.html', + search: '', + title: '', + url: 'http://localhost:9876/context.html' + },{ source: 'segment' }]); }); });