Class: Bidi2pdf::Bidi::NavigationFailedEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/bidi2pdf/bidi/navigation_failed_events.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context_id) ⇒ NavigationFailedEvents

Returns a new instance of NavigationFailedEvents.



10
11
12
# File 'lib/bidi2pdf/bidi/navigation_failed_events.rb', line 10

def initialize(context_id)
  @context_id = context_id
end

Instance Attribute Details

#browser_console_loggerObject (readonly)

Returns the value of attribute browser_console_logger.



8
9
10
# File 'lib/bidi2pdf/bidi/navigation_failed_events.rb', line 8

def browser_console_logger
  @browser_console_logger
end

#context_idObject (readonly)

Returns the value of attribute context_id.



8
9
10
# File 'lib/bidi2pdf/bidi/navigation_failed_events.rb', line 8

def context_id
  @context_id
end

Instance Method Details

#handle_event(data) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/bidi2pdf/bidi/navigation_failed_events.rb', line 14

def handle_event(data)
  event = data["params"]
  method = data["method"]

  if event["context"] == context_id
    handle_response(method, event)
  else
    Bidi2pdf.logger.debug2 "Ignoring Log event: #{method}, context_id: #{context_id}, params: #{event}"
  end
end

#handle_response(_method, event) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bidi2pdf/bidi/navigation_failed_events.rb', line 25

def handle_response(_method, event)
  url = event["url"]
  navigation = event["navigation"]
  timestamp = event["timestamp"]

  Bidi2pdf.notification_service.instrument("navigation_failed_received.bidi2pdf",
                                           {
                                             url: url,
                                             timestamp: timestamp,
                                             navigation: navigation
                                           })

  Bidi2pdf.logger.error "Navigation failed for URL: #{url}, Navigation: #{navigation}"
end