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

Duplicate bidWon event fired when native + universal-creative is used 🐛 #7526

Closed
gpolaert opened this issue Oct 1, 2021 · 2 comments · Fixed by #7543
Closed

Duplicate bidWon event fired when native + universal-creative is used 🐛 #7526

gpolaert opened this issue Oct 1, 2021 · 2 comments · Fixed by #7543
Labels

Comments

@gpolaert
Copy link
Contributor

gpolaert commented Oct 1, 2021

Type of issue

Issue (non-blocking)

Description

Duplicate bidWon event fired when the native and universal-creative render are used

Steps to reproduce

Set the following code

...
const pbNativeTagData = {};
pbNativeTagData.requestAllAssets = true;
pbNativeTagData.adId = 'somethingValid';
...
myIframe.contentWindow.pbNativeTag.renderNativeAd(pbNativeTagData);

Test page

Expected results

An array with the bid that have been rendered using =>pbjs. getAllWinningBids()

Actual results

An array with 2 time the same bid duplicated => pbjs. getAllWinningBids()

Platform details

Other information

This issue is due to the universal creative will post (postMessage) 2 events :

  • one the "allAssetRequest"
  • one for the "impression"

But it seems a return is missing in that code.
So the 2 messages fired a bidWon event.

I think the bug is true also when resizeNativeHeight occured too

https://github.com/prebid/Prebid.js/blob/master/src/secureCreatives.js#L54-L80

    // handle this script from native template in an ad server
    // window.parent.postMessage(JSON.stringify({
    //   message: 'Prebid Native',
    //   adId: '%%PATTERN:hb_adid%%'
    // }), '*');
    if (adObject && data.message === 'Prebid Native') {
      if (data.action === 'assetRequest') {
        const message = getAssetMessage(data, adObject);
        ev.source.postMessage(JSON.stringify(message), ev.origin);
        return;
      } else if (data.action === 'allAssetRequest') {
        const message = getAllAssetsMessage(data, adObject);
        ev.source.postMessage(JSON.stringify(message), ev.origin);
      } else if (data.action === 'resizeNativeHeight') {
        adObject.height = data.height;
        adObject.width = data.width;
        resizeRemoteCreative(adObject);
      }

      const trackerType = fireNativeTrackers(data, adObject);
      if (trackerType === 'click') { return; }

      auctionManager.addWinningBid(adObject);
      events.emit(BID_WON, adObject);
    }
  }
}```

@gpolaert
Copy link
Contributor Author

gpolaert commented Oct 1, 2021

I can do the PR if you want to. Just let me know if the bidWon event should be fired on when the "impression" event is caught

@FilipStamenkovic
Copy link
Contributor

@gpolaert Thanks for reporting this issue. I managed to replicate it. It's not only bidWon that is fired multiple times, also impression tracker is fired multiple times. I opened PR to fix the issue.

@gglas gglas added the bug label Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants