Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FID-251: Update Reconciliation RTD Provider to 2.1 #6037

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/21834411153/rsdk-2', [[300, 250], [728, 90]], 'div-gpt-ad-rsdk-1').addService(googletag.pubads());

googletag.defineSlot('/21834411153/rsdk-2', [[300, 250], [728, 90]], 'div-gpt-ad-rsdk-1')
.addService(googletag.pubads())
.setTargeting('RSDK_VER', '2.1');
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
Expand Down
27 changes: 2 additions & 25 deletions modules/reconciliationRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const MessageType = {
/** @type {ModuleParams} */
const DEFAULT_PARAMS = {
initUrl: 'https://confirm.fiduciadlt.com/init',
impressionUrl: 'https://confirm.fiduciadlt.com/imp',
impressionUrl: 'https://confirm.fiduciadlt.com/pimp',
allowAccess: false,
};
/** @type {ModuleParams} */
Expand Down Expand Up @@ -78,7 +78,7 @@ function handleAdMessage(e) {
adDeliveryId,
});

track.trackGet(_moduleParams.impressionUrl, args);
track.trackPost(_moduleParams.impressionUrl, args);

// Send response back to the Advertiser tag
let response = {
Expand Down Expand Up @@ -186,26 +186,6 @@ export function getSlotByWin(win) {
);
}

/**
* serialize object and return query params string
* @param {Object} data
* @return {string}
*/
export function stringify(query) {
const parts = [];

for (let key in query) {
if (query.hasOwnProperty(key)) {
let val = query[key];
if (typeof query[key] !== 'object') {
parts.push(`${key}=${encodeURIComponent(val)}`);
} else {
parts.push(`${key}=${encodeURIComponent(stringify(val))}`);
}
}
}
return parts.join('&');
}
/**
* Init Reconciliation post messages listeners to handle
* impressions messages from ad creative
Expand Down Expand Up @@ -236,9 +216,6 @@ function trackInit(adUnits) {
* @param {Object} data
*/
export const track = {
trackGet(url, data) {
utils.triggerPixel(`${url}?${stringify(data)}`);
},
trackPost(url, data) {
const ajax = ajaxBuilder();

Expand Down
66 changes: 29 additions & 37 deletions test/spec/modules/reconciliationRtdProvider_spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
reconciliationSubmodule,
track,
stringify,
getTopIFrameWin,
getSlotByWin
} from 'modules/reconciliationRtdProvider.js';
Expand All @@ -18,16 +17,14 @@ describe('Reconciliation Real time data submodule', function () {
}]
};

let trackPostStub, trackGetStub;
let trackPostStub;

beforeEach(function () {
trackPostStub = sinon.stub(track, 'trackPost');
trackGetStub = sinon.stub(track, 'trackGet');
});

afterEach(function () {
trackPostStub.restore();
trackGetStub.restore();
});

describe('reconciliationSubmodule', function () {
Expand Down Expand Up @@ -93,30 +90,6 @@ describe('Reconciliation Real time data submodule', function () {
});
});

describe('stringify parameters', function () {
it('should return query for flat object', function () {
const parameters = {
adUnitId: '/adunit',
adDeliveryId: '12345'
};

expect(stringify(parameters)).to.eql('adUnitId=%2Fadunit&adDeliveryId=12345');
});

it('should return query with nested parameters', function () {
const parameters = {
adUnitId: '/adunit',
adDeliveryId: '12345',
ext: {
adSize: '300x250',
adType: 'banner'
}
};

expect(stringify(parameters)).to.eql('adUnitId=%2Fadunit&adDeliveryId=12345&ext=adSize%3D300x250%26adType%3Dbanner');
});
});

describe('get topmost iframe', function () {
/**
* - top
Expand Down Expand Up @@ -206,21 +179,40 @@ describe('Reconciliation Real time data submodule', function () {
window.parent.postMessage(JSON.stringify({
type: 'rsdk:impression:req',
args: {
sourceMemberId: 'test_member_id',
sourceImpressionId: '123'
tagOwnerMemberId: "test_member_id",
dataSources: [
{
memberId: "member_test",
dataFeedName: "12345",
impressionId: "54321",
impressionIdDataField: "imp_id",
allowedRecipientTypes: 41
}
],
dataRecipients: [
{
type: 1,
memberId: "test_publisher_recipient"
},
{
type: 16,
memberId: "test_agency_recipient"
}
]
}
}), '*');
</script>`);
adSlotIframe.contentDocument.close();

setTimeout(() => {
expect(trackGetStub.calledOnce).to.be.true;
expect(trackGetStub.getCalls()[0].args[0]).to.eql('https://confirm.fiduciadlt.com/imp');
expect(trackGetStub.getCalls()[0].args[1].adUnitId).to.eql('/reconciliationAdunit');
expect(trackGetStub.getCalls()[0].args[1].adDeliveryId).to.eql('12345');
expect(trackGetStub.getCalls()[0].args[1].sourceMemberId).to.eql('test_member_id'); ;
expect(trackGetStub.getCalls()[0].args[1].sourceImpressionId).to.eql('123'); ;
expect(trackGetStub.getCalls()[0].args[1].publisherMemberId).to.eql('test_prebid_publisher');
expect(trackPostStub.calledOnce).to.be.true;
expect(trackPostStub.getCalls()[0].args[0]).to.eql('https://confirm.fiduciadlt.com/pimp');
expect(trackPostStub.getCalls()[0].args[1].adUnitId).to.eql('/reconciliationAdunit');
expect(trackPostStub.getCalls()[0].args[1].adDeliveryId).to.eql('12345');
expect(trackPostStub.getCalls()[0].args[1].tagOwnerMemberId).to.eql('test_member_id'); ;
expect(trackPostStub.getCalls()[0].args[1].dataSources.length).to.eql(1);
expect(trackPostStub.getCalls()[0].args[1].dataRecipients.length).to.eql(2);
expect(trackPostStub.getCalls()[0].args[1].publisherMemberId).to.eql('test_prebid_publisher');
done();
}, 100);
});
Expand Down