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 compliance #11351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

osazos
Copy link
Collaborator

@osazos osazos commented Apr 16, 2024

Type of change

  • Other

Description of change

This PR aims to align Adagio with the Prebid.js standards as requested in #10038 and #10653.

Note that we still have to load our script in a matter of simplicity for our clients. The changes that are done should fit the community requirements especially the fact that we don't use Function() to load the cached version of script in localStorage.

@patmmccann I would really appreciate your feedback before opening it for reviewing and write the public doc.

@osazos osazos marked this pull request as ready for review April 17, 2024 06:51
@osazos osazos force-pushed the adagio-feature/external-script branch from 9712247 to 7efe65c Compare April 17, 2024 13:04
- lock version
- remove loading from localStorage (eval() fn)
@osazos osazos force-pushed the adagio-feature/external-script branch from 7efe65c to 29b6e6e Compare April 18, 2024 08:56
@patmmccann patmmccann assigned patmmccann and unassigned patmmccann Apr 18, 2024
@patmmccann patmmccann self-requested a review April 18, 2024 15:14
@patmmccann patmmccann self-assigned this Apr 18, 2024
Copy link
Collaborator

@robertrmartinez robertrmartinez left a comment

Choose a reason for hiding this comment

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

This looks good besides this one point:

I think the "turning off adagio script load" won't work as expected because the time that the script is loaded is going to occur before the on page code to set bidderSettings will not be there yet.

initAdagio() occurs when the module is loaded.

Which will happen before pbjs.processQueue() is called.

Which if a pub wanted to turn it off, pbjs.bidderSettings.adagio.scriptVersion = 'none', it would likely occur inside of a pbjs.que function block.

There are probably ways around this

  • putting pbjs.bidderSettings.adagio.scriptVersion = 'none' outside of the queue block before prebid loads will probably work

But I wanted to mention this as I would imagine putting the bidderSettings logic inside of a queue block would be the usual way this is done.

Also, not related to this PR, but accessing the storage handler this early during module LOAD time has the same effect.
storage.getDataFromLocalStorage('adagio' ....

We have not given the publisher enough time to wait for pbjs.setConfig's, pbjs.bidderSettings, etc to occur.

This is a more widespread issue I think in many adapters, something to talk about perhaps!

Though, I may be totally wrong and this is handled as expected haha.

@patmmccann
Copy link
Collaborator

we still have to load our script

Are you saying you won't bid if your external script doesnt run?

- `storageAllowed`: Adagio uses browser local storage, explicit access to it must be configured _(since Prebid.js 7.x)_
- `scriptVersion`: Adagio loads an additional script used for measurement. By default the adapter loads a specific version of this script, defined in the adapter itself. Two values can override this behavior:
- `latest`: allow to always get the more recent version of the script
- `none`: deactivates the feature, no script is loaded
Copy link
Collaborator

Choose a reason for hiding this comment

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

please make this the default

utilsMock.expects('logInfo').withExactArgs('Adagio: start script').never();
utilsMock.expects('logWarn').withExactArgs('Adagio: no hash found.').once();
utilsMock.expects('logWarn').withExactArgs('Adagio: invalid script found.').never();
it('loads the latest external script, bypass the lock version', function() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure i'm comfortable with this, we'll need to talk in committee

}

const url = computeAdagioScriptUrl(adagiojsVersion);
loadExternalScript(url, BIDDER_CODE, undefined, undefined, { id: `adagiojs-${getUniqueIdentifierStr()}`, version: adagiojsVersion });
Copy link
Collaborator

Choose a reason for hiding this comment

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

we'll need to discuss if we're going to let a bidder do this, likely we will not, as that was the initial plan. Why not distribute your sidecar script independently of prebid or make it another module?

@patmmccann patmmccann linked an issue Apr 18, 2024 that may be closed by this pull request
@osazos
Copy link
Collaborator Author

osazos commented Apr 19, 2024

Thank you both for the prompt feedback.

This pull request serves as an initial step in addressing this issue rather than attempting to impose a solution.

@patmmccann, we want to avoid requesting our clients to add a script tag, as we perceive it as additional effort for both parties and a significant change in our way of doing.
Since #10653 appears to focus solely on the bidder adapter, could you confirm if relocating the loading of the external script to an RTD module would be acceptable? This appears to be a common practice to use loadExternalScript() in RTD modules.

@robertrmartinez, I understand now. My tests yielded false positives, and I mistakenly believed that the storageManager functions waited for Prebid.js to be fully ready, this is not the case. The behavior is de-facto not compatible with the way we need to load the external script.

@patmmccann
Copy link
Collaborator

patmmccann commented Apr 19, 2024

Loading your script in RTD is absolutely reasonable and encouraged, RTD modules are exempted from the no script rule and publishers understand they may do such activity

@osazos
Copy link
Collaborator Author

osazos commented Apr 22, 2024

Great @patmmccann, we are currently working on a RTD module. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adagio Bid Adapter: update to current standards
3 participants