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

Yieldmo Synthetic Inventory Module: add new module #7537

Merged
merged 4 commits into from
Oct 20, 2021

Conversation

ym-abaranov
Copy link
Contributor

Type of change

  • Bugfix
  • Feature
  • New bidder adapter
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Does this change affect user-facing APIs or examples documented on http://prebid.org?
  • Other

New module. A link to a PR on docs repo here -- prebid/prebid.github.io#3322

@ym-abaranov ym-abaranov force-pushed the yieldmo_synthetic_inventory-module branch from a418a15 to e04dd0e Compare October 5, 2021 21:11
@ChrisHuie ChrisHuie requested a review from Fawke October 6, 2021 14:41
@ym-abaranov ym-abaranov force-pushed the yieldmo_synthetic_inventory-module branch from 44e1738 to 228b42a Compare October 8, 2021 17:47
return;
}
isEnabled = true;
window.top.googletag = window.top.googletag || {cmd: []};
Copy link
Contributor

Choose a reason for hiding this comment

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

@ym-abaranov If google tag is undefined then this module won't work and we should throw some error. In the above line 5 we should do the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@desidiver we are defining an instance of googletag and pushing a callback, so later when the GPT will be initialized it will work okay. I've also added required params validation, now it's throwing an err.

@ym-abaranov ym-abaranov force-pushed the yieldmo_synthetic_inventory-module branch 2 times, most recently from 56a9183 to 8af004d Compare October 12, 2021 19:05
@ChrisHuie ChrisHuie changed the title Yieldmo Synthetic Inventory Module Yieldmo Synthetic Inventory Module: add new module Oct 13, 2021
@desidiver
Copy link
Contributor

@Fawke any feedback on this PR? Thank you.

@ChrisHuie
Copy link
Collaborator

@desidiver it looks like this branch just needs to pull in recent commits to master to fix the errors. There was a linting error that briefly was merged before I could fix it and that must have been the master branch at the time of this pr. We rewrote all utils imports to only use the needed functions a couple of weeks ago and a few prs were still out there that had a .utils root.

@ym-dlabuzov ym-dlabuzov force-pushed the yieldmo_synthetic_inventory-module branch from 8af004d to 7467024 Compare October 15, 2021 14:39
Copy link
Contributor

@Fawke Fawke left a comment

Choose a reason for hiding this comment

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

Hi @ym-abaranov,

The test coverage for this module is only 50%. Can you please make it at least 80% or more?

Also, I'm not sure about accessing googletag global object in the module. Adding @bretg for more clarification to see if we wanna allow it or not. Going through the Module Rules, I didn't find anything against this usage, but since I didn't find any other module accessing this object, I just want to confirm if this is allowed.

@Fawke Fawke requested a review from bretg October 18, 2021 11:20
@ym-dlabuzov
Copy link
Contributor

Hi @Fawke,
I've updated our tests, so now coverage should be > 85%

@bretg
Copy link
Collaborator

bretg commented Oct 18, 2021

There are lots of files in the modules directory that refer to googletag, so in general this is fine.

However, glancing briefly at how this module is doing it, doesn't seem consistent with others.

There's a utils function called isGptPubadsDefined. This could be useful.

For instance, the Rubicon Analytics Adapter has what seems like a good way to handle it. Here it is generalized a bit:

        if (!gptFlag && isGptPubadsDefined()) {
          // Can do special GPT stuff right now!
          gptFlag = true;
        } else if (!gptFlag) {
          gptFlag = true;
          window.googletag = window.googletag || {};
          window.googletag.cmd = window.googletag.cmd || [];
          window.googletag.cmd.push(function () {
            // Can do special GPT stuff once googletag is loaded.
          });
        }

Adding @harpere to weigh in on whether whether this module's implementation of googletag is ok. My gut feeling is that assigning window.top.googletag without first checking that it exists is a problem.

Sounds like this might be another thing that needs to be checked by reviewers, but first we need consensus on the right approach.

@bretg bretg requested review from harpere and removed request for bretg October 18, 2021 21:14
@bretg bretg assigned harpere and unassigned bretg Oct 18, 2021
@harpere
Copy link
Collaborator

harpere commented Oct 19, 2021

@bretg Assuming we're ok with the module accessing GPT, I think the way it's being done is fine. If googletag already exists, this line reassigns it to itself. So only if it doesn't already exist does it assign it to {cmd: []}.

window.top.googletag = window.top.googletag || {cmd: []};

After that, all references to googletag are encapsulated in

googletag.cmd.push(() => {
    // some googletag code
});

So won't be executed until GPT has loaded, and will be executed immediately if it already has.

@ym-dlabuzov ym-dlabuzov force-pushed the yieldmo_synthetic_inventory-module branch from 6751fd0 to e083f86 Compare October 19, 2021 15:40
@ym-dlabuzov ym-dlabuzov force-pushed the yieldmo_synthetic_inventory-module branch from e083f86 to 7a9c720 Compare October 19, 2021 16:02
@ym-dlabuzov
Copy link
Contributor

ym-dlabuzov commented Oct 19, 2021

@Fawke, @bretg I've updated PR, so we are now using isGptPubadsDefined().
However, I don't know why 3rd party test is failing (locally tests are passed for me). Maybe rerunning the build will fix it.

@Fawke Fawke added the LGTM label Oct 20, 2021
@Fawke Fawke merged commit 12a6c7f into prebid:master Oct 20, 2021
cpabst pushed a commit to sovrn/Prebid.js that referenced this pull request Jan 10, 2022
* Yieldmo Synthetic Inventory Module: initial commit

* Updating Documentation

* Test coverage improved

* Fixes after PR (using isGptPubadsDefined and window.googletag instead of window.top.googletag)

Co-authored-by: Nayan <nsavla@yieldmo.com>
Co-authored-by: Dmitriy Labuzov <dlabuzov@yieldmo.com>
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.

7 participants