public void AppViewExtension_Tracks_AppView() { var list = new List<Uri>(); var client = new MeasurementAnalyticsClient(); MeasurementTestHelpers.ConfigureForTest(client, list.Add); client.TrackAppView("SomeScreenName"); Assert.AreEqual(1, list.Count); StringAssert.Contains(list[0].OriginalString, "t=appview"); }
/// <summary> /// Start CSharpAnalytics by restoring the session state, starting the background sender, /// hooking up events to track and firing the application start event and home page view to analytics. /// Call this just before Window.Current.Activate() in your App.OnLaunched method. /// </summary> /// <param name="configuration">Configuration to use, must at a minimum specify your Google Analytics ID and app name.</param> /// <param name="uploadInterval">How often to upload to the server. Lower times = more traffic but realtime. Defaults to 5 seconds.</param> /// <returns>A Task that will complete once CSharpAnalytics is available.</returns> /// <example>await AutoAnalytics.StartAsync(new Configuration("UA-123123123-1", "myapp.someco.com"));</example> public static async Task StartAsync(MeasurementConfiguration configuration, TimeSpan? uploadInterval = null) { Debug.Assert(Client == null); if (Client != null) return; await StartRequesterAsync(uploadInterval ?? TimeSpan.FromSeconds(5)); await RestoreSessionAsync(TimeSpan.FromMinutes(20)); Client = new MeasurementAnalyticsClient(configuration, sessionManager, new WindowsStoreEnvironment(), requester.Add); Client.TrackEvent("Start", "ApplicationLifecycle"); Client.TrackAppView("Home"); HookEvents(); }
public void MeasurementAnalyticsClient_SetCustomMetric_Timespan_Is_Sent() { var actual = new List<Uri>(); var actualTimespan = new TimeSpan(4, 1, 2, 3); var client = new MeasurementAnalyticsClient(); MeasurementTestHelpers.ConfigureForTest(client, actual.Add); client.SetCustomMetric(7, actualTimespan); client.TrackAppView("Test View"); Assert.AreEqual(1, actual.Count); StringAssert.Contains(actual[0].Query, "cm7=" + (int)actualTimespan.TotalSeconds); }
public void MeasurementAnalyticsClient_SetCustomDimension_By_Enum_Is_Sent() { var actual = new List<Uri>(); var client = new MeasurementAnalyticsClient(); MeasurementTestHelpers.ConfigureForTest(client, actual.Add); client.SetCustomDimension(CustomDimensions.Eight, "DimensionEight"); client.TrackAppView("Test View"); Assert.AreEqual(1, actual.Count); StringAssert.Contains(actual[0].Query, "cd8=DimensionEight"); }
public void MeasurementAnalyticsClient_SetCustomMetric_Int_Is_Sent() { var actual = new List<Uri>(); var client = new MeasurementAnalyticsClient(); MeasurementTestHelpers.ConfigureForTest(client, actual.Add); client.SetCustomMetric(6, 6060); client.TrackAppView("Test View"); Assert.AreEqual(1, actual.Count); StringAssert.Contains(actual[0].Query, "cm6=6060"); }