From a064f3c5bc5e474826f82468ff740f900aad4276 Mon Sep 17 00:00:00 2001 From: JimiC Date: Thu, 22 Oct 2015 18:12:49 +0300 Subject: [PATCH] Resolves #38 by adding ability to use GA debug url. --- .../Protocols/Measurement/MeasurementConfiguration.cs | 8 ++++++++ .../Protocols/Measurement/MeasurementUriBuilder.cs | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/CSharpAnalytics/Protocols/Measurement/MeasurementConfiguration.cs b/Source/CSharpAnalytics/Protocols/Measurement/MeasurementConfiguration.cs index 2c01738..669f2ab 100644 --- a/Source/CSharpAnalytics/Protocols/Measurement/MeasurementConfiguration.cs +++ b/Source/CSharpAnalytics/Protocols/Measurement/MeasurementConfiguration.cs @@ -46,6 +46,14 @@ public class MeasurementConfiguration /// public bool UseSsl { get; set; } + /// + /// Gets or sets a value indicating whether to use the debug URL. + /// + /// + /// true if to use the debug URL; otherwise, false. + /// + public bool UseDebugUrl { get; set; } + /// /// Sample rate percentage to determine how likely new visitors will be tracked. /// diff --git a/Source/CSharpAnalytics/Protocols/Measurement/MeasurementUriBuilder.cs b/Source/CSharpAnalytics/Protocols/Measurement/MeasurementUriBuilder.cs index 24e5151..4aaa756 100644 --- a/Source/CSharpAnalytics/Protocols/Measurement/MeasurementUriBuilder.cs +++ b/Source/CSharpAnalytics/Protocols/Measurement/MeasurementUriBuilder.cs @@ -23,6 +23,7 @@ internal class MeasurementUriBuilder private static readonly Random random = new Random(); private static readonly Uri trackingEndpoint = new Uri("http://www.google-analytics.com/collect"); private static readonly Uri secureTrackingEndpoint = new Uri("https://ssl.google-analytics.com/collect"); + private static readonly Uri debugTrackingEndpoint = new Uri("https://www.google-analytics.com/debug/collect"); private readonly SessionManager sessionManager; private readonly MeasurementConfiguration configuration; @@ -52,7 +53,11 @@ public Uri BuildUri(MeasurementActivity activity) { var parameters = BuildParameterList(activity); CarryForwardParameters(activity, parameters); - var endpoint = configuration.UseSsl ? secureTrackingEndpoint : trackingEndpoint; + var endpoint = configuration.UseDebugUrl + ? debugTrackingEndpoint + : configuration.UseSsl + ? secureTrackingEndpoint + : trackingEndpoint; // Fragment is only added temporarily and used to calculate queue time. // It will be removed in MeasurementAnalyticsClient.AdjustUriBeforeRequest.