Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

CMP not found error

Open yieldlift opened this issue 6 years ago • 32 comments

Type of issue

bug, or maybe just a feature

Description

When prebid is loaded on the page where there is no CMP module present, we're getting an error:

"ERROR: CMP not found. Canceling auction as per consentManagement config"

Our consent management config allows auction to continue without consent or cmp module present gdpr: { cmpApi: 'iab', timeout: 8000, allowAuctionWithoutConsent: true }

Steps to reproduce

Described in previous section

Test page

We can provide one if needed

Expected results

Auction can continue if CMP module is not present

Actual results

Error message is shown and auction exits "ERROR: CMP not found. Canceling auction as per consentManagement config"

Platform details

prebid version: 4.2.0-pre

Other information

By looking at the consentManagement.js file this behaviour was introduced by the following change: http://prntscr.com/tuqwhz

yieldlift avatar Aug 05 '20 23:08 yieldlift

set defaultgdprscope

patmmccann avatar Aug 06 '20 16:08 patmmccann

thanks for the feedback @patmmccann , but setting defautGdprScope didnt solve it

gdpr: { cmpApi: 'iab', timeout: 3000, defaultGdprScope: true }

yieldlift avatar Aug 06 '20 19:08 yieldlift

@yieldlift - yes, we always need a test page

What is the scenario here?

If there's a CMP function present, PBJS expects it to respond otherwise it will cancel the auction. If there's not a CMP present, there should be no __tcfapi() function.

bretg avatar Aug 12 '20 18:08 bretg

@yieldlift I'm going to take a look at this, if you can provide a test page that would be very helpful.

GLStephen avatar Aug 12 '20 19:08 GLStephen

@GLStephen here is the test page: https://cdn1.opstag.com/test/index.html?widgetId=13341&pbjs_debug=true

prebid is initialized inside of an iframe, so you would have to go there to see the config, example: document.getElementById('csci-9361a68b70d8-a1c446b4-8b2751bc-9b2e1f74-957c41b8e0b47fdf').contentWindow.pbjs.getConfig()

yieldlift avatar Aug 18 '20 00:08 yieldlift

@yieldlift based on this test page I think the issues is related to what @bretg has mentioned and the following from @jsnellbaker

  1. the allowAuctionWithoutConsent field does not work for TCF2. This was a relatively recent change, around the time I think we were implementing the gdpr enforcement stuff.
  2. If they don’t have a CMP defined on the page, they should just remove the consentManagement config object from their setup. Without this config, it would bypass the module entirely when the auction is running.

Basically, it looks like your creating an invalid state in TCF2/PBJS 4.0 which is not including any CMP functionality but including CMP config. You need to align those two things.

GLStephen avatar Aug 25 '20 15:08 GLStephen

allowAuctionWithoutConsent was removed because it doesn't make sense in TCF2: use defaultGdprScope and enforcement flags instead to get the behavior you and your lawyers have defined.

bretg avatar Aug 25 '20 20:08 bretg

@GLStephen The previous 3.x version was handling it correctly if there is no cmp on the page and the auction proceeded without any issues. Why is the auction aborting if there is no cmp on the page in the 4.x version?

saileshd avatar Aug 28 '20 02:08 saileshd

I agree that we could consider refining the interface here -- if the CMP function doesn't exist at all, that could signal Prebid.js that it's not in GDPR scope -- consentManagement config with cmp: "iab" can be ignored.

Would like community input -- it's possible this weakens Prebid's enforcement regime, and a simple workaround would be to avoid calling setConfig when the function doesn't exist.

if (defined __tcfapi) {
   setConfig({consentManagement})
}

bretg avatar Aug 28 '20 03:08 bretg

@bretg this is how I worked around the issue. Is this the recommended way?

			var consentManagement = {};
			consentManagement.usp = {
				"cmpApi": "iab",
				"timeout": 10000
			};
			if (typeof __tcfapi === 'function') {
				consentManagement.gdpr = {
					"cmpApi": "iab",
					"timeout": 10000,
					"defaultGdprScope": true
				};
			}
			pbjs.setConfig({consentManagement});

saileshd avatar Aug 28 '20 18:08 saileshd

@saileshd this may result in no GDPR enforcement if the CMP just hasn't loaded yet

GLStephen avatar Aug 28 '20 21:08 GLStephen

@saileshd this will not work if the __tcfapi is defined in another window/iframe of the actual prebid code

giannoudak avatar Aug 31 '20 13:08 giannoudak

Ok, I stand corrected. The option of looking for tcfapi() has been removed from https://docs.prebid.org/dev-docs/cmp-best-practices.html

@yieldlift and @saileshd -- you're going to have to find a safe way with your specific CMP to determine whether it's active. Once you've confirmed a given approach with your CMP, we're willing to post the approach on the page to help other users. Of course its possible that CMP/Page integration can be done in multiple ways. Please work with your CMP vendor.

bretg avatar Sep 01 '20 19:09 bretg

Hello Guys, I don't have __tcfapi method defined in my code so the solution suggested by @saileshd here https://github.com/prebid/Prebid.js/issues/5572#issuecomment-683027246 Seems like unreachable code for GDPR settings. My previous settings, pbjs.setConfig({ consentManagement: { usp: { timeout: 8000 }, gdpr: { cmpApi: 'iab', timeout: 8000, allowAuctionWithoutConsent: false } } }); and it is not working with Prebid 4.6.0 . Can you please suggest me the solution.

tandalevaibhav avatar Sep 07 '20 13:09 tandalevaibhav

@saileshd Can you please tell me, Which solution you applied?

tandalevaibhav avatar Sep 08 '20 16:09 tandalevaibhav

Adding my answer to this question -- I was coming up with the same error whilst testing the new Prebid v4.

We also had the allowAuctionWithoutConsent: true flag to allow auctions on v3 if no consent existed, but was trying to create the same behaviour for v4.

As mentioned before, you should follow the advice given on this page: https://docs.prebid.org/dev-docs/cmp-best-practices.html

FYI -- I did not know about this page until I Googled this problem and found the link here.

@bretg can you please make a more prominent link on the sites sidebar for this page? As I believe it contains vital info for upgrading v3 -> v4 and config Prebid changes that were not mentioned in the Prebid blog release post.

@tandalevaibhav if you have consentManagement defined by default, then you may want to do that same approach as I opted for in the end.

If you don't have the CMP or TCF API loading on your non-GDPR pages, you can do something similar to @saileshd approach - mine is just the reverse:

var CMP_TIMEOUT = 8000;
var consentManagement = {
	gdpr: {
		cmpApi: 'iab',
		timeout: CMP_TIMEOUT,
		defaultGdprScope: true // TCF 2.0 & PBJS v4+
	},
	usp: {
		cmpApi: 'iab',
		timeout: CMP_TIMEOUT
	}
}

if (typeof __tcfapi !== 'function') {
	delete consentManagement.gdpr;
}

pbjs.setConfig({consentManagement})

Currently we have the TCF API loading on all countries - but this code works for both CMP and no-CMP pages. We always load our CMP before Prebid initialises and our CMP stub code contains the __tcfapi function, which makes it safe.

jsonUK avatar Sep 09 '20 15:09 jsonUK

From what I see in the code of the consentModule:

The cmpVersion is set to 0, and then when __tcf is found is set to 2, or when __cmp is found it is set to 1. When the timeout is hit, the cmpVersion should still be set to 0.

In the flow of cmpTimedOut -> cmpFailed and exitModule there are checks for when the cmpVersion is set to 1 to continue auctions without consent. This no longer works as the cmpVersion never changed from 0 when no consent provider was found.

So from what I see the current implementation of timeout,it only makes sense when the cmp/tcf does get loaded, but the callback for the consent data is delayed. It does not make sense when the CMP is loaded in too slow.

ReinoutStevens avatar Sep 10 '20 09:09 ReinoutStevens

bretg can you please make a more prominent link on the sites sidebar for this page? As I believe it contains vital info for upgrading v3 -> v4 and config Prebid changes that were not mentioned in the Prebid blog release post.

Place links in the left-nav and on the modules index page.

bretg avatar Sep 11 '20 16:09 bretg

So where are we with this issue.

the timeout does not make sense when the CMP is loaded in too slow.

Is there anything requested here -- code or documentation?

bretg avatar Sep 11 '20 16:09 bretg

From the documentation it was unclear that you can disable the consent module by removing the consent part from prebid's config.

To elaborate, in our setup we have users for which we load in a CMP, and other for which we dont. At first I was afraid I'd have to build two versions of prebid, one with and one without the consent module, and serve the correct version because I couldnt configure prebid what to do when a CMP was not found.

ReinoutStevens avatar Sep 11 '20 18:09 ReinoutStevens