Exemple #1
0
        /// <summary>Snippet for RunReportAsync</summary>
        public async Task RunReportRequestObjectAsync()
        {
            // Snippet: RunReportAsync(RunReportRequest, CallSettings)
            // Additional: RunReportAsync(RunReportRequest, CancellationToken)
            // Create client
            AlphaAnalyticsDataClient alphaAnalyticsDataClient = await AlphaAnalyticsDataClient.CreateAsync();

            // Initialize request argument(s)
            RunReportRequest request = new RunReportRequest
            {
                Entity             = new Entity(),
                Dimensions         = { new Dimension(), },
                Metrics            = { new Metric(), },
                DateRanges         = { new DateRange(), },
                Offset             = 0L,
                Limit              = 0L,
                MetricAggregations =
                {
                    MetricAggregation.Unspecified,
                },
                DimensionFilter     = new FilterExpression(),
                MetricFilter        = new FilterExpression(),
                OrderBys            = { new OrderBy(), },
                CurrencyCode        = "",
                CohortSpec          = new CohortSpec(),
                KeepEmptyRows       = false,
                ReturnPropertyQuota = false,
            };
            // Make the request
            RunReportResponse response = await alphaAnalyticsDataClient.RunReportAsync(request);

            // End snippet
        }
        /// <summary>Snippet for RunReportAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task RunReportRequestObjectAsync()
        {
            // Create client
            BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();

            // Initialize request argument(s)
            RunReportRequest request = new RunReportRequest
            {
                Property           = "",
                Dimensions         = { new Dimension(), },
                Metrics            = { new Metric(), },
                DateRanges         = { new DateRange(), },
                DimensionFilter    = new FilterExpression(),
                MetricFilter       = new FilterExpression(),
                Offset             = 0L,
                Limit              = 0L,
                MetricAggregations =
                {
                    MetricAggregation.Unspecified,
                },
                OrderBys            = { new OrderBy(), },
                CurrencyCode        = "",
                CohortSpec          = new CohortSpec(),
                KeepEmptyRows       = false,
                ReturnPropertyQuota = false,
            };
            // Make the request
            RunReportResponse response = await betaAnalyticsDataClient.RunReportAsync(request);
        }
        static void SampleRunReport(string propertyId = "YOUR-GA4-PROPERTY-ID", string credentialsJsonPath = "")
        {
            /**
             * TODO(developer): Uncomment this variable and replace with your
             *  Google Analytics 4 property ID before running the sample.
             */
            // propertyId = "YOUR-GA4-PROPERTY-ID";

            // [START analyticsdata_json_credentials_initialize]

            /**
             * TODO(developer): Uncomment this variable and replace with a valid path to
             *  the credentials.json file for your service account downloaded from the
             *  Cloud Console.
             *  Otherwise, default service account credentials will be derived from
             *  the GOOGLE_APPLICATION_CREDENTIALS environment variable.
             */
            // credentialsJsonPath = "/path/to/credentials.json";

            // Explicitly use service account credentials by specifying
            // the private key file.
            BetaAnalyticsDataClient client = new BetaAnalyticsDataClientBuilder
            {
                CredentialsPath = credentialsJsonPath
            }.Build();
            // [END analyticsdata_json_credentials_initialize]

            // [START analyticsdata_json_credentials_run_report]
            // Initialize request argument(s)
            RunReportRequest request = new RunReportRequest
            {
                Property   = "property/" + propertyId,
                Dimensions = { new Dimension {
                                   Name = "city"
                               }, },
                Metrics = { new Metric {
                                Name = "activeUsers"
                            }, },
                DateRanges = { new DateRange {
                                   StartDate = "2020-03-31", EndDate = "today"
                               }, },
            };

            // Make the request
            PagedEnumerable <RunReportResponse, DimensionHeader> response = client.RunReport(request);

            // [END analyticsdata_json_credentials_run_report]

            // [START analyticsdata_json_credentials_run_report_response]
            Console.WriteLine("Report result:");
            foreach (RunReportResponse page in response.AsRawResponses())
            {
                foreach (Row row in page.Rows)
                {
                    Console.WriteLine("{0}, {1}", row.DimensionValues[0].Value, row.MetricValues[0].Value);
                }
            }
            // [END analyticsdata_json_credentials_run_report_response]
        }
 /// <summary>Snippet for RunReport</summary>
 public void RunReport_RequestObject()
 {
     // Snippet: RunReport(RunReportRequest,CallSettings)
     // Create client
     AlphaAnalyticsDataClient alphaAnalyticsDataClient = AlphaAnalyticsDataClient.Create();
     // Initialize request argument(s)
     RunReportRequest request = new RunReportRequest();
     // Make the request
     RunReportResponse response = alphaAnalyticsDataClient.RunReport(request);
     // End snippet
 }
        public void RunReport()
        {
            Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient> mockGrpcClient = new Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient>(MockBehavior.Strict);
            RunReportRequest  request          = new RunReportRequest();
            RunReportResponse expectedResponse = new RunReportResponse();

            mockGrpcClient.Setup(x => x.RunReport(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            AlphaAnalyticsDataClient client   = new AlphaAnalyticsDataClientImpl(mockGrpcClient.Object, null);
            RunReportResponse        response = client.RunReport(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for RunReportAsync</summary>
        public async Task RunReportAsync_RequestObject()
        {
            // Snippet: RunReportAsync(RunReportRequest,CallSettings)
            // Additional: RunReportAsync(RunReportRequest,CancellationToken)
            // Create client
            AlphaAnalyticsDataClient alphaAnalyticsDataClient = await AlphaAnalyticsDataClient.CreateAsync();

            // Initialize request argument(s)
            RunReportRequest request = new RunReportRequest();
            // Make the request
            RunReportResponse response = await alphaAnalyticsDataClient.RunReportAsync(request);

            // End snippet
        }
        public async stt::Task RunReportRequestObjectAsync()
        {
            moq::Mock <BetaAnalyticsData.BetaAnalyticsDataClient> mockGrpcClient = new moq::Mock <BetaAnalyticsData.BetaAnalyticsDataClient>(moq::MockBehavior.Strict);
            RunReportRequest request = new RunReportRequest
            {
                Property           = "propertyc9b48d1a",
                Dimensions         = { new Dimension(), },
                Metrics            = { new Metric(), },
                DateRanges         = { new DateRange(), },
                DimensionFilter    = new FilterExpression(),
                MetricFilter       = new FilterExpression(),
                Offset             = -4389998161825790342L,
                Limit              = 7494001492025909162L,
                MetricAggregations =
                {
                    MetricAggregation.Minimum,
                },
                OrderBys            = { new OrderBy(), },
                CurrencyCode        = "currency_code7f81e352",
                CohortSpec          = new CohortSpec(),
                KeepEmptyRows       = true,
                ReturnPropertyQuota = true,
            };
            RunReportResponse expectedResponse = new RunReportResponse
            {
                DimensionHeaders =
                {
                    new DimensionHeader(),
                },
                MetricHeaders = { new MetricHeader(), },
                Rows          = { new Row(), },
                Totals        = { new Row(), },
                Maximums      = { new Row(), },
                Minimums      = { new Row(), },
                RowCount      = 743251772,
                Metadata      = new ResponseMetaData(),
                PropertyQuota = new PropertyQuota(),
                Kind          = "kindf7aa39d9",
            };

            mockGrpcClient.Setup(x => x.RunReportAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <RunReportResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            BetaAnalyticsDataClient client = new BetaAnalyticsDataClientImpl(mockGrpcClient.Object, null);
            RunReportResponse       responseCallSettings = await client.RunReportAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            RunReportResponse responseCancellationToken = await client.RunReportAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task RunReportAsync()
        {
            Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient> mockGrpcClient = new Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient>(MockBehavior.Strict);
            RunReportRequest  request          = new RunReportRequest();
            RunReportResponse expectedResponse = new RunReportResponse();

            mockGrpcClient.Setup(x => x.RunReportAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <RunReportResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            AlphaAnalyticsDataClient client   = new AlphaAnalyticsDataClientImpl(mockGrpcClient.Object, null);
            RunReportResponse        response = await client.RunReportAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void RunReportRequestObject()
        {
            moq::Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient> mockGrpcClient = new moq::Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient>(moq::MockBehavior.Strict);
            RunReportRequest request = new RunReportRequest
            {
                Entity             = new Entity(),
                Dimensions         = { new Dimension(), },
                Metrics            = { new Metric(), },
                DateRanges         = { new DateRange(), },
                Offset             = -4389998161825790342L,
                Limit              = 7494001492025909162L,
                MetricAggregations =
                {
                    MetricAggregation.Minimum,
                },
                DimensionFilter     = new FilterExpression(),
                MetricFilter        = new FilterExpression(),
                OrderBys            = { new OrderBy(), },
                CurrencyCode        = "currency_code7f81e352",
                CohortSpec          = new CohortSpec(),
                KeepEmptyRows       = true,
                ReturnPropertyQuota = true,
            };
            RunReportResponse expectedResponse = new RunReportResponse
            {
                MetricHeaders    = { new MetricHeader(), },
                Rows             = { new Row(), },
                Metadata         = new ResponseMetaData(),
                PropertyQuota    = new PropertyQuota(),
                Totals           = { new Row(), },
                Maximums         = { new Row(), },
                Minimums         = { new Row(), },
                DimensionHeaders =
                {
                    new DimensionHeader(),
                },
                RowCount = 743251772,
            };

            mockGrpcClient.Setup(x => x.RunReport(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AlphaAnalyticsDataClient client   = new AlphaAnalyticsDataClientImpl(mockGrpcClient.Object, null);
            RunReportResponse        response = client.RunReport(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        static void SampleRunReport(string propertyId = "YOUR-GA4-PROPERTY-ID")
        {
            /**
             * TODO(developer): Uncomment this variable and replace with your
             *  Google Analytics 4 property ID before running the sample.
             */
            // propertyId = "YOUR-GA4-PROPERTY-ID";

            // [START analyticsdata_initialize]
            // Using a default constructor instructs the client to use the credentials
            // specified in GOOGLE_APPLICATION_CREDENTIALS environment variable.
            BetaAnalyticsDataClient client = BetaAnalyticsDataClient.Create();
            // [END analyticsdata_initialize]

            // [START analyticsdata_run_report]
            // Initialize request argument(s)
            RunReportRequest request = new RunReportRequest
            {
                Property   = "properties/" + propertyId,
                Dimensions = { new Dimension {
                                   Name = "city"
                               }, },
                Metrics = { new Metric {
                                Name = "activeUsers"
                            }, },
                DateRanges = { new DateRange {
                                   StartDate = "2020-03-31", EndDate = "today"
                               }, },
            };

            // Make the request
            var response = client.RunReport(request);

            // [END analyticsdata_run_report]

            // [START analyticsdata_run_report_response]
            Console.WriteLine("Report result:");
            foreach (Row row in response.Rows)
            {
                Console.WriteLine("{0}, {1}", row.DimensionValues[0].Value, row.MetricValues[0].Value);
            }
            // [END analyticsdata_run_report_response]
        }
Exemple #11
0
        /// <summary>Snippet for RunReport</summary>
        public async Task RunReportRequestObjectAsync()
        {
            // Snippet: RunReportAsync(RunReportRequest, CallSettings)
            // Create client
            BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();

            // Initialize request argument(s)
            RunReportRequest request = new RunReportRequest
            {
                Property           = "",
                Dimensions         = { new Dimension(), },
                Metrics            = { new Metric(), },
                DateRanges         = { new DateRange(), },
                DimensionFilter    = new FilterExpression(),
                MetricFilter       = new FilterExpression(),
                MetricAggregations =
                {
                    MetricAggregation.Unspecified,
                },
                OrderBys            = { new OrderBy(), },
                CurrencyCode        = "",
                CohortSpec          = new CohortSpec(),
                KeepEmptyRows       = false,
                ReturnPropertyQuota = false,
            };
            // Make the request
            PagedAsyncEnumerable <RunReportResponse, DimensionHeader> response = betaAnalyticsDataClient.RunReportAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((DimensionHeader item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((RunReportResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (DimensionHeader item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <DimensionHeader> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (DimensionHeader item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
 /// <summary>
 /// 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.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <RunReportResponse> RunReportAsync(RunReportRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
 /// <summary>
 /// 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.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual RunReportResponse RunReport(RunReportRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
 /// <summary>
 /// 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.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <RunReportResponse> RunReportAsync(RunReportRequest request, st::CancellationToken cancellationToken) =>
 RunReportAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
 /// <summary>
 /// 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.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public override stt::Task <RunReportResponse> RunReportAsync(RunReportRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_RunReportRequest(ref request, ref callSettings);
     return(_callRunReport.Async(request, callSettings));
 }
 /// <summary>
 /// 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.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public override RunReportResponse RunReport(RunReportRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_RunReportRequest(ref request, ref callSettings);
     return(_callRunReport.Sync(request, callSettings));
 }
 partial void Modify_RunReportRequest(ref RunReportRequest request, ref gaxgrpc::CallSettings settings);