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

identityLinkIdSystem: include gpp in 3p envelope retrieval #10745

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions modules/identityLinkIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ajax } from '../src/ajax.js';
import { submodule } from '../src/hook.js';
import {getStorageManager} from '../src/storageManager.js';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';
import { gppDataHandler } from '../src/adapterManager.js';

const MODULE_NAME = 'identityLink';

Expand Down Expand Up @@ -59,12 +60,16 @@ export const identityLinkSubmodule = {
utils.logInfo('identityLink: Consent string is required to call envelope API.');
return;
}
const url = `https://api.rlcdn.com/api/identity/envelope?pid=${configParams.pid}${hasGdpr ? (tcfPolicyV2 ? '&ct=4&cv=' : '&ct=1&cv=') + gdprConsentString : ''}`;
const gppData = gppDataHandler.getConsentData();
const gppString = gppData && gppData.gppString ? gppData.gppString : false;
const gppSectionId = gppData && gppData.gppString && gppData.applicableSections.length > 0 && gppData.applicableSections[0] !== -1 ? gppData.applicableSections[0] : false;
const hasGpp = gppString && gppSectionId;
const url = `https://api.rlcdn.com/api/identity/envelope?pid=${configParams.pid}${hasGdpr ? (tcfPolicyV2 ? '&ct=4&cv=' : '&ct=1&cv=') + gdprConsentString : ''}${hasGpp ? '&gpp=' + gppString + '&gpp_sid=' + gppSectionId : ''}`;
let resp;
resp = function (callback) {
// Check ats during callback so it has a chance to initialise.
// If ats library is available, use it to retrieve envelope. If not use standard third party endpoint
if (window.ats) {
if (window.ats && window.ats.retrieveEnvelope) {
utils.logInfo('identityLink: ATS exists!');
window.ats.retrieveEnvelope(function (envelope) {
if (envelope) {
Expand Down
44 changes: 44 additions & 0 deletions test/spec/modules/identityLinkIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as utils from 'src/utils.js';
import {server} from 'test/mocks/xhr.js';
import {getCoreStorageManager} from '../../../src/storageManager.js';
import {stub} from 'sinon';
import { gppDataHandler } from '../../../src/adapterManager.js';

const storage = getCoreStorageManager();

Expand All @@ -20,6 +21,7 @@ function setTestEnvelopeCookie () {

describe('IdentityLinkId tests', function () {
let logErrorStub;
let gppConsentDataStub;

beforeEach(function () {
defaultConfigParams = { params: {pid: pid} };
Expand Down Expand Up @@ -112,6 +114,48 @@ describe('IdentityLinkId tests', function () {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should call the LiveRamp envelope endpoint with GPP consent string', function() {
gppConsentDataStub = sinon.stub(gppDataHandler, 'getConsentData');
gppConsentDataStub.returns({
ready: true,
gppString: 'DBABLA~BVVqAAAACqA.QA',
applicableSections: [7]
});
let callBackSpy = sinon.spy();
let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://api.rlcdn.com/api/identity/envelope?pid=14&gpp=DBABLA~BVVqAAAACqA.QA&gpp_sid=7');
request.respond(
200,
responseHeader,
JSON.stringify({})
);
expect(callBackSpy.calledOnce).to.be.true;
gppConsentDataStub.restore();
});

it('should NOT call the LiveRamp envelope endpoint if GPP applies but no consent string', function () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this says that the endpoint should NOT be called, but below on line 155 it seems to say it IS called. can you clarify for me, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we should change test description, so we should still call 3p endpoint if we do not have gpp consent string but we would just not attach to url that needs to be called. I will change description now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smenzer can you please take a look? Tnx

gppConsentDataStub = sinon.stub(gppDataHandler, 'getConsentData');
gppConsentDataStub.returns({
ready: true,
gppString: '',
applicableSections: [7]
});
let callBackSpy = sinon.spy();
let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://api.rlcdn.com/api/identity/envelope?pid=14');
request.respond(
200,
responseHeader,
JSON.stringify({})
);
expect(callBackSpy.calledOnce).to.be.true;
gppConsentDataStub.restore();
});

it('should not throw Uncaught TypeError when envelope endpoint returns empty response', function () {
let callBackSpy = sinon.spy();
let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback;
Expand Down