Пример #1
0
        public IEnumerator BugFarmScene_MultipleSentryInit_SendEventForTheLatest()
        {
            yield return(SetupSceneCoroutine("1_BugFarm"));

            // We should use the sample Dsn for the nextDsn
            // to avoid static dsn.
            var options = AssetDatabase.LoadAssetAtPath(ScriptableSentryUnityOptions.GetConfigPath(ScriptableSentryUnityOptions.ConfigName),
                                                        typeof(ScriptableSentryUnityOptions)) as ScriptableSentryUnityOptions;

            var sourceEventCapture = new TestEventCapture();
            var sourceDsn          = "https://[email protected]/5439417";

            using var firstDisposable = InitSentrySdk(o =>
            {
                o.Dsn = sourceDsn;
                o.AddIntegration(new UnityApplicationLoggingIntegration(eventCapture: sourceEventCapture));
            });

            var nextEventCapture = new TestEventCapture();
            var nextDsn          = options?.Dsn;

            using var secondDisposable = InitSentrySdk(o =>
            {
                o.Dsn = nextDsn;
                o.AddIntegration(new UnityApplicationLoggingIntegration(eventCapture: nextEventCapture));
            });
            var testBehaviour = new GameObject("TestHolder").AddComponent <TestMonoBehaviour>();

            testBehaviour.gameObject.SendMessage(nameof(testBehaviour.TestException));

            Assert.NotNull(nextDsn);
            Assert.AreEqual(0, sourceEventCapture.Events.Count, sourceDsn);
            Assert.AreEqual(1, nextEventCapture.Events.Count);
        }
Пример #2
0
        private ScriptableSentryUnityOptions LoadOptions()
        {
            var options = AssetDatabase.LoadAssetAtPath(
                ScriptableSentryUnityOptions.GetConfigPath(SentryOptionsAssetName),
                typeof(ScriptableSentryUnityOptions)) as ScriptableSentryUnityOptions;

            if (options is null)
            {
                options = CreateOptions(SentryOptionsAssetName);
            }

            return(options);
        }
Пример #3
0
        public void Setup()
        {
            var options = AssetDatabase.LoadAssetAtPath(ScriptableSentryUnityOptions.GetConfigPath(ScriptableSentryUnityOptions.ConfigName),
                                                        typeof(ScriptableSentryUnityOptions)) as ScriptableSentryUnityOptions;

            if (options?.Enabled != true)
            {
                return;
            }

            Debug.Log("Disabling local options for the duration of the test.");
            _optionsToRestore         = options;
            _optionsToRestore.Enabled = false;
        }
Пример #4
0
        private void OnLostFocus()
        {
            // Make sure the actual config asset exists before validating/saving. Crashes the editor otherwise.
            if (!File.Exists(ScriptableSentryUnityOptions.GetConfigPath(SentryOptionsAssetName)))
            {
                new UnityLogger(new SentryOptions()).LogWarning("Sentry option could not been saved. " +
                                                                "The configuration asset is missing.");
                return;
            }

            Validate();

            EditorUtility.SetDirty(Options);
            EditorUtility.SetDirty(CliOptions);
            AssetDatabase.SaveAssets();
        }
Пример #5
0
        internal static ScriptableSentryUnityOptions CreateOptions(string?notDefaultConfigName = null)
        {
            if (!AssetDatabase.IsValidFolder("Assets/Resources"))
            {
                AssetDatabase.CreateFolder("Assets", "Resources");
            }

            if (!AssetDatabase.IsValidFolder($"Assets/Resources/{ScriptableSentryUnityOptions.ConfigRootFolder}"))
            {
                AssetDatabase.CreateFolder("Assets/Resources", ScriptableSentryUnityOptions.ConfigRootFolder);
            }

            var scriptableOptions = CreateInstance <ScriptableSentryUnityOptions>();

            SentryOptionsUtility.SetDefaults(scriptableOptions);

            AssetDatabase.CreateAsset(scriptableOptions,
                                      ScriptableSentryUnityOptions.GetConfigPath(notDefaultConfigName));
            AssetDatabase.SaveAssets();

            return(scriptableOptions);
        }
Пример #6
0
 public void Dispose()
 {
     Close(); // calls 'OnLostFocus' implicitly
     AssetDatabase.DeleteAsset(ScriptableSentryUnityOptions.GetConfigPath(SentryOptionsAssetName));
 }