Skip to main content

Environments

Manage different environments in Brainz Lab.

Automatic Detection

The SDK automatically detects your environment from Rails.env:
  • development
  • test
  • staging
  • production

Manual Override

Set explicitly if needed:
BrainzLab.configure do |config|
  config.environment = ENV['BRAINZLAB_ENV'] || Rails.env
end

Environment Keys

Use different keys for different environments:
# .env.development
BRAINZLAB_SECRET_KEY=sk_test_xxxxxxxx

# .env.production
BRAINZLAB_SECRET_KEY=sk_live_xxxxxxxx

Filtering by Environment

In the dashboard, filter by environment:
env:production level:error since:1h

Environment-Specific Config

BrainzLab.configure do |config|
  config.secret_key = ENV['BRAINZLAB_SECRET_KEY']

  case Rails.env
  when 'development'
    config.recall_min_level = :debug
  when 'test'
    config.recall_enabled = false
    config.reflex_enabled = false
  when 'production'
    config.recall_min_level = :info
  end
end

Test Environment

Disable in tests to avoid noise:
# config/environments/test.rb
BrainzLab.configure do |config|
  config.recall_enabled = false
  config.reflex_enabled = false
end
Or use a test key:
config.secret_key = 'sk_test_xxx'