addGoogleAnalytics method

Future<Operation> addGoogleAnalytics(
  1. AddGoogleAnalyticsRequest request,
  2. String parent, {
  3. String? $fields,
})

Links the specified FirebaseProject with an existing Google Analytics account.

Using this call, you can either: - Specify an analyticsAccountId to provision a new Google Analytics property within the specified account and associate the new property with the FirebaseProject. - Specify an existing analyticsPropertyId to associate the property with the FirebaseProject. Note that when you call AddGoogleAnalytics: 1. The first check determines if any existing data streams in the Google Analytics property correspond to any existing Firebase Apps in the FirebaseProject (based on the packageName or bundleId associated with the data stream). Then, as applicable, the data streams and apps are linked. Note that this auto-linking only applies to AndroidApps and IosApps. 2. If no corresponding data streams are found for the Firebase Apps, new data streams are provisioned in the Google Analytics property for each of the Firebase Apps. Note that a new data stream is always provisioned for a Web App even if it was previously associated with a data stream in the Analytics property. Learn more about the hierarchy and structure of Google Analytics accounts in the Analytics documentation. The result of this call is an [Operation](../../v1beta1/operations). Poll the Operation to track the provisioning process by calling GetOperation until [done](../../v1beta1/operations#Operation.FIELDS.done) is true. When done is true, the Operation has either succeeded or failed. If the Operation succeeded, its [response](../../v1beta1/operations#Operation.FIELDS.response) is set to an AnalyticsDetails; if the Operation failed, its [error](../../v1beta1/operations#Operation.FIELDS.error) is set to a google.rpc.Status. To call AddGoogleAnalytics, a project member must be an Owner for the existing FirebaseProject and have the [Edit permission](https://support.google.com/analytics/answer/2884495) for the Google Analytics account. If the FirebaseProject already has Google Analytics enabled, and you call AddGoogleAnalytics using an analyticsPropertyId that's different from the currently associated property, then the call will fail. Analytics may have already been enabled in the Firebase console or by specifying timeZone and regionCode in the call to [AddFirebase](../../v1beta1/projects/addFirebase).

request - The metadata request object.

Request parameters:

parent - The resource name of the FirebaseProject to link to an existing Google Analytics account, in the format: projects/PROJECT_IDENTIFIER Refer to the FirebaseProject [name](../projects#FirebaseProject.FIELDS.name) field for details about PROJECT_IDENTIFIER values. Value must have pattern ^projects/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a Operation.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Operation> addGoogleAnalytics(
  AddGoogleAnalyticsRequest request,
  core.String parent, {
  core.String? $fields,
}) async {
  final _body = convert.json.encode(request);
  final _queryParams = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final _url =
      'v1beta1/' + core.Uri.encodeFull('$parent') + ':addGoogleAnalytics';

  final _response = await _requester.request(
    _url,
    'POST',
    body: _body,
    queryParams: _queryParams,
  );
  return Operation.fromJson(_response as core.Map<core.String, core.dynamic>);
}