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

Set up ahoy app #104

Open
furilo opened this issue Feb 18, 2015 · 6 comments
Open

Set up ahoy app #104

furilo opened this issue Feb 18, 2015 · 6 comments

Comments

@furilo
Copy link
Member

furilo commented Feb 18, 2015

Repo: https://github.com/TrackDons/web-analytics

Things:

  <script type="text/javascript" src="http://localhost:4000/ahoy.js"></script>
  <script>
    ahoy.trackAll();
  </script>
  • When loading TrackDons, I get a CORS error:
XMLHttpRequest cannot load http://localhost:4000/ahoy/events. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 404.

Any hint @ferblape ?

@nobuti
Copy link
Contributor

nobuti commented Feb 19, 2015

Could you try adding Access-Control-Request-Method in the header? Something like this:

headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'GET, POST, PATCH, PUT, DELETE, OPTIONS, HEAD'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
headers['Access-Control-Max-Age'] = '86400'

I could not try it, I'm getting an error bootstrapping the analytics app when rake db:setup:

ArgumentError: Invalid route name, already in use: 'ahoy_engine'

@furilo
Copy link
Member Author

furilo commented Feb 19, 2015

Problem with routes, maybe its what I added in routes.rb which is not needed?

And that's one of the things I tried (although maybe incorrectly...)

@ferblape
Copy link

Sorry, I've never fighted against CORS. I'll take a look in the weekend!

On Thu, Feb 19, 2015 at 9:15 AM, Álvaro Ortiz [email protected]
wrote:

Problem with routes, maybe its what I added in routes.rb which is not
needed?

And that's one of the things I tried (although maybe incorrectly...)


Reply to this email directly or view it on GitHub
#104 (comment).

@ferblape
Copy link

I have fixed the issue in web-analytics repo, but I can't commit!

@furilo
Copy link
Member Author

furilo commented Feb 22, 2015

Now you can

@ferblape
Copy link

Thanks.

Now it worked for me. It looks like the OPTIONS route is mandatory, or at
least that's what I found in the internet.

I haven't had time to play with Ahoy, but it looks like is recording the
analytics, despite that is not tracing any request in the log of the
application!

On Sun, Feb 22, 2015 at 7:28 PM, Álvaro Ortiz [email protected]
wrote:

Now you can


Reply to this email directly or view it on GitHub
#104 (comment).

@furilo furilo mentioned this issue Mar 20, 2015
10 tasks
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