Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samples: fix changes to existing sample and refactor to allow for future tests #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions analytics-data/AnalyticsData.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickStart", "QuickStart\QuickStart.csproj", "{7D9C4AE6-192A-4A99-9933-6AF9F4FE5ECA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickStartJsonCredentials", "QuickStartJsonCredentials\QuickStartJsonCredentials.csproj", "{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.Tests", "Samples.Tests\Samples.Tests.csproj", "{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickStartJsonCredentials", "QuickStartJsonCredentials\QuickStartJsonCredentials.csproj", "{3F777FDA-3F20-4425-B436-6D89BF5F14B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -32,17 +34,29 @@ Global
{7D9C4AE6-192A-4A99-9933-6AF9F4FE5ECA}.Release|x64.Build.0 = Release|Any CPU
{7D9C4AE6-192A-4A99-9933-6AF9F4FE5ECA}.Release|x86.ActiveCfg = Release|Any CPU
{7D9C4AE6-192A-4A99-9933-6AF9F4FE5ECA}.Release|x86.Build.0 = Release|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Debug|x64.ActiveCfg = Debug|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Debug|x64.Build.0 = Debug|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Debug|x86.ActiveCfg = Debug|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Debug|x86.Build.0 = Debug|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Release|Any CPU.Build.0 = Release|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Release|x64.ActiveCfg = Release|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Release|x64.Build.0 = Release|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Release|x86.ActiveCfg = Release|Any CPU
{82CAE36B-3FBE-4DAA-8A23-5D15A15BF1B0}.Release|x86.Build.0 = Release|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Debug|x64.ActiveCfg = Debug|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Debug|x64.Build.0 = Debug|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Debug|x86.ActiveCfg = Debug|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Debug|x86.Build.0 = Debug|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Release|Any CPU.Build.0 = Release|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Release|x64.ActiveCfg = Release|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Release|x64.Build.0 = Release|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Release|x86.ActiveCfg = Release|Any CPU
{EC99ECBD-FCFC-42DC-A9A4-2A27892C56F3}.Release|x86.Build.0 = Release|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Debug|x64.ActiveCfg = Debug|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Debug|x64.Build.0 = Debug|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Debug|x86.ActiveCfg = Debug|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Debug|x86.Build.0 = Debug|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Release|Any CPU.Build.0 = Release|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Release|x64.ActiveCfg = Release|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Release|x64.Build.0 = Release|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Release|x86.ActiveCfg = Release|Any CPU
{3F777FDA-3F20-4425-B436-6D89BF5F14B8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ account credentials.
*/

// [START analyticsdata_json_credentials_quickstart]
using Google.Analytics.Data.V1Beta;
using Google.Analytics.Data.V1Beta;
using System;

namespace AnalyticsSamples
Expand All @@ -50,7 +50,7 @@ static void SampleRunReport(string propertyId="YOUR-GA4-PROPERTY-ID", string cre
* Otherwise, default service account credentials will be derived from
* the GOOGLE_APPLICATION_CREDENTIALS environment variable.
*/
// credentialsJsonPath = "/path/to/credentials.json";
// credentialsJsonPath = "/path/to/credentials.json"

// Explicitly use service account credentials by specifying
// the private key file.
Expand All @@ -65,23 +65,20 @@ static void SampleRunReport(string propertyId="YOUR-GA4-PROPERTY-ID", string cre
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"}, },
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);
var 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())
Console.WriteLine("Report result:");
foreach (Row row in response.Rows)
{
foreach(Row row in page.Rows)
{
Console.WriteLine("{0}, {1}", row.DimensionValues[0].Value, row.MetricValues[0].Value);
}
Console.WriteLine("{0}, {1}", row.DimensionValues[0].Value, row.MetricValues[0].Value);
}
// [END analyticsdata_json_credentials_run_report_response]
}
Expand All @@ -90,6 +87,8 @@ static int Main(string[] args)
SampleRunReport();
return 0;
}


}
}
// [END analyticsdata_json_credentials_quickstart]
21 changes: 21 additions & 0 deletions analytics-data/Samples.Tests/Samples.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\QuickStart\QuickStart.csproj" />
<ProjectReference Include="..\QuickStartJsonCredentials\QuickStartJsonCredentials.csproj" />
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions analytics-data/Samples.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using Xunit;

namespace Samples.Tests
{
public class UnitTest1
{
[Fact]
public void Test1()
{

}
}
}