vue-cookie-law
vue-cookie-law copied to clipboard
"accept" event triggered at start if accepted in the past
vue & vue-cookie-law version
1.13.3
Hi,
I was loosing my hair because Google Analytics was listening 2 times to all my events... but I ended up finding that's cookieLaw component that triggers the @accept='...'
listener even if no click happened.
I mean:
- I'm new user, the cookie consent pops up
- I accept it by clicking, the
@accept
is triggered - If I refresh my page
- the
@accept
is also triggered immediately since I guess the component detects it has been accepted in the past (thanks to local storage)
I thought it would just trigger @accept
when there is a click, and in other case (initialization...), we wait for the component to be ready, and we use isAccepted()
, no?
Thank you,
cc @apertureless
EDIT: If that's the wanted behavior, it would be great to mention it in the docs https://github.com/apertureless/vue-cookie-law#events
Well, the event gets emitted in the mounted hook. https://github.com/apertureless/vue-cookie-law/blob/develop/src/components/CookieLaw.vue#L150-L152
However, I would consider this rather a bug. Because you are right, the accept
event should be only emitted on action.
I will rename the mounted one to accepted
so you have one event that gets emitted on component mounting and one on action. Because I think it is good to have one evenet that will tell you early on if a user accepted cookies previously. Especially if you are not using scoped slots, just the simple version.
The problem is that's a breaking change if people are relying on that.
If you decide to switch to accepted
event, when do you plan to release? Just to know if I workaround in the meantime?
Thank you for your work 👍