Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions integrations/wootric/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
2.5.0 / 2020-05-13
==================

* Add support for page and group in Wootric (#470)

2.4.0 / 2020-02-20
==================

Expand Down
24 changes: 14 additions & 10 deletions integrations/wootric/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ var Wootric = (module.exports = integration('Wootric')
*/

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

Wootric.prototype.page = function() {
// Only track page if we haven't already tracked it
if (this.lastPageTracked === window.location) {
return;
}
Wootric.prototype.page = function(page) {
window.wootricSettings.page_info = page.properties();
window.wootric('page');
};

/**
* Group.
*
* @api public
* @param {Group} group
*/

// Set this page as the last page tracked
this.lastPageTracked = window.location;
Wootric.prototype.group = function(group) {
window.wootricSettings.group_info = group.traits();
window.wootric('group');
};

/**
Expand Down
2 changes: 1 addition & 1 deletion integrations/wootric/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/analytics.js-integration-wootric",
"description": "The Wootric analytics.js integration.",
"version": "2.4.0",
"version": "2.5.0",
"keywords": [
"analytics.js",
"analytics.js-integration",
Expand Down
37 changes: 28 additions & 9 deletions integrations/wootric/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ describe('Wootric', function() {
analytics.assert(window.wootricSettings.version);
});

it('should have lastPageTracked set to null', function() {
analytics.assert(wootric.lastPageTracked === null);
});

it('should call #load', function() {
analytics.called(wootric.load);
});
Expand Down Expand Up @@ -276,16 +272,39 @@ describe('Wootric', function() {

describe('#page', function() {
beforeEach(function() {
analytics.page({});
analytics.page('Pricing', {
title: 'Segment Pricing',
url: 'https://segment.com/pricing',
path: '/pricing',
referrer: 'https://segment.com/warehouses'
});
});

it('should track the current page', function() {
analytics.assert(window.wootricSettings);
analytics.assert(wootric.lastPageTracked);
analytics.equal(window.wootricSettings.page_info.name, 'Pricing');
analytics.equal(
window.wootricSettings.page_info.url,
'https://segment.com/pricing'
);
});
});

describe('#group', function() {
beforeEach(function() {
analytics.group('0e8c78ea9d97a7b8185e8632', {
name: 'Initech',
industry: 'Technology',
employees: 329,
plan: 'enterprise'
});
});

it('should set lastPageTracked to window location', function() {
analytics.assert(wootric.lastPageTracked === window.location);
it('should send group traits to Wootric', function() {
analytics.equal(
window.wootricSettings.group_info.id,
'0e8c78ea9d97a7b8185e8632'
);
analytics.equal(window.wootricSettings.group_info.name, 'Initech');
});
});

Expand Down