Class: Sentiero::Web::MonitoringApp

Inherits:
BaseApp
  • Object
show all
Defined in:
lib/sentiero/web/monitoring_app.rb

Overview

Rack app owning the error/issue tracking (/issues/) and custom-event browsing (/custom-events/) routes. Mounted at the same point as DashboardApp (which delegates those requests here), so PATH_INFO/SCRIPT_NAME are read from env to preserve base_path.

Constant Summary

Constants inherited from BaseApp

BaseApp::ASSETS_DIR, BaseApp::AUTH_WARNING_LOCK, BaseApp::CONTENT_TYPES, BaseApp::CSP_POLICY

Constants included from Escaping

Escaping::HTML_UNSAFE_IN_SCRIPT, Escaping::HTML_UNSAFE_IN_SCRIPT_PATTERN

Instance Method Summary collapse

Methods inherited from BaseApp

reset_auth_warning!, warn_unauthenticated_once

Methods included from Formatting

#format_duration, #format_vital, #parse_browser, #parse_device

Methods included from Escaping

#escape_html, #escape_js_string, #escape_json

Constructor Details

#initializeMonitoringApp

Returns a new instance of MonitoringApp.



16
17
18
19
# File 'lib/sentiero/web/monitoring_app.rb', line 16

def initialize
  super
  BaseApp.warn_unauthenticated_once
end

Instance Method Details

#call(env) ⇒ Object



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
49
50
# File 'lib/sentiero/web/monitoring_app.rb', line 21

def call(env)
  path = env["PATH_INFO"] || "/"
  method = env["REQUEST_METHOD"]

  return unauthorized_response unless authorized?(env)

  case path
  when "/custom-events"
    handle_events_index(env)
  when %r{\A/custom-events/([^/]+)\z}
    event_id = $1
    get_only(method) || guard(event_id) || handle_event_show(env, event_id)
  when "/issues"
    handle_errors_index(env)
  when %r{\A/issues/client/([^/]+)\z}
    # Matched BEFORE the generic /issues/:id case so "client" isn't taken as
    # a server fingerprint. Client error ids are ErrorDiscovery group digests,
    # not store ids, so there is no id guard here.
    id = $1
    get_only(method) || handle_client_error_show(env, id)
  when %r{\A/issues/([^/]+)/status\z}
    problem_id = $1
    post_only(method) || guard(problem_id) || handle_error_status(env, problem_id)
  when %r{\A/issues/([^/]+)\z}
    problem_id = $1
    get_only(method) || guard(problem_id) || handle_error_show(env, problem_id)
  else
    not_found
  end
end