Class: CypressViewportUpdater::GoogleAnalyticsReports
- Inherits:
-
Object
- Object
- CypressViewportUpdater::GoogleAnalyticsReports
show all
- Includes:
- Google::Apis::AnalyticsreportingV4, Google::Auth, SentryLogging
- Defined in:
- app/sidekiq/cypress_viewport_updater/google_analytics_reports.rb
Constant Summary
collapse
- JSON_CREDENTIALS =
Settings.google_analytics_cvu.to_json
- SCOPE =
'https://www.googleapis.com/auth/analytics.readonly'
- VIEW_ID =
'176188361'
Instance Method Summary
collapse
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Constructor Details
Returns a new instance of GoogleAnalyticsReports.
15
16
17
18
19
20
21
22
|
# File 'app/sidekiq/cypress_viewport_updater/google_analytics_reports.rb', line 15
def initialize
@analytics = AnalyticsReportingService.new
@analytics.authorization = ServiceAccountCredentials.make_creds(
json_key_io: StringIO.new(JSON_CREDENTIALS),
scope: SCOPE
)
@reports = nil
end
|
Instance Method Details
#request_reports ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/sidekiq/cypress_viewport_updater/google_analytics_reports.rb', line 24
def request_reports
request = GetReportsRequest.new(report_requests: [
user_report_request,
viewport_report_request
])
begin
@reports = @analytics.batch_get_reports(request).reports
rescue => e
log_exception_to_sentry(e)
end
self
end
|
#user_report ⇒ Object
38
39
40
|
# File 'app/sidekiq/cypress_viewport_updater/google_analytics_reports.rb', line 38
def user_report
@reports[0] if @reports && @reports[0]
end
|
#viewport_report ⇒ Object
42
43
44
|
# File 'app/sidekiq/cypress_viewport_updater/google_analytics_reports.rb', line 42
def viewport_report
@reports[1] if @reports && @reports[1]
end
|