diff --git a/modules/id5IdSystem.js b/modules/id5IdSystem.js index e12aea5f8d1..5ed12d8def2 100644 --- a/modules/id5IdSystem.js +++ b/modules/id5IdSystem.js @@ -19,7 +19,7 @@ import {ajax} from '../src/ajax.js'; import {submodule} from '../src/hook.js'; import {getRefererInfo} from '../src/refererDetection.js'; import {getStorageManager} from '../src/storageManager.js'; -import {uspDataHandler} from '../src/adapterManager.js'; +import {uspDataHandler, gppDataHandler} from '../src/adapterManager.js'; import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'id5Id'; @@ -118,7 +118,7 @@ export const id5IdSubmodule = { } const resp = function (cbFunction) { - new IdFetchFlow(submoduleConfig, consentData, cacheIdObj, uspDataHandler.getConsentData()).execute() + new IdFetchFlow(submoduleConfig, consentData, cacheIdObj, uspDataHandler.getConsentData(), gppDataHandler.getConsentData()).execute() .then(response => { cbFunction(response) }) @@ -170,11 +170,12 @@ export const id5IdSubmodule = { }; class IdFetchFlow { - constructor(submoduleConfig, gdprConsentData, cacheIdObj, usPrivacyData) { + constructor(submoduleConfig, gdprConsentData, cacheIdObj, usPrivacyData, gppData) { this.submoduleConfig = submoduleConfig this.gdprConsentData = gdprConsentData this.cacheIdObj = cacheIdObj this.usPrivacyData = usPrivacyData + this.gppData = gppData } execute() { @@ -285,6 +286,11 @@ class IdFetchFlow { if (this.usPrivacyData !== undefined && !isEmpty(this.usPrivacyData) && !isEmptyStr(this.usPrivacyData)) { data.us_privacy = this.usPrivacyData; } + if (this.gppData) { + data.gpp_string = this.gppData.gppString; + data.gpp_sid = this.gppData.applicableSections; + } + if (signature !== undefined && !isEmptyStr(signature)) { data.s = signature; } diff --git a/test/spec/modules/id5IdSystem_spec.js b/test/spec/modules/id5IdSystem_spec.js index 56b23ba9634..d3d91db010d 100644 --- a/test/spec/modules/id5IdSystem_spec.js +++ b/test/spec/modules/id5IdSystem_spec.js @@ -15,7 +15,7 @@ import {config} from 'src/config.js'; import * as events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; import * as utils from 'src/utils.js'; -import {uspDataHandler} from 'src/adapterManager.js'; +import {uspDataHandler, gppDataHandler} from 'src/adapterManager.js'; import 'src/prebid.js'; import {hook} from '../../../src/hook.js'; import {mockGdprConsent} from '../../helpers/consentData.js'; @@ -259,12 +259,14 @@ describe('ID5 ID System', function () { describe('Xhr Requests from getId()', function () { const responseHeader = HEADERS_CONTENT_TYPE_JSON + let gppStub beforeEach(function () { }); afterEach(function () { uspDataHandler.reset() + gppStub?.restore() }); it('should call the ID5 server and handle a valid response', function () { @@ -730,6 +732,26 @@ describe('ID5 ID System', function () { }); }); + it('should pass gpp_string and gpp_sid to ID5 server', function () { + let xhrServerMock = new XhrServerMock(server) + gppStub = sinon.stub(gppDataHandler, 'getConsentData'); + gppStub.returns({ + ready: true, + gppString: 'GPP_STRING', + applicableSections: [2] + }); + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, ID5_STORED_OBJ); + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.gpp_string).is.equal('GPP_STRING'); + expect(requestBody.gpp_sid).contains(2); + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }); + }); + describe('when legacy cookies are set', () => { let sandbox; beforeEach(() => {