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

AzerionEdge RTD Module: Compatibility with GDPR/USP Privacy Modules #11775

Merged
merged 10 commits into from
Jul 6, 2024
16 changes: 13 additions & 3 deletions modules/azerionedgeRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const REAL_TIME_MODULE = 'realTimeData';
const SUBREAL_TIME_MODULE = 'azerionedge';
export const STORAGE_KEY = 'ht-pa-v1-a';

const IMPROVEDIGITAL_GVLID = '253';

export const storage = getStorageManager({
moduleType: MODULE_TYPE_RTD,
moduleName: SUBREAL_TIME_MODULE,
Expand All @@ -42,14 +44,21 @@ function getScriptURL(config) {
* Attach script tag to DOM
*
* @param {Object} config
* @param {Object} userConsent
*
* @return {void}
*/
export function attachScript(config) {
export function attachScript(config, userConsent) {
const script = getScriptURL(config);
loadExternalScript(script, SUBREAL_TIME_MODULE, () => {
if (typeof window.azerionPublisherAudiences === 'function') {
window.azerionPublisherAudiences(config.params?.process || {});
const publisherConfig = config.params?.process || {};
window.azerionPublisherAudiences({
...publisherConfig,
gdprApplies: userConsent?.gdpr?.gdprApplies,
gdprConsent: userConsent?.gdpr?.consentString,
uspConsent: userConsent?.usp,
});
}
});
}
Expand Down Expand Up @@ -106,7 +115,7 @@ export function setAudiencesToBidders(reqBidsConfigObj, config, audiences) {
* @return {boolean}
*/
function init(config, userConsent) {
attachScript(config);
attachScript(config, userConsent);
return true;
}

Expand Down Expand Up @@ -138,6 +147,7 @@ export const azerionedgeSubmodule = {
name: SUBREAL_TIME_MODULE,
init: init,
getBidRequestData: getBidRequestData,
gvlid: IMPROVEDIGITAL_GVLID,
};

submodule(REAL_TIME_MODULE, azerionedgeSubmodule);
17 changes: 0 additions & 17 deletions modules/azerionedgeRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,6 @@ provided to the module when the user gives the relevant permissions on the publi
As Prebid.js utilizes TCF vendor consent for the RTD module to load, the module needs to be labeled
within the Vendor Exceptions.

### Instructions

If the Prebid GDPR enforcement is enabled, the module should be labeled
as exception, as shown below:

```js
[
{
purpose: 'storage',
enforcePurpose: true,
enforceVendor: true,
vendorExceptions: ["azerionedge"]
},
...
]
```

## Testing

To view an example:
Expand Down
57 changes: 36 additions & 21 deletions test/spec/modules/azerionedgeRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ describe('Azerion Edge RTD submodule', function () {
{ id: '1', visits: 123 },
{ id: '2', visits: 456 },
];

const IMPROVEDIGITAL_GVLID = '253';
const key = 'publisher123';
const bidders = ['appnexus', 'improvedigital'];
const process = { key: 'value' };
const dataProvider = { name: 'azerionedge', waitForIt: true };
const userConsent = {gdpr: {gdprApplies: 'gdpr-applies', consentString: 'consent-string'}, usp: 'usp'};

const resetAll = () => {
window.azerionPublisherAudiences.resetHistory();
loadExternalScript.resetHistory();
}

let reqBidsConfigObj;
let storageStub;
Expand All @@ -33,7 +39,11 @@ describe('Azerion Edge RTD submodule', function () {
let returned;

beforeEach(function () {
returned = azerionedgeRTD.azerionedgeSubmodule.init(dataProvider);
returned = azerionedgeRTD.azerionedgeSubmodule.init(dataProvider, userConsent);
});

it('should have the correct gvlid', () => {
expect(azerionedgeRTD.azerionedgeSubmodule.gvlid).to.equal(IMPROVEDIGITAL_GVLID);
});

it('should return true', function () {
Expand All @@ -49,18 +59,21 @@ describe('Azerion Edge RTD submodule', function () {
expect(loadExternalScript.args[0][0]).to.deep.equal(expected);
});

it('should call azerionPublisherAudiencesStub with empty configuration', function () {
expect(window.azerionPublisherAudiences.args[0][0]).to.deep.equal({});
[
['gdprApplies', userConsent.gdpr.gdprApplies],
['gdprConsent', userConsent.gdpr.consentString],
['uspConsent', userConsent.usp],
].forEach(([key, value]) => {
it(`should call azerionPublisherAudiencesStub with ${key}:${value}`, function () {
expect(window.azerionPublisherAudiences.args[0][0]).to.include({[key]: value});
});
});

describe('with key', function () {
beforeEach(function () {
window.azerionPublisherAudiences.resetHistory();
loadExternalScript.resetHistory();
returned = azerionedgeRTD.azerionedgeSubmodule.init({
...dataProvider,
params: { key },
});
resetAll();
const config = { ...dataProvider, params: { key } };
returned = azerionedgeRTD.azerionedgeSubmodule.init(config, userConsent);
});

it('should return true', function () {
Expand All @@ -75,22 +88,24 @@ describe('Azerion Edge RTD submodule', function () {

describe('with process configuration', function () {
beforeEach(function () {
window.azerionPublisherAudiences.resetHistory();
loadExternalScript.resetHistory();
returned = azerionedgeRTD.azerionedgeSubmodule.init({
...dataProvider,
params: { process },
});
resetAll();
const config = { ...dataProvider, params: { process } };
returned = azerionedgeRTD.azerionedgeSubmodule.init(config, userConsent);
});

it('should return true', function () {
expect(returned).to.equal(true);
});

it('should call azerionPublisherAudiencesStub with process configuration', function () {
expect(window.azerionPublisherAudiences.args[0][0]).to.deep.equal(
process
);
[
['gdprApplies', userConsent.gdpr.gdprApplies],
['gdprConsent', userConsent.gdpr.consentString],
['uspConsent', userConsent.usp],
...Object.entries(process),
].forEach(([key, value]) => {
it(`should call azerionPublisherAudiencesStub with ${key}:${value}`, function () {
expect(window.azerionPublisherAudiences.args[0][0]).to.include({[key]: value});
});
});
});
});
Expand All @@ -111,7 +126,7 @@ describe('Azerion Edge RTD submodule', function () {
);
});

it('does not run apply audiences to bidders', function () {
it('does not apply audiences to bidders', function () {
expect(reqBidsConfigObj.ortb2Fragments.bidder).to.deep.equal({});
});

Expand Down