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

documentReady function triggers start before configuring ahoy #56

Closed
jcamejo opened this issue Jul 16, 2020 · 4 comments
Closed

documentReady function triggers start before configuring ahoy #56

jcamejo opened this issue Jul 16, 2020 · 4 comments

Comments

@jcamejo
Copy link

jcamejo commented Jul 16, 2020

Hi! first of all thanks for this useful tool.

I was having some troubles finding out why on the first page load, visitsUrl was pointing to the default URL 'ahoy/visits' and not the one I set up with the configure method. I find out that the issue is related to the documentReady function call at the end of library source code.

  documentReady(function() {
    if (config.startOnReady) {
      ahoy.start();
    }
  });

  return ahoy;

The problem is synchronization, by the time the library module is required, is very likely that the DOM content has already been loaded, calling the documentReady function with the default parameters that are inside the library source code (where startOnReady. is set to true, mine is set to false). Due to some requirements I'm using require.js that is being loaded after the HTML body tag and it's difficult for me to change this.

I writing this issue also as a reminder, I will like to make a pull request offering an alternative solution when i have some time. I can just change the default config object, but it would be better if it supports my use case.

Let me know what you think or if there's another step or solution that I'm missing.

Thanks!

@nabilfreeman
Copy link

nabilfreeman commented Aug 26, 2020

Hi, also having this problem, pretty silly that the library boots and ignores its own config options. Currently debugging even more issues.

I fixed it by changing the default startOnReady to be false in the local file. Not sure what the best fix is here to keep that automatic booting but also allow people to switch functionality on/off.

@ankane
Copy link
Owner

ankane commented Oct 6, 2020

Hey @jcamejo and @nabilfreeman, which version of Ahoy.js are you on? This should be addressed in #45.

@jcamejo
Copy link
Author

jcamejo commented Mar 5, 2021

Hi @ankane the version was 0.3.7. I will check the issue again by updating the library and let you know if this is still a problem.

Sorry for the delayed answer

@ankane ankane closed this as completed Jul 7, 2021
@nabilfreeman
Copy link

Thanks for the fix!! We are still using Ahoy and finding it very useful 🥳

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

No branches or pull requests

3 participants