Google analytics limits you to ten metrics per query. This means if you need more you need to create a new class for your metrics.
For me the ability to specify the metrics and the dimensions in the parameters I pass in would be very handy as I can chunk the array and pass it to garb in a loop using each_slice.
Also this would clean up my app as I would only have one class for querying which contains my login information and some other setup.
I think that overall I tend to favor instance methods rather than class methods for this type of thing so I can set everything up (logging, credentials, etc) on the initialize and then rely on the base class to do the heavy lifting. For me this seems cleaner but I realize it's a preference thing.
Ideally it would look like this.
class MyGarb < Garb
def initialize
@logger = blah
@credentials =['username', 'password']
@defaults ={:start_date =>1.month.ago, :end_date => 1.day.ago, :limit => 1000, :offset => 1}
super
end
def log(level, str)
@logger level, str
end
Google analytics limits you to ten metrics per query. This means if you need more you need to create a new class for your metrics.
For me the ability to specify the metrics and the dimensions in the parameters I pass in would be very handy as I can chunk the array and pass it to garb in a loop using each_slice.
Also this would clean up my app as I would only have one class for querying which contains my login information and some other setup.
I think that overall I tend to favor instance methods rather than class methods for this type of thing so I can set everything up (logging, credentials, etc) on the initialize and then rely on the base class to do the heavy lifting. For me this seems cleaner but I realize it's a preference thing.
Ideally it would look like this.
class MyGarb < Garb def initialize @logger = blah @credentials =['username', 'password'] @defaults ={:start_date =>1.month.ago, :end_date => 1.day.ago, :limit => 1000, :offset => 1} super end def log(level, str) @logger level, str end
end
results = Mygarb.query :dimensions => [:date], :metrics => [:visits], :filters => [blah]