in python/ga4_setup/setup.py [0:0]
def load_existing_ga4_custom_events(configuration: map):
"""
Loads the existing custom events from Google Analytics 4 based on the provided configuration.
Args:
configuration: A dictionary containing the Google Analytics 4 property ID and data stream ID.
Returns:
A list of existing custom event names.
Raises:
GoogleAnalyticsAdminError: If an error occurs while retrieving the custom events.
"""
response = load_existing_ga4_custom_event_objs(configuration)
existing_event_rules = []
for page in response.pages:
for event_rule_obj in page.event_create_rules:
existing_event_rules.append(event_rule_obj.destination_event)
return existing_event_rules