@@ -53,8 +53,9 @@ public static void main(String... args) throws Exception {
5353 */
5454 String propertyId = "YOUR-GA4-PROPERTY-ID" ;
5555
56- /** TODO(developer): Replace this variable with a valid path to the credentials.json file
57- * for your service account downloaded from the Cloud Console.
56+ /**
57+ * TODO(developer): Replace this variable with a valid path to the credentials.json file for
58+ * your service account downloaded from the Cloud Console.
5859 */
5960 String credentialsJsonPath = "/path/to/credentials.json" ;
6061 sampleRunReport (propertyId , credentialsJsonPath );
@@ -66,8 +67,8 @@ static void sampleRunReport(String propertyId, String credentialsJsonPath) throw
6667 // [START analyticsdata_json_credentials_initialize]
6768 // Explicitly use service account credentials by specifying
6869 // the private key file.
69- GoogleCredentials credentials = GoogleCredentials
70- .fromStream (new FileInputStream (credentialsJsonPath ));
70+ GoogleCredentials credentials =
71+ GoogleCredentials .fromStream (new FileInputStream (credentialsJsonPath ));
7172
7273 BetaAnalyticsDataSettings betaAnalyticsDataSettings =
7374 BetaAnalyticsDataSettings .newBuilder ()
@@ -79,13 +80,13 @@ static void sampleRunReport(String propertyId, String credentialsJsonPath) throw
7980 // [END analyticsdata_json_credentials_initialize]
8081
8182 // [START analyticsdata_json_credentials_run_report]
82- RunReportRequest request = RunReportRequest . newBuilder ()
83- . setProperty ( "properties/" + propertyId )
84- . addDimensions (
85- Dimension .newBuilder ().setName ("city" ))
86- .addMetrics (Metric .newBuilder ().setName ("activeUsers" ))
87- .addDateRanges (
88- DateRange . newBuilder (). setStartDate ( "2020-03-31" ). setEndDate ( "today" )) .build ();
83+ RunReportRequest request =
84+ RunReportRequest . newBuilder ( )
85+ . setProperty ( "properties/" + propertyId )
86+ . addDimensions ( Dimension .newBuilder ().setName ("city" ))
87+ .addMetrics (Metric .newBuilder ().setName ("activeUsers" ))
88+ .addDateRanges (DateRange . newBuilder (). setStartDate ( "2020-03-31" ). setEndDate ( "today" ))
89+ .build ();
8990
9091 // Make the request.
9192 RunReportResponse response = analyticsData .runReport (request );
@@ -95,12 +96,11 @@ static void sampleRunReport(String propertyId, String credentialsJsonPath) throw
9596 System .out .println ("Report result:" );
9697 // Iterate through every row of the API response.
9798 for (Row row : response .getRowsList ()) {
98- System .out .printf ("%s, %s%n" , row . getDimensionValues ( 0 ). getValue (),
99- row .getMetricValues (0 ).getValue ());
99+ System .out .printf (
100+ "%s, %s%n" , row . getDimensionValues ( 0 ). getValue (), row .getMetricValues (0 ).getValue ());
100101 }
101102 // [END analyticsdata_json_credentials_print_report]
102103 }
103104 }
104105}
105106// [END analyticsdata_json_credentials_quickstart]
106-
0 commit comments