Skip to content

Commit c2a032a

Browse files
authored
Merge pull request Driftt#9 from Driftt/integration-options
send integration options to drift identify
2 parents 7587333 + 7774e6f commit c2a032a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ Drift.prototype.identify = function(identify) {
6969
if (!identify.userId()) return this.debug('user id required');
7070
var traits = identify.traits();
7171
var id = identify.userId();
72+
var integrationOptions = identify.options(this.name);
7273
delete traits.id;
73-
window.drift.identify(id, traits);
74+
window.drift.identify(id, traits, integrationOptions);
7475
this.identified = true;
7576
};
7677

test/index.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,41 @@ describe('Drift', function() {
8484
analytics.identify('id', { email: '[email protected]' });
8585
analytics.called(window.drift.identify, 'id', { email: '[email protected]' });
8686
});
87+
88+
it('should send id, traits and integration options', function() {
89+
analytics.identify(
90+
'id',
91+
{ email: '[email protected]' },
92+
{ drift: { signedIdentity: 'signedidentityjwt' } }
93+
);
94+
95+
analytics.called(
96+
window.drift.identify,
97+
'id',
98+
{ email: '[email protected]' },
99+
{ signedIdentity: 'signedidentityjwt' }
100+
);
101+
});
102+
103+
it('should send only integration options for drift', function() {
104+
analytics.identify(
105+
'id',
106+
{ email: '[email protected]' },
107+
{ otherintegration: { option: '123' }, drift: { option: 'test' } }
108+
);
109+
110+
analytics.called(window.drift.identify, 'id', { email: '[email protected]' }, { option: 'test' });
111+
});
112+
113+
it('should send empty object as integration options if they are undefined', function() {
114+
analytics.identify(
115+
'id',
116+
{ email: '[email protected]' },
117+
{ otherintegration: { option: '123' }, drift: undefined }
118+
);
119+
120+
analytics.called(window.drift.identify, 'id', { email: '[email protected]' }, {});
121+
});
87122
});
88123

89124
describe('#track', function() {

0 commit comments

Comments
 (0)