def entry()

in python/ga4_setup/setup.py [0:0]


def entry():
  """
  This function is the entry point for the setup script. It takes three arguments:

  Args:
    ga4_resource: The Google Analytics 4 resource to be configured.
    ga4_property_id: The Google Analytics 4 property ID.
    ga4_stream_id: The Google Analytics 4 data stream ID.

  Raises:
    GoogleAnalyticsAdminError: If an error occurs while configuring the Google Analytics 4 resource.
  """
  
  '''
  Following Google API scopes are required to call Google Analytics Admin API:
  https://www.googleapis.com/auth/analytics
  https://www.googleapis.com/auth/analytics.edit
  https://www.googleapis.com/auth/analytics.manage.users
  https://www.googleapis.com/auth/analytics.manage.users.readonly
  https://www.googleapis.com/auth/analytics.provision
  https://www.googleapis.com/auth/analytics.readonly
  https://www.googleapis.com/auth/analytics.user.deletion
  '''

  import argparse

  parser = argparse.ArgumentParser()
  parser.add_argument('--ga4_resource', type=str, required=True)
  parser.add_argument('--ga4_property_id', type=str, required=True)
  parser.add_argument('--ga4_stream_id', type=str, required=True)
  args = parser.parse_args()

  configuration = {
    'property_id': args.ga4_property_id,
    'stream_id': args.ga4_stream_id
  }

  # python setup.py --ga4_resource=measurement_properties
  if args.ga4_resource == "measurement_properties":
    secret_display_name = 'MAJ Activation'
    properties = {
      'measurement_id': get_measurement_id(configuration),
      'measurement_secret': get_measurement_protocol_secret(configuration, secret_display_name)
    }
    print(json.dumps(properties))

  if args.ga4_resource == "check_property_type":
    property = get_property(configuration)
    is_property_supported = set((property.property_type.PROPERTY_TYPE_ORDINARY, property.property_type.PROPERTY_TYPE_SUBPROPERTY, property.property_type.PROPERTY_TYPE_ROLLUP))
    
    result = {}
    if property.property_type in is_property_supported:
      result = {'supported': "True"}
    else:
      result = {'supported': "False"}

    print(json.dumps(result))

  # python setup.py --ga4_resource=custom_events
  if args.ga4_resource == "custom_events":
    rename_existing_ga4_custom_events(configuration, "mas_", "maj_")
    create_custom_events(configuration)

  # python setup.py --ga4_resource=custom_dimensions
  if args.ga4_resource == "custom_dimensions":
    rename_existing_ga4_custom_dimensions(configuration, "MDE ", "MAJ ")
    create_custom_dimensions(configuration)