
Security News
Researcher Exposes Zero-Day Clickjacking Vulnerabilities in Major Password Managers
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
Google Analytics API wrapper.
It uses Oauth2 as authorization
Add this line to your application's Gemfile:
gem 'ariadna'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ariadna
Create a new connexion with your Oauth2 access token
analytics = Ariadna::Analytics.new(access_token)
Get a list of all accounts available
accounts = analytics.accounts.all
Get a list of all web properties available for an account
properties = accounts.first.properties.all
Get a list of all profiles available for a web property
profiles = properties.first.profiles.all
Create a query with metrics and dimensions
results = profile.results.select(
:metrics => [:visits, :bounces, :timeOnSite],
:dimensions => [:country]
)
.where(
:start_date => Date.today,
:end_date => 2.months.ago,
:browser => "==Firefox"
)
.limit(100)
.offset(40)
.order([:visits, :bounces])
.all
All the metrics and dimensions returned by the query are mapped into attributes.
results.each do |result|
puts result.visits
puts result.bounces
puts result.timeOnSite
puts result.country
end
Ariadna::Analytics.new(access_token, proxy_settings, refresh_token_data)
There are three possible params:
access_token (mandatory): an oauth2 access token
proxy_settings (optional): a hash containing your proxy options
refresh_token_data (optional): a hash with information about your app so access_token can be renewed automatically in case it is expired.
analytics = Ariadna::Analytics.new(
access_token,
{ proxy_host: 'proxy.yourproxy.com',
proxy_port: 8080,
proxy_user: 'username',
proxy_pass: 'password'
},
# Google access tokens are short term so chances are you are going to need to refresh them
{ refresh_token: analytics_refresh_token,
client_id: 'apps.googleusercontent.com',
client_secret: 'client_secret',
current_user: current_user
}
)
Ariadna is agnostic about the way you get your Oauth2 access token.
For the development of this gem I've been using Omiauth with the Google Oauth2 strategy
gem 'omniauth'
gem 'omniauth-google-oauth2'
Google Oauth2 tokens have a very short life. To make things easy if the connexion gives a 401 error and there is a refresh token passed as a param Ariadna will try to get a new access token from Google and store it in the current user info calling update_access_token_from_google. If you want to use this feature you must create a method in your user model that saves this token.
def update_access_token_from_google(new_token)
update_attribute(:google_oauth2_token, new_token)
end
It is obviously out of the scope of this gem to update tokens but it is definetly something that will make your life easier.
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that ariadna demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.