当前位置: 首页>>代码示例>>C#>>正文


C# TelemetryClient.TrackEvent方法代码示例

本文整理汇总了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);
        }
开发者ID:emresevinc,项目名称:WindowsApp,代码行数:25,代码来源:MainPage.xaml.cs

示例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;
        }
开发者ID:michaelquinn5280,项目名称:Portfolio,代码行数:25,代码来源:MailHelper.cs

示例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();
        }
开发者ID:hendrikmaarand,项目名称:vso.io,代码行数:27,代码来源:RedirectController.cs

示例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);
 }
开发者ID:Arthur-Lee,项目名称:Baconit,代码行数:12,代码来源:TelemetryManager.cs

示例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);
        }
开发者ID:dmossberg,项目名称:MusicStoreMvcSource,代码行数:9,代码来源:Telemetry.cs

示例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;
        }
开发者ID:MikeCodesDotNet,项目名称:Beer-Drinkin,代码行数:42,代码来源:IdentityHelper.cs

示例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 ...");
        }
开发者ID:Zoltu,项目名称:bags-amazon-synchronizer,代码行数:11,代码来源:SynchronizerBase.cs

示例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? :\
     }
 }
开发者ID:drasticactions,项目名称:Pureisuteshon-App,代码行数:12,代码来源:ResultChecker.cs

示例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);
 }
开发者ID:Arthur-Lee,项目名称:Baconit,代码行数:16,代码来源:TelemetryManager.cs

示例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}
         });
 }
开发者ID:ZhiYuanHuang,项目名称:NuGetGallery,代码行数:13,代码来源:AppInsightsHealthIndicatorLogger.cs

示例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);
     }
 }
开发者ID:agangal,项目名称:TeamSnapV3,代码行数:50,代码来源:MainPage.xaml.cs

示例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();
        }
开发者ID:scout119,项目名称:ScratchDotNet,代码行数:15,代码来源:App.xaml.cs

示例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);
        }
开发者ID:ZhiYuanHuang,项目名称:NuGetGallery,代码行数:15,代码来源:AppInsightsHealthIndicatorLogger.cs

示例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");
        }
开发者ID:Sitecore,项目名称:Sitecore-Instance-Manager,代码行数:48,代码来源:Analytics.cs

示例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();
        }
开发者ID:girish,项目名称:NuGet.Jobs,代码行数:16,代码来源:ApplicationInsights.cs


注:本文中的Microsoft.ApplicationInsights.TelemetryClient.TrackEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。