Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Expose appcues group call #1

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions integrations/appcues/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.3.0 / 2021-12-02
==================

* Appcues now accepts the group Segment call!


2.2.0 / 2016-10-06
==================
Expand Down
16 changes: 14 additions & 2 deletions integrations/appcues/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

var integration = require('@segment/analytics.js-integration');
var isObject = require('isobject');
var load = require('@segment/load-script');

/**
Expand Down Expand Up @@ -36,7 +35,7 @@ Appcues.prototype.initialize = function() {
*/

Appcues.prototype.loaded = function() {
return isObject(window.Appcues);
return typeof window.Appcues === 'object' && window.Appcues != null;
};

/**
Expand Down Expand Up @@ -90,6 +89,19 @@ Appcues.prototype.track = function(track) {
window.Appcues.track(track.event(), track.properties());
};

/**
* Group.
*
* http://appcues.com/docs#group
*
* @api public
* @param {Group} group
*/

Appcues.prototype.group = function(group) {
window.Appcues.group(group.groupId(), group.traits());
};

/**
* Expose plugin.
*/
Expand Down
5 changes: 2 additions & 3 deletions integrations/appcues/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/analytics.js-integration-appcues",
"description": "The Appcues analytics.js integration.",
"version": "2.2.1",
"version": "2.3.0",
"keywords": [
"analytics.js",
"analytics.js-integration",
Expand All @@ -25,8 +25,7 @@
},
"dependencies": {
"@segment/analytics.js-integration": "^2.1.0",
"@segment/load-script": "^1.0.1",
"isobject": "^2.1.0"
"@segment/load-script": "^1.0.1"
},
"devDependencies": {
"@segment/analytics.js-core": "^3.0.0",
Expand Down
14 changes: 14 additions & 0 deletions integrations/appcues/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,19 @@ describe('Appcues', function() {
});
});
});

describe('#group', function() {
beforeEach(function() {
analytics.stub(window.Appcues, 'group');
});

it('should send an id and group name', function() {
analytics.group('id', { groupName: 'group-1' });
analytics.called(window.Appcues.group, 'id', {
groupName: 'group-1',
id: 'id'
});
});
});
});
});