umami-ruby 0.1.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.test +9 -0
- data/.simplecov +36 -0
- data/CHANGELOG.md +94 -1
- data/CLAUDE.md +45 -0
- data/README.md +396 -25
- data/Rakefile +10 -1
- data/context7.json +4 -0
- data/docs/Umami/APIError.html +2 -2
- data/docs/Umami/AuthenticationError.html +2 -2
- data/docs/Umami/Client.html +11047 -1855
- data/docs/Umami/ClientError.html +2 -2
- data/docs/Umami/Configuration.html +401 -81
- data/docs/Umami/ConfigurationError.html +2 -2
- data/docs/Umami/Error.html +2 -2
- data/docs/Umami/NotFoundError.html +2 -2
- data/docs/Umami/ServerError.html +2 -2
- data/docs/Umami.html +3 -3
- data/docs/_index.html +2 -2
- data/docs/file.CHANGELOG.html +117 -3
- data/docs/file.LICENSE.html +2 -2
- data/docs/file.README.html +465 -30
- data/docs/index.html +465 -30
- data/docs/method_list.html +395 -19
- data/docs/top-level-namespace.html +2 -2
- data/lib/umami/client.rb +1023 -192
- data/lib/umami/configuration.rb +62 -0
- data/lib/umami/errors.rb +10 -3
- data/lib/umami/version.rb +1 -1
- metadata +7 -62
data/lib/umami/configuration.rb
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
1
|
module Umami
|
|
2
|
+
# Configuration class for the Umami client.
|
|
3
|
+
#
|
|
4
|
+
# @example Configure for Umami Cloud
|
|
5
|
+
# Umami.configure do |config|
|
|
6
|
+
# config.access_token = "your_api_key"
|
|
7
|
+
# end
|
|
8
|
+
#
|
|
9
|
+
# @example Configure for self-hosted with access token
|
|
10
|
+
# Umami.configure do |config|
|
|
11
|
+
# config.uri_base = "https://your-umami-instance.com"
|
|
12
|
+
# config.access_token = "your_access_token"
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# @example Configure for self-hosted with credentials
|
|
16
|
+
# Umami.configure do |config|
|
|
17
|
+
# config.uri_base = "https://your-umami-instance.com"
|
|
18
|
+
# config.credentials = { username: "user", password: "pass" }
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# @example Configure with custom timeout
|
|
22
|
+
# Umami.configure do |config|
|
|
23
|
+
# config.access_token = "your_api_key"
|
|
24
|
+
# config.request_timeout = 60 # 60 seconds instead of default 120
|
|
25
|
+
# end
|
|
2
26
|
class Configuration
|
|
27
|
+
# Base URL for Umami Cloud API (used for most API calls)
|
|
28
|
+
# @return [String]
|
|
3
29
|
UMAMI_CLOUD_URL = "https://api.umami.is".freeze
|
|
4
30
|
|
|
31
|
+
# Base URL for Umami Cloud send endpoint (used only for send_event)
|
|
32
|
+
# @note The send endpoint uses a different base URL than other API calls
|
|
33
|
+
# @return [String]
|
|
34
|
+
UMAMI_CLOUD_SEND_URL = "https://cloud.umami.is".freeze
|
|
35
|
+
|
|
36
|
+
# @!attribute [rw] uri_base
|
|
37
|
+
# @return [String, nil] Base URL for the Umami API
|
|
38
|
+
# @!attribute [rw] request_timeout
|
|
39
|
+
# @return [Integer] Request timeout in seconds (default: 120)
|
|
40
|
+
# @!attribute [rw] access_token
|
|
41
|
+
# @return [String, nil] Access token for API authentication
|
|
42
|
+
# @!attribute [r] username
|
|
43
|
+
# @return [String, nil] Username for self-hosted authentication (set via credentials=)
|
|
44
|
+
# @!attribute [r] password
|
|
45
|
+
# @return [String, nil] Password for self-hosted authentication (set via credentials=)
|
|
5
46
|
attr_reader :uri_base, :request_timeout, :access_token, :username, :password
|
|
6
47
|
|
|
48
|
+
# Initialize a new Configuration with default values
|
|
7
49
|
def initialize
|
|
8
50
|
@uri_base = nil
|
|
9
51
|
@request_timeout = 120
|
|
@@ -13,11 +55,16 @@ module Umami
|
|
|
13
55
|
@dirty = false
|
|
14
56
|
end
|
|
15
57
|
|
|
58
|
+
# Set the base URI for the Umami API
|
|
59
|
+
# @param url [String] The base URL (trailing slash will be removed)
|
|
16
60
|
def uri_base=(url)
|
|
17
61
|
@uri_base = url&.chomp('/')
|
|
18
62
|
@dirty = true
|
|
19
63
|
end
|
|
20
64
|
|
|
65
|
+
# Set the access token for API authentication
|
|
66
|
+
# @note Setting an access token clears any username/password credentials
|
|
67
|
+
# @param token [String] The access token
|
|
21
68
|
def access_token=(token)
|
|
22
69
|
@access_token = token
|
|
23
70
|
@username = nil
|
|
@@ -25,6 +72,10 @@ module Umami
|
|
|
25
72
|
@dirty = true
|
|
26
73
|
end
|
|
27
74
|
|
|
75
|
+
# Set username/password credentials for self-hosted authentication
|
|
76
|
+
# @note Setting credentials clears any access token
|
|
77
|
+
# @param creds [Hash] Credentials hash with :username and :password keys
|
|
78
|
+
# @raise [Umami::ConfigurationError] if username or password is missing
|
|
28
79
|
def credentials=(creds)
|
|
29
80
|
raise Umami::ConfigurationError, "Both username and password are required" unless creds[:username] && creds[:password]
|
|
30
81
|
|
|
@@ -34,10 +85,21 @@ module Umami
|
|
|
34
85
|
@dirty = true
|
|
35
86
|
end
|
|
36
87
|
|
|
88
|
+
# Set the request timeout in seconds
|
|
89
|
+
# @param timeout [Integer] Timeout in seconds
|
|
90
|
+
def request_timeout=(timeout)
|
|
91
|
+
@request_timeout = timeout
|
|
92
|
+
@dirty = true
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Check if configured for Umami Cloud
|
|
96
|
+
# @return [Boolean] true if using Umami Cloud (access token without custom URI)
|
|
37
97
|
def cloud?
|
|
38
98
|
@access_token && @uri_base.nil?
|
|
39
99
|
end
|
|
40
100
|
|
|
101
|
+
# Validate the configuration and apply defaults
|
|
102
|
+
# @raise [Umami::ConfigurationError] if configuration is invalid
|
|
41
103
|
def validate!
|
|
42
104
|
return unless @dirty
|
|
43
105
|
|
data/lib/umami/errors.rb
CHANGED
|
@@ -5,12 +5,19 @@ module Umami
|
|
|
5
5
|
# Error raised when there's a configuration issue
|
|
6
6
|
class ConfigurationError < Error; end
|
|
7
7
|
|
|
8
|
-
# Error raised when authentication fails
|
|
9
|
-
class AuthenticationError < Error; end
|
|
10
|
-
|
|
11
8
|
# Base error class for API-related errors
|
|
12
9
|
class APIError < Error; end
|
|
13
10
|
|
|
11
|
+
# Error raised when authentication fails — a rejected login, a login
|
|
12
|
+
# response without a token, or an API request answered 401/403 (an
|
|
13
|
+
# expired or revoked token on a long-lived client, insufficient
|
|
14
|
+
# permissions). Deliberately a subclass of APIError since 0.2.1:
|
|
15
|
+
# before that, HTTP 401/403 surfaced as ClientError, so callers who
|
|
16
|
+
# `rescue Umami::APIError` were already catching them — subclassing
|
|
17
|
+
# APIError keeps those rescues working while giving auth failures
|
|
18
|
+
# their own class to match on.
|
|
19
|
+
class AuthenticationError < APIError; end
|
|
20
|
+
|
|
14
21
|
# Error raised when a resource is not found
|
|
15
22
|
class NotFoundError < APIError; end
|
|
16
23
|
|
data/lib/umami/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: umami-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- rameerez
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2026-07-24 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -24,62 +23,6 @@ dependencies:
|
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '2.0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: bundler
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '2.0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '2.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rake
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '13.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '13.0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: yard
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: redcarpet
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - ">="
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0'
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - ">="
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0'
|
|
83
26
|
description: A simple and efficient Ruby gem to interact with the Umami analytics
|
|
84
27
|
API
|
|
85
28
|
email:
|
|
@@ -88,11 +31,15 @@ executables: []
|
|
|
88
31
|
extensions: []
|
|
89
32
|
extra_rdoc_files: []
|
|
90
33
|
files:
|
|
34
|
+
- ".env.test"
|
|
35
|
+
- ".simplecov"
|
|
91
36
|
- ".yardopts"
|
|
92
37
|
- CHANGELOG.md
|
|
38
|
+
- CLAUDE.md
|
|
93
39
|
- LICENSE.txt
|
|
94
40
|
- README.md
|
|
95
41
|
- Rakefile
|
|
42
|
+
- context7.json
|
|
96
43
|
- docs/Umami.html
|
|
97
44
|
- docs/Umami/APIError.html
|
|
98
45
|
- docs/Umami/AuthenticationError.html
|
|
@@ -136,7 +83,6 @@ metadata:
|
|
|
136
83
|
source_code_uri: https://github.com/rameerez/umami-ruby
|
|
137
84
|
changelog_uri: https://github.com/rameerez/umami-ruby/blob/main/CHANGELOG.md
|
|
138
85
|
documentation_uri: https://rameerez.github.io/umami-ruby/
|
|
139
|
-
post_install_message:
|
|
140
86
|
rdoc_options: []
|
|
141
87
|
require_paths:
|
|
142
88
|
- lib
|
|
@@ -151,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
151
97
|
- !ruby/object:Gem::Version
|
|
152
98
|
version: '0'
|
|
153
99
|
requirements: []
|
|
154
|
-
rubygems_version: 3.
|
|
155
|
-
signing_key:
|
|
100
|
+
rubygems_version: 3.6.2
|
|
156
101
|
specification_version: 4
|
|
157
102
|
summary: Ruby wrapper for the Umami API
|
|
158
103
|
test_files: []
|