Skip to content

Commit

Permalink
Fix event firing on native click
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewlane committed Feb 26, 2019
1 parent b6c5644 commit d8685bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function fireNativeTrackers(message, adObject) {
}

(trackers || []).forEach(triggerPixel);
return message.action;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/secureCreatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ function receiveMessage(ev) {
// adId: '%%PATTERN:hb_adid%%'
// }), '*');
if (data.message === 'Prebid Native') {
fireNativeTrackers(data, adObject);
const trackerType = fireNativeTrackers(data, adObject);
if (trackerType === 'click') { return; }

auctionManager.addWinningBid(adObject);
events.emit(BID_WON, adObject);
}
Expand Down
3 changes: 2 additions & 1 deletion test/spec/native_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ describe('native.js', function () {
});

it('fires click trackers', function () {
fireNativeTrackers({ action: 'click' }, bid);
const trackerType = fireNativeTrackers({ action: 'click' }, bid);
expect(trackerType).to.equal('click');
sinon.assert.calledOnce(triggerPixelStub);
sinon.assert.calledWith(triggerPixelStub, bid.native.clickTrackers[0]);
});
Expand Down

0 comments on commit d8685bf

Please sign in to comment.