Skip to content

Commit c1d57c2

Browse files
committed
Add consent parameters to Start.io UID requests and update endpoints
1 parent 6679ba5 commit c1d57c2

3 files changed

Lines changed: 51 additions & 8 deletions

File tree

modules/startioSystem.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
* @module modules/startioSystem
55
* @requires module:modules/userId
66
*/
7-
import { logError } from '../src/utils.js';
7+
import { logError, formatQS } from '../src/utils.js';
88
import { submodule } from '../src/hook.js';
99
import { ajax } from '../src/ajax.js';
1010
import { getStorageManager } from '../src/storageManager.js';
1111
import { MODULE_TYPE_UID } from '../src/activities/modules.js';
12+
import { getUserSyncParams } from '../libraries/userSyncUtils/userSyncUtils.js';
1213

1314
const MODULE_NAME = 'startioId';
1415
const DEFAULT_ENDPOINT = 'https://cs.startappnetwork.com/get-uid-obj?p=m4b8b3y4';
@@ -49,7 +50,15 @@ function storeId(id, expiresInDays) {
4950
}
5051
}
5152

52-
function fetchIdFromServer(callback, expiresInDays) {
53+
function fetchIdFromServer(callback, expiresInDays, consentData) {
54+
const consentParams = getUserSyncParams(
55+
consentData?.gdpr,
56+
consentData?.usp,
57+
consentData?.gpp
58+
);
59+
const queryString = formatQS(consentParams);
60+
const url = queryString ? `${DEFAULT_ENDPOINT}&${queryString}` : DEFAULT_ENDPOINT;
61+
5362
const callbacks = {
5463
success: response => {
5564
let responseId;
@@ -71,7 +80,7 @@ function fetchIdFromServer(callback, expiresInDays) {
7180
callback();
7281
}
7382
};
74-
ajax(DEFAULT_ENDPOINT, callbacks, undefined, { method: 'GET' });
83+
ajax(url, callbacks, undefined, { method: 'GET' });
7584
}
7685

7786
export const startioIdSubmodule = {
@@ -92,7 +101,7 @@ export const startioIdSubmodule = {
92101
}
93102
const storageConfig = config && config.storage;
94103
const expiresInDays = storageConfig && storageConfig.expires;
95-
return { callback: (cb) => fetchIdFromServer(cb, expiresInDays) };
104+
return { callback: (cb) => fetchIdFromServer(cb, expiresInDays, consentData) };
96105
},
97106

98107
eids: {

test/spec/modules/startioBidAdapter_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ describe('Prebid Adapter: Startio', function () {
461461
const syncs = spec.getUserSyncs({ iframeEnabled: true }, []);
462462

463463
expect(syncs).to.have.lengthOf(1);
464-
expect(syncs[0].url).to.equal('https://cs.startappnetwork.com/sync?p=1002');
464+
expect(syncs[0].url).to.equal('https://cs.startappnetwork.com/sync?p=m4b8b3y4');
465465
});
466466
});
467467
});

test/spec/modules/startioSystem_spec.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('StartIO ID System', function () {
4343
expect(startioIdSubmodule.eids).to.deep.equal({
4444
'startioId': {
4545
source: 'start.io',
46-
atype: 3
46+
atype: 1
4747
}
4848
});
4949
});
@@ -77,7 +77,7 @@ describe('StartIO ID System', function () {
7777
source: 'start.io',
7878
uids: [
7979
{
80-
atype: 3,
80+
atype: 1,
8181
id: TEST_UID
8282
}
8383
]
@@ -129,7 +129,7 @@ describe('StartIO ID System', function () {
129129

130130
const request = server.requests[0];
131131
expect(request.method).to.eq('GET');
132-
expect(request.url).to.eq('https://cs.startappnetwork.com/get-uid-obj?p=1002');
132+
expect(request.url).to.eq('https://cs.startappnetwork.com/get-uid-obj?p=m4b8b3y4');
133133

134134
const serverId = 'new-server-id-12345';
135135
request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ uid: serverId }));
@@ -138,6 +138,40 @@ describe('StartIO ID System', function () {
138138
expect(callbackSpy.lastCall.lastArg).to.equal(serverId);
139139
});
140140

141+
it('should append consent params to the request URL', function () {
142+
const consentData = {
143+
gdpr: {
144+
gdprApplies: true,
145+
consentString: 'TEST_CONSENT_STRING'
146+
},
147+
usp: '1YNN',
148+
gpp: {
149+
gppString: 'TEST_GPP_STRING',
150+
applicableSections: [7]
151+
}
152+
};
153+
154+
const callbackSpy = sinon.spy();
155+
const callback = startioIdSubmodule.getId(validConfig, consentData).callback;
156+
callback(callbackSpy);
157+
158+
const request = server.requests[0];
159+
expect(request.url).to.include('gdpr=1');
160+
expect(request.url).to.include('gdpr_consent=TEST_CONSENT_STRING');
161+
expect(request.url).to.include('us_privacy=1YNN');
162+
expect(request.url).to.include('gpp=TEST_GPP_STRING');
163+
expect(request.url).to.include('gpp_sid=7');
164+
});
165+
166+
it('should send request without consent params when consentData is absent', function () {
167+
const callbackSpy = sinon.spy();
168+
const callback = startioIdSubmodule.getId(validConfig).callback;
169+
callback(callbackSpy);
170+
171+
const request = server.requests[0];
172+
expect(request.url).to.eq('https://cs.startappnetwork.com/get-uid-obj?p=m4b8b3y4');
173+
});
174+
141175
it('should log error if server response is missing uid field', function () {
142176
const callbackSpy = sinon.spy();
143177
const callback = startioIdSubmodule.getId(validConfig).callback;

0 commit comments

Comments
 (0)