nhsuk / cookie-consent

In-house solution for managing cookies on nhs.uk
MIT License
19 stars 7 forks source link

Config for disabling Splunk logging at run time #99

Open chrimesdev opened 4 years ago

chrimesdev commented 4 years ago

We need the ability to disable Splunk logging when consuming the banner in applications. If the application is not on the nhs.uk domain there are console errors when the banner is interacted with.

Screenshot 2020-06-21 at 14 05 50

Mike's comment on this issue shows that the logging URL is hard-coded which is specific to nhs.uk only.

https://github.com/nhsuk/cookie-consent#script-options

There is a config for disabling/enabling at build time but nothing at run time.

mikemonteith commented 4 years ago

Also, the logging URL is hard-coded to a specific NHS url, making this less usable for others: https://github.com/nhsuk/cookie-consent/blob/bd1fb2b4f564880542ddeea84c4af0bc879317a9/src/cookieconsent.js#L180

mikemonteith commented 4 years ago

Maybe there should be a config option more like LOGGING_URL which can be set to any URL

Spencerooni commented 3 years ago

I've just came across this too. Perhaps a slightly different scenario.

I’m referencing the nhs uk analytics cookie script for testing as per the example repo of implementing adobe analytics. I've got everything working but there’s an error in the console where it seems to communicate whether you’ve seen the cookie banner (and then when you've accepted cookies) to nhs.uk.

Access to XMLHttpRequest at 'https://www.nhs.uk/our-policies/cookies-policy/?policy-action=seen' from origin 'https://localhost:5012' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

It makes sense as our app is not hosted on nhs.uk (and in my case above I'm just running locally). It would be nice to be able to supply a test url in window.NHSUK_SETTINGS as per some other settings or an alternative to turn this call off when not in production.