facebook / facebook-ruby-business-sdk

Ruby SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
210 stars 159 forks source link

Breakdown fields are missing on AdsInsights #203

Open afn opened 1 year ago

afn commented 1 year ago

Which SDK version are you using?

18.0.2

What's the issue?

The AdInsights object doesn't have fields for breakdowns

Steps/Sample code to reproduce the issue

spend_stats = FacebookAds::AdAccount
                .get(ad_account_id, session)
                .insights(
                  time_range: { since: date.to_s(:db), until: date.to_s(:db) },
                  breakdowns: ['hourly_stats_aggregated_by_advertiser_time_zone'],
                  fields: %w[impressions clicks spend ad_id adset_id campaign_id],
                  level: 'ad',
                )
                .all
spend_stats[0].impressions # => "1234"
spend_stats[0].ad_id # => "some-ad-id"
spend_stats[0].hourly_stats_aggregated_by_advertiser_time_zone # NoMethodError: undefined method `hourly_stats_aggregated_by_advertiser_time_zone' for #<FacebookAds::AdsInsights {:impressions=>"1234", :clicks=>"x", :spend=>"x", :ad_id=>"some-ad-id", :adset_id=>"some-adset-id", :campaign_id=>"some-campaign-id", :date_start=>"2023-10-18", :date_stop=>"2023-10-18", :hourly_stats_aggregated_by_advertiser_time_zone=>"06:00:00 - 06:59:59"}>
spend_stats[0][:hourly_stats_aggregated_by_advertiser_time_zone] # => "06:00:00 - 06:59:59"

Observed Results:

Calling hourly_stats_aggregated_by_advertiser_time_zone on the AdInsights object raises a NoMethodError

Expected Results:

Calling hourly_stats_aggregated_by_advertiser_time_zone on the AdInsights object returns the value of the field