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

Adagio Bid Adapter: external script loading improvement #9296

Closed
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
7 changes: 5 additions & 2 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const LOG_PREFIX = 'Adagio:';
const FEATURES_VERSION = '1';
export const ENDPOINT = 'https://mp.4dex.io/prebid';
const SUPPORTED_MEDIA_TYPES = [BANNER, NATIVE, VIDEO];
const ADAGIO_TAG_URL = 'https://script.4dex.io/localstore.js';
const ADAGIO_TAG_URL = 'https://script.4dex.io/adagio.js';
Copy link
Collaborator

Choose a reason for hiding this comment

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

please lock this to a version and update what is available in https://github.com/Prebid-org/prebid-js-external-js-adagio-io/tree/master/dist

Copy link
Collaborator Author

@osazos osazos Nov 29, 2022

Choose a reason for hiding this comment

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

Hi @patmmccann, we make regular updates, we can't lock to a version. We always work this way, is something changed?

update what is available in…

Do you want I make some cleanup?

Copy link
Collaborator

@patmmccann patmmccann Nov 29, 2022

Choose a reason for hiding this comment

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

please see #5804 ; as part of Prebid 5, Criteo locked their load to a version. Also, the private repo has unminified code.

const ADAGIO_CACHE_TAG_URL = 'https://script.4dex.io/localstore.js';
const ADAGIO_LOCALSTORAGE_KEY = 'adagioScript';
const GVLID = 617;
export const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE});
Expand Down Expand Up @@ -177,7 +178,7 @@ export function getAdagioScript() {

storage.localStorageIsEnabled(isValid => {
if (isValid) {
loadExternalScript(ADAGIO_TAG_URL, BIDDER_CODE);
loadExternalScript(ADAGIO_CACHE_TAG_URL, BIDDER_CODE);
} else {
// Try-catch to avoid error when 3rd party cookies is disabled (e.g. in privacy mode)
try {
Expand All @@ -191,6 +192,8 @@ export function getAdagioScript() {
} catch (e) {
logInfo(`${LOG_PREFIX} unable to clear Adagio scripts from localstorage.`);
}

loadExternalScript(ADAGIO_TAG_URL, BIDDER_CODE);
}
});
}
Expand Down
11 changes: 7 additions & 4 deletions test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,8 @@ describe('Adagio bid adapter', () => {
const VALID_SCRIPT_CONTENT = 'var _ADAGIO=function(){};(_ADAGIO)();\n';
const INVALID_SCRIPT_CONTENT = 'var _ADAGIO=function(){//corrupted};(_ADAGIO)();\n';
const ADAGIO_LOCALSTORAGE_KEY = 'adagioScript';
const ADAGIO_TAG_URL = 'https://script.4dex.io/adagio.js';
const ADAGIO_CACHE_TAG_URL = 'https://script.4dex.io/localstore.js';

beforeEach(function() {
localStorage.removeItem(ADAGIO_LOCALSTORAGE_KEY);
Expand All @@ -1538,18 +1540,20 @@ describe('Adagio bid adapter', () => {
sinon.assert.callCount(adagio.adagioScriptFromLocalStorageCb, 1);
});

it('should load external script if the user consent', function() {
it('should load localstore.js external script if the user consent', function() {
sandbox.stub(storage, 'localStorageIsEnabled').callsArgWith(0, true);
getAdagioScript();

expect(loadExternalScript.called).to.be.true;
sinon.assert.calledWith(loadExternalScript, ADAGIO_CACHE_TAG_URL);
});

it('should not load external script if the user does not consent', function() {
it('should load adagio.js external script if the user does not consent', function() {
sandbox.stub(storage, 'localStorageIsEnabled').callsArgWith(0, false);
getAdagioScript();

expect(loadExternalScript.called).to.be.false;
expect(loadExternalScript.called).to.be.true;
sinon.assert.calledWith(loadExternalScript, ADAGIO_TAG_URL);
});

it('should remove the localStorage key if exists and the user does not consent', function() {
Expand All @@ -1558,7 +1562,6 @@ describe('Adagio bid adapter', () => {

getAdagioScript();

expect(loadExternalScript.called).to.be.false;
expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null;
});
});
Expand Down