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

Access values of the config #108

Closed
OndraM opened this issue Nov 20, 2021 · 1 comment · Fixed by #113
Closed

Access values of the config #108

OndraM opened this issue Nov 20, 2021 · 1 comment · Fixed by #113
Labels
enhancement New feature or request
Milestone

Comments

@OndraM
Copy link
Contributor

OndraM commented Nov 20, 2021

Hi,
would be possible to add a way how to read values of the _config after the plugin was initialized? Or would you accept pull request implementing this?

For example - for analytics purposes, we would like to track the language in which user gave consent. However if the language autodetection is enabled, the language is resolved internally in the plugin, and there doesn't seems to be a way how to get the actual resolved value of the current_lang.

I was thinking about something like:

const config = cookieconsent.get('config');
console.log(config.current_lang);

// or to not confuse with `get` which is used for reading  the cookie data
const config = cookieconsent.getConfig();

We would also possibly have an use case for reading other values of the config, not only current_lang.

There would obviously needs to be only a "get" method for the config, as it could be set only on initialization.

@orestbida orestbida added the enhancement New feature or request label Nov 20, 2021
@orestbida
Copy link
Owner

I think we should go with .getConfig(). A PR is very welcome!

@orestbida orestbida added this to the v2.7 milestone Nov 20, 2021
OndraM added a commit to OndraM/cookieconsent that referenced this issue Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants