From 1cb674698db2e7ab038c8dcb2f1e3bed5bd00f62 Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Thu, 25 Mar 2021 12:23:10 -0700 Subject: [PATCH] docs: update region tag names to match the convention (#55) * docs: update region tag names to match the convention * lint --- .../samples/snippets/quickstart.py | 16 ++++++++-------- .../snippets/quickstart_json_credentials.py | 14 ++++++++------ .../samples/snippets/quickstart_oauth2.py | 8 ++++---- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/google-analytics-data/samples/snippets/quickstart.py b/packages/google-analytics-data/samples/snippets/quickstart.py index c3fe192f12466..7572097f34788 100644 --- a/packages/google-analytics-data/samples/snippets/quickstart.py +++ b/packages/google-analytics-data/samples/snippets/quickstart.py @@ -26,7 +26,7 @@ pip3 install --upgrade google-analytics-data python3 quickstart.py """ -# [START google_analytics_data_quickstart] +# [START analyticsdata_quickstart] from google.analytics.data_v1beta import BetaAnalyticsDataClient from google.analytics.data_v1beta.types import DateRange from google.analytics.data_v1beta.types import Dimension @@ -40,13 +40,13 @@ def sample_run_report(property_id="YOUR-GA4-PROPERTY-ID"): # Google Analytics 4 property ID before running the sample. # property_id = "YOUR-GA4-PROPERTY-ID" - # [START google_analytics_data_initialize] + # [START analyticsdata_run_report_initialize] # Using a default constructor instructs the client to use the credentials # specified in GOOGLE_APPLICATION_CREDENTIALS environment variable. client = BetaAnalyticsDataClient() - # [END google_analytics_data_initialize] + # [END analyticsdata_run_report_initialize] - # [START google_analytics_data_run_report] + # [START analyticsdata_run_report] request = RunReportRequest( property="properties/" + str(property_id), dimensions=[Dimension(name="city")], @@ -54,16 +54,16 @@ def sample_run_report(property_id="YOUR-GA4-PROPERTY-ID"): date_ranges=[DateRange(start_date="2020-03-31", end_date="today")], ) response = client.run_report(request) - # [END google_analytics_data_run_report] + # [END analyticsdata_run_report] - # [START google_analytics_data_run_report_response] + # [START analyticsdata_run_report_response] print("Report result:") for row in response.rows: print(row.dimension_values[0].value, row.metric_values[0].value) - # [END google_analytics_data_run_report_response] + # [END analyticsdata_run_report_response] -# [END google_analytics_data_quickstart] +# [END analyticsdata_quickstart] if __name__ == "__main__": diff --git a/packages/google-analytics-data/samples/snippets/quickstart_json_credentials.py b/packages/google-analytics-data/samples/snippets/quickstart_json_credentials.py index 97b9b4f7a08f7..a30c8ea19f44b 100644 --- a/packages/google-analytics-data/samples/snippets/quickstart_json_credentials.py +++ b/packages/google-analytics-data/samples/snippets/quickstart_json_credentials.py @@ -27,7 +27,7 @@ pip3 install --upgrade google-analytics-data python3 quickstart_json_credentials.py """ -# [START google_analytics_data_quickstart] +# [START analyticsdata_json_credentials_quickstart] from google.analytics.data_v1beta import BetaAnalyticsDataClient from google.analytics.data_v1beta.types import DateRange from google.analytics.data_v1beta.types import Dimension @@ -41,7 +41,7 @@ def sample_run_report(property_id="YOUR-GA4-PROPERTY-ID", credentials_json_path= # Google Analytics 4 property ID before running the sample. # property_id = "YOUR-GA4-PROPERTY-ID" - # [START google_analytics_data_initialize] + # [START analyticsdata_json_credentials_initialize] # TODO(developer): Uncomment this variable and replace with a valid path to # the credentials.json file for your service account downloaded from the # Cloud Console. @@ -50,9 +50,9 @@ def sample_run_report(property_id="YOUR-GA4-PROPERTY-ID", credentials_json_path= # Explicitly use service account credentials by specifying # the private key file. client = BetaAnalyticsDataClient().from_service_account_json(credentials_json_path) - # [END google_analytics_data_initialize] + # [END analyticsdata_json_credentials_initialize] - # [START google_analytics_data_run_report] + # [START analyticsdata_json_credentials_run_report] request = RunReportRequest( property="properties/" + str(property_id), dimensions=[Dimension(name="city")], @@ -60,12 +60,14 @@ def sample_run_report(property_id="YOUR-GA4-PROPERTY-ID", credentials_json_path= date_ranges=[DateRange(start_date="2020-03-31", end_date="today")], ) response = client.run_report(request) - # [END google_analytics_data_run_report] + # [END analyticsdata_json_credentials_run_report] print("Report result:") for row in response.rows: print(row.dimension_values[0].value, row.metric_values[0].value) -# [END google_analytics_data_quickstart] + + +# [END analyticsdata_json_credentials_quickstart] if __name__ == "__main__": diff --git a/packages/google-analytics-data/samples/snippets/quickstart_oauth2.py b/packages/google-analytics-data/samples/snippets/quickstart_oauth2.py index 4ef32280ac313..83aae0bb7253e 100644 --- a/packages/google-analytics-data/samples/snippets/quickstart_oauth2.py +++ b/packages/google-analytics-data/samples/snippets/quickstart_oauth2.py @@ -27,7 +27,7 @@ pip3 install --upgrade google-analytics-data python3 quickstart_oauth2.py """ -# [START google_analytics_data_quickstart] +# [START analyticsdata_quickstart_oauth2] from google.analytics.data import BetaAnalyticsDataClient from google.analytics.data_v1beta.types import DateRange from google.analytics.data_v1beta.types import Dimension @@ -59,7 +59,7 @@ def sample_run_report(credentials=None, property_id="YOUR-GA4-PROPERTY-ID"): def get_credentials(): """Creates an OAuth2 credentials instance.""" - # [START google_analytics_data_initialize] + # [START analyticsdata_initialize] appflow = flow.InstalledAppFlow.from_client_secrets_file( "client_secrets.json", scopes=["https://www.googleapis.com/auth/analytics.readonly"], @@ -75,7 +75,7 @@ def get_credentials(): else: appflow.run_console() return appflow.credentials - # [END google_analytics_data_initialize] + # [END analyticsdata_initialize] def main(): @@ -83,7 +83,7 @@ def main(): sample_run_report(credentials) -# [END google_analytics_data_quickstart] +# [END analyticsdata_quickstart_oauth2] if __name__ == "__main__": main()