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

consentManagement: "Cannot read property 'gdpr' of undefined" when not configuring consent module #5832

Closed
derdeka opened this issue Oct 7, 2020 · 3 comments · Fixed by #5873
Assignees
Labels

Comments

@derdeka
Copy link
Contributor

derdeka commented Oct 7, 2020

Type of issue

Bug

Description

I want to conditional enable or disable the consent module per publisher website via config but using the same prebid js file.
When including the consentModule but not setting a consentManagent config, the backward compatibility is throwing an exception:
image

Steps to reproduce

  • include consentModule in prebid build
  • do not include consentManagement config params

Expected results

No exception.

Actual results

consentManagement.js:454 Uncaught TypeError: Cannot read property 'gdpr' of undefined

Platform details

prebid.js 4.9.0

Suggested solution:

Swapping lines. Instead of:

// if `config.gdpr` or `config.usp` exist, assume new config format.
// else for backward compatability, just use `config`
config = config.gdpr || config.usp ? config.gdpr : config;
if (!config || typeof config !== 'object') {
utils.logWarn('consentManagement config not defined, exiting consent manager');
return;
}

do this:

  if (!config || typeof config !== 'object') {
    utils.logWarn('consentManagement config not defined, exiting consent manager');
    return;
  }
  // if `config.gdpr` or `config.usp` exist, assume new config format.
  // else for backward compatability, just use `config`
  config = config.gdpr || config.usp ? config.gdpr : config;
@Fawke Fawke self-assigned this Oct 8, 2020
@Fawke
Copy link
Contributor

Fawke commented Oct 8, 2020

Hi @derdeka,

I'm not able to reproduce your issue. I tried including the consentManagement module, but didn't include it in the call to pbjs.setConfig, but I didn't get the exception that you were talking about.

My configuration with consentManagement module included in the build:

pbjs.setConfig({
  consentManagement: {}
});

Were you trying something similar?

@derdeka
Copy link
Contributor Author

derdeka commented Oct 19, 2020

I currently doing something like this:

pbjs.setConfig({
  consentManagement: hasTcfCmp() ? {} : undefined,
});

@Fawke
Copy link
Contributor

Fawke commented Oct 19, 2020

@derdeka, Thanks for bringing this up, I think we should definitely swap those lines. This is a weird edge case which I think won't arise for many publishers because generally they don't include the consentManagement object itself in the config if they wanna disable consentManagement module.

Here's a page which lists cmp best practices which goes hand in hand with the usage of consentManagement module.

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.

2 participants