public void Start() { ///Login in will set profile type try { EmotivDeviceManager.Setup(); } catch (NullEmotivDeviceException e) { LoginPanel.OnDismiss -= Start; LoginPanel.OnDismiss += Start; DisplayManager.Display(LoginPanel); Crashlytics.RecordCustomException("Emotiv Exception", "thrown exception", e.StackTrace); return; } ///Configure layout if (ApplyUserSettings) { MainConfig(); } ///Start selecting SelectionManager.AllowSelection = true; }
public static void LogError(string errorName, string errorDesc) { #if analytics Crashlytics.RecordCustomException(errorName, errorDesc, ""); //FirebaseAnalytics.LogEvent (FirebaseAnalytics., errorName, isFatal ? "fatal" : "not fatal"); ProjectManager.Log("[Analytics Error] " + errorName + ", " + errorDesc); #endif }
/// <summary> /// Method that generates log entries and crashes on Android, which are logged on Fabric.io (using Crashlytics) /// </summary> public void CrashMe() { StackFrame fr = new StackFrame(1, true); StackTrace st = new StackTrace(fr); Crashlytics.ThrowNonFatal(); Crashlytics.RecordCustomException("NotSoGood Exception", "I have no clue what just happened", st); Crashlytics.Log("Non Fatal Just Happened"); }
private static void HandleLog(string message, string stackTraceString, LogType type) { if (type == LogType.Exception) { Utils.Log(kitName, "Recording exception: " + message); string[] messageParts = getMessageParts(message); Crashlytics.RecordCustomException(messageParts[0], messageParts[1], stackTraceString); } }
// Contact the twitter api to send a message to the user public void Message(string msg) { try { authHandler.makeTwitterAPICallNoReturnVal(() => authHandler.Interactor.createDM(currentTweet.User.ScreenName, msg)); // send the message to the user DisplayManager.PushNotification("Messaged!"); } catch (Exception e) { DisplayManager.PushNotification("Failed to message: Connection error. Please check your internet."); Debug.Log("Failed to message " + e); Crashlytics.RecordCustomException("Twitter Exception", "thrown exception", e.StackTrace); } }
public void StartRecording(TestingSet TestingSet) { int record = TestingSet.RecordDuration; int rest = TestingSet.RestDuration; EmotivCommandType[] prompts = TestingSet.Prompts; if (OverideDurations) { record = RecordDuration; rest = RestDuration; } if (OveridePrompts) { prompts = Prompts; } LastTestingSessions = prompts; try { Title.text = ""; States = new List <IEmotivState> [prompts.Length]; for (int i = 0; i < States.Length; i++) { States[i] = new List <IEmotivState>(); } IsBreak = true; SessionIndex = 0; DeviceManager.ReaderPlugin.OnRead -= ListenToState; DeviceManager.ReaderPlugin.OnRead += ListenToState; StartCoroutine(StartReading(prompts, record, rest)); } catch (Exception e) { Debug.Log(e); Crashlytics.RecordCustomException("Profile Exception", "thrown exception", e.StackTrace); } }
private void ListenToState(IEmotivState e) { try { if (IsBreak) { return; } //Debug.Log(e.State); States[SessionIndex].Add(e); } catch (Exception x) { Debug.Log(x); Crashlytics.RecordCustomException("Profile Exception", "thrown exception", x.StackTrace); } }
/// <summary> /// Creates device either to random or Epoc device and insures connectivity. /// Call 'OnSuccess' when connection suceesd. /// </summary> public void Connect() { try { if (IsRandom) { Device = new RandomEmotivDevice(); } else { Device = new EPOCEmotivDevice(Username.text, Password.text, Profile.text); } string error = ""; bool suc = true; Device.OnConnectAttempted += (b, m) => { error = m; suc = b; }; Device.Connect(); if (suc) { title.text = "Connected!"; OnSucuess.Invoke(); } else { title.text = error; } } catch (Exception e) { title.text = e.ToString(); Crashlytics.RecordCustomException("Device Connection Exception", "thrown exception", e.StackTrace); } }
public static void ThrowNonFatal(string error) { Crashlytics.RecordCustomException("ERROR", error, error); Crashlytics.ThrowNonFatal(); }
// Populate the screen with the current set of messages public void setDMPage(int dmPage) { // Make sure the current page is within the bounds of the dm array if ((dmPage * 5) <= directMessages.Count) { // Destroy all children, which are existing objects foreach (GameObject messageObject in messageObjects) { try { GameObject.Destroy(messageObject); } catch (Exception e) { Debug.Log("Error destroying object: " + messageObject.name); Crashlytics.RecordCustomException("Twitter Exception", "thrown exception", e.StackTrace); } } // Get the user name of the current user. string currentUserName = authHandler.makeTwitterAPICall( () => authHandler.Interactor.getCurrentUser()); int numToStart = dmPage * 5; // find the starting index of the array, there are 5 messages per page int YPoint = -125; // Starting point for the objects // Loop over each of the messages for the page and create the UI objects for (int i = numToStart; (i < numToStart + 5) && (i < directMessages.Count); i++) { DirectMessage currentDM = directMessages[i]; if (currentDM.Sender.ScreenName == currentUserName) // if the message was sent by the current user { GameObject go = Instantiate(Resources.Load("currentUserMessage")) as GameObject; // load the prefab go.transform.SetParent(DMsHolder.transform, false); // set the prefab as a child of the list of dms Text messageText = go.transform.Find("messageText").GetComponent <Text>(); //set the text of the message messageText.text = currentDM.Text; Text username = go.transform.Find("username").GetComponent <Text>(); // set the username of the message username.text = currentDM.Sender.ScreenName; Text time = go.transform.Find("time").GetComponent <Text>(); // set the time of the message time.text = currentDM.CreatedAt.ToString("MM/dd/yy H:mm:ss"); go.transform.localPosition = new Vector3(0, YPoint); // put the message in the correct location messageObjects.Add(go); } else if (currentDM.Recipient.ScreenName == currentUserName) // if the message was sent by the other user { GameObject go = Instantiate(Resources.Load("otherUserMessage")) as GameObject; // load the prefab go.transform.SetParent(DMsHolder.transform, false); // set the prefab as a child of the list of dms Text messageText = go.transform.Find("messageText").GetComponent <Text>(); // set the text of the message messageText.text = currentDM.Text; Text username = go.transform.Find("username").GetComponent <Text>(); // set the username of the message username.text = currentDM.Sender.ScreenName; Text time = go.transform.Find("time").GetComponent <Text>(); // set the time of the message time.text = currentDM.CreatedAt.ToString("MM/dd/yy H:mm:ss"); go.transform.localPosition = new Vector3(0, YPoint); // put the message in the correct location messageObjects.Add(go); } YPoint += 63; // move the message to the next location for messages } } NewerDMs.enabled = dmPage > 0; NewerDMs.interactable = dmPage > 0; OlderDMs.enabled = ((dmPage + 1) * 5) <= directMessages.Count; OlderDMs.interactable = ((dmPage + 1) * 5) <= directMessages.Count; }
IEnumerator StartReading(EmotivCommandType[] Sessions, int RecordDuration, int RestDuration) { while (SessionIndex < Sessions.Length) { Title.text = "Break - Target " + Sessions[SessionIndex]; yield return(new WaitForSeconds(RestDuration)); IsBreak = false; Title.text = "Do " + Sessions[SessionIndex]; yield return(new WaitForSeconds(RecordDuration)); IsBreak = true; SessionIndex++; } try { List <EmotivCommandType> uniqueList = new List <EmotivCommandType>(); Dictionary <EmotivCommandType, Metrix> Metrix = new Dictionary <EmotivCommandType, Metrix>(); //Dictionary<EmotivCommandType, List<float>> TypeAvergaeAccuracy = new Dictionary<EmotivCommandType, List<float>>(); foreach (EmotivCommandType c in Sessions) { if (!uniqueList.Contains(c)) { uniqueList.Add(c); Metrix.Add(c, new Metrix()); //TypeAvergaeAccuracy.Add(c,new List<float>()); } } for (int i = 0; i < Sessions.Length; i++) { int TP = 0; int size = 0; Metrix met = Metrix[Sessions[i]]; for (int j = 0; j < States[i].Count; j++) { //count size++; //correct if (Sessions[i] == States[i][j].Command) { TP++; } if (States[i][j].Command == EmotivCommandType.PUSH) { if (States[i][j].Power > met.max) { met.max = States[i][j].Power; } if (States[i][j].Power < met.min) { met.min = States[i][j].Power; } met.totalPower += States[i][j].Power; } } met.TP += TP; met.size += size; Config.TargetCommand = Sessions[i]; met.Rates.Add(Calculator.Calculate(States[i], Config)); //TypeAvergaeAccuracy[Sessions[i]].Add(((float)TP) / size); } //printing results //Displaying result string textToDisplay = ""; /* useless shit * foreach(var d in Metrix) * { * textToDisplay += "Total " + d.Key.ToString() + " = " + (((float)d.Value.TP) / d.Value.size).ToString("0.00") + * "\n Max = " + d.Value.max.ToString("0.00") + * " Min = " + d.Value.min.ToString("0.00") + * " Avg = " + (d.Value.totalPower / d.Value.size).ToString("0.00") + "\n"; * }*/ //std? i failed stat Dictionary <EmotivCommandType, float> variance = new Dictionary <EmotivCommandType, float>(); Dictionary <EmotivCommandType, List <float> > AllowedVariance = new Dictionary <EmotivCommandType, List <float> >(); Dictionary <EmotivCommandType, float> averages = new Dictionary <EmotivCommandType, float>(); float allTotalVariance = 0; float ValidTotalVariance = 0; float OverlayLimit = .20f; Dictionary <EmotivCommandType, int> OutliersCount = new Dictionary <EmotivCommandType, int>(); int totalOutliers = 0; float MinPushRateOnPush = 1.01f; float MaxPushRateOnNeutral = -0.01f; float AllMinPushRateOnPush = 1.01f; float AllMaxPushRateOnNeutral = -0.01f; foreach (EmotivCommandType uc in uniqueList) { variance.Add(uc, 0); AllowedVariance.Add(uc, new List <float>()); OutliersCount.Add(uc, 0); averages.Add(uc, 0); //calculate average float averageAvg = 0; foreach (float avg in Metrix[uc].Rates) { averageAvg += avg; } averageAvg /= Metrix[uc].Rates.Count; averages[uc] = averageAvg; textToDisplay += uc.ToString() + " (" + averageAvg.ToString("0.00") + "),"; //calculate variance foreach (float avg in Metrix[uc].Rates) { textToDisplay += avg.ToString("0.00"); if (uc == EmotivCommandType.PUSH) { AllMinPushRateOnPush = Math.Min(AllMinPushRateOnPush, avg); } else if (uc == EmotivCommandType.NEUTRAL) { AllMaxPushRateOnNeutral = Math.Max(AllMaxPushRateOnNeutral, (1 - avg)); } variance[uc] += Math.Abs(averageAvg - avg); if (Math.Abs(avg - averageAvg) >= OverlayLimit) { textToDisplay += "*,"; OutliersCount[uc]++; totalOutliers++; //terribale continue; } textToDisplay += ","; AllowedVariance[uc].Add(Math.Abs(averageAvg - avg)); if (uc == EmotivCommandType.PUSH) { MinPushRateOnPush = Math.Min(MinPushRateOnPush, avg); } else if (uc == EmotivCommandType.NEUTRAL) { MaxPushRateOnNeutral = Math.Max(MaxPushRateOnNeutral, (1 - avg)); } } textToDisplay += "lul"; textToDisplay = textToDisplay.Replace(",lul", "\n"); // lul //variance[uc] /= Metrix[uc].Rates.Count; allTotalVariance += variance[uc]; ValidTotalVariance += AllowedVariance[uc].Sum(); //all /*textToDisplay += "All - MinFP: " + AllMinPushRateOnPush.ToString("0.00") + ", MaxFP: " + AllMaxPushRateOnNeutral.ToString("0.00") + ", V[" + uc.ToString() + "]: " + variance[uc].ToString("0.00") + "\n"; + // valid (exclude outliers) + textToDisplay += "Valid - MinFP: " + MinPushRateOnPush.ToString("0.00") + ", MaxFP: " + MaxPushRateOnNeutral.ToString("0.00") + ", V[" + uc.ToString() + "]: " + AllowedVariance[uc].Sum().ToString("0.00") + " Out: " + OutliersCount[uc] + "\n\n"; */ } summary = textToDisplay; //float AllValidity = AllMinPushRateOnPush - AllMaxPushRateOnNeutral; //float valifValidity = MinPushRateOnPush - MaxPushRateOnNeutral; Title.text = "Task 1 is completed! (=^◡^=)"; /* string summary1 = textToDisplay + "All - Average V:" + (allTotalVariance / uniqueList.Count).ToString("0.00") + ", Gap: " + AllValidity.ToString("0.00") + "\n" + "Valid - Average V:" + (ValidTotalVariance / uniqueList.Count).ToString("0.00") + ", Gap: " + valifValidity.ToString("0.00") + " Total Out: " + totalOutliers + "\n"; */ if (OnFinished != null) { OnFinished.Invoke(); } } catch (Exception e) { Debug.Log(e); Crashlytics.RecordCustomException("Profile Exception", "thrown exception", e.StackTrace); } }//end func
public void initializeAuthComponent() { if (Authenticator == null) { try { Authenticator = TwitterAuthenticator.Instance; } catch (Exception e) { Debug.Log(e.StackTrace); checkErrorCodes(e); } } if (Authenticator == null) { DisplayManager.PushNotification("Something went wrong with your twitter authentication. If this persists please contact the development team."); navigateToTwitterAuthPage("Authenticator is null"); } // See if the accesstoken and access secret have already been entered before string accesstoken = PlayerPrefs.GetString("Access Token"); string accessSecret = PlayerPrefs.GetString("Access Secret"); // If the access token and access secret have been set before, then load them back into the API if (Remember && !string.IsNullOrEmpty(accesstoken) && !string.IsNullOrEmpty(accessSecret)) { // Set the tokens to the previously received tokens makeTwitterAPICallNoReturnVal(() => Authenticator.setTokens(accesstoken, accessSecret)); try { Interactor = new TwitterInteractor(Authenticator); } catch (Exception e) { Debug.Log(e.StackTrace); checkErrorCodes(e); } if (Interactor == null) { DisplayManager.PushNotification("Something went wrong with your twitter authentication. If this persists please contact the development team."); navigateToTwitterAuthPage("Interactor is null"); } // Recover from errors having to do with exceptions in home timeline thread Interactor.getHomeTimelineNavigatable().OnExp = exception => { Debug.Log(exception.Message.ToString()); Crashlytics.RecordCustomException("Twitter Exception", "thrown exception", exception.StackTrace); DisplayManager.PushNotification("Something went wrong with your twitter implementation."); navigateToTwitterHome(); }; // Recover from errors having to do with exceptions in dm users thread Interactor.getDmUsersNavigatable().OnExp = exception => { Debug.Log(exception.Message.ToString()); Crashlytics.RecordCustomException("Twitter Exception", "thrown exception", exception.StackTrace); DisplayManager.PushNotification("Something went wrong with your twitter implementation."); navigateToTwitterHome(); }; navigateToTwitterHome(); } else // Otherwise, we need to authenticate the user. { navigateToTwitterAuthPage(); } }
private void checkErrorCodes(Exception e) { Crashlytics.RecordCustomException("Twitter Exception", "thrown exception", e.StackTrace); Debug.LogError(e.StackTrace); if (e.Message.Contains("Status is a duplicate")) { DisplayManager.PushNotification("Failed to tweet: Duplicate status!"); return; } else if (e.Message.Contains("Could not authenticate you")) { DisplayManager.PushNotification("Unable to authenticate you. Please try to log in again."); } else if (e.Message.Contains("User has been suspended")) { DisplayManager.PushNotification("Your account has been temporarily suspended. Please try again later."); } else if (e.Message.Contains("Rate limit exceeded.")) { DisplayManager.PushNotification("Sorry! We are experiencing heavy traffic. Please try again in a bit."); return; } else if (e.Message.Contains("Invalid or expired token")) { DisplayManager.PushNotification("Your session timed out. Please log back in."); } else if (e.Message.Contains("Unable to verify your credentials")) { DisplayManager.PushNotification("Invalid credentials. Please try again."); } else if (e.Message.Contains("Over capacity")) { DisplayManager.PushNotification("Twitter is temporarily over capacity. Please try again later."); } else if (e.Message.Contains("You are unable to follow more people at this time")) { DisplayManager.PushNotification("Sorry you can't follow this person at this time."); return; } else if (e.Message.Contains("User is over daily status update limit")) { DisplayManager.PushNotification("Sorry you have posted too many times today. Please try again tomorrow."); return; } else if (e.Message.Contains("The text of your direct message is over the max character limit")) { DisplayManager.PushNotification("Your message is too long! Please try a shorter status."); return; } else { if (e is WebException) { DisplayManager.PushNotification("Something is wrong with your internet connection, please fix it and try again."); } else if (e is TwitterException) { DisplayManager.PushNotification("Something went wrong with your authorization. Please authorize this application for Twitter again."); } else { DisplayManager.PushNotification("An unknown error has occurred. If this persists, please contact the dev team."); return; } } navigateToTwitterAuthPage(e.Message.ToString()); }