Class: BetterAuth::Telemetry::NoopPublisher

Inherits:
Object
  • Object
show all
Defined in:
lib/better_auth/telemetry/noop_publisher.rb

Overview

Publisher returned from create when telemetry is disabled, when no ‘BETTER_AUTH_TELEMETRY_ENDPOINT` is configured and no `custom_track` is supplied, or when the soft-load fallback inside Auth#initialize cannot load the telemetry gem.

Calling ‘#publish` on a `NoopPublisher` is always safe: the method accepts any event-shaped argument, performs no work, raises no error, and returns `nil`. `#enabled?` always reports `false`. This lets callers treat `auth.telemetry` as a non-nullable, always-callable collaborator without having to nil-check before each `publish` call.

Examples:

publisher = BetterAuth::Telemetry::NoopPublisher.new
publisher.publish(type: "ping", payload: {}) # => nil
publisher.enabled?                           # => false

Instance Method Summary collapse

Instance Method Details

#enabled?Boolean

Returns always ‘false`.

Returns:

  • (Boolean)

    always ‘false`.



28
29
30
# File 'lib/better_auth/telemetry/noop_publisher.rb', line 28

def enabled?
  false
end

#publish(_event) ⇒ nil

Parameters:

  • _event (Object)

    any event payload; ignored.

Returns:

  • (nil)


23
24
25
# File 'lib/better_auth/telemetry/noop_publisher.rb', line 23

def publish(_event)
  nil
end