jkrall / analytical

Gem for managing multiple analytics services in your rails app.
MIT License
380 stars 92 forks source link

BUG: unitialized constant Analytical::Modules::Production #30

Closed redbar0n closed 12 years ago

redbar0n commented 12 years ago

Hey,

I discovered a really annoying bug when you create the analytical.yml file exactly according to the readme, like this:

production: google: key: UA-5555555-5 clicky: key: 55555

This will give the error:

uninitialized constant Analytical::Modules::Production

or

uninitialized constant Analytical::Modules::Kissmetrics

when calling the "analytical" helper from a controller or a view.

The error is resolved when removing the space before the API-keys, so the file looks like this:

production: google: key:UA-5555555-5 clicky: key:55555

This is a very annoying bug, since it's almost impossible to detect. I hope you're able to fix it soon.

PS: I would suggest to update the Readme in the meanwhile, so more people don't unnecessarily run into it by following the setup procedure there.

Cheers.

shiftb commented 12 years ago

The other way to fix is to add another environment setting (it can be empty):

development: production: {module}: ....

That seemed to fix it for me as well and actually handle environments correctly.

indirect commented 12 years ago

The actual bug here is that the gem is trying to use a module named Kissmetrics, but the module is named KissMetrics (note the difference in capitalization).

indirect commented 12 years ago

Sorry, should have added the solution: The solution is to capitalize your YAML keys exactly the same way the ruby modules are capitalized. Here's an example analytical.yml file.

production:
  KissMetrics:
    js_url_key: "//blah.cloudfront.net/abc.js"
development:
test:

At that point, maybe you should catch the NameError, tell the users they tried to configure something that doesn't exist, and give them a list of valid module names?

redbar0n commented 12 years ago

@indirect
Are you sure? Try to remove these two lines from your analytical.yml file, and see if it still works:

development:
test:

I'm suspecting it might be @shiftbs quick fix that is actually at work here.

indirect commented 12 years ago

Yes, I'm completely positive, because I wrote a patch that fixes it and submitted it as a pull request. :)

On Jan 27, 2012, at 2:07 AM, redbar0nreply@reply.github.com wrote:

@indirect
Are you sure? Try to remove these two lines from your analytical.yml file, and see if it still works:

development: test:

I'm suspecting it might be @shiftbs quick fix that is actually at work here.


Reply to this email directly or view it on GitHub: https://github.com/jkrall/analytical/issues/30#issuecomment-3684507

redbar0n commented 12 years ago

Ah, sweet. :-) It's still mysterious to me though how it worked for me when I removed the whitespaces, while having the same capitalization..