Class: Avo::DebugController

Inherits:
ApplicationController show all
Defined in:
app/controllers/avo/debug_controller.rb

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods inherited from BaseApplicationController

#exception_logger, #turbo_frame_request?

Methods included from Concerns::FindAssociationField

#find_association_field

Methods included from Concerns::Breadcrumbs

#add_breadcrumb, #avo_breadcrumbs

Methods included from UrlHelpers

#edit_resource_path, #new_resource_path, #preview_resource_path, #related_resources_path, #resource_attach_path, #resource_detach_path, #resource_path, #resource_view_path, #resources_path

Methods included from ApplicationHelper

#a_button, #a_link, #button_classes, #card_classes, #chart_color, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #resource_grid, #resource_show_path, #resource_table

Methods included from CommonController

#default_url_options, #extra_default_url_options

Methods included from InitializesAvo

#_current_user, #context, #init_app

Instance Method Details

#refresh_licenseObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/avo/debug_controller.rb', line 29

def refresh_license
  license = Licensing::LicenseManager.refresh_license request

  if license.valid?
    flash[:notice] = "avohq.io responded: \"#{license.id.humanize} license is valid\"."
  elsif license.response["reason"].present?
    flash[:error] = "avohq.io responded: \"#{license.response["reason"]}\"."
  else
    flash[:error] = license.response["error"]
  end

  redirect_back fallback_location: avo.avo_private_status_path
end

#reportObject



26
27
# File 'app/controllers/avo/debug_controller.rb', line 26

def report
end

#send_to_hqObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/avo/debug_controller.rb', line 14

def send_to_hq
  url = "#{ENV["HQ_URL"]}/api/v3/debug_requests"
  timeout = 10 # seconds
  license_key = Avo::Services::DebugService.debug_report(request)[:hq_payload][:license_key]
  body = params[:body]
  body = {license_key: license_key, body: body, payload: Avo::Services::DebugService.debug_report(request).to_json}.to_json

  Avo::Licensing::Request.post(url, body:, timeout:)

  render turbo_stream: turbo_stream.replace(:send_to_hq, plain: "Payload sent to Avo HQ.")
end

#statusObject



7
8
9
10
11
12
# File 'app/controllers/avo/debug_controller.rb', line 7

def status
  respond_to do |format|
    format.html { render :status }
    format.text { render :status }
  end
end