Module: Shipeasy::SDK

Defined in:
lib/shipeasy-sdk.rb,
lib/shipeasy/sdk/see.rb,
lib/shipeasy/sdk/eval.rb,
lib/shipeasy/sdk/skill.rb,
lib/shipeasy/sdk/anon_id.rb,
lib/shipeasy/sdk/murmur3.rb,
lib/shipeasy/sdk/railtie.rb,
lib/shipeasy/sdk/version.rb,
lib/shipeasy/sdk/telemetry.rb,
lib/shipeasy/sdk/sticky_store.rb,
lib/shipeasy/sdk/rack_middleware.rb

Defined Under Namespace

Modules: AnonId, Eval, Murmur3, See, Skill Classes: InMemoryStickyStore, RackMiddleware, Railtie, Telemetry

Constant Summary collapse

VERSION =
"2.4.0"

Class Method Summary collapse

Class Method Details

.control_flow_exception(err) ⇒ Object

Mark an exception as expected control flow (reports nothing). Works without a client — it only stamps the exception object.



76
77
78
# File 'lib/shipeasy-sdk.rb', line 76

def self.control_flow_exception(err)
  See::ControlFlowChain.new(err)
end

.default_clientObject



49
50
51
# File 'lib/shipeasy-sdk.rb', line 49

def self.default_client
  @see_default_mutex.synchronize { @see_default_client }
end

.new_client(api_key: Shipeasy.config.api_key, base_url: Shipeasy.config.base_url) ⇒ Object

Convenience constructor for a heavyweight Engine. Reads api_key + base_url from the gem-wide config when omitted. Most apps should prefer Shipeasy.configure { … } + Shipeasy::Client.new(user) instead.



27
28
29
# File 'lib/shipeasy-sdk.rb', line 27

def self.new_client(api_key: Shipeasy.config.api_key, base_url: Shipeasy.config.base_url)
  Shipeasy::Engine.new(api_key: api_key, base_url: base_url)
end

.see(problem) ⇒ Object

Report a caught exception via the default client. Use client.see to target a specific client.



55
56
57
58
59
60
61
62
# File 'lib/shipeasy-sdk.rb', line 55

def self.see(problem)
  client = default_client
  if client.nil?
    Shipeasy::Logging.warn "[shipeasy] see() called before a client was created — error dropped"
    return See::NullChain.new
  end
  client.see(problem)
end

.see_violation(name) ⇒ Object

Report a non-exception problem via the default client.



65
66
67
68
69
70
71
72
# File 'lib/shipeasy-sdk.rb', line 65

def self.see_violation(name)
  client = default_client
  if client.nil?
    Shipeasy::Logging.warn "[shipeasy] see_violation() called before a client was created — error dropped"
    return See::NullChain.new
  end
  client.see_violation(name)
end

.set_default_client(client) ⇒ Object

Register the client backing the module-level see() funcs. Called automatically from Engine#initialize; also exposed for explicit use.



44
45
46
47
# File 'lib/shipeasy-sdk.rb', line 44

def self.set_default_client(client)
  @see_default_mutex.synchronize { @see_default_client = client }
  client
end