DesktopAnalytics.Analytics.ReportIpAddressOfThisMachineAsync C# (CSharp) Method

ReportIpAddressOfThisMachineAsync() private method

private ReportIpAddressOfThisMachineAsync ( ) : void
return void
		private void ReportIpAddressOfThisMachineAsync()
		{
			using (var client = new WebClient())
			{
				try
				{
					Uri uri;
					Uri.TryCreate(UrlThatReturnsExternalIpAddress, UriKind.Absolute, out uri);
					client.DownloadDataCompleted += (object sender, DownloadDataCompletedEventArgs e) =>
					{
						try
						{
							var externalIpAddress = System.Text.Encoding.UTF8.GetString(e.Result).Trim();
							Debug.WriteLine(String.Format("DesktopAnalytics: external ip = {0}", externalIpAddress));
							_options.Context.Add("ip", externalIpAddress);
							_propertiesThatGoWithEveryEvent.Add("ip", externalIpAddress);
						}
						catch (Exception)
						{
							// we get here when the user isn't online, or anything else prevents us from
							// getting their ip. Still worth reporting the launch in the later case.
							TrackWithApplicationProperties("Launch");
							return;
						}
						UpdateSegmentIOInformationOnThisUser();
						TrackWithApplicationProperties("Launch");
					};
					client.DownloadDataAsync(uri);

				}
				catch (Exception)
				{
					return;
				}
			}
		}