1414
1515'use strict' ;
1616
17- /** Google Analytics Data API sample application retrieving dimension and metrics
18- metadata.
19-
20- See https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/getMetadata
21- for more information.
22-
23- Before you start the application, please review the comments starting with
24- "TODO(developer)" and update the code to use correct values.
25-
26- Usage:
27- npm install
28- node getCommonMetadata.js
17+ /**
18+ * Google Analytics Data API sample application retrieving dimension and metrics
19+ * metadata.
20+ *
21+ * See https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/getMetadata
22+ * for more information.
23+ *
24+ * Before you start the application, please review the comments starting with
25+ * "TODO(developer)" and update the code to use correct values.
26+ *
27+ * Usage:
28+ * npm install
29+ * node getCommonMetadata.js
2930 */
3031
3132function main ( propertyId = 'YOUR-GA4-PROPERTY-ID' ) {
@@ -43,13 +44,15 @@ function main(propertyId = 'YOUR-GA4-PROPERTY-ID') {
4344 // needs to be created once, and can be reused for multiple requests.
4445 const analyticsDataClient = new BetaAnalyticsDataClient ( ) ;
4546
46- // Retrieves dimensions and metrics available for all Google Analytics 4 properties.
47+ // Retrieves dimensions and metrics available for all Google Analytics 4
48+ // properties.
4749 async function getCommonMetadata ( ) {
4850 const [ response ] = await analyticsDataClient . getMetadata ( {
4951 name : `properties/${ propertyId } /metadata` ,
5052 } ) ;
5153 console . log (
52- 'Dimensions and metrics available for all Google Analytics 4 properties:'
54+ 'Dimensions and metrics available for all ' +
55+ 'Google Analytics 4 properties:' ,
5356 ) ;
5457 printGetMetadataResponse ( response ) ;
5558 }
@@ -58,11 +61,12 @@ function main(propertyId = 'YOUR-GA4-PROPERTY-ID') {
5861
5962 // Prints results of the getMetadata call.
6063 function printGetMetadataResponse ( response ) {
61- //[START analyticsdata_print_get_metadata_response]
62- response . dimensions . forEach ( dimension => {
64+ // [START analyticsdata_print_get_metadata_response]
65+ response . dimensions . forEach ( ( dimension ) => {
6366 console . log ( 'DIMENSION' ) ;
6467 console . log (
65- `${ dimension . apiName } (${ dimension . uiName } ): ${ dimension . description } `
68+ `${ dimension . apiName } (${ dimension . uiName } ): ` +
69+ `${ dimension . description } ` ,
6670 ) ;
6771 console . log ( `custom definition: ${ dimension . customDefinition } ` ) ;
6872 if (
@@ -74,10 +78,10 @@ function main(propertyId = 'YOUR-GA4-PROPERTY-ID') {
7478 console . log ( ) ;
7579 } ) ;
7680
77- response . metrics . forEach ( metric => {
81+ response . metrics . forEach ( ( metric ) => {
7882 console . log ( 'METRIC' ) ;
7983 console . log (
80- `${ metric . apiName } (${ metric . uiName } ): ${ metric . description } `
84+ `${ metric . apiName } (${ metric . uiName } ): ${ metric . description } ` ,
8185 ) ;
8286 console . log ( `custom definition: ${ metric . customDefinition } ` ) ;
8387 if ( metric . expression ) {
@@ -94,7 +98,7 @@ function main(propertyId = 'YOUR-GA4-PROPERTY-ID') {
9498 // [END analyticsdata_get_common_metadata]
9599}
96100
97- process . on ( 'unhandledRejection' , err => {
101+ process . on ( 'unhandledRejection' , ( err ) => {
98102 console . error ( err . message ) ;
99103 process . exitCode = 1 ;
100104} ) ;
0 commit comments