Socket
Book a DemoInstallSign in
Socket

umami-ruby

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

umami-ruby

0.1.3
bundlerRubygems
Version published
Maintainers
1
Created
Source

Umami Ruby

Gem Version

A Ruby wrapper for the Umami analytics API.

Installation

Add this line to your application's Gemfile:

gem 'umami-ruby'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install umami-ruby

Documentation

Full API documentation is available online or can be generated using YARD:

yard doc
yard server

Usage

Configuration

You can put this config in a handy location within your Rails project, like config/initializers/umami.rb

For self-hosted Umami instances:

# With username and password
Umami.configure do |config|
  config.uri_base = "https://your-umami-instance.com"
  config.credentials = {
    username: "your_username",
    password: "your_password"
  }
end

# Or with an access token
Umami.configure do |config|
  config.uri_base = "https://your-umami-instance.com"
  config.access_token = "your_access_token"
end

For Umami Cloud:

Umami.configure do |config|
  config.access_token = "your_api_key"
  # No need to specify uri_base for Umami Cloud
end

Using the Client

After configuration, you can use the client to interact with the Umami API:

client = Umami::Client.new

# Get all websites
websites = client.websites

# Get a specific website
website = client.website("website_id")

# Get website stats
stats = client.website_stats("website_id", { startAt: 1656679719687, endAt: 1656766119687 })

# Verify token
token_info = client.verify_token

Error Handling

The gem defines several custom error classes:

  • Umami::ConfigurationError: Raised for configuration-related issues.
  • Umami::AuthenticationError: Raised for authentication-related issues.
  • Umami::APIError: Raised for API request failures.

Logging

The gem uses a logger that can be configured:

Umami.logger.level = Logger::DEBUG

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rameerez/umami-ruby. Our code of conduct is: just be nice and make your mom proud of what you do and post online.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 25 Jul 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.