sija / garb Goto Github PK
View Code? Open in Web Editor NEWA Ruby wrapper for the Google Analytics API
Home Page: http://sija.github.io/garb/
License: MIT License
A Ruby wrapper for the Google Analytics API
Home Page: http://sija.github.io/garb/
License: MIT License
Hi Sija
I'm a beginner in RoR development and like to use your version of the garb gem. But I struggle at the user login. Do you have a little sample app in rails to share with a rails-newbie?
KR, Fabian
I am on the 0.9.1 version of the gem and I have disabled 2-Step Verification. I checked the gem files and api_key isnt isnt a attribute for Garb::Session in version(I think its only needed if I have 2-Step verification enabled). Can you please let me know what am I missing.
Garb::Session.login("<my email>", "<mypwd>")
returns Garb::AuthenticationRequest::AuthError, below is the log
Garb::AuthenticationRequest::AuthError: Garb::AuthenticationRequest::AuthError
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.1/lib/garb/authentication_request.rb:37:in `block in send_request'
from /home/alok/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/http.rb:1322:in `block (2 levels) in transport_request'
from /home/alok/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/http.rb:2671:in `reading_body'
from /home/alok/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/http.rb:1321:in `block in transport_request'
from /home/alok/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
from /home/alok/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
from /home/alok/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/http.rb:1293:in `request'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
from /home/alok/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
from /home/alok/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/http.rb:745:in `start'
from /home/alok/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.1/lib/garb/authentication_request.rb:36:in `send_request'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.1/lib/garb/authentication_request.rb:49:in `auth_token'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.1/lib/garb/session.rb:10:in `login'
from (irb):12
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.19/lib/rails/commands/console.rb:47:in `start'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.19/lib/rails/commands/console.rb:8:in `start'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.19/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'irb(main):013:0>
As the updated readme says that the ClientLogin, AuthSub and OAuth 1.0 shutdown scheduled for April 20, 2015. The password and the username is correct.The Garb is now unable to authenticate to the servers of google. This is what I get
when I execute the command :
Garb::Session.login('[email protected]', 'password')
Garb::Request::Authentication::AuthError: Garb::Request::Authentication::AuthError
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bundler/gems/garb-86e1bc667477/lib/garb/request/authentication.rb:39:in `block in send_request'
Are there any workarounds?
I'm having a hard time getting data from Google using an OAuth authorized token. I have the following:
Garb::Session.access_token = current_user.google_api_token
raise Garb::Management::Account.all.to_yaml
I'm aware improvements could be made all over the place, but that aside I'm getting some pretty unexpected result:
undefined method `get' for "ya29.AHES6ZSGqK4BMwuvzQvYCK5JG1Y...":String
I'm getting the feeling I'm doing something wrong here but I can't figure out what. I have looked at both the source and the code but that's not helping. The curent_user.google_api_token
I generate using omniauth-google-oauth2
. Help would be greatly appreciated!
When we use the GA dashboard and see results they are sampled. We fetch results via Garb from a GA profile for a certain date range as follows:
class Downloads
extend Garb::Model
metrics :totalEvents
dimensions :eventAction, :eventLabel, :eventCategory, :date
end
downloads = Downloads.results(<profile id of view in GA>, start_date: Date.civil(2015,8,10), end_date: Date.today, offset: 1, limit: 800)
When I view the same data in GA profile from the dashboard I see the sampling message on top. The numbers fetched from Garb match the numbers in the CSV export for the same data range. Does this mean the data fetched via Garb is also sampled ?
I am querying data with filtering and metrics operators as mentioned above are not working. However equal and not equal are working fine. Can you help to take a look? thank you.
Is there a way to adjust the timeout value?
(e.g. the twitter gem does this with Twitter.connection_options = {:timeout => 50, :open_timeout => 20}
)
I am trying to filter the result set by date.
Exits.results(profile, :filters => [{:page_path.eql => '/',:start_date => '2012-12-09'}])
or
Exits.results(profile, :filters => [{:page_path.eql => '/'}, {:start_date => '2012-12-09'}])
but it gives me "Garb::BadRequestError: [400] Invalid Value" error.
can you please tell me why ?
When asking for 'goals' of a profile, if the parsed_response['items'] is nil (no goals for this profile) the following error is thrown:
undefined method map' for nil:NilClass -> lib/garb/management/goal.rb:14:in all'
In feed.rb, 'entries' method should be like:
parsed_response ? (parsed_response['items'] || []) : []
I switched to using instances of Garb::Session after reading this post by viget (http://viget.com/extend/google-analytics-api-with-ruby-and-garb-making-it-even-easier). After I switched from using global sessions though, my traffic report in the Google API console for my project dropped down to zero. I think it's cause in Garb::Request::Data, it only checks to see if the global session has an api_key, not also the session bundled with the profile. Could you change it to pass the api_key for the profile session?
Hello,
I'm trying to upgrade my application from an old version of Garb to your new fork since Google seems to have fully deprecated the version of the API that version is using. Unfortunately, I'm having trouble even getting started, and can't figure out why.
So far, I'm just trying to get a list of available accounts, but I get an "EOFError: end of file reader" when I try this. I suspect it's because of some setting in Google Anayltics, but I enabled the API over in the Google API Console. Is there some other step I'm missing?
>> require 'garb'
=> []
>> Garb.logger = Rails.logger
=> #<Logger:0x10bdab2e8 @logdev=#<Logger::LogDevice:0x10bdab220 @shift_age=nil, @filename=nil, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x10bdab1d0 @mon_count=0, @mon_owner=nil, @mon_waiting_queue=[], @mon_entering_queue=[]>, @dev=#<IO:0x10ba8caa8>, @shift_size=nil>, @formatter=#<Logger::SimpleFormatter:0x11479da00 @datetime_format=nil>, @default_formatter=#<Logger::Formatter:0x10bdab270 @datetime_format=nil>, @level=0, @progname=nil>
>> Garb::Session.login(USERNAME, PASSWORD)
# response hidden
>> Garb::Management::Account.all
Garb::Request -> /analytics/v3/management/accounts
EOFError: end of file reached
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:135:in `sysread'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/timeout.rb:67:in `timeout'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/timeout.rb:101:in `timeout'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:2028:in `read_status_line'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:2017:in `read_new'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1051:in `__request__'
from /Users/clifff/.rvm/gems/ree-1.8.7-2011.03@global/gems/rest-client-1.6.1/lib/restclient/net_http_ext.rb:17:in `request_without_newrelic_trace'
from /Users/clifff/.rvm/gems/ree-1.8.7-2011.03@app/gems/newrelic_rpm-3.5.3.25/lib/new_relic/agent/instrumentation/net.rb:22:in `request'
from /Users/clifff/.rvm/gems/ree-1.8.7-2011.03@app/gems/newrelic_rpm-3.5.3.25/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
from /Users/clifff/.rvm/gems/ree-1.8.7-2011.03@app/gems/newrelic_rpm-3.5.3.25/lib/new_relic/agent/instrumentation/net.rb:21:in `request'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:772:in `get'
from /Users/clifff/.rvm/gems/ree-1.8.7-2011.03@app/bundler/gems/garb-7441306ec592/lib/garb/request/data.rb:84:in `single_user_request'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:543:in `start'
from /Users/clifff/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:440:in `start'
from /Users/clifff/.rvm/gems/ree-1.8.7-2011.03@app/bundler/gems/garb-7441306ec592/lib/garb/request/data.rb:77:in `single_user_request'
Can I ask another simple parsing question?
I'm still not clear on how best to subset from the returned object of class Garb::ResultSet
. For instance, I'd like to query the results in the set that have page_path
= "some/path". I realize I can filter by path during the call, but I would rather make one API call and then pull the data out path by path, but my ruby-fu isn't up to scratch. Sorry if this is a basic ruby question, but not sure where to start since the return data appears to be of of a custom class.
(e.g. for the example shown in the readme, how would you construct the call so that instead of
data = Exits.results(profile, :filters => {:page_path.eql => '/'})
you could do
data = Exits.results(profile)
and then I'd like to do something like data[page_path = "/"]
, or whatever the subsetting syntax is that I cannot figure out. sorry for such a basic question and thanks so much.
Hi,
nice work!
... i think json should be replaced by multi_json or should be listed as dependency ...
LoadError: no such file to load -- json
from /home/leite/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /home/leite/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /home/leite/.rvm/gems/ruby-1.8.7-p352@tests/gems/garb-0.9.5/lib/garb.rb:12
from /home/leite/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60:in `gem_original_require'
from /home/leite/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60:in `require'
from (irb):4
I have version 1.7.7 of the json
gem installed;
gem list json
*** LOCAL GEMS ***
json (1.7.7, 1.7.6, 1.7.5, 1.7.3)
But when calling Garb, I get the warning
You are using an old or stdlib version of json gem
Please upgrade to the recent version by adding this to your Gemfile:
gem 'json', '~> 1.7.7'
Not sure what I have done wrong?
My script used to run without warnings until I updated my gems yesterday. I have pulled the latest version of garb from the repo as well and installed it, but the warning persists.
Hi,
I am using the Signet gem to get OAuth2 access token for a service account. We are using Garb to fetch data from GA and display more logically for our consumers. We have updated Garb gem version 0.9.8.
I tried the following
Garb::Session.access_token = access_token
Garb::Management::Profile.all
and I encountered the following error:
NoMethodError: undefined method `get' for #<String:0xcd585ac>
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/request/data.rb:94:in `oauth_user_request'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/request/data.rb:41:in `send_request'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/management/feed.rb:21:in `response'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/management/feed.rb:13:in `parsed_response'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/management/feed.rb:17:in `entries'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/management/profile.rb:14:in `all'
from (irb):16
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.19/lib/rails/commands/console.rb:47:in `start'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.19/lib/rails/commands/console.rb:8:in `start'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.19/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I think I am using it in a wrong way, I checked the docs and did not find anything related to fetching data by Authenticating by service accounts. I have verified from Google API playground the the access token I used is valid. Can you guide me as to what am I doing wrong ? Is it possible to do this via Garb (as I am not using Single User Login anymore as we need server to server interactions and using Service accounts is the only way.
Thanks,
Alok
Thanks for taking over/maintaining this excellent gem. Probably just a stupid ruby question (I don't know ruby well, only use it by necessity for Jekyll), but I don't see how to extract the results returned by a query.
I authenticate just fine, run a query such as
data = Exits.results(profile, :filters => {:page_path.eql => '/'}, :start_date => Chronic.parse("2011-01-01"))
And then try to get the number of pageviews, say. For some reason, data.first
is an "OpenStruct" but data.results is an "array" of length 1, and data[0]. I see that:
irb(main):098:0> data.results
=> [#<OpenStruct page_path="/", exits="3706", pageviews="10440">]
But I don't see how to get pageviews. Neither data.results["pageviews"]
nor data.first["pageviews"]
return anything.
Forgive me for my naivete on ruby arrays, hashes and openstructs; (I'm familiar mostly with C and R only). Thanks much for the help.
Hello, all.
Please help me.
I use Garb::Management::Profile.all.detect and error happend to below:
MultiJson::AdapterError (Did not recognize your adapter specification (193: %1 は有効な Win32 アプリケーションではありません。 - C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.8.1/lib/json/ext/parser.so).):
app/services/analytics_service.rb:26:in load_profile' app/controllers/users_controller.rb:13:in
show'
my environment is:
OS: windows 7 home premium 64bit
Ruby 2.0.0 64bit
load profile is defined below source:
require 'rubygems'
require 'garb'
require 'uri'
require 'active_support/time'
require 'yaml'
class AnalyticsService
def self.load_profile
#設定読み込み
f = File.open(File.join(Rails.root, 'app','services','conf.yml'))
conf_str = f.read
myconf = YAML.load(conf_str)
#先月の初め
# start_date = (1.month.ago Time.now).beginning_of_month
#先月の終わり
# end_date = (1.month.ago Time.now).end_of_month
# セッションログイン
Garb::Session.login(
myconf['ga']['google_id'],
myconf['ga']['google_pw']
)
# プロファイル情報の取得
profile = Garb::Management::Profile.all.detect { |p|
p.web_property_id == myconf['ga']['property_id']
p.id == myconf['ga']['profile_id']
}
end
# 指標とディメンションをGarb::Modelをextendしたクラスに定義
# class PageTitle
# extend Garb::Model
# metrics :pageviews
# dimensions :date
# end
# cond = {
# :start_date => start_date,
# :end_date => end_date,
# # :filters => { :page_path.contains => '^/items/' }
# }
# rs = PageTitle.results(profile, cond)
# p rs
# rs.each do |r|
# puts r.pageviews # ページビュー
# end
end
called load_profile method below source(controller)
class UsersController < ApplicationController
before_action :signed_in_user, only: [:index, :edit, :update, :destroy]
before_action :correct_user, only: [:edit, :update]
before_action :admin_user, only: :destroy
def index
@users = User.paginate(page: params[:page])
end
def show
@user = User.find(params[:id])
ga_profile = AnalyticsService.load_profile
cond = {
:start_date => '2012-12-05',
:end_date => '2013-01-05',
# :filters => { :page_path.contains => '^/items/' }
}
@data = AnalyticsServiceClass::PageTitle.results(ga_profile, cond)
end
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
sign_in @user
flash[:success] = "Welcome to the Sample App!"
redirect_to @user
else
render 'new'
end
end
def edit
end
def update
if @user.update_attributes(user_params)
flash[:success] = "Profile updated"
redirect_to @user
else
render 'edit'
end
end
def destroy
User.find(params[:id]).destroy
flash[:success] = "User destroyed."
redirect_to users_url
end
private
def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation)
end
# Before actions
def signed_in_user
unless signed_in?
store_location
redirect_to signin_url, notice: "Please sign in."
end
end
def correct_user
@user = User.find(params[:id])
redirect_to(root_path) unless current_user?(@user)
end
def admin_user
redirect_to(root_path) unless current_user.admin?
end
end
gemfile is below:
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.5'
gem 'pg', '0.15.1'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sprockets', '2.11.0'
gem 'bcrypt-ruby', '3.1.2'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'garb'
group :development, :test do
gem 'rspec-rails', '2.13.1'
gem 'guard-rspec', '2.5.0'
gem 'spork-rails', '4.0.0'
gem 'guard-spork', '1.5.0'
gem 'childprocess', '0.3.6'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.2.1'
end
gem 'sass-rails', '4.0.2'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'rails_12factor', '0.0.2'
end
Trying to get this to work with an OAuth2 access token i get this error.
NoMethodError: undefined method `entries' for #Garb::Management::Feed:0x0000012b32ba78
Does anyone know if this fork of Garb works with OAuth2?
Thanks!
I have an app hosted on AWS Elastic Beanstalk and it doesn't support pulling Gems from Git.
Yes, I know it sucks. But is what I have working for now. And version working on RubyGems is the outdated one https://rubygems.org/gems/garb
Thanks!
I'm querying for keywords that produce the most revenue from organic search. However, it returns many duplicate keywords each with different revenue amounts. It seems as if the data is being returned in "chunks" and not consolidating. When I run the same exact query in the google analytics query explorer, it does not return any duplicate keywords.
my query
Garb::Session.login(ENV['GA_USERNAME'], ENV['GA_PASSWORD'])
profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == ENV['GA_WEB_PROPERTY_ID']}
options = {
:start_date => (Date.today - 30),
:end_date => Date.today,
:dimensions => :keyword,
:metrics => :totalValue,
:filters => {
:medium.eql => 'organic'
},
:sort => '-totalValue'
}
report = ThisReport.results(profile, options)
I'm using garb gem to fetch my google analytics data..followed the wiki section for connecting to GA as
session = Garb::Session.new
Garb::Session.access_token = access_token
But not able to fetch access_token from oauth2 client as i'm unable to refresh the access_token.
Please somebody help me out
Hi, i can't connect and authorized.
I generated server key, paste api-key and nothing happens.
What data should be here Garb::Session.access_token =?????????????
Garb::Session.login('[email protected]', 'milkmilk')
Garb::Session.api_key = api-key
Garb::Session.access_token =access_token
profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == 'UA-XXXX-X'}
profile= Garb::Profile.all.first
report = Garb::Report.new(profile, {:metrics => [:visits]})
report.all
p "##" *1000
p report.all
puts profile.visits
Dependabot can't resolve your Ruby dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
Bundler::GemNotFound with message: Could not find gem 'jferris-mocha' in any of the gem sources listed in your Gemfile.
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
You can mention @dependabot in the comments below to contact the Dependabot team.
Hi,
We're using your gem in one of our projects and I was wondering why you're not pushing the latest versions of your gem to rubygems.org.
It's not very pretty to have to use the github
option in a Gemfile.
Thank you !
I tried to install this by inserting the following line into my gemfile & running bundle install, but no go.
gem 'garb', :git => 'git://github.com/Sija/garb.git'
I get this error:
Fetching git://github.com/Sija/garb.git
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/source.rb:582:in
': No such file or directory - git clone "git://github.com/Sija/garb.git" "C:/R
uby193/lib/ruby/gems/1.9.1/cache/bundler/git/garb-e842720de50ae026d8afe9526ed8e7
9cc2ed72b8" --bare --no-hardlinks (Errno::ENOENT)
At first I had vigetlabs's garb installed, but same error after removing that. No luck through gem install either.
I was able to clone this repository from git, but couldn't get it to install from source either. Something about lack of a gem file. Tried building it from the gemspec, and I get "Invalid gemspec in [garb.gemspec]: No such file or directory - git ls-files ERROR: Error loading gemspec. Aborting."
Is anyone else having this problem, or am I having a bizarre error on my end? And yes, I'm on Windows 7.
What should I do with the following error? Do I need to upgrade to use https://github.com/tpitale/legato?
Garb::ClientError: There was an internal error.
/home/ubuntu/.rvm/gems/ruby-2.1.5@yoolk_office/gems/garb-0.9.8/lib/garb/request/data.rb:59:in `handle_response'
/home/ubuntu/.rvm/gems/ruby-2.1.5@yoolk_office/gems/garb-0.9.8/lib/garb/request/data.rb:45:in `send_request'
/home/ubuntu/.rvm/gems/ruby-2.1.5@yoolk_office/gems/garb-0.9.8/lib/garb/management/feed.rb:21:in `response'
/home/ubuntu/.rvm/gems/ruby-2.1.5@yoolk_office/gems/garb-0.9.8/lib/garb/management/feed.rb:13:in `parsed_response'
/home/ubuntu/.rvm/gems/ruby-2.1.5@yoolk_office/gems/garb-0.9.8/lib/garb/management/feed.rb:17:in `entries'
Hi Sija!
Maybe this isn't an actual error and is something that i am doing wrong but I just can't get passed this error:
Garb::AuthError
I've set the Garb::Session.api_key as in the Google APi's Console that is in the Simple API Access.
Garb::Session.login(username, password) is the username and password the email and corresponding password to access the google analytics account?
I'm really new in rails and specially in google analytics so I'm a little bit lost here. If its nothing wrong with the gem can you point out what am I doing wrong? I tried to read the documentation but here:
https://developers.google.com/analytics/solutions/articles/hello-analytics-api there no option for rails and I followed the PHP.
Hi Sija,
I switched to your fork of garb because the main branch of the gem was attempting to access deprecated aspects of the Google Analytics API.
I switched by updating my Gemfile like this: gem 'garb', :git => 'https://github.com/Sija/garb.git'
Previously, with the main branch of the gem I could start and use my app just find. In fact, the only thing I couldn't do was see Vanity reports based on my Google Analytics data.
Now, however, when I try to start the app, I get the following error.
Do I have to change some other aspect of the app to use your fork of the gem?
Thanks,
Steven.
Rails server --debugger => Booting WEBrick => Rails 3.2.8 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Exiting /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/metric/google_analytics.rb:66:in
initialize': uninitialized constant Garb::Resource (NameError)
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/metric/google_analytics.rb:22:in new' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/metric/google_analytics.rb:22:in
google_analytics'
from /Users/steven/Dropbox/testivate/experiments/metrics/acquire.rb:3:in block in new_binding' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/metric/base.rb:30:in
instance_eval'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/metric/base.rb:30:in metric' from /Users/steven/Dropbox/testivate/experiments/metrics/acquire.rb:1:in
new_binding'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/metric/base.rb:103:in eval' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/metric/base.rb:103:in
block in load'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/metric/base.rb:101:in instance_eval' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/metric/base.rb:101:in
load'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/playground.rb:196:in block in metrics' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/playground.rb:195:in
each'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/playground.rb:195:in metrics' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/playground.rb:168:in
metric'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/ab_test.rb:126:in block in metrics' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/ab_test.rb:126:in
map'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/ab_test.rb:126:in metrics' from /Users/steven/Dropbox/testivate/experiments/oxford_comma.rb:4:in
block in new_binding'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/base.rb:21:in instance_eval' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/base.rb:21:in
define'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/ab_test.rb:502:in ab_test' from /Users/steven/Dropbox/testivate/experiments/oxford_comma.rb:1:in
new_binding'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/base.rb:53:in eval' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/base.rb:53:in
block in load'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/base.rb:51:in instance_eval' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/experiment/base.rb:51:in
load'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/playground.rb:141:in block in experiments' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/playground.rb:140:in
each'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/playground.rb:140:in experiments' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/playground.rb:159:in
load!'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/vanity-1.8.0/lib/vanity/frameworks/rails.rb:10:in block in load!' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:34:in
call'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:34:in execute_hook' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:43:in
block in run_load_hooks'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in each' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in
run_load_hooks'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application/finisher.rb:59:in block in <module:Finisher>' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:30:in
instance_exec'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:30:in run' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:55:in
block in run_initializers'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:54:in each' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:54:in
run_initializers'
from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application.rb:136:in initialize!' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in
method_missing'
from /Users/steven/Dropbox/testivate/config/environment.rb:6:in <top (required)>' from /Users/steven/Dropbox/testivate/config.ru:4:in
block in
instance_eval' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:51:in
initialize'new' from /Users/steven/Dropbox/testivate/config.ru:1:in
'eval' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:40:in
parse_file'app' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/server.rb:46:in
app'wrapped_app' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/server.rb:252:in
start'start' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:55:in
block in <top (required)>'tap' from /Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:50:in
<top (required)>'require' from script/rails:6:in
'`I have more than 1000 profiles but Garb::Management::Profile.all return only 1000 profiles.
Authentication works just fine following your README when I use your gem locally, but authentication fails when I attempt to deploy from Travis CI. The key, username, and password are correct but for some reason Google detects this as a possible intrusion and blocks access anyway. Following Google's directions about logging in and permitting access through my local machine doesn't help.
Have you seen this done or have any idea how to handle this case? I've encrypted my API key, username, password, etc with the standard travis mechanism and verified that they are interpreted correctly on travis CI. Perhaps Google just wants to prevent this kind of access?
My ruby script is here, as a jekyll plugin. Thanks for your help or any suggestions on how to work around this!
Thank you so much for maintaining garb!
I can't figure out what I'm always getting 400. This is my model:
class G2
extend Garb::Model
metrics :pageviews
end
and this is my call:
G2.results(profile, :filters => {:pageviews.gte=>3})
and I get this:
Garb::BadRequestError: [400] Invalid Value : https://www.googleapis.com/analytics/v3/data/ga?ids=ga:XXXXXXXX&start-date=2013-01-07&end-date=2013-02-06&metrics=ga:pageviews&filters=ga:pageviews%3E%3D3
If I don't include the :filters symbol, then the request will be successful. I tested this query using the GA Query Tool and it works.
Any thing I have missed?
Hey,
I am the original creator and maintainer of Garb. I worked on it for over 3 years. 1ec223d
I was hoping you wouldn't mind adding me at least as a contributor in the README.
It would also be really nice if you would add a link and a mention that I've rewritten Garb as Legato, and continue to maintain it with new features. https://github.com/tpitale/legato
Obviously, not everyone can transition, but it would be great if people knew that I was still working on this problem in some form. 😄
Thanks much,
Tony Pitale
I am able to fetch Google Analytics profiles from one of the account but I have another account which don't have any profiles so in that case when I try to fetch the profiles then it throws an exception.
How can I check whether account has any profiles or not?
Thanks,
Nidhi Sarvaiya
I've tried...
:filters => {:keyword.eql => 'keywordA|keywordB'}
I've also tried the regex from this post: http://stackoverflow.com/questions/11966535/and-or-filter-in-ruby-on-rails
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.