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

tnc Id System : fixes for docs and performance improvements #12315

Merged
merged 2 commits into from
Oct 20, 2024
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
8 changes: 3 additions & 5 deletions modules/tncIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ const waitTNCScript = (tncNS) => {
var tnc = window[tncNS];
if (!tnc) reject(new Error('No TNC Object'));
if (tnc.tncid) resolve(tnc.tncid);
tnc.ready(() => {
tnc = window[tncNS];
if (tnc.tncid) resolve(tnc.tncid);
else tnc.on('data-sent', () => resolve(tnc.tncid));
tnc.ready(async () => {
let tncid = await tnc.getTNCID('prebid');
resolve(tncid);
});
});
}
Expand All @@ -31,7 +30,6 @@ const tncCallback = function (cb) {
tncNS = '__tncPbjs';
promiseArray.push(loadRemoteScript());
}

return Promise.all(promiseArray).then(() => waitTNCScript(tncNS)).then(cb).catch(() => cb());
}

Expand Down
19 changes: 9 additions & 10 deletions modules/userId/userId.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,15 @@ pbjs.setConfig({
Example showing how to configure a `params` object to pass directly to bid adapters

```

pbjs.setConfig({
userSync: {
userIds: [{
name: 'tncId',
params: {
providerId: "c8549079-f149-4529-a34b-3fa91ef257d1"
}
}],
syncDelay: 5000
}
userSync: {
userIds: [{
name: 'tncId',
params: {
url: 'https://js.tncid.app/remote.min.js' //Optional
}
}],
syncDelay: 5000
}
});
```
14 changes: 5 additions & 9 deletions test/spec/modules/tncIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('TNCID tests', function () {
Object.defineProperty(window, '__tnc', {
value: {
ready: (readyFunc) => { readyFunc() },
on: (name, cb) => { cb() },
tncid: 'TNCID_TEST_ID_1',
providerId: 'TEST_PROVIDER_ID_1',
},
Expand All @@ -71,8 +70,8 @@ describe('TNCID tests', function () {
it('GDPR is OK and page has TNC script with ns: __tnc but not loaded, TNCID is assigned and returned', function () {
Object.defineProperty(window, '__tnc', {
value: {
ready: (readyFunc) => { readyFunc() },
on: (name, cb) => { cb() },
ready: async (readyFunc) => { await readyFunc() },
getTNCID: async (name) => { return 'TNCID_TEST_ID_1' },
providerId: 'TEST_PROVIDER_ID_1',
},
configurable: true
Expand All @@ -82,18 +81,15 @@ describe('TNCID tests', function () {
const {callback} = tncidSubModule.getId({}, { gdprApplies: false });

return callback(completeCallback).then(() => {
expect(completeCallback.calledOnceWithExactly(undefined)).to.be.true;
expect(completeCallback.calledOnceWithExactly('TNCID_TEST_ID_1')).to.be.true;
})
});

it('GDPR is OK and page has TNC script with ns: __tncPbjs, TNCID is returned', function () {
Object.defineProperty(window, '__tncPbjs', {
value: {
ready: (readyFunc) => { readyFunc() },
on: (name, cb) => {
window.__tncPbjs.tncid = 'TNCID_TEST_ID_2';
cb();
},
ready: async (readyFunc) => { await readyFunc() },
getTNCID: async (name) => { return 'TNCID_TEST_ID_2' },
providerId: 'TEST_PROVIDER_ID_1',
options: {},
},
Expand Down