本文整理汇总了C#中Microsoft.ApplicationInsights.TelemetryClient.TrackEvent方法的典型用法代码示例。如果您正苦于以下问题:C# TelemetryClient.TrackEvent方法的具体用法?C# TelemetryClient.TrackEvent怎么用?C# TelemetryClient.TrackEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.ApplicationInsights.TelemetryClient
的用法示例。
在下文中一共展示了TelemetryClient.TrackEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: kameraBtn_Click
private async void kameraBtn_Click(object sender, RoutedEventArgs e)
{
ApplicationView.GetForCurrentView().TitleBar.BackgroundColor = Colors.Red; // Uygulamanın title barı kırmızı olur
ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = false; // Ekran screen shoot alınamaz.
var client = new TelemetryClient();
client.TrackEvent("ResimCekButonunaTiklandi");
var camera = new CameraCaptureUI();
camera.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
camera.PhotoSettings.AllowCropping = true;
var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);
// resmi azure'a upload etmek için önce WindowsAzure.Storage 'ı nugetten ekle
// var acount= CloudStorageAccount.Parse("");
// var blobClient = account.CreateCloudBlobClient();
// var folder = blobClient.GetBlockBlobReference("images");
// burada azure'da blob'un içinde images klasorunde profile.jpg adında bir alan oluşturup çekilen fotoğraf buraya upload edilir.
// var blobFile = folder.GetBlockBlobReference("profile.jpg");
// blobFile.UploadFromFileAsync(file);
}
示例2: SendMessage
public static bool SendMessage(ContactAttempt contactAttempt)
{
var telemetry = new TelemetryClient();
bool success;
try
{
var contactInfo = _contactInfoRepository.GetContactInfo(contactAttempt.ProfileId);
MailMessage mailMessage = new MailMessage(contactAttempt.EmailAddress, contactInfo.EmailAddress, contactAttempt.Subject, contactAttempt.Message);
var client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["MailUserName"], ConfigurationManager.AppSettings["MailPassword"]);
client.Send(mailMessage);
telemetry.TrackEvent("EmailSent", GetEmailSentTrackingProperties(contactAttempt, contactInfo));
success = true;
}
catch(Exception ex)
{
telemetry.TrackException(ex);
success = false;
}
return success;
}
示例3: Redirect
public ActionResult Redirect(string id)
{
string subdomain = (string)Request.RequestContext.RouteData.Values["subdomain"];
if (subdomain == null ||
subdomain == "vso")
{
throw new HttpException(400, "Bad Request");
}
int number = 0;
if (int.TryParse(id, out number) == false)
{
throw new HttpException(400, "Bad Request");
}
TelemetryClient telemetry = new TelemetryClient();
telemetry.TrackEvent("Redirect", new Dictionary<string, string> {
{ "Account", subdomain },
{ "Work Item", id }
});
Response.StatusCode = 302;
Response.RedirectLocation = String.Format("https://{0}.visualstudio.com/DefaultCollection/_workitems/edit/{1}", subdomain, number);
return new ContentResult();
}
示例4: ReportEvent
/// <summary>
/// Reports an event with a string data to the telemetry system.
/// </summary>
/// <param name="eventName"></param>
public void ReportEvent(object component, string eventName, string data)
{
TelemetryClient client = new TelemetryClient();
EventTelemetry eventT = new EventTelemetry();
eventT.Name = component.GetType().Name + ":" + eventName;
eventT.Properties.Add("data", data);
client.TrackEvent(eventName);
}
示例5: LogServiceCallFailure
public static void LogServiceCallFailure(string url, int attempt)
{
TelemetryClient telemetry = new TelemetryClient();
var d = new Dictionary<string, string>();
d.Add("service call failed", url);
d.Add("attempt", attempt.ToString());
telemetry.TrackEvent(url, d);
}
示例6: FindSidAsync
public static async Task<string> FindSidAsync(IPrincipal claimsPrincipal, HttpRequestMessage request)
{
var aiTelemetry = new TelemetryClient();
var principal = claimsPrincipal as ClaimsPrincipal;
if (principal == null)
{
aiTelemetry.TrackEvent("FindSidAsync: ClaimsPrincipal is null!");
return string.Empty;
}
var match = principal.FindFirst("http://schemas.microsoft.com/identity/claims/identityprovider");
string provider;
if (match != null)
provider = match.Value;
else
{
aiTelemetry.TrackEvent("FindSidAsync: Can't find identity provider");
return string.Empty;
}
ProviderCredentials creds = null;
if (string.Equals(provider, "facebook", StringComparison.OrdinalIgnoreCase))
{
creds = await claimsPrincipal.GetAppServiceIdentityAsync<FacebookCredentials>(request);
}
else if (string.Equals(provider, "microsoftaccount", StringComparison.OrdinalIgnoreCase))
{
creds = await claimsPrincipal.GetAppServiceIdentityAsync<MicrosoftAccountCredentials>(request);
}
else if (string.Equals(provider, "twitter", StringComparison.OrdinalIgnoreCase))
{
creds = await claimsPrincipal.GetAppServiceIdentityAsync<TwitterCredentials>(request);
}
if (creds == null)
{
aiTelemetry.TrackEvent("FindSidAsync: Credentials not found");
return string.Empty;
}
return creds.UserId;
}
示例7: SynchronizerBase
public SynchronizerBase(Configuration config, TelemetryClient telemetryClient)
{
if(telemetryClient == null)
throw new ArgumentNullException("Telemetry client cannot be null.");
_telemetryClient = telemetryClient;
_config = config;
_amazonClient = new AmazonUtilities(_config.AmazonAccessKey, _config.AmazonSecretKey, _config.AmazonAssociateTag);
_watch = new Stopwatch();
_telemetryClient.TrackEvent("Synchronization System Initialized ...");
}
示例8: LogEvent
public static void LogEvent(string eventName, Dictionary<string, string> events)
{
try
{
var tc = new TelemetryClient();
tc.TrackEvent(eventName, events);
}
catch (Exception)
{
// Ignore errors? From logs? :\
}
}
示例9: ReportUnExpectedEvent
/// <summary>
/// Reports an event that might need to be looked at, an unexpected event.
/// </summary>
/// <param name="eventName"></param>
public void ReportUnExpectedEvent(object component, string eventName, Exception excpetion = null)
{
TelemetryClient client = new TelemetryClient();
EventTelemetry eventT = new EventTelemetry();
eventT.Name = component.GetType().Name + ":" + eventName;
eventT.Properties.Add("error", "unexpected");
if(excpetion != null)
{
eventT.Properties.Add("exception", excpetion.Message);
}
client.TrackEvent(eventName);
}
示例10: LogIncreaseHealth
public void LogIncreaseHealth(Uri endpoint, int health)
{
var telemetryClient = new TelemetryClient();
telemetryClient.TrackEvent("Endpoint Health Changed",
new Dictionary<string, string>()
{
{"Endpoint", endpoint.ToString()},
{"Event", "Increase"}
}, new Dictionary<string, double>()
{
{"Endpoint Health", health}
});
}
示例11: MainPage
public MainPage()
{
//test for network connectivity
this.InitializeComponent();
methodLibrary mlibrary = new methodLibrary();
//Debug.WriteLine("ConnectionProfile Info : " + networkInfo);
try
{
Package pack = Package.Current;
PackageId packId = pack.Id;
PackageVersion packVer = packId.Version;
string appver = String.Format("{0}.{1}.{2}.{3}", packVer.Major, packVer.Minor, packVer.Build, packVer.Revision);
if (ApplicationData.Current.LocalSettings.Values["AppVersion"] == null)
{
ApplicationData.Current.LocalSettings.Values["POSTCallMade"] = true;
ApplicationData.Current.LocalSettings.Values["RefreshClicked"] = "true";
ApplicationData.Current.LocalSettings.Values["AppVersion"] = appver;
}
else if ((string)ApplicationData.Current.LocalSettings.Values["AppVersion"] != appver)
{
ApplicationData.Current.LocalSettings.Values["POSTCallMade"] = true;
ApplicationData.Current.LocalSettings.Values["RefreshClicked"] = "true";
ApplicationData.Current.LocalSettings.Values["AppVersion"] = appver;
}
Debug.WriteLine("File.Exists" + File.Exists("fileUserClass.txt"));
Debug.WriteLine("isNullOrEmpty :" + String.IsNullOrEmpty((string)ApplicationData.Current.LocalSettings.Values["Tokens"]));
if (methodLibrary.checkNetworkConnectivity())
{
if (String.IsNullOrEmpty((string)ApplicationData.Current.LocalSettings.Values["Tokens"]))
{
//mlibrary.writeToLogFile((DateTime.UtcNow).ToString() + ": Token doesn't exist. Navigating to SignIn page");
RootPage.Navigate(typeof(signin));
}
else
{
Debug.WriteLine("in mainpage : " + ApplicationData.Current.LocalSettings.Values["Tokens"]);
//mlibrary.writeToLogFile((DateTime.UtcNow).ToString() + ": Token exists. Navigating to Dashboard page");
RootPage.Navigate(typeof(Dashboard));
}
}
else
networkProblems.Visibility = Visibility.Visible;
}
catch (Exception ex)
{
//mlibrary.writeToLogFile((DateTime.UtcNow).ToString() + ": Exception in MainPage.xaml.cs");
var tc = new TelemetryClient();
tc.TrackEvent("MainPage Exception : " + ex);
}
}
示例12: App
public App()
{
this.DispatcherUnhandledException += App_DispatcherUnhandledException;
_kernel = new StandardKernel(new Scratch.Common.Module(), new AppModule());
var telemetryClient = new TelemetryClient();
telemetryClient.InstrumentationKey = "2a8f2947-dfe9-48ef-8c8d-13184f9e46f9";
telemetryClient.Context.Session.Id = Guid.NewGuid().ToString();
telemetryClient.Context.Device.Language = Thread.CurrentThread.CurrentUICulture.Name;
telemetryClient.Context.Device.OperatingSystem = Environment.OSVersion.VersionString;
telemetryClient.Context.Device.ScreenResolution = string.Format("{0}x{1}", SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight);
telemetryClient.Context.Component.Version = typeof(App).Assembly.GetName().Version.ToString();
telemetryClient.TrackEvent("Application Start");
_kernel.Bind<TelemetryClient>().ToConstant(telemetryClient).InSingletonScope();
}
示例13: LogDecreaseHealth
public void LogDecreaseHealth(Uri endpoint, int health, Exception exception)
{
var telemetryClient = new TelemetryClient();
telemetryClient.TrackEvent("Endpoint Health Changed",
new Dictionary<string, string>()
{
{"Endpoint", endpoint.ToString()},
{"Event", "Decrease"}
}, new Dictionary<string, double>()
{
{"Endpoint Health", health}
});
QuietLog.LogHandledException(exception);
}
示例14: Start
public static void Start()
{
if (CoreApp.DoNotTrack())
{
return;
}
Log.Debug("Insights - starting");
try
{
var configuration = TelemetryConfiguration.Active;
Assert.IsNotNull(configuration, "configuration");
configuration.TelemetryChannel = new PersistenceChannel("Sitecore Instance Manager");
configuration.InstrumentationKey = "1447f72f-2d39-401b-91ac-4d5c502e3359";
var client = new TelemetryClient(configuration)
{
InstrumentationKey = "1447f72f-2d39-401b-91ac-4d5c502e3359"
};
Analytics.telemetryClient = client;
try
{
// ReSharper disable PossibleNullReferenceException
client.Context.Component.Version = string.IsNullOrEmpty(ApplicationManager.AppVersion) ? "0.0.0.0" : ApplicationManager.AppVersion;
client.Context.Session.Id = Guid.NewGuid().ToString();
client.Context.User.Id = Environment.MachineName + "\\" + Environment.UserName;
client.Context.User.AccountId = CoreApp.GetCookie();
client.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
// ReSharper restore PossibleNullReferenceException
client.TrackEvent("Start");
client.Flush();
}
catch (Exception ex)
{
client.TrackException(ex);
Log.Error(ex, "Error in app insights");
}
}
catch (Exception ex)
{
Log.Error(ex, "Error in app insights");
}
Log.Debug("Insights - started");
}
示例15: TrackPackageNotFound
public static void TrackPackageNotFound(string id, string version, string logFileName)
{
if (!_initialized)
{
return;
}
var telemetryClient = new TelemetryClient();
var telemetry = new EventTelemetry("PackageNotFound");
telemetry.Properties.Add("PackageId", id);
telemetry.Properties.Add("PackageVersion", version);
telemetry.Properties.Add("LogFile", logFileName);
telemetryClient.TrackEvent(telemetry);
telemetryClient.Flush();
}