public void SanitizeWillTrimAppropriateFields() { PageViewTelemetry telemetry = new PageViewTelemetry(); telemetry.Name = new string('Z', Property.MaxNameLength + 1); telemetry.Properties.Add(new string('X', Property.MaxDictionaryNameLength) + 'X', new string('X', Property.MaxValueLength + 1)); telemetry.Properties.Add(new string('X', Property.MaxDictionaryNameLength) + 'Y', new string('X', Property.MaxValueLength + 1)); telemetry.Metrics.Add(new string('Y', Property.MaxDictionaryNameLength) + 'X', 42.0); telemetry.Metrics.Add(new string('Y', Property.MaxDictionaryNameLength) + 'Y', 42.0); telemetry.Url = new Uri("http://foo.com/" + new string('Y', Property.MaxUrlLength + 1)); ((ITelemetry)telemetry).Sanitize(); Assert.Equal(new string('Z', Property.MaxNameLength), telemetry.Name); Assert.Equal(2, telemetry.Properties.Count); Assert.Equal(new string('X', Property.MaxDictionaryNameLength), telemetry.Properties.Keys.ToArray()[0]); Assert.Equal(new string('X', Property.MaxValueLength), telemetry.Properties.Values.ToArray()[0]); Assert.Equal(new string('X', Property.MaxDictionaryNameLength - 3) + "001", telemetry.Properties.Keys.ToArray()[1]); Assert.Equal(new string('X', Property.MaxValueLength), telemetry.Properties.Values.ToArray()[1]); Assert.Equal(2, telemetry.Metrics.Count); Assert.Equal(new string('Y', Property.MaxDictionaryNameLength), telemetry.Metrics.Keys.ToArray()[0]); Assert.Equal(new string('Y', Property.MaxDictionaryNameLength - 3) + "001", telemetry.Metrics.Keys.ToArray()[1]); Assert.Equal(new Uri("http://foo.com/" + new string('Y', Property.MaxUrlLength - 15)), telemetry.Url); }
/// <summary> /// Initializes a new instance of the <see cref="TelemetryForm"/> class. /// </summary> public TelemetryForm() { _telemetryData = new PageViewTelemetry( !string.IsNullOrWhiteSpace(this.Name) ? this.Name : this.GetType().Name); _telemetryClientFetcher = new Lazy<TelemetryClient>(() => { System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(this.TelemetryClientName), $"No Telemetry client name set on Telemetry Button \"{this.Name}\""); if (!string.IsNullOrWhiteSpace(this.TelemetryClientName)) { try { return Telemetry.GetClient(this.TelemetryClientName); } catch (Exception ex) { System.Diagnostics.Debug.Fail( $"Couldn't find telemetry client with name {this.TelemetryClientName}", ex.ToString()); } } return null; }); }
public void VerifyExpectedDefaultValue() { var pageViewTelemetry = new PageViewTelemetry(); Assert.AreEqual(SamplingDecision.None, pageViewTelemetry.ProactiveSamplingDecision); Assert.AreEqual(SamplingTelemetryItemTypes.PageView, pageViewTelemetry.ItemTypeFlag); }
public void PageViewTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new PageViewTelemetry(); // Extension is not set, means it'll be null. // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); }
public void VerifyExpectedDefaultValue() { var pageViewTelemetry = new PageViewTelemetry(); Assert.IsFalse(pageViewTelemetry.IsSampledOutAtHead); Assert.AreEqual(SamplingTelemetryItemTypes.PageView, pageViewTelemetry.ItemTypeFlag); }
public void PageViewTelemetrySuppliesConstructorThatTakesNameParameter() { string expectedPageName = "My page view"; var instance = new PageViewTelemetry(expectedPageName); Assert.AreEqual(expectedPageName, instance.Name); }
/// <summary> /// Initializes a new instance of the <see cref="PageViewTelemetry"/> class by cloning an existing instance. /// </summary> /// <param name="source">Source instance of <see cref="PageViewTelemetry"/> to clone from.</param> private PageViewTelemetry(PageViewTelemetry source) { this.Data = source.Data.DeepClone(); this.context = source.context.DeepClone(this.Data.properties); this.extension = source.extension?.DeepClone(); this.Timestamp = source.Timestamp; }
public void SanitizeWillTrimAppropriateFields() { PageViewTelemetry telemetry = new PageViewTelemetry(); telemetry.Name = new string('Z', Property.MaxNameLength + 1); telemetry.Properties.Add(new string('X', Property.MaxDictionaryNameLength) + 'X', new string('X', Property.MaxValueLength + 1)); telemetry.Properties.Add(new string('X', Property.MaxDictionaryNameLength) + 'Y', new string('X', Property.MaxValueLength + 1)); telemetry.Metrics.Add(new string('Y', Property.MaxDictionaryNameLength) + 'X', 42.0); telemetry.Metrics.Add(new string('Y', Property.MaxDictionaryNameLength) + 'Y', 42.0); telemetry.Url = new Uri("http://foo.com/" + new string('Y', Property.MaxUrlLength + 1)); ((ITelemetry)telemetry).Sanitize(); Assert.AreEqual(new string('Z', Property.MaxNameLength), telemetry.Name); Assert.AreEqual(2, telemetry.Properties.Count); string[] keys = telemetry.Properties.Keys.OrderBy(s => s).ToArray(); string[] values = telemetry.Properties.Values.OrderBy(s => s).ToArray(); Assert.AreEqual(new string('X', Property.MaxDictionaryNameLength), keys[1]); Assert.AreEqual(new string('X', Property.MaxValueLength), values[1]); Assert.AreEqual(new string('X', Property.MaxDictionaryNameLength - 3) + "1", keys[0]); Assert.AreEqual(new string('X', Property.MaxValueLength), values[0]); Assert.AreEqual(2, telemetry.Metrics.Count); keys = telemetry.Metrics.Keys.OrderBy(s => s).ToArray(); Assert.AreEqual(new string('Y', Property.MaxDictionaryNameLength), keys[1]); Assert.AreEqual(new string('Y', Property.MaxDictionaryNameLength - 3) + "1", keys[0]); Assert.AreEqual(new Uri("http://foo.com/" + new string('Y', Property.MaxUrlLength - 15)), telemetry.Url); }
/// <summary> /// Gets the club status page. The club id specifies the club to display. The checkin and /// checkout buttons direct here with the corresponding query parameter containing the /// reference id for the reservation of interest. /// </summary> /// <param name="clubId">Required parameter specifying the id of the club to show</param> /// <param name="clubStatusSecret">If a club status secret is configured, it must be provided here</param> /// <param name="checkin">If present, the reference id of a reservation to check in</param> /// <param name="checkout">If present, the reference id of a reservation to check out</param> /// <returns>The club status page</returns> public async Task<ActionResult> Index( [FromUri] string clubId, [FromUri] string clubStatusSecret = null, [FromUri] string checkin = null, [FromUri] string checkout = null) { if (string.IsNullOrEmpty(clubId) || !EnvironmentDefinition.Instance.MapClubIdToClubInfo.ContainsKey(clubId)) { return this.HttpNotFound("Missing or unknown club id"); } ClubStatus model = new ClubStatus(clubId); model.IsKiosk = clubStatusSecret != null && clubStatusSecret == model.ClubInfo.ClubStatusSecret; // If the return value is non-null, it's an error message from the checkin or checkout // and we display it as an alert at the top of the page. ViewBag.Message = await model.LoadDataAsync(checkin, checkout); var viewResult = View("ClubStatus", model); // Send the telemetry as late as possible to get more accurate page load times. var pageViewTelemetry = new PageViewTelemetry("clubStatus"); pageViewTelemetry.Properties["clubId"] = clubId; pageViewTelemetry.Properties["isCheckIn"] = (checkin != null).ToString(); pageViewTelemetry.Properties["isCheckOut"] = (checkout != null).ToString(); pageViewTelemetry.Properties["isKiosk"] = model.IsKiosk.ToString(); this.TelemetryClient.TrackPageView(pageViewTelemetry); return viewResult; }
public void TrackPageView(string name, string parameter) { if (!IsTrackingEnabled) return; var telemetry = new PageViewTelemetry(name); if (!string.IsNullOrEmpty(parameter)) telemetry.Properties.Add("Parameter", parameter); Client.TrackPageView(telemetry); }
public void PageViewTelemetryImplementsISupportMetrics() { PageViewTelemetry item = new PageViewTelemetry(); item.Metrics.Add("Test", 10); Assert.IsNotNull(item as ISupportMetrics); Assert.AreEqual(10, (item as ISupportMetrics).Metrics["Test"]); }
public void PageViewTelemetryHasCorrectValueOfSamplingPercentageAfterSerialization() { var telemetry = new PageViewTelemetry("my page view"); ((ISupportSampling)telemetry).SamplingPercentage = 10; var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<PageViewTelemetry, DataPlatformModel.PageViewData>(telemetry); Assert.Equal(10, item.SampleRate); }
/// <summary> /// Initializes a new instance of the <see cref="PageViewTelemetry"/> class by cloning an existing instance. /// </summary> /// <param name="source">Source instance of <see cref="PageViewTelemetry"/> to clone from.</param> private PageViewTelemetry(PageViewTelemetry source) { this.Data = source.Data.DeepClone(); this.context = source.context.DeepClone(this.Data.properties); this.extension = source.extension?.DeepClone(); this.Timestamp = source.Timestamp; this.samplingPercentage = source.samplingPercentage; this.ProactiveSamplingDecision = source.ProactiveSamplingDecision; }
/// <summary> /// Initializes a new instance of the <see cref="PageViewTelemetry"/> class by cloning an existing instance. /// </summary> /// <param name="source">Source instance of <see cref="PageViewTelemetry"/> to clone from.</param> private PageViewTelemetry(PageViewTelemetry source) { this.Data = source.Data.DeepClone(); this.context = source.context.DeepClone(this.Data.properties); this.extension = source.extension?.DeepClone(); this.Timestamp = source.Timestamp; this.samplingPercentage = source.samplingPercentage; this.IsSampledOutAtHead = source.IsSampledOutAtHead; }
public void PageViewTelemetryHasCorrectValueOfSamplingPercentageAfterSerialization() { var telemetry = new PageViewTelemetry("my page view"); ((ISupportSampling)telemetry).SamplingPercentage = 10; var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <AI.PageViewData>(telemetry); Assert.AreEqual(10, item.sampleRate); }
protected override void OnNavigatedFrom(NavigationEventArgs e) { //當使用者離開頁面時, 將資料記錄下來做分析 var telemetry = new TelemetryClient(); PageViewTelemetry pvT = new PageViewTelemetry("ViewedUVDetailView"); TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true; telemetry.Context.Device.Id = BasicInfo.DeviceID; telemetry.Context.User.Id = BasicInfo.UserName; telemetry.TrackPageView(pvT); }
public void InitializeCutsPortFromIp() { var dictionary = new Dictionary<string, string> { { "X-Forwarded-For", "1.2.3.4:54321" } }; var module = new TestableClientIpHeaderTelemetryInitializer(dictionary); var telemetry = new PageViewTelemetry(); module.Initialize(telemetry); Assert.AreEqual("1.2.3.4", telemetry.Context.Location.Ip); }
public void SanitizePopulatesNameWithErrorBecauseItIsRequiredByEndpoint() { var telemetry = new PageViewTelemetry { Name = null }; ((ITelemetry)telemetry).Sanitize(); Assert.AreEqual("n/a", telemetry.Name); }
protected override void OnNavigatedFrom(NavigationEventArgs e) { TelemetryClient telemetry = new TelemetryClient(); TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true; PageViewTelemetry pvT = new PageViewTelemetry("ViewedMapView"); telemetry.Context.Device.Id = BasicInfo.DeviceID; telemetry.Context.User.Id = BasicInfo.UserName; pvT.Duration = DateTime.Now.Subtract(startViewTime); telemetry.TrackPageView(pvT); }
public void SanitizePopulatesNameWithErrorBecauseItIsRequiredByEndpoint() { var telemetry = new PageViewTelemetry { Name = null }; ((ITelemetry)telemetry).Sanitize(); Assert.Contains("name", telemetry.Name, StringComparison.OrdinalIgnoreCase); Assert.Contains("required", telemetry.Name, StringComparison.OrdinalIgnoreCase); }
public void SerializePopulatesRequiredFieldsOfPageViewTelemetry() { using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { var pvTelemetry = new PageViewTelemetry(); pvTelemetry.Context.InstrumentationKey = Guid.NewGuid().ToString(); ((ITelemetry)pvTelemetry).Sanitize(); var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <AI.PageViewData>(pvTelemetry); Assert.AreEqual(2, item.data.baseData.ver); Assert.IsNotNull(item.data.baseData.id); Assert.IsNotNull(item.time); Assert.AreEqual(new TimeSpan(), TimeSpan.Parse(item.data.baseData.duration)); } }
public void PageViewTelemetryDeepCloneCopiesAllProperties() { var pageView = new PageViewTelemetry("My Page"); pageView.Url = new Uri("http://temp.org/page1"); pageView.Duration = TimeSpan.FromSeconds(123); pageView.Metrics.Add("Metric1", 30); pageView.Properties.Add("Property1", "Value1"); pageView.Extension = new MyTestExtension(); PageViewTelemetry other = (PageViewTelemetry)pageView.DeepClone(); CompareLogic deepComparator = new CompareLogic(); var result = deepComparator.Compare(pageView, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); }
public void PageViewTelemetryTelemetryPropertiesFromContextAndItemSerializesToPropertiesInJson() { var expected = new PageViewTelemetry(); expected.Context.GlobalProperties.Add("TestPropertyGlobal", "contextpropvalue"); expected.Properties.Add("TestProperty", "TestPropertyValue"); ((ITelemetry)expected).Sanitize(); Assert.AreEqual(1, expected.Properties.Count); Assert.AreEqual(1, expected.Context.GlobalProperties.Count); Assert.IsTrue(expected.Properties.ContainsKey("TestProperty")); Assert.IsTrue(expected.Context.GlobalProperties.ContainsKey("TestPropertyGlobal")); var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <AI.PageViewData>(expected); // Items added to both PageViewTelemetry.Properties, and PageViewTelemetry.Context.GlobalProperties are serialized to properties. Assert.AreEqual(2, item.data.baseData.properties.Count); Assert.IsTrue(item.data.baseData.properties.ContainsKey("TestPropertyGlobal")); Assert.IsTrue(item.data.baseData.properties.ContainsKey("TestProperty")); }
public void PageViewTelemetrySerializesToJsonCorrectly() { var expected = new PageViewTelemetry("My Page"); expected.Url = new Uri("http://temp.org/page1"); expected.Duration = TimeSpan.FromSeconds(123); expected.Metrics.Add("Metric1", 30); expected.Properties.Add("Property1", "Value1"); var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<PageViewTelemetry, DataPlatformModel.PageViewData>(expected); // NOTE: It's correct that we use the v1 name here, and therefore we test against it. Assert.Equal(item.Name, Microsoft.Developer.Analytics.DataCollection.Model.v1.ItemType.PageView); Assert.Equal(typeof(DataPlatformModel.PageViewData).Name, item.Data.BaseType); Assert.Equal(2, item.Data.BaseData.Ver); Assert.Equal(expected.Name, item.Data.BaseData.Name); Assert.Equal(expected.Duration, item.Data.BaseData.Duration); Assert.Equal(expected.Url.ToString(), item.Data.BaseData.Url); Assert.Equal(expected.Properties.ToArray(), item.Data.BaseData.Properties.ToArray()); }
public void PageViewTelemetrySerializesToJsonCorrectly() { var expected = new PageViewTelemetry("My Page"); expected.Url = new Uri("http://temp.org/page1"); expected.Duration = TimeSpan.FromSeconds(123); expected.Metrics.Add("Metric1", 30); expected.Properties.Add("Property1", "Value1"); var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <PageViewTelemetry, DataPlatformModel.PageViewData>(expected); // NOTE: It's correct that we use the v1 name here, and therefore we test against it. Assert.Equal(item.Name, Microsoft.Developer.Analytics.DataCollection.Model.v1.ItemType.PageView); Assert.Equal(typeof(DataPlatformModel.PageViewData).Name, item.Data.BaseType); Assert.Equal(2, item.Data.BaseData.Ver); Assert.Equal(expected.Name, item.Data.BaseData.Name); Assert.Equal(expected.Duration, item.Data.BaseData.Duration); Assert.Equal(expected.Url.ToString(), item.Data.BaseData.Url); Assert.Equal(expected.Properties.ToArray(), item.Data.BaseData.Properties.ToArray()); }
public void PageViewTelemetrySerializesToJsonCorrectly() { var expected = new PageViewTelemetry("My Page"); expected.Url = new Uri("http://temp.org/page1"); expected.Duration = TimeSpan.FromSeconds(123); expected.Metrics.Add("Metric1", 30); expected.Properties.Add("Property1", "Value1"); var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <AI.PageViewData>(expected); // NOTE: It's correct that we use the v1 name here, and therefore we test against it. Assert.AreEqual(item.name, AI.ItemType.PageView); Assert.AreEqual(nameof(AI.PageViewData), item.data.baseType); Assert.AreEqual(2, item.data.baseData.ver); Assert.AreEqual(expected.Name, item.data.baseData.name); Assert.AreEqual(expected.Duration, TimeSpan.Parse(item.data.baseData.duration)); Assert.AreEqual(expected.Url.ToString(), item.data.baseData.url); AssertEx.AreEqual(expected.Properties.ToArray(), item.data.baseData.properties.ToArray()); }
public void PageViewTelemetryReturnsDefaultDurationAsTimespanZero() { PageViewTelemetry item = new PageViewTelemetry(); Assert.AreEqual(TimeSpan.Zero, item.Duration); }
public void PageViewTelemetryReturnsNonNullContext() { PageViewTelemetry item = new PageViewTelemetry(); Assert.IsNotNull(item.Context); }
public Task ReportMetrics(ISiloPerformanceMetrics metricsData) { if (!Initialized) return Task.CompletedTask; var pageView = new PageViewTelemetry(SiloName); pageView.Properties.Add("deploymentId", DeploymentId); Telemetry.TrackMetric("ActivationCount", metricsData.ActivationCount); Telemetry.TrackMetric("CpuUsage", metricsData.CpuUsage); Telemetry.TrackMetric("AvailablePhysicalMemory", metricsData.AvailablePhysicalMemory); Telemetry.TrackMetric("ClientCount", metricsData.ClientCount); Telemetry.TrackMetric("MemoryUsage", metricsData.MemoryUsage); Telemetry.TrackMetric("ReceivedMessages", metricsData.ReceivedMessages); Telemetry.TrackMetric("ReceiveQueueLength", metricsData.ReceiveQueueLength); Telemetry.TrackMetric("RecentlyUsedActivationCount", metricsData.RecentlyUsedActivationCount); Telemetry.TrackMetric("RequestQueueLength", metricsData.RequestQueueLength); Telemetry.TrackMetric("SendQueueLength", metricsData.SendQueueLength); Telemetry.TrackMetric("SentMessages", metricsData.SentMessages); Telemetry.TrackMetric("TotalPhysicalMemory", metricsData.TotalPhysicalMemory); var props = new Dictionary<string, string>(); props.Add("DeploymentId", DeploymentId); props.Add("HostName", HostName); Telemetry.TrackEvent("ReportMetrics",props); Telemetry.Flush(); return Task.CompletedTask; }
/// <summary> /// Initializes a new instance of the <see cref="PageViewTelemetry"/> class by cloning an existing instance. /// </summary> /// <param name="source">Source instance of <see cref="PageViewTelemetry"/> to clone from.</param> private PageViewTelemetry(PageViewTelemetry source) { this.Data = source.Data.DeepClone(); this.context = source.context.DeepClone(this.Data.properties); }
public void SanitizePopulatesNameWithErrorBecauseItIsRequiredByEndpoint() { var telemetry = new PageViewTelemetry { Name = null }; ((ITelemetry)telemetry).Sanitize(); Assert.Contains("name", telemetry.Name, StringComparison.OrdinalIgnoreCase); Assert.Contains("required", telemetry.Name, StringComparison.OrdinalIgnoreCase); }
public override bool Edit(IPolicyEditArgs policyEditArgs) { PageViewTelemetry pvt = new PageViewTelemetry("BranchPolicyEdit"); Stopwatch pvtrak = new Stopwatch(); pvtrak.Start(); bool result = false; try { IBranchPatternsRepository repo = new BranchPatternsRepository(branchPatterns); var wpfwindow = new BranchLockPolicyEditorWindow(policyEditArgs, repo); ElementHost.EnableModelessKeyboardInterop(wpfwindow); wpfwindow.ShowDialog(); branchPatterns = repo.FindAll().ToList(); TellMe.Instance.TrackMetric("BranchPolicyCount", branchPatterns.Count); result= true; } catch (Exception ex) { TellMe.Instance.TrackException(ex); MessageBox.Show(string.Format("There was an error loading the Edit Vew for BranchPatternPolicy:/n/n {0}", ex.Message)); result= false; } pvt.Duration = pvtrak.Elapsed; TellMe.Instance.TrackPageView(pvt); return result; }
public void PageViewTelemetryImplementsISupportSamplingContract() { var telemetry = new PageViewTelemetry(); Assert.NotNull(telemetry as ISupportSampling); }
public void PageViewTelemetrySuppliesConstructorThatTakesNameParameter() { string expectedPageName = "My page view"; var instance = new PageViewTelemetry(expectedPageName); Assert.Equal(expectedPageName, instance.Name); }
public void PageViewTelemetryImplementsISupportAdvancedSamplingContract() { var telemetry = new PageViewTelemetry(); Assert.IsNotNull(telemetry as ISupportAdvancedSampling); }
public void InitializeSetsLocationIpToUserHostAddressIfHeadersIsEmpty() { var module = new TestableClientIpHeaderTelemetryInitializer(new Dictionary<string, string>()); var telemetry = new PageViewTelemetry(); module.Initialize(telemetry); Assert.AreEqual("127.0.0.1", telemetry.Context.Location.Ip); }
public TelemetryForm() { _telemetryData = new PageViewTelemetry(this.Name); InitializeComponent(); }
/// <summary> /// Send information about the page viewed in the application. /// </summary> public void TrackPageView(PageViewTelemetry telemetry) { if (telemetry == null) { telemetry = new PageViewTelemetry(); } this.Track(telemetry); }
public void TrackPageViewSendsGivenPageViewTelemetryToTelemetryChannel() { var sentTelemetry = new List<ITelemetry>(); TelemetryClient client = this.InitializeTelemetryClient(sentTelemetry); var pageViewTelemetry = new PageViewTelemetry("TestName"); client.TrackPageView(pageViewTelemetry); var channelPageView = (PageViewTelemetry)sentTelemetry.Single(); Assert.Same(pageViewTelemetry, channelPageView); }
private void LogUsageEvent(AzurePSQoSEvent qos) { foreach (TelemetryClient client in TelemetryClients) { var pageViewTelemetry = new PageViewTelemetry { Name = qos.CommandName ?? "empty", Duration = qos.Duration, Timestamp = qos.StartTime }; LoadTelemetryClientContext(qos, pageViewTelemetry.Context); PopulatePropertiesFromQos(qos, pageViewTelemetry.Properties); client.TrackPageView(pageViewTelemetry); } }
public void RichPayloadEventSourcePageViewSentTest() { var client = new TelemetryClient(); client.InstrumentationKey = Guid.NewGuid().ToString(); using (var listener = new Microsoft.ApplicationInsights.TestFramework.TestEventListener()) { listener.EnableEvents(RichPayloadEventSource.Log.EventSourceInternal, EventLevel.Verbose, RichPayloadEventSource.Keywords.PageViews); var item = new PageViewTelemetry("TestPage"); item.Context.Properties.Add("property1", "value1"); item.Context.User.Id = "testUserId"; item.Context.Operation.Id = Guid.NewGuid().ToString(); client.TrackPageView(item); var actualEvent = listener.Messages.FirstOrDefault(); Assert.IsNotNull(actualEvent); Assert.AreEqual(client.InstrumentationKey, actualEvent.Payload[0]); object[] tags = actualEvent.Payload[1] as object[]; Assert.AreEqual("ai.user.id", ((Dictionary<string, object>)(tags[0]))["Key"]); Assert.AreEqual("testUserId", ((Dictionary<string, object>)(tags[0]))["Value"]); Assert.AreEqual("ai.operation.id", ((Dictionary<string, object>)(tags[1]))["Key"]); Assert.AreEqual(item.Context.Operation.Id, ((Dictionary<string, object>)(tags[1]))["Value"]); Assert.IsNotNull(actualEvent.Payload[2]); } }
public void PageViewTelemetryReturnsNonNullContext() { PageViewTelemetry item = new PageViewTelemetry(); Assert.NotNull(item.Context); }
public void PageViewTelemetryReturnsDefaultDurationAsTimespanZero() { PageViewTelemetry item = new PageViewTelemetry(); Assert.Equal(TimeSpan.Zero, item.Duration); }
private static void SerializePageViewTelemetry(PageViewTelemetry pageViewTelemetry, JsonWriter writer) { writer.WriteStartObject(); pageViewTelemetry.WriteTelemetryName(writer, PageViewTelemetry.TelemetryName); pageViewTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { writer.WriteStartObject(); // TODO: MetricTelemetry should write type as this.data.baseType once Common Schema 2.0 compliant. writer.WriteProperty("baseType", pageViewTelemetry.BaseType); writer.WritePropertyName("baseData"); { writer.WriteStartObject(); writer.WriteProperty("ver", pageViewTelemetry.Data.ver); writer.WriteProperty("name", pageViewTelemetry.Data.name); writer.WriteProperty("url", pageViewTelemetry.Data.url); writer.WriteProperty("duration", pageViewTelemetry.Data.duration); writer.WriteProperty("measurements", pageViewTelemetry.Data.measurements); writer.WriteProperty("properties", pageViewTelemetry.Data.properties); writer.WriteEndObject(); } writer.WriteEndObject(); } writer.WriteEndObject(); }
public void TrackPageView(string pageName) { var tel = new PageViewTelemetry(pageName); tel.Properties.Add(new KeyValuePair<string, string>("Machine_name", _machine)); tel.Properties.Add(new KeyValuePair<string, string>("User_name", _user)); tel.Properties.Add(new KeyValuePair<string, string>("Domain_name", _domain)); _telemetryClient.TrackPageView(tel); }
public void InitializeGetsIpFromFirstAvailableHeader() { var dictionary = new Dictionary<string, string> { { "CustomHeader1", "1.2.3.4, 2.3.4.5" }, { "CustomHeader2", "3.4.5.6" }, }; var module = new TestableClientIpHeaderTelemetryInitializer(dictionary); module.HeaderNames.Add("CustomHeader1"); module.HeaderNames.Add("CustomHeader2"); var telemetry = new PageViewTelemetry(); module.Initialize(telemetry); Assert.AreEqual("1.2.3.4", telemetry.Context.Location.Ip); }