コード例 #1
0
        private void handledUnthrownExceptionClick(object sender, RoutedEventArgs e)
        {
            Exception exception = new Exception("description");

            exception.Data.Add("MethodName", "methodName");
            Crittercism.LogHandledException(exception);
        }
コード例 #2
0
 private void handledExceptionClick(object sender,RoutedEventArgs e) {
     try {
         ThrowException();
     } catch (Exception ex) {
         Crittercism.LogHandledException(ex);
     }
 }
コード例 #3
0
        // Work will be called when a worker thread is started via
        // Thread thread = new Thread(new ThreadStart(Worker.Work));
        // thread.Start();
        public static void Work()
        {
            Console.WriteLine("Worker.Work running in its own thread.");
            Random random = new Random();

            while (true)
            {
                // Wait around 2 second.
                Thread.Sleep(random.Next(4000));
                if (random.Next(10) == 0)
                {
                    try {
                        string[] names = { "Breadcrumb", "Strawberry", "Seed", "Grape", "Lettuce" };
                        string   name  = names[random.Next(0, names.Length)];
                        Crittercism.LeaveBreadcrumb(name);
                    } catch (Exception e) {
                        Console.WriteLine("UNEXPECTED ERROR!!! " + e.Message);
                    };
                }
                else
                {
                    int i = 0;
                    int j = 5;
                    try {
                        int k = j / i;
                    } catch (Exception ex) {
                        Crittercism.LogHandledException(ex);
                    }
                }
            }
        }
コード例 #4
0
 partial void HandledExceptionButton_TouchUpInside(UIButton sender)
 {
     try {
         throw new Exception("Custom exception");
     } catch (Exception e) {
         Crittercism.LogHandledException(e);
     }
 }
コード例 #5
0
 public static void LogHandledException()
 {
     try {
         TestHelpers.ThrowException();
     } catch (Exception ex) {
         Crittercism.LogHandledException(ex);
     }
 }
コード例 #6
0
 private static void CommandLogHandledException(string arg)
 {
     if (arg.Length == 0)
     {
         arg = "Deep Error";
     }
     Console.WriteLine("LogHandledException: \"" + arg + "\"");
     try {
         ThrowException(arg);
     } catch (Exception e) {
         Crittercism.LogHandledException(e);
     }
 }
コード例 #7
0
 public void HandledUnthrownExceptionTest()
 {
     try {
         Exception exception = new Exception("description");
         exception.Data.Add("MethodName", "methodName");
         Crittercism.LogHandledException(exception);
     } catch (Exception) {
         // logHandledException should not throw its own exception
         // when passed an unthrown user created Exception object
         // with null stacktrace.
         Assert.Fail();
     }
 }
コード例 #8
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            var item = await SampleDataSource.GetItemAsync((string)e.NavigationParameter);

            this.DefaultViewModel["Item"] = item;
            Debug.WriteLine("UniqueId == " + item.UniqueId);
            Crittercism.LeaveBreadcrumb("UniqueId == " + item.UniqueId);
            if (item.UniqueId.Equals("SetUsername"))
            {
                Random   random = new Random();
                string[] names  = { "Blue Jay", "Chinchilla", "Chipmunk", "Gerbil", "Hamster", "Parrot", "Robin", "Squirrel", "Turtle" };
                string   name   = names[random.Next(0, names.Length)];
                Crittercism.SetUsername("Critter " + name);
            }
            else if (item.UniqueId.Equals("LeaveBreadcrumb"))
            {
                Random   random = new Random();
                string[] names  = { "Breadcrumb", "Strawberry", "Seed", "Grape", "Lettuce" };
                string   name   = names[random.Next(0, names.Length)];
                Crittercism.LeaveBreadcrumb(name);
            }
            else if (item.UniqueId.Equals("LogHandledException"))
            {
                {
                    try {
                        ThrowException();
                    } catch (Exception ex) {
                        Crittercism.LogHandledException(ex);
                    }
                }
            }
            else if (item.UniqueId.Equals("LogUnhandledException"))
            {
                ThrowException();
            }
        }
コード例 #9
0
        internal static void ItemClick(Frame frame, SampleDataItem item)
        {
            // Navigate to the appropriate destination page, configuring the new page
            // by passing required information as a navigation parameter
            string itemId = item.UniqueId;

            Debug.WriteLine("UniqueId == " + itemId);
            if (itemId.Equals("Set Username"))
            {
                Random   random = new Random();
                string[] names  = { "Blue Jay", "Chinchilla", "Chipmunk", "Gerbil", "Hamster", "Parrot", "Robin", "Squirrel", "Turtle" };
                string   name   = names[random.Next(0, names.Length)];
                Crittercism.SetUsername("Critter " + name);
            }
            else if (itemId.Equals("Leave Breadcrumb"))
            {
                Random   random = new Random();
                string[] names  = { "Breadcrumb", "Strawberry", "Seed", "Grape", "Lettuce" };
                string   name   = names[random.Next(0, names.Length)];
                Crittercism.LeaveBreadcrumb(name);
            }
            else if (itemId.Equals("Network Request"))
            {
                LogNetworkRequest();
            }
            else if (itemId.Equals("Handled Exception"))
            {
                {
                    try {
                        ThrowException();
                    } catch (Exception ex) {
                        Crittercism.LogHandledException(ex);
                    }
                }
            }
            else if (itemId.Equals("Begin Userflow"))
            {
                UserflowClick(frame, item);
            }
            else if (itemId.Equals("Crash"))
            {
                ThrowException();
            }
            else
            {
                // We are on "End Userflow" SectionPage .
                if (itemId.Equals("Succeed"))
                {
                    Crittercism.EndUserflow(userflowName);
                }
                else if (itemId.Equals("Fail"))
                {
                    Crittercism.FailUserflow(userflowName);
                }
                else if (itemId.Equals("Cancel"))
                {
                    Crittercism.CancelUserflow(userflowName);
                }
                ;
                userflowItem.Title = beginUserflowLabel;
                frame.GoBack();
            }
        }
コード例 #10
0
 /// <summary>
 /// Exception the specified exception, message, channel and context.
 /// </summary>
 /// <param name="exception">Exception.</param>
 /// <param name="message">Message.</param>
 /// <param name="channel">Channel.</param>
 /// <param name="context">Context.</param>
 public static void Exception(Exception exception, string message = "", LogChannel channel = LogChannel.General, UnityEngine.Object context = null)
 {
     DoLog(message, channel, LogType.Exception, exception, context);
     Crittercism.LogHandledException(exception);
 }
コード例 #11
0
        protected override void OnCreate(Bundle bundle)
        {
            // Initialize Crittercism
            Crittercism.Init(ApplicationContext, "YOUR APP ID GOES HERE");

            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            Button ButtonLeaveBreadcrumb = FindViewById <Button>(Resource.Id.ButtonBreadcrumb);

            ButtonLeaveBreadcrumb.Click += delegate(object sender, EventArgs e) {
                Crittercism.LeaveBreadcrumb("My Breadcrumb");
            };

            Button ButtonSetUserName = FindViewById <Button>(Resource.Id.ButtonSetUserName);

            ButtonSetUserName.Click += delegate {
                Crittercism.SetUserName("MrsCritter");
            };

            Button ButtonSetMetadata = FindViewById <Button>(Resource.Id.ButtonSetMetadata);

            ButtonSetMetadata.Click += delegate {
                Crittercism.SetMetadata("Game Level", "5");
            };

            Button ButtonCrash = FindViewById <Button>(Resource.Id.ButtonCrash);

            ButtonCrash.Click += delegate(object sender, EventArgs e) {
                CrashInnerException();
                //CrashDivideByZero();
                //CrashNullReference();
                //CrashIndexOutOfRange();
                //CrashCustomException();
            };

            Button ButtonHandledException = FindViewById <Button>(Resource.Id.ButtonHandledException);

            ButtonHandledException.Click += delegate(object sender, EventArgs e) {
                try {
                    CrashInnerException();
                } catch (System.Exception error) {
                    Crittercism.LogHandledException(error);
                }
            };

            Button ButtonLogNetworkRequest = FindViewById <Button>(Resource.Id.ButtonLogNetworkRequest);

            ButtonLogNetworkRequest.Click += delegate(object sender, EventArgs e) {
                Random   random  = new Random();
                string[] methods = { "GET", "POST", "HEAD" };
                string   method  = methods[random.Next(methods.Length)];
                string[] urls    = { "http://www.critterwebservice.com",
                                     "http://www.crittersearchengine.com/?ilove=critters",
                                     "http://www.critterdatingservice.com/nutlovers",
                                     "http://www.crittergourmetfood.com/nutsandberries.htm",
                                     "http://www.critterworldnews.com/summerfun",
                                     "http://www.crittermoviereviews.com/starring=mrscritter",
                                     "http://www.critterburrowdecor.com" };
                string   url           = urls[random.Next(urls.Length)];
                int[]    responseCodes = { 200, 202, 400, 404 };
                int      responseCode  = responseCodes[random.Next(responseCodes.Length)];
                Crittercism.LogNetworkRequest(
                    method,
                    url,
                    (long)(1000 * random.NextDouble()),
                    random.Next(10000),
                    random.Next(1000),
                    responseCode,
                    0);
            };

            Button ButtonBeginTransaction = FindViewById <Button>(Resource.Id.ButtonBeginTransaction);

            ButtonBeginTransaction.Click += delegate(object sender, EventArgs e) {
                Crittercism.BeginUserflow("Exercise");
            };

            Button ButtonEndTransaction = FindViewById <Button>(Resource.Id.ButtonEndTransaction);

            ButtonEndTransaction.Click += delegate(object sender, EventArgs e) {
                Crittercism.EndUserflow("Exercise");
            };

            Button ButtonFailTransaction = FindViewById <Button>(Resource.Id.ButtonFailTransaction);

            ButtonFailTransaction.Click += delegate(object sender, EventArgs e) {
                Crittercism.FailUserflow("Exercise");
            };

            Button ButtonSetTransactionValue = FindViewById <Button>(Resource.Id.ButtonSetTransactionValue);
            Button ButtonGetTransactionValue = FindViewById <Button>(Resource.Id.ButtonGetTransactionValue);

            ButtonSetTransactionValue.Click += delegate(object sender, EventArgs e) {
                Random random = new Random();
                Crittercism.SetUserflowValue("Exercise", random.Next(1000));
            };
            ButtonGetTransactionValue.Click += delegate(object sender, EventArgs e) {
                int value = Crittercism.GetUserflowValue("Exercise");
                ButtonGetTransactionValue.Text = value.ToString();
            };
        }