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

"accept" event triggered at start if accepted in the past #71

Open
sneko opened this issue Sep 10, 2020 · 2 comments
Open

"accept" event triggered at start if accepted in the past #71

sneko opened this issue Sep 10, 2020 · 2 comments
Labels

Comments

@sneko
Copy link

sneko commented Sep 10, 2020

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

@apertureless
Copy link
Owner

apertureless commented Sep 10, 2020

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.

@sneko
Copy link
Author

sneko commented Sep 10, 2020

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants