mbuzz 0.11.0 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff302e119aa981ced654677a020929b3b2065055961e253b08e106b52750fed4
4
- data.tar.gz: ed21ef016dcbac2bb9918a07f03efcce264b9f01046a1ada510e526a107c7ed1
3
+ metadata.gz: fd98d9872cc6ec740c9b705e67f9a883e534fb5fa07dbc610b8829680bf8381d
4
+ data.tar.gz: 48c12c4a9a7ab7904aebe2f08249d06eef325b65fb99004556c8bcd262b909fb
5
5
  SHA512:
6
- metadata.gz: 6f9e1ff36c152c2eaa085892b41f7e18e995f7de122413d6d42cc4d44d2199f6e8fa3096ce2e06be4b87a6b2a8daaebcaf80d037e11e85df9298d9b3a33f7e27
7
- data.tar.gz: 1a18bdf46411b450c247396d595e094404d6b8f7ef487560c8af697c65317f2f6efcf1969a0a86b3a9b349a95f89fd0dce5b546a4d9d5307dd99cf0a3b9d3f85
6
+ metadata.gz: e3bee0fa8f5bfc4daee2a9ffa3743d7d00d06818e2bc0b2ebbaa0e4de6c9011d23ba33f991292c11336c2094a2b1a6d75b9a8db5a4da7d02a76cc56d5a2477c6
7
+ data.tar.gz: 42e8200e96d6c1837f9fd2e177024452acd6cf3ffc35a346faabfd6f8fbdb04885c54272f84bc171ce7e97072bd14b11a17ff82ff1ec5a56b304382e050cba60
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [0.12.0] - 2026-11-16
11
+
12
+ ### Added
13
+
14
+ - **`api_url:` option for data-resident installs.** `init()` accepts it again (removed in 0.8.2 so a live install could not be redirected). Explicit opt-in: `https://` only; a region key (`sk_live_au_...`) must be paired with it and it with a region key, otherwise `init()` throws; there is no fallback host, so a failed request is dropped, never retried against `api.mbuzz.co`. Installs that do not set it behave exactly as before. `Mbuzz.init` now validates it; previously `config.api_url` was an unchecked accessor, which still exists but is not validated when assigned directly.
15
+
8
16
  ## [0.11.0] - 2026-10-14
9
17
 
10
18
  ### Added
data/README.md CHANGED
@@ -240,7 +240,7 @@ is what preserves its full two-year life — a cookie written by `document.cooki
240
240
  ```ruby
241
241
  Mbuzz.init(
242
242
  api_key: "sk_live_...", # Required - from mbuzz.co dashboard
243
- api_url: "https://api.mbuzz.co/api/v1", # Optional - API endpoint
243
+ api_url: nil, # Optional - data-resident installs only: https host for a region key (sk_live_au_...); a region key requires it and vice versa
244
244
  debug: false # Optional - enable debug logging
245
245
  )
246
246
  ```
@@ -26,7 +26,7 @@ module Mbuzz
26
26
  ].freeze
27
27
 
28
28
  def initialize
29
- @api_url = "https://api.mbuzz.co/api/v1"
29
+ @api_url = DEFAULT_API_URL
30
30
  @enabled = true
31
31
  @debug = false
32
32
  @timeout = 5
@@ -36,6 +36,26 @@ module Mbuzz
36
36
  @skip_extensions = []
37
37
  end
38
38
 
39
+ DEFAULT_API_URL = "https://api.mbuzz.co/api/v1"
40
+ REGION_KEY = /\Ask_[a-z]+_[a-z]{2}_/
41
+
42
+ # api_url is an explicit opt-in for data-resident installs (spec M9). https
43
+ # only; no api_url means api.mbuzz.co, always; a region key (sk_live_au_...)
44
+ # must be paired with api_url and api_url with a region key; test keys are
45
+ # exempt from the pairing. There is no fallback host: a failed request is
46
+ # dropped, never retried against api.mbuzz.co.
47
+ def self.resolve_api_url(api_key, api_url)
48
+ has_url = !api_url.to_s.empty?
49
+ raise ConfigurationError, "api_url must start with https://" if has_url && !api_url.start_with?("https://")
50
+
51
+ unless api_key.to_s.start_with?("sk_test_") || has_url == REGION_KEY.match?(api_key.to_s)
52
+ raise ConfigurationError, "api_url and the API key region must be set together: " \
53
+ "a region key needs api_url, and api_url needs a region key"
54
+ end
55
+
56
+ (has_url ? api_url : DEFAULT_API_URL).chomp("/")
57
+ end
58
+
39
59
  def validate!
40
60
  raise ConfigurationError, "api_key is required" if api_key.nil? || api_key.empty?
41
61
  end
data/lib/mbuzz/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mbuzz
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.0"
5
5
  end
data/lib/mbuzz.rb CHANGED
@@ -56,8 +56,11 @@ module Mbuzz
56
56
  # @param debug [Boolean, nil] Enable debug logging
57
57
  # @param skip_paths [Array<String>, nil] Additional paths to skip tracking (e.g., ["/admin", "/internal"])
58
58
  # @param skip_extensions [Array<String>, nil] Additional extensions to skip (e.g., [".pdf"])
59
- def self.init(api_key:, session_timeout: nil, debug: nil, skip_paths: nil, skip_extensions: nil)
60
- config.api_key = api_key
59
+ def self.init(api_key:, api_url: nil, session_timeout: nil, debug: nil, skip_paths: nil, skip_extensions: nil)
60
+ Configuration.resolve_api_url(api_key, api_url).then do |resolved_url|
61
+ config.api_key = api_key
62
+ config.api_url = resolved_url
63
+ end
61
64
  config.session_timeout = session_timeout if session_timeout
62
65
  config.debug = debug unless debug.nil?
63
66
  config.skip_paths = skip_paths if skip_paths
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbuzz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mbuzz team