Skip to content

v0.3.4

Compare
Choose a tag to compare
@tg666 tg666 released this 05 Jan 21:11
· 100 commits to main since this release

❗ Possible BC break if you are using an event CookieConsentWrapper.on('init', ...)

Removed

  • Removed argument wrapper for an event init. Callbacks for the event now have no arguments now, please use directly CookieConsentWrapper inside a callback function.

Why?

Internally event callbacks are stored in a "temporary" CookieConsentWrapper object if the wrapper is not currently available e.g. the script cookie-consent.min.js is not fully downloaded by a browser but you attaching some event callback.
At this point, the GTM can't provide the argument wrapper into your callback because Template's code is sandboxed JavaScript, and custom objects like CookieConsentWrapper instance are not supported by this sandbox so undefined is passed as the argument instead of the wrapper.

How to modify your events

Simply call the wrapper directly inside a callback function. So instead of this:

CookieConsentWrapper.on('init', function (wrapper) {
    # the wrapper argument is now undefined
    wrapper.unwrap();
});

Use this:

CookieConsentWrapper.on('init', function () {
    CookieConsentWrapper.unwrap();
});