umami-ruby 0.1.2 → 0.2.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 +83 -1
- data/CLAUDE.md +45 -0
- data/README.md +397 -26
- data/Rakefile +10 -1
- 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 +989 -192
- data/lib/umami/configuration.rb +62 -0
- data/lib/umami/version.rb +1 -1
- data/lib/umami-ruby.rb +1 -0
- 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/version.rb
CHANGED
data/lib/umami-ruby.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative "umami"
|
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.2.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-02-03 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,8 +31,11 @@ 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
|
|
@@ -119,6 +65,7 @@ files:
|
|
|
119
65
|
- docs/js/jquery.js
|
|
120
66
|
- docs/method_list.html
|
|
121
67
|
- docs/top-level-namespace.html
|
|
68
|
+
- lib/umami-ruby.rb
|
|
122
69
|
- lib/umami.rb
|
|
123
70
|
- lib/umami/client.rb
|
|
124
71
|
- lib/umami/configuration.rb
|
|
@@ -135,7 +82,6 @@ metadata:
|
|
|
135
82
|
source_code_uri: https://github.com/rameerez/umami-ruby
|
|
136
83
|
changelog_uri: https://github.com/rameerez/umami-ruby/blob/main/CHANGELOG.md
|
|
137
84
|
documentation_uri: https://rameerez.github.io/umami-ruby/
|
|
138
|
-
post_install_message:
|
|
139
85
|
rdoc_options: []
|
|
140
86
|
require_paths:
|
|
141
87
|
- lib
|
|
@@ -150,8 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
150
96
|
- !ruby/object:Gem::Version
|
|
151
97
|
version: '0'
|
|
152
98
|
requirements: []
|
|
153
|
-
rubygems_version: 3.
|
|
154
|
-
signing_key:
|
|
99
|
+
rubygems_version: 3.6.2
|
|
155
100
|
specification_version: 4
|
|
156
101
|
summary: Ruby wrapper for the Umami API
|
|
157
102
|
test_files: []
|