Example #1
0
        private void Awake()
        {
            Configuration = GetComponent <BacktraceClient>().Configuration;
            if (Configuration == null || !Configuration.IsValid())
            {
                Debug.LogWarning("Configuration doesn't exists or provided serverurl/token are invalid");
                _enable = false;
                return;
            }

            DatabaseSettings = new BacktraceDatabaseSettings(Configuration);
            if (DatabaseSettings == null)
            {
                _enable = false;
                return;
            }
            if (Configuration.CreateDatabase)
            {
                Directory.CreateDirectory(Configuration.DatabasePath);
            }
            _enable = Configuration.Enabled && BacktraceConfiguration.ValidateDatabasePath(Configuration.DatabasePath);

            if (!_enable)
            {
                return;
            }

            _lastConnection = Time.time;

            BacktraceDatabaseContext     = new BacktraceDatabaseContext(DatabasePath, DatabaseSettings.RetryLimit, DatabaseSettings.RetryOrder);
            BacktraceDatabaseFileContext = new BacktraceDatabaseFileContext(DatabasePath, DatabaseSettings.MaxDatabaseSize, DatabaseSettings.MaxRecordCount);
            BacktraceApi = new BacktraceApi(Configuration.ToCredentials(), Convert.ToUInt32(Configuration.ReportPerMin));
        }
Example #2
0
        /// <summary>
        /// Reload Backtrace database configuration. Reloading configuration is required, when you change
        /// BacktraceDatabase configuration options.
        /// </summary>
        public void Reload()
        {
            // validate configuration
            if (Configuration == null)
            {
                Configuration = GetComponent <BacktraceClient>().Configuration;
            }
            if (Configuration == null || !Configuration.IsValid())
            {
                Debug.LogWarning("Configuration doesn't exists or provided serverurl/token are invalid");
                Enable = false;
                return;
            }


            //setup database object
            DatabaseSettings = new BacktraceDatabaseSettings(Configuration);

            Enable = Configuration.Enabled && BacktraceConfiguration.ValidateDatabasePath(Configuration.DatabasePath);
            if (!Enable)
            {
                Debug.LogWarning("Cannot initialize database - invalid database configuration. Database is disabled");
                return;
            }
            CreateDatabaseDirectory();
            SetupMultisceneSupport();
            _lastConnection = Time.time;

            //Setup database context
            BacktraceDatabaseContext     = new BacktraceDatabaseContext(DatabasePath, DatabaseSettings.RetryLimit, DatabaseSettings.RetryOrder, DatabaseSettings.DeduplicationStrategy);
            BacktraceDatabaseFileContext = new BacktraceDatabaseFileContext(DatabasePath, DatabaseSettings.MaxDatabaseSize, DatabaseSettings.MaxRecordCount);
            BacktraceApi        = new BacktraceApi(Configuration.ToCredentials());
            _reportLimitWatcher = new ReportLimitWatcher(Convert.ToUInt32(Configuration.ReportPerMin));
        }
Example #3
0
        /// <summary>
        /// Initialize new Backtrace integration
        /// </summary>
        /// <param name="configuration">Backtrace configuration scriptable object</param>
        /// <param name="attributes">Client side attributes</param>
        /// <param name="gameObjectName">game object name</param>
        /// <returns>Backtrace client</returns>
        public static BacktraceClient Initialize(BacktraceConfiguration configuration, Dictionary <string, string> attributes = null, string gameObjectName = "BacktraceClient")
        {
            if (string.IsNullOrEmpty(gameObjectName))
            {
                throw new ArgumentException("Missing game object name");
            }

            if (configuration == null || string.IsNullOrEmpty(configuration.ServerUrl))
            {
                throw new ArgumentException("Missing valid configuration");
            }

            if (Instance != null)
            {
                return(Instance);
            }
            var             backtrackGameObject = new GameObject(gameObjectName, typeof(BacktraceClient), typeof(BacktraceDatabase));
            BacktraceClient backtraceClient     = backtrackGameObject.GetComponent <BacktraceClient>();

            backtraceClient.Configuration = configuration;
            if (configuration.Enabled)
            {
                BacktraceDatabase backtraceDatabase = backtrackGameObject.GetComponent <BacktraceDatabase>();
                backtraceDatabase.Configuration = configuration;
            }
            backtrackGameObject.SetActive(true);
            backtraceClient.Refresh();
            backtraceClient.SetAttributes(attributes);

            return(backtraceClient);
        }
Example #4
0
        void DrawBacktraceConfigSections()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(BacktraceIntegrationWindowLabels.LABEL_INTEGRATION_CONFIGSECTION_HEADER, BTEditorUtility.HeaderTextStyle);
            GUILayout.FlexibleSpace();

            backtraceConfiguration = (BacktraceConfiguration)EditorGUILayout
                                     .ObjectField(backtraceConfiguration, typeof(BacktraceConfiguration), false, new GUILayoutOption[]
            {
                GUILayout.MinWidth(position.width / 3)
            });

            EditorGUILayout.EndHorizontal();
            BTEditorUtility.DrawHorizontalUILine(Color.grey, 2, 1);
            if (backtraceConfiguration != null)
            {
                BTEditorUtility.DrawSubHeading("Settings for: " + backtraceConfiguration.name);

                if (backtraceConfigurationEditor == null)
                {
                    backtraceConfigurationEditor = UnityEditor.Editor.CreateEditor(backtraceConfiguration);
                }
                backtraceConfigurationEditor.OnInspectorGUI();
                backtraceConfigurationEditor.Repaint();
            }
            else
            {
                DrawConfigCreatorSection();
            }
        }
        public BacktraceDatabaseSettings(string databasePath, BacktraceConfiguration configuration)
        {
            if (configuration == null || string.IsNullOrEmpty(databasePath))
            {
                return;
            }

            DatabasePath   = databasePath;
            _configuration = configuration;
        }
        internal static INativeClient CreateNativeClient(BacktraceConfiguration configuration, string gameObjectName, IDictionary <string, string> attributes, ICollection <string> attachments)
        {
#if UNITY_EDITOR
            return(null);
#else
#if UNITY_ANDROID
            return(new Android.NativeClient(gameObjectName, configuration, attributes, attachments));
#elif UNITY_IOS
            return(new iOS.NativeClient(configuration, attributes, attachments));
#else
            return(null);
#endif
#endif
        }
Example #7
0
        internal static INativeClient GetNativeClient(BacktraceConfiguration configuration, string gameObjectName)
        {
#if UNITY_EDITOR
            return(null);
#else
#if UNITY_ANDROID
            return(new Android.NativeClient(gameObjectName, configuration));
#elif UNITY_IOS
            return(new iOS.NativeClient(gameObjectName, configuration));
#else
            return(null);
#endif
#endif
        }
Example #8
0
        public BacktraceDatabaseSettings(BacktraceConfiguration configuration)
        {
            if (configuration == null)
            {
                return;
            }

            DatabasePath    = configuration.DatabasePath;
            MaxRecordCount  = Convert.ToUInt32(configuration.MaxRecordCount);
            MaxDatabaseSize = configuration.MaxDatabaseSize;
            AutoSendMode    = configuration.AutoSendMode;
            RetryInterval   = Convert.ToUInt32(configuration.RetryInterval);
            RetryLimit      = Convert.ToUInt32(configuration.RetryLimit);
            RetryOrder      = configuration.RetryOrder;
        }
Example #9
0
        private static void CreateAsset(string fileName)
        {
            BacktraceConfiguration asset = ScriptableObject.CreateInstance <BacktraceConfiguration>();
            var currentProjectPath       = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (string.IsNullOrEmpty(currentProjectPath))
            {
                currentProjectPath = "Assets";
            }
            else if (File.Exists(currentProjectPath))
            {
                currentProjectPath = Path.GetDirectoryName(currentProjectPath);
            }
            var destinationPath = Path.Combine(currentProjectPath, fileName);

            if (File.Exists(destinationPath))
            {
                var files         = Directory.GetFiles(currentProjectPath);
                var lastFileIndex = files
                                    .Where(n =>
                                           Path.GetFileNameWithoutExtension(n).StartsWith(DEFAULT_CONFIGURATION_NAME) &&
                                           Path.GetExtension(n) == DEFAULT_EXTENSION_NAME)
                                    .Select(n =>
                {
                    int startIndex = n.IndexOf('(') + 1;
                    int endIndex   = n.IndexOf(')');
                    int result;
                    if (startIndex != 0 && endIndex != -1 && int.TryParse(n.Substring(startIndex, endIndex - startIndex), out result))
                    {
                        return(result);
                    }
                    return(0);
                })
                                    .DefaultIfEmpty().Max();

                lastFileIndex++;
                destinationPath = Path.Combine(currentProjectPath,
                                               string.Format("{0}({1}){2}", DEFAULT_CONFIGURATION_NAME, lastFileIndex, DEFAULT_EXTENSION_NAME));
            }
            Debug.Log(string.Format("Generating new Backtrace configuration file available in path: {0}",
                                    destinationPath));
            AssetDatabase.CreateAsset(asset, destinationPath);
            AssetDatabase.SaveAssets();
            Selection.activeObject = asset;
        }
        /// <summary>
        /// Reload Backtrace database configuration. Reloading configuration is required, when you change
        /// BacktraceDatabase configuration options.
        /// </summary>
        public void Reload()
        {
            // validate configuration
            if (Configuration == null)
            {
                Configuration = GetComponent <BacktraceClient>().Configuration;
            }
            if (Instance != null)
            {
                return;
            }
            if (Configuration == null || !Configuration.IsValid())
            {
                Enable = false;
                return;
            }

#if UNITY_SWITCH
            Enable = false;
#else
            Enable = Configuration.Enabled && InitializeDatabasePaths();
#endif
            if (!Enable)
            {
                if (Configuration.Enabled)
                {
                    Debug.LogWarning("Cannot initialize database - invalid path to database. Database is disabled");
                }
                return;
            }


            //setup database object
            DatabaseSettings = new BacktraceDatabaseSettings(DatabasePath, Configuration);
            SetupMultisceneSupport();
            _lastConnection = Time.time;
            LastFrameTime   = Time.time;
            //Setup database context
            BacktraceDatabaseContext     = new BacktraceDatabaseContext(DatabaseSettings);
            BacktraceDatabaseFileContext = new BacktraceDatabaseFileContext(DatabaseSettings.DatabasePath, DatabaseSettings.MaxDatabaseSize, DatabaseSettings.MaxRecordCount);
            BacktraceApi        = new BacktraceApi(Configuration.ToCredentials());
            _reportLimitWatcher = new ReportLimitWatcher(Convert.ToUInt32(Configuration.ReportPerMin));
        }
Example #11
0
    /// <summary>
    /// Full options constructor.
    /// </summary>
    /// <param name="backtraceConfiguration">BacktraceConfiguration</param>
    /// <param name="autowrite">Whether or not to spawn a background thread to write new breadcrumbs to disk</param>
    /// <param name="millisWaitBeforeWrite">How many millis to wait before spawning a write thread</param>
    /// <param name="backtraceConfiguration">BacktraceConfiguration</param>
    /// <returns>BreadcrumbsWriter</returns>
    public BreadcrumbsWriter(BacktraceConfiguration backtraceConfiguration, bool autowrite, int millisWaitBeforeWrite, long maxFileSize)
    {
        this.waitBeforeWrite = millisWaitBeforeWrite;
        this.autoWrite       = autowrite;
        this.maxFileSize     = maxFileSize;
        string breadcrumbsDir = backtraceConfiguration.GetFullDatabasePath() + BREADCRUMBS_DIRNAME;

        if (!Directory.Exists(breadcrumbsDir))
        {
            Directory.CreateDirectory(breadcrumbsDir);
        }

        breadcrumbsFilePath = breadcrumbsDir + Path.DirectorySeparatorChar + BREADCRUMB_FILENAME;
        if (File.Exists(breadcrumbsFilePath))
        {
            breadcrumbsByteSize = new FileInfo(breadcrumbsFilePath).Length;
            breadcrumbs         = new LinkedList <string>(File.ReadAllLines(breadcrumbsFilePath));
        }
        else
        {
            breadcrumbs = new LinkedList <string>();
        }
    }
Example #12
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            SerializedProperty serverUrl = serializedObject.FindProperty("ServerUrl");

            serverUrl.stringValue = BacktraceConfiguration.UpdateServerUrl(serverUrl.stringValue);
            EditorGUILayout.PropertyField(serverUrl, new GUIContent(BacktraceConfigurationLabels.LABEL_SERVER_URL));
            if (!BacktraceConfiguration.ValidateServerUrl(serverUrl.stringValue))
            {
                EditorGUILayout.HelpBox("Please insert valid Backtrace server url!", MessageType.Error);
            }

            EditorGUILayout.PropertyField(
                serializedObject.FindProperty("HandleUnhandledExceptions"),
                new GUIContent(BacktraceConfigurationLabels.LABEL_HANDLE_UNHANDLED_EXCEPTION));

            EditorGUILayout.PropertyField(
                serializedObject.FindProperty("ReportPerMin"),
                new GUIContent(BacktraceConfigurationLabels.LABEL_REPORT_PER_MIN));

            GUIStyle clientAdvancedSettingsFoldout = new GUIStyle(EditorStyles.foldout);

            showClientAdvancedSettings = EditorGUILayout.Foldout(showClientAdvancedSettings, "Client advanced settings", clientAdvancedSettingsFoldout);
            if (showClientAdvancedSettings)
            {
#if UNITY_2018_4_OR_NEWER
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("IgnoreSslValidation"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_IGNORE_SSL_VALIDATION));
#endif
#if UNITY_ANDROID || UNITY_IOS
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("HandleANR"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_HANDLE_ANR));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("OomReports"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_HANDLE_OOM));

#if UNITY_2019_2_OR_NEWER && UNITY_ANDROID
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("SymbolsUploadToken"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_SYMBOLS_UPLOAD_TOKEN));
#endif
#endif
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("UseNormalizedExceptionMessage"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_USE_NORMALIZED_EXCEPTION_MESSAGE));
#if UNITY_STANDALONE_WIN
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("SendUnhandledGameCrashesOnGameStartup"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_SEND_UNHANDLED_GAME_CRASHES_ON_STARTUP));
#endif

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("ReportFilterType"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_REPORT_FILTER));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("NumberOfLogs"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_NUMBER_OF_LOGS));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("PerformanceStatistics"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_PERFORMANCE_STATISTICS));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("DestroyOnLoad"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_DESTROY_CLIENT_ON_SCENE_LOAD));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("Sampling"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_SAMPLING));

                SerializedProperty gameObjectDepth = serializedObject.FindProperty("GameObjectDepth");
                EditorGUILayout.PropertyField(gameObjectDepth, new GUIContent(BacktraceConfigurationLabels.LABEL_GAME_OBJECT_DEPTH));

                if (gameObjectDepth.intValue < -1)
                {
                    EditorGUILayout.HelpBox("Please insert value greater or equal -1", MessageType.Error);
                }
            }
#if !UNITY_SWITCH
            SerializedProperty enabled = serializedObject.FindProperty("Enabled");
            EditorGUILayout.PropertyField(enabled, new GUIContent(BacktraceConfigurationLabels.LABEL_ENABLE_DATABASE));
            bool databaseEnabled = enabled.boolValue;
#else
            bool databaseEnabled = false;
#endif
            if (databaseEnabled)
            {
                SerializedProperty databasePath = serializedObject.FindProperty("DatabasePath");
                EditorGUILayout.PropertyField(databasePath, new GUIContent(BacktraceConfigurationLabels.LABEL_PATH));
                if (string.IsNullOrEmpty(databasePath.stringValue))
                {
                    EditorGUILayout.HelpBox("Please insert valid Backtrace database path!", MessageType.Error);
                }


                GUIStyle databaseFoldout = new GUIStyle(EditorStyles.foldout);
                showDatabaseSettings = EditorGUILayout.Foldout(showDatabaseSettings, "Advanced database settings", databaseFoldout);
                if (showDatabaseSettings)
                {
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("DeduplicationStrategy"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_DEDUPLICATION_RULES));

#if UNITY_STANDALONE_WIN
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("MinidumpType"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_MINIDUMP_SUPPORT));
#endif

#if UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("AddUnityLogToReport"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_ADD_UNITY_LOG));
#endif

#if UNITY_ANDROID || UNITY_IOS
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("CaptureNativeCrashes"),
                        new GUIContent(BacktraceConfigurationLabels.CAPTURE_NATIVE_CRASHES));
#endif
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("AutoSendMode"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_AUTO_SEND_MODE));

                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("CreateDatabase"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_CREATE_DATABASE_DIRECTORY));

                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("GenerateScreenshotOnException"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_GENERATE_SCREENSHOT_ON_EXCEPTION));

                    SerializedProperty maxRecordCount = serializedObject.FindProperty("MaxRecordCount");
                    EditorGUILayout.PropertyField(maxRecordCount, new GUIContent(BacktraceConfigurationLabels.LABEL_MAX_REPORT_COUNT));

                    SerializedProperty maxDatabaseSize = serializedObject.FindProperty("MaxDatabaseSize");
                    EditorGUILayout.PropertyField(maxDatabaseSize, new GUIContent(BacktraceConfigurationLabels.LABEL_MAX_DATABASE_SIZE));

                    SerializedProperty retryInterval = serializedObject.FindProperty("RetryInterval");
                    EditorGUILayout.PropertyField(retryInterval, new GUIContent(BacktraceConfigurationLabels.LABEL_RETRY_INTERVAL));

                    EditorGUILayout.LabelField("Backtrace database require at least one retry.");
                    SerializedProperty retryLimit = serializedObject.FindProperty("RetryLimit");
                    EditorGUILayout.PropertyField(retryLimit, new GUIContent(BacktraceConfigurationLabels.LABEL_RETRY_LIMIT));

                    SerializedProperty retryOrder = serializedObject.FindProperty("RetryOrder");
                    EditorGUILayout.PropertyField(retryOrder, new GUIContent(BacktraceConfigurationLabels.LABEL_RETRY_ORDER));
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            SerializedProperty serverUrl = serializedObject.FindProperty("ServerUrl");

            serverUrl.stringValue = BacktraceConfiguration.UpdateServerUrl(serverUrl.stringValue);
            EditorGUILayout.PropertyField(serverUrl, new GUIContent(LABEL_SERVER_URL));
            if (!BacktraceConfiguration.ValidateServerUrl(serverUrl.stringValue))
            {
                EditorGUILayout.HelpBox("Please insert valid Backtrace server url!", MessageType.Error);
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("ReportPerMin"), new GUIContent(LABEL_REPORT_PER_MIN));

            SerializedProperty unhandledExceptions = serializedObject.FindProperty("HandleUnhandledExceptions");

            EditorGUILayout.PropertyField(unhandledExceptions, new GUIContent(LABEL_HANDLE_UNHANDLED_EXCEPTION));


#if UNITY_2018_4_OR_NEWER
            SerializedProperty sslValidation = serializedObject.FindProperty("IgnoreSslValidation");
            EditorGUILayout.PropertyField(sslValidation, new GUIContent(LABEL_IGNORE_SSL_VALIDATION));
#endif

            SerializedProperty deduplicationStrategy = serializedObject.FindProperty("DeduplicationStrategy");
            EditorGUILayout.PropertyField(deduplicationStrategy, new GUIContent(LABEL_DEDUPLICATION_RULES));

            SerializedProperty destroyOnLoad = serializedObject.FindProperty("DestroyOnLoad");
            EditorGUILayout.PropertyField(destroyOnLoad, new GUIContent(LABEL_DESTROY_CLIENT_ON_SCENE_LOAD));


            SerializedProperty gameObjectDepth = serializedObject.FindProperty("GameObjectDepth");
            EditorGUILayout.PropertyField(gameObjectDepth, new GUIContent(LABEL_GAME_OBJECT_DEPTH));

            if (gameObjectDepth.intValue < -1)
            {
                EditorGUILayout.HelpBox("Please insert value greater or equal -1", MessageType.Error);
            }

            SerializedProperty enabled = serializedObject.FindProperty("Enabled");
            EditorGUILayout.PropertyField(enabled, new GUIContent(LABEL_ENABLE_DATABASE));

            if (enabled.boolValue)
            {
                EditorGUILayout.LabelField("Backtrace Database settings.");

                SerializedProperty databasePath = serializedObject.FindProperty("DatabasePath");
                EditorGUILayout.PropertyField(databasePath, new GUIContent(LABEL_PATH));
                if (string.IsNullOrEmpty(databasePath.stringValue))
                {
                    EditorGUILayout.HelpBox("Please insert valid Backtrace database path!", MessageType.Error);
                }

#if UNITY_STANDALONE_WIN
                EditorGUILayout.HelpBox("Minidump support works only on Windows machines.", MessageType.Warning);
                SerializedProperty miniDumpType = serializedObject.FindProperty("MinidumpType");
                EditorGUILayout.PropertyField(miniDumpType, new GUIContent(LABEL_MINIDUMP_SUPPORT));
#endif

                SerializedProperty autoSendMode = serializedObject.FindProperty("AutoSendMode");
                EditorGUILayout.PropertyField(autoSendMode, new GUIContent(LABEL_AUTO_SEND_MODE));


                SerializedProperty createDatabase = serializedObject.FindProperty("CreateDatabase");
                EditorGUILayout.PropertyField(createDatabase, new GUIContent(LABEL_CREATE_DATABASE_DIRECTORY));

                SerializedProperty maxRecordCount = serializedObject.FindProperty("MaxRecordCount");
                EditorGUILayout.PropertyField(maxRecordCount, new GUIContent(LABEL_MAX_REPORT_COUNT));

                SerializedProperty maxDatabaseSize = serializedObject.FindProperty("MaxDatabaseSize");
                EditorGUILayout.PropertyField(maxDatabaseSize, new GUIContent(LABEL_MAX_DATABASE_SIZE));

                SerializedProperty retryInterval = serializedObject.FindProperty("RetryInterval");
                EditorGUILayout.PropertyField(retryInterval, new GUIContent(LABEL_RETRY_INTERVAL));

                EditorGUILayout.LabelField("Backtrace database require at least one retry.");
                SerializedProperty retryLimit = serializedObject.FindProperty("RetryLimit");
                EditorGUILayout.PropertyField(retryLimit, new GUIContent(LABEL_RETRY_LIMIT));

                SerializedProperty retryOrder = serializedObject.FindProperty("RetryOrder");
                EditorGUILayout.PropertyField(retryOrder, new GUIContent(LABEL_RETRY_ORDER));
            }

            serializedObject.ApplyModifiedProperties();
        }
Example #14
0
        void DrawConfigCreatorSection()
        {
            BTEditorUtility.DrawSubHeading(BacktraceIntegrationWindowLabels.LABEL_INTEGRATION_CONFIGCREATIONSECTION_SUBHEADER);

            // Buttons
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(BacktraceIntegrationWindowLabels.LABEL_INTEGRATION_CONFIGCREATION_BUTTON,
                                 BTEditorUtility.DefineLayoutSizingConstraints(10, 30, 60, position.width / 2)))
            {
                string fullPath = pathToCreateScriptable + configFileName + ".asset";
                if (File.Exists(fullPath))
                {
                    windowLogMessage = fullPath + " already exists! No configuration asset was created.";
                    logMessageType   = MessageType.Warning;
                    return;
                }

                if (!Directory.Exists(pathToCreateScriptable))
                {
                    Directory.CreateDirectory(pathToCreateScriptable);
                    windowLogMessage = pathToCreateScriptable + " directory created.\n" + fullPath + " created successfully!";
                }
                else
                {
                    windowLogMessage = fullPath + " created successfully!";
                }
                logMessageType = MessageType.Info;

                BacktraceConfiguration configAsset = ScriptableObject.CreateInstance <BacktraceConfiguration>();
                AssetDatabase.CreateAsset(configAsset, fullPath);
                AssetDatabase.SaveAssets();

                EditorUtility.FocusProjectWindow();
                Selection.activeObject       = configAsset;
                backtraceConfiguration       = configAsset;
                backtraceConfigurationEditor = UnityEditor.Editor.CreateEditor(backtraceConfiguration);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();


            // Text fields
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            EditorStyles.textField.wordWrap = true;
            GUILayout.Label(BacktraceIntegrationWindowLabels.LABEL_INTEGRATION_CONFIGNAME);
            configFileName = GUILayout.TextField(configFileName,
                                                 BTEditorUtility.DefineLayoutSizingConstraints(10, 20, 60, 600));
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            GUILayout.Label(BacktraceIntegrationWindowLabels.LABEL_INTEGRATION_ASSETPATH);

            pathToCreateScriptable = GUILayout.TextField(pathToCreateScriptable,
                                                         BTEditorUtility.DefineLayoutSizingConstraints(10, 20, 60, 600));
            EditorStyles.textField.wordWrap = false;
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            SerializedProperty serverUrl = serializedObject.FindProperty("ServerUrl");

            serverUrl.stringValue = BacktraceConfiguration.UpdateServerUrl(serverUrl.stringValue);
            EditorGUILayout.PropertyField(serverUrl, new GUIContent(LABEL_SERVER_URL));
            if (!BacktraceConfiguration.ValidateServerUrl(serverUrl.stringValue))
            {
                EditorGUILayout.HelpBox("Please insert valid Backtrace server url!", MessageType.Error);
            }

            SerializedProperty token = serializedObject.FindProperty("Token");

            EditorGUILayout.PropertyField(token, new GUIContent(LABEL_TOKEN));
            if (!BacktraceConfiguration.ValidateToken(token.stringValue))
            {
                EditorGUILayout.HelpBox("Token requires at least 64 characters!", MessageType.Warning);
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("ReportPerMin"), new GUIContent(LABEL_REPORT_PER_MIN));


            SerializedProperty unhandledExceptions = serializedObject.FindProperty("HandleUnhandledExceptions");

            EditorGUILayout.PropertyField(unhandledExceptions, new GUIContent(LABEL_HANDLE_UNHANDLED_EXCEPTION));

            SerializedProperty enabled = serializedObject.FindProperty("Enabled");

            EditorGUILayout.PropertyField(enabled, new GUIContent(LABEL_ENABLE_DATABASE));

            if (enabled.boolValue)
            {
                EditorGUILayout.LabelField("Backtrace Database settings.");

                SerializedProperty databasePath = serializedObject.FindProperty("DatabasePath");
                EditorGUILayout.PropertyField(databasePath, new GUIContent(LABEL_PATH));
                if (string.IsNullOrEmpty(databasePath.stringValue))
                {
                    EditorGUILayout.HelpBox("Please insert valid Backtrace database path!", MessageType.Error);
                }

                SerializedProperty autoSendMode = serializedObject.FindProperty("AutoSendMode");
                EditorGUILayout.PropertyField(autoSendMode, new GUIContent(LABEL_AUTO_SEND_MODE));


                SerializedProperty createDatabase = serializedObject.FindProperty("CreateDatabase");
                EditorGUILayout.PropertyField(createDatabase, new GUIContent(LABEL_CREATE_DATABASE_DIRECTORY));

                SerializedProperty maxRecordCount = serializedObject.FindProperty("MaxRecordCount");
                EditorGUILayout.PropertyField(maxRecordCount, new GUIContent(LABEL_MAX_REPORT_COUNT));

                SerializedProperty maxDatabaseSize = serializedObject.FindProperty("MaxDatabaseSize");
                EditorGUILayout.PropertyField(maxDatabaseSize, new GUIContent(LABEL_MAX_DATABASE_SIZE));

                SerializedProperty retryInterval = serializedObject.FindProperty("RetryInterval");
                EditorGUILayout.PropertyField(retryInterval, new GUIContent(LABEL_RETRY_INTERVAL));

                EditorGUILayout.LabelField("Backtrace database require at least one retry.");
                SerializedProperty retryLimit = serializedObject.FindProperty("RetryLimit");
                EditorGUILayout.PropertyField(retryLimit, new GUIContent(LABEL_RETRY_LIMIT));

                SerializedProperty retryOrder = serializedObject.FindProperty("RetryOrder");
                EditorGUILayout.PropertyField(retryOrder, new GUIContent(LABEL_RETRY_ORDER));
            }

            serializedObject.ApplyModifiedProperties();
        }
Example #16
0
 /// <summary>
 /// Minimal constructor. Sets default of autowrite, 100ms wait before write and 32kB max breadcrumb file size
 /// </summary>
 /// <param name="backtraceConfiguration">BacktraceConfiguration</param>
 /// <returns>BreadcrumbsWriter</returns>
 public BreadcrumbsWriter(BacktraceConfiguration backtraceConfiguration) : this(backtraceConfiguration, true, 100, 32 * 1024)
 {
 }