facebook / facebook-ruby-business-sdk

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

Breakdown fields on AdsInsights no longer available in new version? #99

Closed Reizar closed 4 years ago

Reizar commented 4 years ago

Which SDK version are you using?

0.7.0.0

What's the issue?

I recently updated from v0.5.0.2 to v0.7.0.0, some of my code has started to break and I can't find why these fields are missing.

Basically the fields in AdsInsights that are related to breakdowns have been removed, eg: age, gender.

Each of the breakdown options used to be defined as a field on the AdsInsights object, so that you could get the value of the breakdown being specified.

Steps/Sample code to reproduce the issue

An AdReportRun is created with the following code:

ad_report_run = ad_account.insights.create(
  fields: insight_fields,
  time_increment: 1,
  use_account_attribution_setting: true,
  time_range: {since: time_since.to_s, until: today.to_s},
  breakdowns: ['age']
)

Then later, the ad report run would be accessed and I will attempt to read what the age breakdown value is: ( code is a bit generic as it supports different breakdowns and combined breakdowns )

breakdowns = ['age']
FacebookAds::AdReportRun.get(api_ad_report_id, session).insights.each do |insight|
  if breakdowns && breakdowns.length > 0
    breakdown_type = breakdowns.join("-")
    breakdown_value = breakdowns.map {|breakdown_name| insight.send(breakdown_name)}.join("-")
  else
    breakdown_type, breakdown_value = nil, nil
  end
end

Observed Results:

Following error is raised:

NoMethodError: undefined method 'age' for #<FacebookAds::AdsInsights:0x000055d6455ddb78>

Expected Results:

Expected age group to be returned, eg: "18-25"

This is code that worked in the previous versions, so just wondering if there is now a new way of handling breakdowns in insights? ( It looks like this wasn't a problem in v0.6.0.0 but was then changed )

Thanks

stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.