Skip to content

Commit dc3340b

Browse files
Han Kimhankim813
authored andcommitted
Reject any events missing userId
1 parent d4c29ff commit dc3340b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var Heap = module.exports = integration('Heap')
1414
.endpoint('https://heapanalytics.com/api')
1515
.channels(['server', 'mobile'])
1616
.ensure('settings.appId')
17+
.ensure('message.userId') // Heap drops all anonymous events anyway so no need to send without this
1718
.mapper(mapper)
1819
.retries(2);
1920

test/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,21 @@ describe('Heap', function () {
2525
.name('Heap')
2626
.endpoint('https://heapanalytics.com/api')
2727
.ensure('settings.appId')
28+
.ensure('message.userId')
2829
.channels(['mobile', 'server']);
2930
});
3031

3132
describe('.validate()', function () {
3233
it('should be invalid without appId', function () {
33-
test.invalid({}, {});
34+
test.invalid({ userId: 'han' }, {});
3435
});
3536

3637
it('should be valid with appId', function () {
37-
test.valid({}, settings);
38+
test.valid({ userId: 'han' }, settings);
39+
});
40+
41+
it('should be invalid if message does not contain userId', function() {
42+
test.invalid({}, settings);
3843
});
3944
});
4045

0 commit comments

Comments
 (0)