Module: Sciosano
- Defined in:
- lib/sciosano.rb,
lib/sciosano/client.rb,
lib/sciosano/report.rb,
lib/sciosano/context.rb,
lib/sciosano/version.rb,
lib/sciosano/breadcrumb.rb,
lib/sciosano/configuration.rb,
lib/sciosano/integrations/rack.rb,
lib/sciosano/integrations/rails.rb,
lib/sciosano/integrations/sidekiq.rb,
lib/sciosano/integrations/active_job.rb
Defined Under Namespace
Modules: Integrations Classes: Breadcrumb, Client, Configuration, ConfigurationError, Context, Error, Report
Constant Summary collapse
- VERSION =
"0.1.0"
Class Attribute Summary collapse
-
.client ⇒ Object
Returns the value of attribute client.
Class Method Summary collapse
-
.add_breadcrumb(category:, message:, data: {}, type: :default) ⇒ Object
Add a breadcrumb.
-
.capture_exception(exception, context = {}) ⇒ String?
Capture an exception.
-
.capture_message(message, level: :info, context: {}) ⇒ String?
Capture a message.
-
.clear_user ⇒ Object
Clear user context.
-
.configuration ⇒ Configuration
Get the current configuration.
-
.configure {|Configuration| ... } ⇒ Object
Configure sciosano.
-
.set_extra(key, value) ⇒ Object
Set extra context.
-
.set_tags(tags) ⇒ Object
Set tags.
-
.set_user(id: nil, email: nil, name: nil, **extra) ⇒ Object
Set user context.
-
.verify_installation ⇒ Array<String>
Verify the installation is working correctly.
-
.with_context(context = {}) { ... } ⇒ Object
Execute block with additional context.
Class Attribute Details
.client ⇒ Object
Returns the value of attribute client.
31 32 33 |
# File 'lib/sciosano.rb', line 31 def client @client end |
Class Method Details
.add_breadcrumb(category:, message:, data: {}, type: :default) ⇒ Object
Add a breadcrumb
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/sciosano.rb', line 92 def (category:, message:, data: {}, type: :default) return unless client client.( Breadcrumb.new( type: type, category: category, message: , data: data ) ) end |
.capture_exception(exception, context = {}) ⇒ String?
Capture an exception
68 69 70 71 72 |
# File 'lib/sciosano.rb', line 68 def capture_exception(exception, context = {}) return nil unless client client.capture_exception(exception, context) end |
.capture_message(message, level: :info, context: {}) ⇒ String?
Capture a message
80 81 82 83 84 |
# File 'lib/sciosano.rb', line 80 def (, level: :info, context: {}) return nil unless client client.(, level: level, context: context) end |
.clear_user ⇒ Object
Clear user context
118 119 120 121 122 |
# File 'lib/sciosano.rb', line 118 def clear_user return unless client client.clear_user end |
.configuration ⇒ Configuration
Get the current configuration
52 53 54 |
# File 'lib/sciosano.rb', line 52 def configuration @configuration ||= Configuration.new end |
.configure {|Configuration| ... } ⇒ Object
Configure sciosano
42 43 44 45 46 47 |
# File 'lib/sciosano.rb', line 42 def configure yield configuration self.client = Client.new(configuration) setup_integrations log_initialization end |
.set_extra(key, value) ⇒ Object
Set extra context
128 129 130 131 132 |
# File 'lib/sciosano.rb', line 128 def set_extra(key, value) return unless client client.set_extra(key, value) end |
.set_tags(tags) ⇒ Object
Set tags
137 138 139 140 141 |
# File 'lib/sciosano.rb', line 137 def () return unless client client.() end |
.set_user(id: nil, email: nil, name: nil, **extra) ⇒ Object
Set user context
111 112 113 114 115 |
# File 'lib/sciosano.rb', line 111 def set_user(id: nil, email: nil, name: nil, **extra) return unless client client.set_user(id: id, email: email, name: name, **extra) end |
.verify_installation ⇒ Array<String>
Verify the installation is working correctly
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/sciosano.rb', line 156 def verify_installation issues = [] unless client issues << "Client not initialized - call Sciosano.configure first" return issues end # Check Rails middleware if defined?(Rails.application) && Rails.application middleware_installed = Rails.application.middleware.any? do |m| m.klass == Sciosano::Integrations::RackMiddleware rescue m == Sciosano::Integrations::RackMiddleware end issues << "Rails middleware not installed" unless middleware_installed end # Check API key format unless configuration.api_key&.start_with?("sciosano_") issues << "API key appears invalid (should start with 'sciosano_')" end issues end |
.with_context(context = {}) { ... } ⇒ Object
Execute block with additional context
147 148 149 150 151 |
# File 'lib/sciosano.rb', line 147 def with_context(context = {}) return yield unless client client.with_context(context) { yield } end |