Class: Google::Analytics::Data::V1alpha::AnalyticsData::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/analytics/data/v1alpha/analytics_data/client.rb

Overview

Client for the AnalyticsData service.

Google Analytics reporting data service.

Defined Under Namespace

Classes: Configuration

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#metadata_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new AnalyticsData client object.

Examples

To create a new AnalyticsData client with the default configuration:

client = ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.new

To create a new AnalyticsData client with a custom configuration:

client = ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the AnalyticsData client.

Yield Parameters:



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 130

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/analytics/data/v1alpha/analytics_data_api_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  credentials ||= Credentials.default scope: @config.scope
  if credentials.is_a?(String) || credentials.is_a?(Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @analytics_data_stub = ::Gapic::ServiceStub.new(
    ::Google::Analytics::Data::V1alpha::AlphaAnalyticsData::Stub,
    credentials:  credentials,
    endpoint:     @config.endpoint,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors
  )
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the AnalyticsData Client class.

See Configuration for a description of the configuration fields.

Example

To modify the configuration for all AnalyticsData clients:

::Google::Analytics::Data::V1alpha::AnalyticsData::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 57

def self.configure
  @configure ||= begin
    namespace = ["Google", "Analytics", "Data", "V1alpha"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const&.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.timeout = 60.0
    default_config.retry_policy = {
      initial_delay: 1.0,
      max_delay:     60.0,
      multiplier:    1.3,
      retry_codes:   [2]
    }

    default_config.rpcs.run_report.timeout = 60.0

    default_config.rpcs.run_pivot_report.timeout = 60.0

    default_config.rpcs.batch_run_reports.timeout = 60.0

    default_config.rpcs.batch_run_pivot_reports.timeout = 60.0

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#batch_run_pivot_reports(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::BatchRunPivotReportsResponse #batch_run_pivot_reports(entity: nil, requests: nil) ⇒ ::Google::Analytics::Data::V1alpha::BatchRunPivotReportsResponse

Returns multiple pivot reports in a batch. All reports must be for the same Entity.

Overloads:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 474

def batch_run_pivot_reports request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::BatchRunPivotReportsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.batch_run_pivot_reports..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.batch_run_pivot_reports.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.batch_run_pivot_reports.retry_policy
  options.apply_defaults metadata:     @config.,
                         retry_policy: @config.retry_policy

  @analytics_data_stub.call_rpc :batch_run_pivot_reports, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#batch_run_reports(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::BatchRunReportsResponse #batch_run_reports(entity: nil, requests: nil) ⇒ ::Google::Analytics::Data::V1alpha::BatchRunReportsResponse

Returns multiple reports in a batch. All reports must be for the same Entity.

Overloads:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 408

def batch_run_reports request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::BatchRunReportsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.batch_run_reports..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.batch_run_reports.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.batch_run_reports.retry_policy
  options.apply_defaults metadata:     @config.,
                         retry_policy: @config.retry_policy

  @analytics_data_stub.call_rpc :batch_run_reports, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#configure {|config| ... } ⇒ Client::Configuration

Configure the AnalyticsData Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



105
106
107
108
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 105

def configure
  yield @config if block_given?
  @config
end

#get_metadata(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::Metadata #get_metadata(name: nil) ⇒ ::Google::Analytics::Data::V1alpha::Metadata

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.

Overloads:

  • #get_metadata(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::Metadata

    Pass arguments to get_metadata via a request object, either of type GetMetadataRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Analytics::Data::V1alpha::GetMetadataRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_metadata(name: nil) ⇒ ::Google::Analytics::Data::V1alpha::Metadata

    Pass arguments to get_metadata via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      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 4 (GA4) Property identifier.

      Example: properties/1234/metadata

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 604

def  request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::GetMetadataRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs...to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs..timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs..retry_policy
  options.apply_defaults metadata:     @config.,
                         retry_policy: @config.retry_policy

  @analytics_data_stub.call_rpc :get_metadata, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_universal_metadata(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::UniversalMetadata

Returns metadata for dimensions and metrics available in reporting methods. Used to explore the dimensions and metrics. Dimensions and metrics will be mostly added over time, but renames and deletions may occur.

This method returns Universal Metadata. Universal Metadata are dimensions and metrics applicable to any property such as country and totalUsers.

Pass arguments to get_universal_metadata via a request object, either of type GetUniversalMetadataRequest or an equivalent Hash.

Parameters:

  • request (::Google::Analytics::Data::V1alpha::GetUniversalMetadataRequest, ::Hash)

    A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

  • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 531

def  request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::GetUniversalMetadataRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs...to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs..timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs..retry_policy
  options.apply_defaults metadata:     @config.,
                         retry_policy: @config.retry_policy

  @analytics_data_stub.call_rpc :get_universal_metadata, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#run_pivot_report(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::RunPivotReportResponse #run_pivot_report(entity: nil, dimensions: nil, metrics: nil, dimension_filter: nil, metric_filter: nil, pivots: nil, date_ranges: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil) ⇒ ::Google::Analytics::Data::V1alpha::RunPivotReportResponse

Returns a customized pivot report of your Google Analytics event data. Pivot reports are more advanced and expressive formats than regular reports. In a pivot report, dimensions are only visible if they are included in a pivot. Multiple pivots can be specified to further dissect your data.

Overloads:

  • #run_pivot_report(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::RunPivotReportResponse

    Pass arguments to run_pivot_report via a request object, either of type RunPivotReportRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Analytics::Data::V1alpha::RunPivotReportRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #run_pivot_report(entity: nil, dimensions: nil, metrics: nil, dimension_filter: nil, metric_filter: nil, pivots: nil, date_ranges: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil) ⇒ ::Google::Analytics::Data::V1alpha::RunPivotReportResponse

    Pass arguments to run_pivot_report via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • entity (::Google::Analytics::Data::V1alpha::Entity, ::Hash) (defaults to: nil)

      A property whose events are tracked. Within a batch request, this entity should either be unspecified or consistent with the batch-level entity.

    • dimensions (::Array<::Google::Analytics::Data::V1alpha::Dimension, ::Hash>) (defaults to: nil)

      The dimensions requested. All defined dimensions must be used by one of the following: dimension_expression, dimension_filter, pivots, order_bys.

    • metrics (::Array<::Google::Analytics::Data::V1alpha::Metric, ::Hash>) (defaults to: nil)

      The metrics requested, at least one metric needs to be specified. All defined metrics must be used by one of the following: metric_expression, metric_filter, order_bys.

    • dimension_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) (defaults to: nil)

      The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter.

    • metric_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) (defaults to: nil)

      The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter.

    • pivots (::Array<::Google::Analytics::Data::V1alpha::Pivot, ::Hash>) (defaults to: nil)

      Describes the visual format of the report's dimensions in columns or rows. The union of the fieldNames (dimension names) in all pivots must be a subset of dimension names defined in Dimensions. No two pivots can share a dimension. A dimension is only visible if it appears in a pivot.

    • date_ranges (::Array<::Google::Analytics::Data::V1alpha::DateRange, ::Hash>) (defaults to: nil)

      The date range to retrieve event data for the report. If multiple date ranges are specified, event data from each date range is used in the report. A special dimension with field name "dateRange" can be included in a Pivot's field names; if included, the report compares between date ranges. In a cohort request, this dateRanges must be unspecified.

    • currency_code (::String) (defaults to: nil)

      A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field is empty, the report uses the entity's default currency.

    • cohort_spec (::Google::Analytics::Data::V1alpha::CohortSpec, ::Hash) (defaults to: nil)

      Cohort group associated with this request. If there is a cohort group in the request the 'cohort' dimension must be present.

    • keep_empty_rows (::Boolean) (defaults to: nil)

      If false or unspecified, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter.

    • return_property_quota (::Boolean) (defaults to: nil)

      Toggles whether to return the current state of this Analytics Property's quota. Quota is returned in PropertyQuota.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 342

def run_pivot_report request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::RunPivotReportRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.run_pivot_report..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.run_pivot_report.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.run_pivot_report.retry_policy
  options.apply_defaults metadata:     @config.,
                         retry_policy: @config.retry_policy

  @analytics_data_stub.call_rpc :run_pivot_report, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#run_realtime_report(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::RunRealtimeReportResponse #run_realtime_report(property: nil, dimensions: nil, metrics: nil, limit: nil, dimension_filter: nil, metric_filter: nil, metric_aggregations: nil, order_bys: nil, return_property_quota: nil) ⇒ ::Google::Analytics::Data::V1alpha::RunRealtimeReportResponse

The Google Analytics Realtime API returns a customized report of realtime event data for your property. These reports show events and usage from the last 30 minutes.

Overloads:

  • #run_realtime_report(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::RunRealtimeReportResponse

    Pass arguments to run_realtime_report via a request object, either of type RunRealtimeReportRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Analytics::Data::V1alpha::RunRealtimeReportRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #run_realtime_report(property: nil, dimensions: nil, metrics: nil, limit: nil, dimension_filter: nil, metric_filter: nil, metric_aggregations: nil, order_bys: nil, return_property_quota: nil) ⇒ ::Google::Analytics::Data::V1alpha::RunRealtimeReportResponse

    Pass arguments to run_realtime_report via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • property (::String) (defaults to: nil)

      A Google Analytics GA4 property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see where to find your Property ID.

      Example: properties/1234

    • dimensions (::Array<::Google::Analytics::Data::V1alpha::Dimension, ::Hash>) (defaults to: nil)

      The dimensions requested and displayed.

    • metrics (::Array<::Google::Analytics::Data::V1alpha::Metric, ::Hash>) (defaults to: nil)

      The metrics requested and displayed.

    • limit (::Integer) (defaults to: nil)

      The number of rows to return. If unspecified, 10 rows are returned. If -1, all rows are returned.

    • dimension_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) (defaults to: nil)

      The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter.

    • metric_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) (defaults to: nil)

      The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter.

    • metric_aggregations (::Array<::Google::Analytics::Data::V1alpha::MetricAggregation>) (defaults to: nil)

      Aggregation of metrics. Aggregated metric values will be shown in rows where the dimension_values are set to "RESERVED_(MetricAggregation)".

    • order_bys (::Array<::Google::Analytics::Data::V1alpha::OrderBy, ::Hash>) (defaults to: nil)

      Specifies how rows are ordered in the response.

    • return_property_quota (::Boolean) (defaults to: nil)

      Toggles whether to return the current state of this Analytics Property's Realtime quota. Quota is returned in PropertyQuota.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 699

def run_realtime_report request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::RunRealtimeReportRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.run_realtime_report..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "property" => request.property
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.run_realtime_report.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.run_realtime_report.retry_policy
  options.apply_defaults metadata:     @config.,
                         retry_policy: @config.retry_policy

  @analytics_data_stub.call_rpc :run_realtime_report, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#run_report(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::RunReportResponse #run_report(entity: nil, dimensions: nil, metrics: nil, date_ranges: nil, offset: nil, limit: nil, metric_aggregations: nil, dimension_filter: nil, metric_filter: nil, order_bys: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil) ⇒ ::Google::Analytics::Data::V1alpha::RunReportResponse

Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the Google Analytics tracking code. The data returned from the API is as a table with columns for the requested dimensions and metrics. Metrics are individual measurements of user activity on your property, such as active users or event count. Dimensions break down metrics across some common criteria, such as country or event name.

Overloads:

  • #run_report(request, options = nil) ⇒ ::Google::Analytics::Data::V1alpha::RunReportResponse

    Pass arguments to run_report via a request object, either of type RunReportRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Analytics::Data::V1alpha::RunReportRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #run_report(entity: nil, dimensions: nil, metrics: nil, date_ranges: nil, offset: nil, limit: nil, metric_aggregations: nil, dimension_filter: nil, metric_filter: nil, order_bys: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil) ⇒ ::Google::Analytics::Data::V1alpha::RunReportResponse

    Pass arguments to run_report via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • entity (::Google::Analytics::Data::V1alpha::Entity, ::Hash) (defaults to: nil)

      A property whose events are tracked. Within a batch request, this entity should either be unspecified or consistent with the batch-level entity.

    • dimensions (::Array<::Google::Analytics::Data::V1alpha::Dimension, ::Hash>) (defaults to: nil)

      The dimensions requested and displayed.

    • metrics (::Array<::Google::Analytics::Data::V1alpha::Metric, ::Hash>) (defaults to: nil)

      The metrics requested and displayed.

    • date_ranges (::Array<::Google::Analytics::Data::V1alpha::DateRange, ::Hash>) (defaults to: nil)

      Date ranges of data to read. If multiple date ranges are requested, each response row will contain a zero based date range index. If two date ranges overlap, the event data for the overlapping days is included in the response rows for both date ranges. In a cohort request, this dateRanges must be unspecified.

    • offset (::Integer) (defaults to: nil)

      The row count of the start row. The first row is counted as row 0.

    • limit (::Integer) (defaults to: nil)

      The number of rows to return. If unspecified, 10 rows are returned. If -1, all rows are returned.

    • metric_aggregations (::Array<::Google::Analytics::Data::V1alpha::MetricAggregation>) (defaults to: nil)

      Aggregation of metrics. Aggregated metric values will be shown in rows where the dimension_values are set to "RESERVED_(MetricAggregation)".

    • dimension_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) (defaults to: nil)

      The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter.

    • metric_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) (defaults to: nil)

      The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter.

    • order_bys (::Array<::Google::Analytics::Data::V1alpha::OrderBy, ::Hash>) (defaults to: nil)

      Specifies how rows are ordered in the response.

    • currency_code (::String) (defaults to: nil)

      A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field is empty, the report uses the entity's default currency.

    • cohort_spec (::Google::Analytics::Data::V1alpha::CohortSpec, ::Hash) (defaults to: nil)

      Cohort group associated with this request. If there is a cohort group in the request the 'cohort' dimension must be present.

    • keep_empty_rows (::Boolean) (defaults to: nil)

      If false or unspecified, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter.

    • return_property_quota (::Boolean) (defaults to: nil)

      Toggles whether to return the current state of this Analytics Property's quota. Quota is returned in PropertyQuota.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/google/analytics/data/v1alpha/analytics_data/client.rb', line 239

def run_report request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::RunReportRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.run_report..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.run_report.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.run_report.retry_policy
  options.apply_defaults metadata:     @config.,
                         retry_policy: @config.retry_policy

  @analytics_data_stub.call_rpc :run_report, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end