Class: Avo::Services::TelemetryService
- Inherits:
-
Object
- Object
- Avo::Services::TelemetryService
- Defined in:
- lib/avo/services/telemetry_service.rb
Class Method Summary collapse
- .app_name ⇒ Object
- .avo_metadata ⇒ Object
- .config_metadata ⇒ Object
- .other_metadata(type = :actions) ⇒ Object
- .telemetry_info ⇒ Object
Class Method Details
.app_name ⇒ Object
19 20 21 22 23 |
# File 'lib/avo/services/telemetry_service.rb', line 19 def app_name Rails.application.class.to_s.split("::").first rescue nil end |
.avo_metadata ⇒ Object
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 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/avo/services/telemetry_service.rb', line 25 def resources = Avo.resource_manager.all dashboards = Avo::Current.app.dashboard_manager.all field_definitions = resources.map(&:get_field_definitions) fields_count = field_definitions.map(&:count).sum fields_per_resource = sprintf("%0.01f", fields_count / (resources.count + 0.0)) field_types = {} custom_fields_count = 0 field_definitions.each do |fields| fields.each do |field| field_types[field.type] ||= 0 field_types[field.type] += 1 custom_fields_count += 1 if field.custom? end end { resources_count: resources.count, dashboards_count: dashboards.count, fields_count: fields_count, fields_per_resource: fields_per_resource, custom_fields_count: custom_fields_count, field_types: field_types, **(:actions), **(:filters), main_menu_present: Avo.configuration..present?, profile_menu_present: Avo.configuration..present?, cache_store: Avo.cache_store&.class&.to_s, ** } # rescue => error # { # error: error.message # } end |
.config_metadata ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/avo/services/telemetry_service.rb', line 76 def { config: { root_path: Avo.configuration.root_path, app_name: Avo.configuration.app_name } } end |
.other_metadata(type = :actions) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/avo/services/telemetry_service.rb', line 63 def (type = :actions) resources = Avo.resource_manager.all types = resources.map(&:"get_#{type}") type_count = types.flatten.uniq.count type_per_resource = sprintf("%0.01f", types.map(&:count).sum / (resources.count + 0.0)) { "#{type}_count": type_count, "#{type}_per_resource": type_per_resource } end |
.telemetry_info ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/avo/services/telemetry_service.rb', line 3 def telemetry_info { # license: Avo.configuration.license, # license_key: Avo.configuration.license_key, avo_version: Avo::VERSION, rails_version: Rails::VERSION::STRING, ruby_version: RUBY_VERSION, environment: Rails.env, # ip: current_request&.ip, # host: current_request&.host, # port: current_request&.port, app_name: app_name, avo_metadata: , } end |