Fetching data from Google analytics GA4 api in rails

98 views Asked by At

This has probably something to do with recent migration to GA4, but for some reason my previous code stopped working and now I have problems with fetching basic data.

I think now I need to use different library, this is what I have so far but it crashes

  • warning: undefining the allocator of T_DATA class GRPC::Core::MetadataArray objc[4318]: +[__NSTimeZone initialize] may have been in progress in another thread when fork() was called. objc[4318]: +[__NSTimeZone initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead.*
require 'google/analytics/data/v1beta'

client = ::Google::Analytics::Data::V1beta::AnalyticsData::Client.new do |config|
  config.credentials = "config/google-api.json"
end


hash = {"property": "properties/XXXXXXXXXX", "dimensions":[{"name":"date"}],"metrics":[{"name":"activeUsers"}],"date_ranges":[{"start_date":"2023-10-01","end_date":"2023-10-10"}]}

request = ::Google::Analytics::Data::V1beta::RunReportRequest.new hash

response = client.run_report request

Thanks in advance.

0

There are 0 answers