Make the gem work without ActiveRecord#195
Conversation
There was a problem hiding this comment.
👍 Looks like a good change to not rely on ActiveRecord.
@hrmtl - Have you tested that this works in an environment that does not have ActiveRecord ?
@goodviber - Could you review also please and what's your opinion on having a config item also to control sending db events ?
| return | ||
| end | ||
|
|
||
| if defined?(ActiveRecord) |
There was a problem hiding this comment.
We may want to introduce a config item, such as send_db_events to control this rather than just relying on ActiveRecord being present or not. TBD.
There was a problem hiding this comment.
I did try that but the gem code would throw an error while loading in the Rails app. I agree that a config item would be nice, but maybe we can do it as an improvement in the future.
There was a problem hiding this comment.
I got a NameError for ActiveRecord when starting the Rails server. I think that happened when the gem code was loaded before the config got read.
There was a problem hiding this comment.
@goodviber Thanks. I haven't tested it with an app running ActiveRecord. Does the test suite not cover that?
|
@asatwal Yes, I've tested it in the FABS Rails app which doesn't have ActiveRecord. I was able to successfully track web requests into BigQuery. |
|
@asatwal If you have CI setup here, can we run the test suite please? |
asatwal
left a comment
There was a problem hiding this comment.
👍 - Nice work. Looks good to me.
|
@asatwal Thanks! |
The
dfe-analyticsgem currently assumes the presence of a database andActiveRecordin any app that uses it.This PR adds a few modifications to allow the gem to work without a database.
The motivation for this came when we started to incorporate the gem into the GHBS FABS Rails app. Our app doesn't use a database. It uses Contentful CMS as its backend.
We only need the web requests tracking feature of
dfe-analytics.This PR makes the following modifications to allow the use of the gem without a database:
As per my discussion with @asatwal, there may be scope to do a bigger refactor to modularise all the AR-related code. However, I did not want to make any big changes with my first PR seeing as many projects are using this gem.
This PR does just enough to make the gem usable without AR. Any feedback or suggestions are welcome.