Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement allow all tracing for OPs #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,28 @@ gem "trailblazer-pro-rails"

Note: we're currently playing with various invocation styles and at some point you might not even have to use `Operation.wtf?` anymore.

## Configuration (optional)

Configure your operations to use the web debugger, example configuration:
```ruby
# config/environments/development.rb
config.trailblazer.pro.trace_operations = {
"API::V1::Diagram::Operation::Update" => true,
"API::V1::Diagram::Operation::Create" => true,
}
```

Or, if you want to trace all operations, use `:all` as the value.
```ruby
# config/environments/development.rb
config.trailblazer.pro.trace_operations = :all
```

Disable printing trace to console, show only link to web debugger.
```ruby
# config/environments/development.rb
config.trailblazer.pro.render_wtf = false
```

## Testing

Expand Down
8 changes: 5 additions & 3 deletions lib/trailblazer/pro/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ class Railtie < ::Rails::Railtie
trace_operations = config.trailblazer.pro.trace_operations

if trace_operations
# constants can be passed as strings to avoid autoloading issues.
trace_operations = trace_operations.collect { |klass, config| [klass.constantize, config] }.to_h
if trace_operations.is_a?(Hash)
# constants can be passed as strings to avoid autoloading issues.
trace_operations = trace_operations.collect { |klass, config| [klass.constantize, config] }.to_h
end

Pro.trace_operations!(trace_operations)
end

# TODO: add {Activity.invoke} here, too!
# Trailblazer::Activity.extend(Pro::Call::Activity) # FIXME: only if allowed! # TODO: only apply to selected OPs.
else # no configuration happend, yet.
else # no configuration happened, yet.
Pro.initialize!(api_key: "")
end
end
Expand Down