Class: Maze::BugsnagConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/maze/bugsnag_config.rb

Defined Under Namespace

Classes: AmbiguousErrorMiddleware, AssertErrorMiddleware, ErrorCaptureMiddleware

Class Method Summary collapse

Class Method Details

.start_bugsnag(cucumber_config) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/maze/bugsnag_config.rb', line 7

def start_bugsnag(cucumber_config)
  # Use MAZE_BUGSNAG_API_KEY explicitly to avoid collisions with test env
  return unless Maze.config.enable_bugsnag && ENV['MAZE_BUGSNAG_API_KEY']

  Bugsnag.configure do |config|
    config.api_key = ENV['MAZE_BUGSNAG_API_KEY']
    config.app_version = Maze::VERSION
    config.(:'test driver', {
      'driver type': Maze.driver.class,
      'device farm': Maze.config.farm,
      'capabilities': Maze.config.capabilities
    }) if Maze.driver

    if ENV['BUILDKITE']
       = {
        'pipeline': ENV['BUILDKITE_PIPELINE_NAME'],
        'repo': ENV['BUILDKITE_REPO'],
        'build url': ENV['BUILDKITE_BUILD_URL'],
        'branch': ENV['BUILDKITE_BRANCH'],
        'builder': ENV['BUILDKITE_BUILD_CREATOR'],
        'message': ENV['BUILDKITE_MESSAGE'],
        'step': ENV['BUILDKITE_LABEL']
      }
      if ENV['BUILDKITE_JOB_ID']
        ['job url'] = ENV['BUILDKITE_BUILD_URL'] + "#" + ENV['BUILDKITE_JOB_ID']
      end
    end
    config.middleware.use(AssertErrorMiddleware)
    config.middleware.use(AmbiguousErrorMiddleware)
    config.middleware.use(ErrorCaptureMiddleware)
    config.(:'buildkite', )
    config.project_root = Dir.pwd
  end

  Bugsnag.start_session

  at_exit do
    if $!
      Bugsnag.notify($!)
    end
  end
end