https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-libraries 我已经在 c# 中运行了快速入门的示例代码,并且效果很好。但我想在用 vb.net 编写的旧项目中使用它。
当我创建 RunReportRequest 对象时,属性似乎是只读的......
Dim entity As New Entity()
entity.PropertyId = propertyId
Dim m As New Metric
m.Name = "activeUsers"
Dim metrics = New Google.Protobuf.Collections.RepeatedField(Of Metric)
metrics.Add(m)
Dim d As New Dimension
d.Name = "city"
Dim dimensions As New Google.Protobuf.Collections.RepeatedField(Of Dimension)
dimensions.Add(d)
Dim r As New DateRange
r.StartDate = "2021-01-01"
r.EndDate = "2021-04-31"
Dim range As New Google.Protobuf.Collections.RepeatedField(Of DateRange)
range.Add(r)
Dim request As New RunReportRequest
With request
.Entity = entity
.Dimensions = dimensions
.Metrics = metrics
.DateRanges = range
End With
当我在“RunReportRequest”对象上按 F5 时:
<DebuggerNonUserCode>
Public Shared ReadOnly Property Descriptor As MessageDescriptor
<DebuggerNonUserCode>
Public Shared ReadOnly Property Parser As MessageParser(Of RunReportRequest)
'
' Summary:
' 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.
<DebuggerNonUserCode>
Public ReadOnly Property DateRanges As RepeatedField(Of DateRange)
'
' Summary:
' The row count of the start row. The first row is counted as row 0. To learn more
' about this pagination parameter, see [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
<DebuggerNonUserCode>
Public Property Offset As Long
'
' Summary:
' The number of rows to return. If unspecified, 10 rows are returned. If -1, all
' rows are returned. To learn more about this pagination parameter, see [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
<DebuggerNonUserCode>
Public Property Limit As Long
'
' Summary:
' A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field
' is empty, the report uses the entity's default currency.
<DebuggerNonUserCode>
Public Property CurrencyCode As String
'
' Summary:
' The filter clause of dimensions. Dimensions must be requested to be used in this
' filter. Metrics cannot be used in this filter.
<DebuggerNonUserCode>
Public Property DimensionFilter As FilterExpression
'
' Summary:
' 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.
<DebuggerNonUserCode>
Public Property MetricFilter As FilterExpression
'
' Summary:
' Specifies how rows are ordered in the response.
<DebuggerNonUserCode>
Public ReadOnly Property OrderBys As RepeatedField(Of OrderBy)
'
' Summary:
' Cohort group associated with this request. If there is a cohort group in the
' request the 'cohort' dimension must be present.
<DebuggerNonUserCode>
Public Property CohortSpec As CohortSpec
'
' Summary:
' Aggregation of metrics. Aggregated metric values will be shown in rows where
' the dimension_values are set to "RESERVED_(MetricAggregation)".
<DebuggerNonUserCode>
Public ReadOnly Property MetricAggregations As RepeatedField(Of MetricAggregation)
'
' Summary:
' The metrics requested and displayed.
<DebuggerNonUserCode>
Public ReadOnly Property Metrics As RepeatedField(Of Metric)
'
' Summary:
' Toggles whether to return the current state of this Analytics Property's quota.
' Quota is returned in [PropertyQuota](#PropertyQuota).
<DebuggerNonUserCode>
Public Property ReturnPropertyQuota As Boolean
'
' Summary:
' A property whose events are tracked. Within a batch request, this entity should
' either be unspecified or consistent with the batch-level entity.
<DebuggerNonUserCode>
Public Property Entity As Entity
'
' Summary:
' 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.
<DebuggerNonUserCode>
Public Property KeepEmptyRows As Boolean
'
' Summary:
' The dimensions requested and displayed.
<DebuggerNonUserCode>
Public ReadOnly Property Dimensions As RepeatedField(Of Dimension)
我已经安装了这个版本:Install-Package Google.Analytics.Data.V1Alpha -Version 1.0.0-alpha01