Class: Conversant::V3::Services::CDN::Analytics
- Inherits:
-
Object
- Object
- Conversant::V3::Services::CDN::Analytics
- Defined in:
- lib/conversant/v3/services/cdn/analytics.rb
Overview
Analytics service for CDN metrics and reporting
Provides comprehensive analytics data for CDN performance including:
- Bandwidth and volume metrics
- Viewer statistics
- Request rates and hit rates
- HTTP status code distribution
- Referrer and popular content analytics
- Origin request metrics
- ISP and user agent analytics
Instance Attribute Summary collapse
-
#parent ⇒ CDN
readonly
The parent CDN service instance.
Instance Method Summary collapse
-
#bandwidths(payload) ⇒ Hash?
Get bandwidth analytics data.
-
#byte_hit_rate(params) ⇒ Hash?
Get byte hit rate analytics.
-
#http_codes(payload) ⇒ Hash?
Get HTTP status code analytics.
-
#initialize(parent) ⇒ Analytics
constructor
Initialize analytics service.
-
#isp(payload) ⇒ Array
Get ISP analytics.
-
#number_of_concurrent_viewers(payload) ⇒ Array
Get number of concurrent viewers by domain.
-
#origin_bandwidth(payload) ⇒ Array
Get origin bandwidth analytics.
-
#origin_http_codes(payload) ⇒ Array
Get origin HTTP status codes.
-
#origin_request(payload) ⇒ Hash?
Get origin request analytics.
-
#popular_content_url_by_domain(payload) ⇒ Array
Get popular content URLs by domain.
-
#popular_content_url_csv_by_domain(payload) ⇒ String?
Get popular content URL CSV export by domain.
-
#popular_content_url_total_by_domain(payload) ⇒ Hash?
Get total popular content URL count by domain.
-
#referrer_by_domain(payload) ⇒ Array
Get referrer analytics by domain.
-
#referrer_csv_by_domain(payload) ⇒ String?
Get referrer CSV export by domain.
-
#referrer_total_by_domain(payload) ⇒ Hash?
Get total referrer count by domain.
-
#request_hit_rate(params) ⇒ Hash?
Get request hit rate analytics.
-
#request_per_second(payload) ⇒ Hash?
Get requests per second (RPS) analytics.
-
#request_visit_number(payload) ⇒ Hash?
Get request and visit number statistics.
-
#user_agent(payload) ⇒ Array
Get user agent analytics by domain.
-
#user_agent_csv(payload) ⇒ String?
Get user agent CSV export by domain.
-
#viewers(payload) ⇒ Array?
Get viewer analytics data.
-
#volumes(payload) ⇒ Hash?
Get volume analytics data.
Constructor Details
#initialize(parent) ⇒ Analytics
Initialize analytics service
45 46 47 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 45 def initialize(parent) @parent = parent end |
Instance Attribute Details
#parent ⇒ CDN (readonly)
Returns the parent CDN service instance.
40 41 42 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 40 def parent @parent end |
Instance Method Details
#bandwidths(payload) ⇒ Hash?
Get bandwidth analytics data
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 73 def bandwidths(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/bandwidth', payload)) if response&.[]('bandwidth') { averageThroughput: response&.[]('averageThroughput'), data: response&.[]('bandwidth'), } end rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#byte_hit_rate(params) ⇒ Hash?
Get byte hit rate analytics
327 328 329 330 331 332 333 334 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 327 def byte_hit_rate(params) query_string = URI.encode_www_form(params) response = JSON.parse(@parent.send(:call, 'GET', "/api/byte_rate_chart_data?#{query_string}", nil)) response rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#http_codes(payload) ⇒ Hash?
Get HTTP status code analytics
202 203 204 205 206 207 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 202 def http_codes(payload) JSON.parse(@parent.send(:call, 'POST', "/api/report/customers/#{@parent.customer_id}/http_codes", payload)) rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#isp(payload) ⇒ Array
Get ISP analytics
446 447 448 449 450 451 452 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 446 def isp(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/isp', payload)) response || [] rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |
#number_of_concurrent_viewers(payload) ⇒ Array
Get number of concurrent viewers by domain
354 355 356 357 358 359 360 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 354 def number_of_concurrent_viewers(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/domain/viewers', payload)) response || [] rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |
#origin_bandwidth(payload) ⇒ Array
Get origin bandwidth analytics
341 342 343 344 345 346 347 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 341 def origin_bandwidth(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/origin_bandwidth', payload)) response || [] rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |
#origin_http_codes(payload) ⇒ Array
Get origin HTTP status codes
367 368 369 370 371 372 373 374 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 367 def origin_http_codes(payload) customer_id = @parent.send(:customer_id) response = JSON.parse(@parent.send(:call, 'POST', "/api/report/customers/#{customer_id}/origin_http_codes", payload)) response || [] rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |
#origin_request(payload) ⇒ Hash?
Get origin request analytics
293 294 295 296 297 298 299 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 293 def origin_request(payload) response = JSON.parse(@parent.send(:call, 'GET', "/api/origin_request_chart_data?#{payload.to_query}")) { data: response['requestSpots'] } if response&.[]('requestSpots') rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#popular_content_url_by_domain(payload) ⇒ Array
Get popular content URLs by domain
265 266 267 268 269 270 271 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 265 def popular_content_url_by_domain(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/getUrlByDomain', payload)) response&.[]('list') || [] rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |
#popular_content_url_csv_by_domain(payload) ⇒ String?
Get popular content URL CSV export by domain
420 421 422 423 424 425 426 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 420 def popular_content_url_csv_by_domain(payload) response = @parent.send(:call, 'POST', '/api/report/getUrlCsvByDomain', payload) response rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#popular_content_url_total_by_domain(payload) ⇒ Hash?
Get total popular content URL count by domain
407 408 409 410 411 412 413 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 407 def popular_content_url_total_by_domain(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/getUrlTotalByDomain', payload)) response rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#referrer_by_domain(payload) ⇒ Array
Get referrer analytics by domain
233 234 235 236 237 238 239 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 233 def referrer_by_domain(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/getReferrerByDomain', payload)) response&.[]('list') || [] rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |
#referrer_csv_by_domain(payload) ⇒ String?
Get referrer CSV export by domain
394 395 396 397 398 399 400 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 394 def referrer_csv_by_domain(payload) response = @parent.send(:call, 'POST', '/api/report/getReferrerCsvByDomain', payload) response rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#referrer_total_by_domain(payload) ⇒ Hash?
Get total referrer count by domain
381 382 383 384 385 386 387 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 381 def referrer_total_by_domain(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/getReferrerTotalByDomain', payload)) response rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#request_hit_rate(params) ⇒ Hash?
Get request hit rate analytics
313 314 315 316 317 318 319 320 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 313 def request_hit_rate(params) query_string = URI.encode_www_form(params) response = JSON.parse(@parent.send(:call, 'GET', "/api/hit_rate_chart_data?#{query_string}", nil)) response rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#request_per_second(payload) ⇒ Hash?
Get requests per second (RPS) analytics
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 165 def request_per_second(payload) response = JSON.parse(@parent.send(:call, 'GET', "/api/rps_chart_data?#{payload.to_query}")) if response&.[]('datas') { maxQuantity: response['maxQuantity'], avgQuantity: response['avgQuantity'], httpTotalQuantity: response['httpTotalQuantity'], httpsTotalQuantity: response['httpsTotalQuantity'], data: response['datas'], } end rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#request_visit_number(payload) ⇒ Hash?
Get request and visit number statistics
433 434 435 436 437 438 439 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 433 def request_visit_number(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/request_visit_number', payload)) response rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#user_agent(payload) ⇒ Array
Get user agent analytics by domain
459 460 461 462 463 464 465 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 459 def user_agent(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/domain/userAgent', payload)) response&.[]('list') || [] rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |
#user_agent_csv(payload) ⇒ String?
Get user agent CSV export by domain
472 473 474 475 476 477 478 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 472 def user_agent_csv(payload) response = @parent.send(:call, 'POST', '/api/report/domain/userAgentCsv', payload) response rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#viewers(payload) ⇒ Array?
Get viewer analytics data
136 137 138 139 140 141 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 136 def viewers(payload) JSON.parse(@parent.send(:call, 'POST', '/api/report/viewers', payload)) rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#volumes(payload) ⇒ Hash?
Get volume analytics data
108 109 110 111 112 113 114 |
# File 'lib/conversant/v3/services/cdn/analytics.rb', line 108 def volumes(payload) response = JSON.parse(@parent.send(:call, 'POST', '/api/report/volume', payload)) { data: response&.[]('volumes') } if response&.[]('volumes') rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |