beyonk-group / gdpr-cookie-consent-banner

A GDPR compliant cookie consent banner implementation
MIT License
251 stars 42 forks source link

Add consent agreement status to events #67

Open silllli opened 5 months ago

silllli commented 5 months ago

This PR adds the agreed status (true or false) to both the component and window consent events. It enables to check whether consent was given or rejected. If a user changes their mind and updates their settings after their initial decision, it’s now possible to act accordingly (and disable analytics tools without reloading the page for example).

It implies a breaking change, since the events will now be fired agreed to or not. Existing code needs to be updated by adding a check for event.detail.agreed. Using the same event as before is more elegant than adding a completely new event with a different naming logic in my opinion (which would be necessary since the original event simply uses its consent type as name).

Closes #63