Skip to content

Commit

Permalink
Added .Net Standard project version. Signed assembly with Strong Name.
Browse files Browse the repository at this point in the history
  • Loading branch information
ion-sapoval committed Oct 28, 2017
1 parent 9683f33 commit af5af1a
Show file tree
Hide file tree
Showing 142 changed files with 3,253 additions and 10 deletions.
Empty file.
Binary file not shown.
Empty file.
Binary file modified src/.vs/GoogleMeasurementProtocol/v15/sqlite3/storage.ide
Binary file not shown.
11 changes: 10 additions & 1 deletion src/GoogleMeasurementProtocol.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.16
VisualStudioVersion = 15.0.27004.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleAnalyticsMeasurementProtocol", "GoogleMeasurementProtocol\GoogleAnalyticsMeasurementProtocol.csproj", "{5DA1474F-FDF8-4014-8FC1-6F7303C0C027}"
EndProject
Expand All @@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Tests", "_Tests", "{721487
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{100892AF-7638-451F-B7C0-526D32C668B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleAnalyticsMeasurementProtocol_NetStandard", "GoogleMeasurementProtocol_NetStandard\GoogleAnalyticsMeasurementProtocol_NetStandard.csproj", "{5C815671-C60E-40A8-9330-96C4280A6775}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -29,6 +31,10 @@ Global
{100892AF-7638-451F-B7C0-526D32C668B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{100892AF-7638-451F-B7C0-526D32C668B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{100892AF-7638-451F-B7C0-526D32C668B2}.Release|Any CPU.Build.0 = Release|Any CPU
{5C815671-C60E-40A8-9330-96C4280A6775}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C815671-C60E-40A8-9330-96C4280A6775}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C815671-C60E-40A8-9330-96C4280A6775}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C815671-C60E-40A8-9330-96C4280A6775}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -37,4 +43,7 @@ Global
{D384B248-F909-4A49-94D0-FC23727AD117} = {72148752-6269-4980-A51D-6A1B9A47897B}
{100892AF-7638-451F-B7C0-526D32C668B2} = {72148752-6269-4980-A51D-6A1B9A47897B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55743CD3-9780-4563-BDF0-B0B4001D2F89}
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions src/GoogleMeasurementProtocol/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.1.0")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyVersion("1.4.2.0")]
[assembly: AssemblyFileVersion("1.4.2.0")]
21 changes: 21 additions & 0 deletions src/GoogleMeasurementProtocol_NetStandard/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace GoogleMeasurementProtocol
{
public static class HitTypes
{
public const string PageView = "pageview";

public const string ScreenView = "screenview";

public const string Event = "event";

public const string Transaction = "transaction";

public const string Item = "item";

public const string Social = "social";

public const string Exception = "exception";

public const string Timing = "timing";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using GoogleMeasurementProtocol.Parameters;

namespace GoogleMeasurementProtocol.Extensions
{
public static class ListExtensions
{
public static NameValueCollection GenerateNameValueCollection(this List<Parameter> list)
{
var nameValueCollection = new NameValueCollection();

if (list == null)
{
return nameValueCollection;
}

foreach (var param in list)
{
switch (param.ValueType.Name)
{
case "Boolean":

nameValueCollection[param.Name] = param.Value == null ? string.Empty : (bool)param.Value ? "1" : "0";
break;

case "Decimal":
nameValueCollection[param.Name] = param.Value == null ? string.Empty : Convert.ToString(param.Value, CultureInfo.InvariantCulture);
break;

default:
nameValueCollection[param.Name] = param.Value == null ? string.Empty : param.Value.ToString();
break;
}
}

return nameValueCollection;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>GoogleMeasurementProtocol</AssemblyName>
<RootNamespace>GoogleMeasurementProtocol</RootNamespace>
<PackageId>GoogleMeasurementProtocol</PackageId>
<Version>1.4.3</Version>
<Authors>Ion Sapoval</Authors>
<Company>Ion Sapoval</Company>
<Description>.Net library for sending Google Analytics Measurement Protocol requests.
This library provides support for creating any type of Measurement Protocol request by using any of the existing Measurement Protocol request parameters.</Description>
<Copyright>Copyright (c) 2014</Copyright>
<PackageLicenseUrl>https://github.com/ion-sapoval/google-measurement-protocol-dotnet/blob/master/LICENSE.TXT</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/ion-sapoval/google-measurement-protocol-dotnet</PackageProjectUrl>
<PackageTags>MeasurementProtocol Google GoogleMeasurementProtocol Analytics</PackageTags>
<PackageReleaseNotes>Signed assembly with a Strong Name.
Converted to a .Net Standard library.</PackageReleaseNotes>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Net;
using GoogleMeasurementProtocol.Parameters;
using GoogleMeasurementProtocol.Parameters.General;
using GoogleMeasurementProtocol.Requests;


namespace GoogleMeasurementProtocol
{
public class GoogleAnalyticsRequestFactory
{
private readonly IWebProxy _proxy;
private readonly ProtocolVersion _protocolVersion = new ProtocolVersion("1");
private readonly TrackingId _trackingId;

[Obsolete("Google is supporting now only https protocol. Parameter useSsl doesn't have any effect.")]
public GoogleAnalyticsRequestFactory(TrackingId trackingId, bool useSslConnection, IWebProxy proxy = null) : this(trackingId, proxy)
{
}

[Obsolete("Google is supporting now only https protocol. Parameter useSsl doesn't have any effect.")]
public GoogleAnalyticsRequestFactory(string trackingId, bool useSslConnection, IWebProxy proxy = null) : this(trackingId, proxy)
{
}

public GoogleAnalyticsRequestFactory(TrackingId trackingId, IWebProxy proxy = null)
{
if (trackingId?.Value == null)
{
throw new ArgumentException("TrackingId can't be null or empty.", nameof(trackingId));
}

_trackingId = trackingId;
_proxy = proxy;
}

public GoogleAnalyticsRequestFactory(string trackingId, IWebProxy proxy = null)
{
if (string.IsNullOrEmpty(trackingId))
{
throw new ArgumentException("TrackingId can't be null or empty.", nameof(trackingId));
}

_trackingId = new TrackingId(trackingId);
_proxy = proxy;
}


public IGoogleAnalyticsRequest CreateRequest(string hitType, IEnumerable<Parameter> requestParameters = null)
{
if (hitType == null)
{
throw new ArgumentNullException(nameof(hitType));
}

IGoogleAnalyticsRequest request;

switch (hitType.ToLower())
{
case HitTypes.PageView:

request = new PageViewRequest(_proxy);
break;

case HitTypes.Event:

request = new EventRequest(_proxy);
break;

case HitTypes.Exception:

request = new ExceptionTrackingRequest(_proxy);
break;

case HitTypes.Item:

request = new ItemRequest(_proxy);
break;

case HitTypes.ScreenView:

request = new ScreenTrackingRequest(_proxy);
break;

case HitTypes.Social:

request = new SocialInteractionsRequest(_proxy);
break;

case HitTypes.Timing:

request = new UserTimingTrackingRequest(_proxy);
break;

case HitTypes.Transaction:

request = new TransactionRequest(_proxy);
break;


default:
throw new ApplicationException("Unknown hitType: " + hitType);
}

request.Parameters.Add(_protocolVersion);
request.Parameters.Add(_trackingId);

if (requestParameters != null)
{
request.Parameters.AddRange(requestParameters);
}

return request;
}
}
}
Binary file added src/GoogleMeasurementProtocol_NetStandard/Key.snk
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace GoogleMeasurementProtocol.Parameters.AppTracking
{
/// <summary>
/// Application identifier.
/// </summary>
public class ApplicationId : Parameter
{
public ApplicationId(string value)
: base(value)
{
}

public override string Name => "aid";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace GoogleMeasurementProtocol.Parameters.AppTracking
{
/// <summary>
/// Application installer identifier.
/// </summary>
public class ApplicationInstallerId : Parameter
{
public ApplicationInstallerId(string value)
: base(value)
{
}

public override string Name => "aiid";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace GoogleMeasurementProtocol.Parameters.AppTracking
{
/// <summary>
/// Specifies the application name.
/// </summary>
public class ApplicationName : Parameter
{
public ApplicationName(string value)
: base(value)
{
}

public override string Name => "an";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace GoogleMeasurementProtocol.Parameters.AppTracking
{
/// <summary>
/// Specifies the application version.
/// </summary>
public class ApplicationVersion : Parameter
{
public ApplicationVersion(string value)
: base(value)
{
}

public override string Name => "av";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace GoogleMeasurementProtocol.Parameters.ContentExperiments
{
/// <summary>
/// This parameter specifies that this user has been exposed to an experiment with the given ID.
/// It should be sent in conjunction with the Experiment Variant parameter.
/// </summary>
public class ExperimentId : Parameter
{
public ExperimentId(string value)
: base(value)
{
}

public override string Name => "xid";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace GoogleMeasurementProtocol.Parameters.ContentExperiments
{
/// <summary>
/// This parameter specifies that this user has been exposed to a particular variation of an experiment.
/// It should be sent in conjunction with the Experiment ID parameter.
/// </summary>
public class ExperimentVariant : Parameter
{
public ExperimentVariant(string value)
: base(value)
{
}

public override string Name => "xvar";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using GoogleMeasurementProtocol.Validators;

namespace GoogleMeasurementProtocol.Parameters.ContentInformation
{
public class ContentGroup : Parameter
{
public byte GroupIndex { get; set; }

public ContentGroup(string value, byte groupIndex = 1) : base(value)
{
GroupIndex = groupIndex;
Value = FormatValue(Value as string);
}

public override string Name
{
get
{
IndexValidator.ValidateContentGroupIndex(GroupIndex);

return $"cg{GroupIndex}";
}
}

private string FormatValue(string value)
{
if (string.IsNullOrEmpty(value))
{
return value;
}

return value.Replace("\\\\", "\\").Trim('\\');
}
}
}
Loading

0 comments on commit af5af1a

Please sign in to comment.