Skip to content

Commit

Permalink
AzerionEdge RTD Module: Compatibility with GDPR/USP Privacy Modules (p…
Browse files Browse the repository at this point in the history
…rebid#11775)

* Azerion Edge RTD Module: Initial release

### Type of change

[x] Feature: New RTD Submodule

### Description of change

Adds new Azerion Edge RTD module.

Maintainer: azerion.com

Contact: @garciapuig @mserrate @gguridi

* Azerion Edge RTD Module: Initial release. Typo

* AzerionEdge RTD Module: Documentation: Required parameters

Type of change:
Documentation/Feature

Description of change:
Specifying new required parameters on documentation.
Updating examples.

* AzerionEdge RTD Module: Compatible with GDPR/USP Privacy Modules (#14)

- Added GDPR validation.
- We validate against ImproveDigital vendor ID consent and several purposes.
- We don't load edge script, nor process the existing data, if consent wasn't given.
- Adding support for USP consent.

* AzerionEdgeRTDModule: Passing the consent to the script execution  (prebid#17)

Adding GVL ID to the module configuration
Passing the consent to the script execution instead of handling it in prebid (prebid#16)

---------
Co-authored-by: Gorka Guridi <gorka.guridi@azerion.com>

---------

Co-authored-by: Gorka Guridi <gorka.guridi@gmail.com>
  • Loading branch information
garciapuig and gguridi authored Jul 6, 2024
1 parent 4422d44 commit c30f105
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 41 deletions.
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

0 comments on commit c30f105

Please sign in to comment.