Skip to content

Commit

Permalink
resolve issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dLepetynskyiIntentiq committed Oct 6, 2024
1 parent bfe0b15 commit c2406da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
17 changes: 10 additions & 7 deletions modules/intentIqAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function initReadLsIds() {
}
}

function bidWon(args) {
function bidWon(args, isReportExternal) {
if (!iiqAnalyticsAnalyticsAdapter.initOptions.lsValueInitialized) { initLsValues(); }

if (isNaN(iiqAnalyticsAnalyticsAdapter.initOptions.partner) || iiqAnalyticsAnalyticsAdapter.initOptions.partner == -1) return;
Expand All @@ -144,20 +144,23 @@ function bidWon(args) {
}

if (iiqAnalyticsAnalyticsAdapter.initOptions.lsValueInitialized && !iiqAnalyticsAnalyticsAdapter.initOptions.lsIdsInitialized) { initReadLsIds(); }
if (!iiqAnalyticsAnalyticsAdapter.initOptions.manualReport) {
ajax(constructFullUrl(preparePayload(args, true)), undefined, null, { method: 'GET' });
if ((isReportExternal && iiqAnalyticsAnalyticsAdapter.initOptions.manualReport) || (!isReportExternal && !iiqAnalyticsAnalyticsAdapter.initOptions.manualReport)) {
ajax(constructFullUrl(preparePayload(args, true)), undefined, null, {method: 'GET'});
logInfo('IIQ ANALYTICS -> BID WON')
return true
return true;
}

}

function getRandom(start, end) {
return Math.floor((Math.random() * (end - start + 1)) + start);
}

const intentIqBidWon = { reportExternalWin: bidWon }
window.pbjs.intentIqBidWon = intentIqBidWon
function reportExternalWin(args) {
return bidWon(args, true)
}

const intentIqBidWon = { reportExternalWin: reportExternalWin }
window.intentIqAnalyticsAdapter = intentIqBidWon

export function preparePayload(data) {
let result = getDefaultDataObject();
Expand Down
10 changes: 8 additions & 2 deletions test/spec/modules/intentIqAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,14 @@ describe('IntentIQ tests all', function () {
events.emit(EVENTS.BID_WON, wonRequest);
expect(iiqAnalyticsAnalyticsAdapter.initOptions.currentGroup).to.equal('B');
expect(iiqAnalyticsAnalyticsAdapter.initOptions.fpid).to.be.not.null;
expect(window.pbjs.intentIqBidWon.reportExternalWin).to.be.a('function');
expect(window.pbjs.intentIqBidWon.reportExternalWin({cpm: 1, currency: 'USD'})).to.equal(true);
});

it('should handle reportExternalWin', function () {
iiqAnalyticsAnalyticsAdapter.initOptions.manualReport = true;
localStorage.setItem(FIRST_PARTY_KEY, '{"pcid":"testpcid", "group": "B"}');
localStorage.setItem(FIRST_PARTY_KEY + '_' + partner, '{"data":"testpcid"}');
expect(window.intentIqAnalyticsAdapter.reportExternalWin).to.be.a('function');
expect(window.intentIqAnalyticsAdapter.reportExternalWin({cpm: 1, currency: 'USD'})).to.equal(true);
});

it('should return window.location.href when window.self === window.top', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/intentIqIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ describe('IntentIQ tests', function () {
expect(savedClientHints).to.equal(handleClientHints(testClientHints));
});

it('should get firstPartyData', async () => {
it('should run callback from params', async () => {
let wasCallbackCalled = false
const callbackConfigParams = { params: { partner: partner,
pai: pai,
Expand Down

0 comments on commit c2406da

Please sign in to comment.