Skip to content

Commit 8d5d682

Browse files
authored
Expose Appcues group call (#648)
* add appcues group call support * bump minor version * docs: update history.md * remove isobject dependency * improving loaded check
1 parent 05e07c7 commit 8d5d682

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

integrations/appcues/HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.3.0 / 2021-12-02
2+
==================
3+
4+
* Appcues now accepts the group Segment call!
5+
16

27
2.2.0 / 2016-10-06
38
==================

integrations/appcues/lib/index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

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

1110
/**
@@ -36,7 +35,7 @@ Appcues.prototype.initialize = function() {
3635
*/
3736

3837
Appcues.prototype.loaded = function() {
39-
return isObject(window.Appcues);
38+
return typeof window.Appcues === 'object' && window.Appcues != null;
4039
};
4140

4241
/**
@@ -90,6 +89,19 @@ Appcues.prototype.track = function(track) {
9089
window.Appcues.track(track.event(), track.properties());
9190
};
9291

92+
/**
93+
* Group.
94+
*
95+
* http://appcues.com/docs#group
96+
*
97+
* @api public
98+
* @param {Group} group
99+
*/
100+
101+
Appcues.prototype.group = function(group) {
102+
window.Appcues.group(group.groupId(), group.traits());
103+
};
104+
93105
/**
94106
* Expose plugin.
95107
*/

integrations/appcues/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-appcues",
33
"description": "The Appcues analytics.js integration.",
4-
"version": "2.2.1",
4+
"version": "2.3.0",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",
@@ -25,8 +25,7 @@
2525
},
2626
"dependencies": {
2727
"@segment/analytics.js-integration": "^2.1.0",
28-
"@segment/load-script": "^1.0.1",
29-
"isobject": "^2.1.0"
28+
"@segment/load-script": "^1.0.1"
3029
},
3130
"devDependencies": {
3231
"@segment/analytics.js-core": "^3.0.0",

integrations/appcues/test/index.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,19 @@ describe('Appcues', function() {
115115
});
116116
});
117117
});
118+
119+
describe('#group', function() {
120+
beforeEach(function() {
121+
analytics.stub(window.Appcues, 'group');
122+
});
123+
124+
it('should send an id and group name', function() {
125+
analytics.group('id', { groupName: 'group-1' });
126+
analytics.called(window.Appcues.group, 'id', {
127+
groupName: 'group-1',
128+
id: 'id'
129+
});
130+
});
131+
});
118132
});
119133
});

0 commit comments

Comments
 (0)