Skip to content

Commit e0706ae

Browse files
authored
DEST-2110 CC-6445 Add support for page and group in Wootric (#470)
1 parent b80faa1 commit e0706ae

File tree

4 files changed

+47
-20
lines changed

4 files changed

+47
-20
lines changed

integrations/wootric/HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
2.5.0 / 2020-05-13
2+
==================
13

4+
* Add support for page and group in Wootric (#470)
5+
26
2.4.0 / 2020-02-20
37
==================
48

integrations/wootric/lib/index.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ var Wootric = (module.exports = integration('Wootric')
2828
*/
2929

3030
Wootric.prototype.initialize = function() {
31-
// We use this to keep track of the last page that Wootric has tracked to
32-
// ensure we don't accidentally send a duplicate page call
33-
this.lastPageTracked = null;
3431
window.wootricSettings = window.wootricSettings || {};
3532
window.wootricSettings.account_token = this.options.accountToken;
3633
window.wootricSettings.version = 'wootric-segment-js-2.3.0';
@@ -101,14 +98,21 @@ Wootric.prototype.track = function(track) {
10198
* @param {Page} page
10299
*/
103100

104-
Wootric.prototype.page = function() {
105-
// Only track page if we haven't already tracked it
106-
if (this.lastPageTracked === window.location) {
107-
return;
108-
}
101+
Wootric.prototype.page = function(page) {
102+
window.wootricSettings.page_info = page.properties();
103+
window.wootric('page');
104+
};
105+
106+
/**
107+
* Group.
108+
*
109+
* @api public
110+
* @param {Group} group
111+
*/
109112

110-
// Set this page as the last page tracked
111-
this.lastPageTracked = window.location;
113+
Wootric.prototype.group = function(group) {
114+
window.wootricSettings.group_info = group.traits();
115+
window.wootric('group');
112116
};
113117

114118
/**

integrations/wootric/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-wootric",
33
"description": "The Wootric analytics.js integration.",
4-
"version": "2.4.0",
4+
"version": "2.5.0",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",

integrations/wootric/test/index.test.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ describe('Wootric', function() {
6969
analytics.assert(window.wootricSettings.version);
7070
});
7171

72-
it('should have lastPageTracked set to null', function() {
73-
analytics.assert(wootric.lastPageTracked === null);
74-
});
75-
7672
it('should call #load', function() {
7773
analytics.called(wootric.load);
7874
});
@@ -276,16 +272,39 @@ describe('Wootric', function() {
276272

277273
describe('#page', function() {
278274
beforeEach(function() {
279-
analytics.page({});
275+
analytics.page('Pricing', {
276+
title: 'Segment Pricing',
277+
url: 'https://segment.com/pricing',
278+
path: '/pricing',
279+
referrer: 'https://segment.com/warehouses'
280+
});
280281
});
281282

282283
it('should track the current page', function() {
283-
analytics.assert(window.wootricSettings);
284-
analytics.assert(wootric.lastPageTracked);
284+
analytics.equal(window.wootricSettings.page_info.name, 'Pricing');
285+
analytics.equal(
286+
window.wootricSettings.page_info.url,
287+
'https://segment.com/pricing'
288+
);
289+
});
290+
});
291+
292+
describe('#group', function() {
293+
beforeEach(function() {
294+
analytics.group('0e8c78ea9d97a7b8185e8632', {
295+
name: 'Initech',
296+
industry: 'Technology',
297+
employees: 329,
298+
plan: 'enterprise'
299+
});
285300
});
286301

287-
it('should set lastPageTracked to window location', function() {
288-
analytics.assert(wootric.lastPageTracked === window.location);
302+
it('should send group traits to Wootric', function() {
303+
analytics.equal(
304+
window.wootricSettings.group_info.id,
305+
'0e8c78ea9d97a7b8185e8632'
306+
);
307+
analytics.equal(window.wootricSettings.group_info.name, 'Initech');
289308
});
290309
});
291310

0 commit comments

Comments
 (0)