From 42e4385d56f8735f8c375babadbe0005b721e569 Mon Sep 17 00:00:00 2001 From: Lev Chechulin Date: Mon, 2 Feb 2026 22:15:12 +0100 Subject: [PATCH 1/3] fix: fix fb --- src/facebook/facebook_client.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/facebook/facebook_client.py b/src/facebook/facebook_client.py index ab265bf..7e95996 100644 --- a/src/facebook/facebook_client.py +++ b/src/facebook/facebook_client.py @@ -73,7 +73,7 @@ def get_total_reach( """ batches = self._get_all_batches( connection_name="insights", - metric="page_posts_impressions_unique", + metric="page_impressions_unique", period=period.value, since=since, until=until, @@ -91,7 +91,7 @@ def get_organic_reach( """ batches = self._get_all_batches( connection_name="insights", - metric="page_posts_impressions_organic_unique", + metric="page_impressions_organic_unique", period=period.value, since=since, until=until, @@ -127,7 +127,7 @@ def get_new_fan_count( """ batches = self._get_all_batches( connection_name="insights", - metric="page_fan_adds_unique", + metric="page_daily_follows_unique", period=period.value, since=since, until=until, @@ -147,7 +147,12 @@ def _get_all_batches( } params.update(kwargs) page = self._make_graph_api_call(f"{self._page_id}/{connection_name}", params) - result += page["data"] + + if "error" in page: + logger.error(f"Error fetching {connection_name}: {page['error']}") + return result + + result += page.get("data", []) # process next result += self._iterate_over_pages(connection_name, since, until, page, True) # process previous @@ -192,10 +197,14 @@ def _iterate_over_pages( current_page = self._make_graph_api_call( f"{self._page_id}/{connection_name}", args ) + if "error" in current_page: + logger.error(f"Error in pagination for {connection_name}: {current_page['error']}") + break + if "data" in current_page: result += current_page["data"] else: - logger.error(f"Error in pagination: {current_page}") + logger.warning(f"No data found in pagination response: {current_page}") break return result From 15b90af81c275f91a529811ebd883a92774f1f7c Mon Sep 17 00:00:00 2001 From: Lev Chechulin Date: Mon, 2 Feb 2026 22:29:18 +0100 Subject: [PATCH 2/3] fix: fix formatting --- src/facebook/facebook_client.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/facebook/facebook_client.py b/src/facebook/facebook_client.py index 7e95996..f349692 100644 --- a/src/facebook/facebook_client.py +++ b/src/facebook/facebook_client.py @@ -70,6 +70,8 @@ def get_total_reach( ) -> List[Tuple[datetime, int]]: """ Get statistics on the total reach of new posts. + NOTE: 'page_posts_impressions_unique' is deprecated in v19.0. + Using 'page_impressions_unique' (Total Page Reach) as replacement. """ batches = self._get_all_batches( connection_name="insights", @@ -88,6 +90,8 @@ def get_organic_reach( ) -> List[Tuple[datetime, int]]: """ Get statistics on the organic reach of new posts. + NOTE: 'page_posts_impressions_organic_unique' is deprecated in v19.0. + Using 'page_impressions_organic_unique' (Organic Page Reach) as replacement. """ batches = self._get_all_batches( connection_name="insights", @@ -124,6 +128,8 @@ def get_new_fan_count( ) -> List[Tuple[datetime, int]]: """ Get the number of new people who liked the page for the period. + NOTE: 'page_fan_adds_unique' is deprecated. + Using 'page_daily_follows_unique' (New Followers) as proxy. """ batches = self._get_all_batches( connection_name="insights", @@ -147,7 +153,7 @@ def _get_all_batches( } params.update(kwargs) page = self._make_graph_api_call(f"{self._page_id}/{connection_name}", params) - + if "error" in page: logger.error(f"Error fetching {connection_name}: {page['error']}") return result @@ -198,8 +204,10 @@ def _iterate_over_pages( f"{self._page_id}/{connection_name}", args ) if "error" in current_page: - logger.error(f"Error in pagination for {connection_name}: {current_page['error']}") - break + logger.error( + f"Error in pagination for {connection_name}: {current_page['error']}" + ) + break if "data" in current_page: result += current_page["data"] From 290ac9093debc61326bdca33456a0cf2217c718b Mon Sep 17 00:00:00 2001 From: Lev Chechulin Date: Mon, 2 Feb 2026 22:31:47 +0100 Subject: [PATCH 3/3] fix: comments --- src/facebook/facebook_client.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/facebook/facebook_client.py b/src/facebook/facebook_client.py index f349692..cf43038 100644 --- a/src/facebook/facebook_client.py +++ b/src/facebook/facebook_client.py @@ -90,8 +90,6 @@ def get_organic_reach( ) -> List[Tuple[datetime, int]]: """ Get statistics on the organic reach of new posts. - NOTE: 'page_posts_impressions_organic_unique' is deprecated in v19.0. - Using 'page_impressions_organic_unique' (Organic Page Reach) as replacement. """ batches = self._get_all_batches( connection_name="insights", @@ -128,8 +126,6 @@ def get_new_fan_count( ) -> List[Tuple[datetime, int]]: """ Get the number of new people who liked the page for the period. - NOTE: 'page_fan_adds_unique' is deprecated. - Using 'page_daily_follows_unique' (New Followers) as proxy. """ batches = self._get_all_batches( connection_name="insights",