Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakdowns fields should not be included in the "fields" list #285

Open
NicksPlace opened this issue Jan 6, 2025 · 1 comment
Open

Breakdowns fields should not be included in the "fields" list #285

NicksPlace opened this issue Jan 6, 2025 · 1 comment

Comments

@NicksPlace
Copy link

NicksPlace commented Jan 6, 2025

I am using tap-facebook(meltano variant) and trying to include a breakdown of "product_id". Unfortunately this also adds "product_id" to the field list which will cause a failure on a POST request(which is what is used in the tap.

I have tested CURL statements to confirm this behavior. GET works with "product_id" as breakdown and in field. POST works with breakdown = "product_id" and not in field list.

I believe a POST needs to be made due to the nature of how the report is delivered and processed.

Suggested solution in the ad_insights.py

` def get_records(
self,
context: Context | None,
) -> t.Iterable[dict | tuple[dict, dict | None]]:
self._initialize_client()

    time_increment = self._report_definition["time_increment_days"]

    sync_end_date = pendulum.parse(  # type: ignore[union-attr]
        self.config.get("end_date", pendulum.today().to_date_string()),
    ).date()

    report_start = self._get_start_date(context)
    report_end = report_start.add(days=time_increment)

    columns = self._get_selected_columns()
    breakdowns = self._report_definition.get("breakdowns", [])
    fields = [col for col in columns if col not in set(breakdowns)]

    while report_start <= sync_end_date:
        params = {
            "level": self._report_definition["level"],
            "action_breakdowns": self._report_definition["action_breakdowns"],
            "action_report_time": self._report_definition["action_report_time"],
            "breakdowns": breakdowns,
            "fields": fields,
            "time_increment": time_increment,
            "limit": 100,
            "action_attribution_windows": [
                self._report_definition["action_attribution_windows_view"],
                self._report_definition["action_attribution_windows_click"],
            ],
            "time_range": {
                "since": report_start.to_date_string(),
                "until": report_end.to_date_string(),
            },
        }

`

@NicksPlace
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant