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

Yahoo ConnectId : gpp consent module usage. #10022

Merged
merged 1 commit into from
Jun 1, 2023
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
10 changes: 9 additions & 1 deletion modules/connectIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {includes} from '../src/polyfill.js';
import {getRefererInfo} from '../src/refererDetection.js';
import {getStorageManager} from '../src/storageManager.js';
import {formatQS, isPlainObject, logError, parseUrl} from '../src/utils.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 = 'connectId';
Expand Down Expand Up @@ -148,6 +148,14 @@ export const connectIdSubmodule = {
us_privacy: uspString
};

const gppConsent = gppDataHandler.getConsentData();
if (gppConsent) {
data.gpp = `${gppConsent.gppString ? gppConsent.gppString : ''}`;
if (Array.isArray(gppConsent.applicableSections)) {
data.gpp_sid = gppConsent.applicableSections.join(',');
}
}

let topmostLocation = getRefererInfo().topmostLocation;
if (typeof topmostLocation === 'string') {
data.url = topmostLocation.split('?')[0];
Expand Down
47 changes: 43 additions & 4 deletions test/spec/modules/connectIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {expect} from 'chai';
import {connectIdSubmodule, storage} from 'modules/connectIdSystem.js';
import {server} from '../../mocks/xhr';
import {parseQS, parseUrl} from 'src/utils.js';
import {uspDataHandler} from 'src/adapterManager.js';
import {uspDataHandler, gppDataHandler} from 'src/adapterManager.js';

const TEST_SERVER_URL = 'http://localhost:9876/';

Expand All @@ -14,6 +14,10 @@ describe('Yahoo ConnectID Submodule', () => {
const OVERRIDE_ENDPOINT = 'https://foo/bar';
const STORAGE_KEY = 'connectId';
const USP_DATA = '1YYY';
const GPP_DATA = {
gppString: 'gppconsent',
applicableSections: [6, 7]
};

it('should have the correct module name declared', () => {
expect(connectIdSubmodule.name).to.equal('connectId');
Expand All @@ -34,6 +38,7 @@ describe('Yahoo ConnectID Submodule', () => {
let localStorageEnabledStub;
let removeLocalStorageDataStub;
let uspConsentDataStub;
let gppConsentDataStub;

let consentData;
beforeEach(() => {
Expand All @@ -48,10 +53,12 @@ describe('Yahoo ConnectID Submodule', () => {
localStorageEnabledStub = sinon.stub(storage, 'localStorageIsEnabled');
removeLocalStorageDataStub = sinon.stub(storage, 'removeDataFromLocalStorage');
uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData');
gppConsentDataStub = sinon.stub(gppDataHandler, 'getConsentData');

cookiesEnabledStub.returns(true);
localStorageEnabledStub.returns(true);
uspConsentDataStub.returns(USP_DATA);
gppConsentDataStub.returns(GPP_DATA);

consentData = {
gdprApplies: 1,
Expand All @@ -69,6 +76,7 @@ describe('Yahoo ConnectID Submodule', () => {
localStorageEnabledStub.restore();
removeLocalStorageDataStub.restore();
uspConsentDataStub.restore();
gppConsentDataStub.restore();
});

function invokeGetIdAPI(configParams, consentData) {
Expand Down Expand Up @@ -284,7 +292,9 @@ describe('Yahoo ConnectID Submodule', () => {
gdpr_consent: consentData.consentString,
v: '1',
url: TEST_SERVER_URL,
us_privacy: USP_DATA
us_privacy: USP_DATA,
gpp: GPP_DATA.gppString,
gpp_sid: GPP_DATA.applicableSections.join(',')
};
const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]);

Expand All @@ -307,7 +317,9 @@ describe('Yahoo ConnectID Submodule', () => {
pixelId: PIXEL_ID,
gdpr_consent: consentData.consentString,
url: TEST_SERVER_URL,
us_privacy: USP_DATA
us_privacy: USP_DATA,
gpp: GPP_DATA.gppString,
gpp_sid: GPP_DATA.applicableSections.join(',')
};
const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]);

Expand All @@ -332,7 +344,9 @@ describe('Yahoo ConnectID Submodule', () => {
gdpr_consent: consentData.consentString,
v: '1',
url: TEST_SERVER_URL,
us_privacy: USP_DATA
us_privacy: USP_DATA,
gpp: GPP_DATA.gppString,
gpp_sid: GPP_DATA.applicableSections.join(',')
};
const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]);

Expand All @@ -347,6 +361,31 @@ describe('Yahoo ConnectID Submodule', () => {
endpoint: OVERRIDE_ENDPOINT
}, consentData);

const expectedParams = {
he: HASHED_EMAIL,
'1p': '0',
gdpr: '1',
gdpr_consent: consentData.consentString,
v: '1',
url: TEST_SERVER_URL,
us_privacy: USP_DATA,
gpp: GPP_DATA.gppString,
gpp_sid: GPP_DATA.applicableSections.join(',')
};
const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]);

expect(ajaxStub.firstCall.args[0].indexOf(`${OVERRIDE_ENDPOINT}?`)).to.equal(0);
expect(requestQueryParams).to.deep.equal(expectedParams);
expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true});
});

it('Makes an ajax GET request to the specified override API endpoint without GPP', () => {
gppConsentDataStub.returns(undefined);
invokeGetIdAPI({
he: HASHED_EMAIL,
endpoint: OVERRIDE_ENDPOINT
}, consentData);

const expectedParams = {
he: HASHED_EMAIL,
'1p': '0',
Expand Down