Module: BetterAuth::Telemetry::CurrentOptions
- Defined in:
- lib/better_auth/telemetry/project_id.rb
Overview
Thread-local registry that lets ProjectId.resolve_project_name discover the host’s ‘app_name` without changing the public method signature `BetterAuth::Telemetry.project_id(base_url)` (Requirement 14.1).
‘BetterAuth::Telemetry.create` sets `app_name` for the duration of an init flow via CurrentOptions.with_app_name; outside of that scope the reader returns `nil` and the project-name resolver falls through to the next rule in the chain (Bundler.locked_gems → Bundler.root).
The store is per-thread so concurrent ‘create` calls in different threads don’t clobber each other.
Constant Summary collapse
- KEY =
:better_auth_telemetry_current_options_app_name
Class Method Summary collapse
-
.app_name ⇒ String?
The app name set by the most recent CurrentOptions.with_app_name block on the current thread, or ‘nil`.
-
.app_name=(value) ⇒ String?
The value just stored.
-
.with_app_name(value) { ... } ⇒ Object
Run ‘block` with `app_name` set to `value`, restoring the prior value (typically `nil`) on the way out — even when the block raises.
Class Method Details
.app_name ⇒ String?
Returns the app name set by the most recent with_app_name block on the current thread, or ‘nil`.
30 31 32 |
# File 'lib/better_auth/telemetry/project_id.rb', line 30 def app_name Thread.current[KEY] end |
.app_name=(value) ⇒ String?
Returns the value just stored.
36 37 38 |
# File 'lib/better_auth/telemetry/project_id.rb', line 36 def app_name=(value) Thread.current[KEY] = value end |
.with_app_name(value) { ... } ⇒ Object
Run ‘block` with `app_name` set to `value`, restoring the prior value (typically `nil`) on the way out — even when the block raises.
47 48 49 50 51 52 53 |
# File 'lib/better_auth/telemetry/project_id.rb', line 47 def with_app_name(value) prior = Thread.current[KEY] Thread.current[KEY] = value yield ensure Thread.current[KEY] = prior end |