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

Resolves #38 by adding ability to use GA debug url. #44

Open
wants to merge 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public class MeasurementConfiguration
/// </summary>
public bool UseSsl { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to use the debug URL.
/// </summary>
/// <value>
/// <c>true</c> if to use the debug URL; otherwise, <c>false</c>.
/// </value>
public bool UseDebugUrl { get; set; }

/// <summary>
/// Sample rate percentage to determine how likely new visitors will be tracked.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down