Class: Quilt::Performance::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/quilt_rails/performance/report.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events:, navigations:, connection:) ⇒ Report

Returns a new instance of Report.



31
32
33
34
35
# File 'lib/quilt_rails/performance/report.rb', line 31

def initialize(events:, navigations:, connection:)
  @events = events
  @navigations = navigations
  @connection = connection
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



8
9
10
# File 'lib/quilt_rails/performance/report.rb', line 8

def connection
  @connection
end

#eventsObject

Returns the value of attribute events.



6
7
8
# File 'lib/quilt_rails/performance/report.rb', line 6

def events
  @events
end

Returns the value of attribute navigations.



7
8
9
# File 'lib/quilt_rails/performance/report.rb', line 7

def navigations
  @navigations
end

Class Method Details

.from_params(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/quilt_rails/performance/report.rb', line 10

def self.from_params(params)
  params.transform_keys! { |key| key.underscore.to_sym }
  params[:connection] = { effectiveType: 'unknown' } if params[:connection].blank?

  connection = Connection.from_params(params[:connection])

  Report.new(
    connection: connection,
    navigations: (params[:navigations] || []).map do |navigation|
      navigation = Navigation.from_params(navigation)
      navigation.connection = connection
      navigation
    end,
    events: (params[:events] || []).map do |event|
      event = Event.from_params(event)
      event.connection = connection
      event
    end,
  )
end