@google-analytics/data
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -55,2 +55,7 @@ { | ||
}, | ||
"GetUniversalMetadata": { | ||
"timeout_millis": 60000, | ||
"retry_codes_name": "unknown", | ||
"retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" | ||
}, | ||
"GetMetadata": { | ||
@@ -57,0 +62,0 @@ "timeout_millis": 60000, |
@@ -99,2 +99,5 @@ import * as gax from 'google-gax'; | ||
batchRunPivotReports(request: protos.google.analytics.data.v1alpha.IBatchRunPivotReportsRequest, callback: Callback<protos.google.analytics.data.v1alpha.IBatchRunPivotReportsResponse, protos.google.analytics.data.v1alpha.IBatchRunPivotReportsRequest | null | undefined, {} | null | undefined>): void; | ||
getUniversalMetadata(request: protos.google.analytics.data.v1alpha.IGetUniversalMetadataRequest, options?: gax.CallOptions): Promise<[protos.google.analytics.data.v1alpha.IUniversalMetadata, (protos.google.analytics.data.v1alpha.IGetUniversalMetadataRequest | undefined), {} | undefined]>; | ||
getUniversalMetadata(request: protos.google.analytics.data.v1alpha.IGetUniversalMetadataRequest, options: gax.CallOptions, callback: Callback<protos.google.analytics.data.v1alpha.IUniversalMetadata, protos.google.analytics.data.v1alpha.IGetUniversalMetadataRequest | null | undefined, {} | null | undefined>): void; | ||
getUniversalMetadata(request: protos.google.analytics.data.v1alpha.IGetUniversalMetadataRequest, callback: Callback<protos.google.analytics.data.v1alpha.IUniversalMetadata, protos.google.analytics.data.v1alpha.IGetUniversalMetadataRequest | null | undefined, {} | null | undefined>): void; | ||
getMetadata(request: protos.google.analytics.data.v1alpha.IGetMetadataRequest, options?: gax.CallOptions): Promise<[protos.google.analytics.data.v1alpha.IMetadata, protos.google.analytics.data.v1alpha.IGetMetadataRequest | undefined, {} | undefined]>; | ||
@@ -104,3 +107,3 @@ getMetadata(request: protos.google.analytics.data.v1alpha.IGetMetadataRequest, options: gax.CallOptions, callback: Callback<protos.google.analytics.data.v1alpha.IMetadata, protos.google.analytics.data.v1alpha.IGetMetadataRequest | null | undefined, {} | null | undefined>): void; | ||
/** | ||
* Return a fully-qualified propertyMetadata resource name string. | ||
* Return a fully-qualified metadata resource name string. | ||
* | ||
@@ -110,11 +113,11 @@ * @param {string} property | ||
*/ | ||
propertyMetadataPath(property: string): string; | ||
metadataPath(property: string): string; | ||
/** | ||
* Parse the property from PropertyMetadata resource. | ||
* Parse the property from Metadata resource. | ||
* | ||
* @param {string} propertyMetadataName | ||
* A fully-qualified path representing property_metadata resource. | ||
* @param {string} metadataName | ||
* A fully-qualified path representing Metadata resource. | ||
* @returns {string} A string representing the property. | ||
*/ | ||
matchPropertyFromPropertyMetadataName(propertyMetadataName: string): string | number; | ||
matchPropertyFromMetadataName(metadataName: string): string | number; | ||
/** | ||
@@ -121,0 +124,0 @@ * Terminate the GRPC channel and close the client. |
@@ -123,3 +123,3 @@ "use strict"; | ||
this.pathTemplates = { | ||
propertyMetadataPathTemplate: new this._gaxModule.PathTemplate('properties/{property}/metadata'), | ||
metadataPathTemplate: new this._gaxModule.PathTemplate('properties/{property}/metadata'), | ||
}; | ||
@@ -163,2 +163,3 @@ // Put together the default options sent with requests. | ||
'batchRunPivotReports', | ||
'getUniversalMetadata', | ||
'getMetadata', | ||
@@ -438,9 +439,47 @@ ]; | ||
* | ||
* This method returns Universal Metadata. Universal Metadata are dimensions | ||
* and metrics applicable to any property such as `country` and `totalUsers`. | ||
* | ||
* @param {Object} request | ||
* The request object that will be sent. | ||
* @param {object} [options] | ||
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. | ||
* @returns {Promise} - The promise which resolves to an array. | ||
* The first element of the array is an object representing [UniversalMetadata]{@link google.analytics.data.v1alpha.UniversalMetadata}. | ||
* The promise has a method named "cancel" which cancels the ongoing API call. | ||
*/ | ||
getUniversalMetadata(request, optionsOrCallback, callback) { | ||
request = request || {}; | ||
let options; | ||
if (typeof optionsOrCallback === 'function' && callback === undefined) { | ||
callback = optionsOrCallback; | ||
options = {}; | ||
} | ||
else { | ||
options = optionsOrCallback; | ||
} | ||
options = options || {}; | ||
this.initialize(); | ||
return this.innerApiCalls.getUniversalMetadata(request, options, callback); | ||
} | ||
/** | ||
* Returns metadata for dimensions and metrics available in reporting methods. | ||
* Used to explore the dimensions and metrics. In this method, a Google | ||
* Analytics 4 (GA4) Property Identifier is specified in the request, and | ||
* the metadata response includes Custom dimensions and metrics as well as | ||
* Universal metadata. | ||
* | ||
* For example if a custom metric with parameter name `levels_unlocked` is | ||
* registered to a property, the Metadata response will contain | ||
* `customEvent:levels_unlocked`. Universal metadata are dimensions and | ||
* metrics applicable to any property such as `country` and `totalUsers`. | ||
* | ||
* @param {Object} request | ||
* The request object that will be sent. | ||
* @param {string} request.name | ||
* Required. The name of the metadata to retrieve. Either has the form | ||
* 'metadata' or 'properties/{property}/metadata'. This name field is | ||
* Required. The resource name of the metadata to retrieve. This name field is | ||
* specified in the URL path and not URL parameters. Property is a numeric | ||
* Google Analytics App + Web Property Id. | ||
* Google Analytics 4 (GA4) Property identifier. | ||
* | ||
* Example: properties/1234/metadata | ||
* @param {object} [options] | ||
@@ -475,3 +514,3 @@ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. | ||
/** | ||
* Return a fully-qualified propertyMetadata resource name string. | ||
* Return a fully-qualified metadata resource name string. | ||
* | ||
@@ -481,4 +520,4 @@ * @param {string} property | ||
*/ | ||
propertyMetadataPath(property) { | ||
return this.pathTemplates.propertyMetadataPathTemplate.render({ | ||
metadataPath(property) { | ||
return this.pathTemplates.metadataPathTemplate.render({ | ||
property: property, | ||
@@ -488,10 +527,10 @@ }); | ||
/** | ||
* Parse the property from PropertyMetadata resource. | ||
* Parse the property from Metadata resource. | ||
* | ||
* @param {string} propertyMetadataName | ||
* A fully-qualified path representing property_metadata resource. | ||
* @param {string} metadataName | ||
* A fully-qualified path representing Metadata resource. | ||
* @returns {string} A string representing the property. | ||
*/ | ||
matchPropertyFromPropertyMetadataName(propertyMetadataName) { | ||
return this.pathTemplates.propertyMetadataPathTemplate.match(propertyMetadataName).property; | ||
matchPropertyFromMetadataName(metadataName) { | ||
return this.pathTemplates.metadataPathTemplate.match(metadataName).property; | ||
} | ||
@@ -498,0 +537,0 @@ /** |
# Changelog | ||
### [1.0.1](https://www.github.com/googleapis/nodejs-analytics-data/compare/v1.0.0...v1.0.1) (2020-11-03) | ||
### Bug Fixes | ||
* **deps:** update dependency @google-cloud/billing to v2 ([#7](https://www.github.com/googleapis/nodejs-analytics-data/issues/7)) ([de83230](https://www.github.com/googleapis/nodejs-analytics-data/commit/de832308358059c3dbd59a4e9b118b5c2a208570)) | ||
## 1.0.0 (2020-09-02) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@google-analytics/data", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Data client for Node.js", | ||
@@ -60,4 +60,4 @@ "repository": "googleapis/nodejs-analytics-data", | ||
"typescript": "^3.9.6", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.12" | ||
"webpack": "^5.0.0", | ||
"webpack-cli": "^4.0.0" | ||
}, | ||
@@ -64,0 +64,0 @@ "engines": { |
@@ -60,15 +60,17 @@ [//]: # "This README.md file is auto-generated, all changes to this file will be lost." | ||
```javascript | ||
// Imports the Google Cloud client library | ||
/** | ||
* TODO(developer): Uncomment this variable and replace with your GA4 | ||
* property ID before running the sample. | ||
*/ | ||
// const propertyId = 'YOUR-GA4-PROPERTY-ID'; | ||
// eslint-disable-next-line node/no-extraneous-require, node/no-missing-require | ||
// Imports the Google Analytics Data API client library | ||
const {AlphaAnalyticsDataClient} = require('@google-analytics/data'); | ||
// TODO(developer): replace with your prefered project ID. | ||
// const projectId = 'my-project' | ||
// Creates a client | ||
const client = new AlphaAnalyticsDataClient(); | ||
// Runs a simple report. | ||
async function runReport() { | ||
const res = await client.runReport({ | ||
const [response] = await client.runReport({ | ||
entity: { | ||
@@ -79,4 +81,4 @@ propertyId: propertyId, | ||
{ | ||
startDate: startDate, | ||
endDate: endDate, | ||
startDate: '2020-03-31', | ||
endDate: 'today', | ||
}, | ||
@@ -86,3 +88,3 @@ ], | ||
{ | ||
name: nameOfDimensions, | ||
name: 'city', | ||
}, | ||
@@ -92,8 +94,11 @@ ], | ||
{ | ||
name: nameOfMetrics, | ||
name: 'activeUsers', | ||
}, | ||
], | ||
}); | ||
console.log(res[0].rows); | ||
return res[0].rows; | ||
console.log('Report result:'); | ||
response.rows.forEach(row => { | ||
console.log(row.dimensionValues[0], row.metricValues[0]); | ||
}); | ||
} | ||
@@ -100,0 +105,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2051961
32419
184