Пример #1
0
        public void Refresh()
        {
            if (Configuration == null || !Configuration.IsValid())
            {
                return;
            }

            if (Instance != null)
            {
                return;
            }

            Enabled = true;

            CaptureUnityMessages();
            _reportLimitWatcher = new ReportLimitWatcher(Convert.ToUInt32(Configuration.ReportPerMin));


            BacktraceApi = new BacktraceApi(
                credentials: new BacktraceCredentials(Configuration.GetValidServerUrl()),

#if UNITY_2018_4_OR_NEWER
                ignoreSslValidation: Configuration.IgnoreSslValidation
#else
                ignoreSslValidation: false
#endif
                );
            BacktraceApi.EnablePerformanceStatistics = Configuration.PerformanceStatistics;

            if (!Configuration.DestroyOnLoad)
            {
                DontDestroyOnLoad(gameObject);
                _instance = this;
            }
            if (Configuration.Enabled)
            {
                Database = GetComponent <BacktraceDatabase>();
                if (Database != null)
                {
                    Database.Reload();
                    Database.SetApi(BacktraceApi);
                    Database.SetReportWatcher(_reportLimitWatcher);
                }
            }

            _nativeClient = NativeClientFactory.GetNativeClient(Configuration, name);
            if (_nativeClient != null)
            {
                foreach (var attribute in _clientAttributes)
                {
                    _nativeClient.SetAttribute(attribute.Key, attribute.Value);
                }
            }
            if (Configuration.SendUnhandledGameCrashesOnGameStartup && isActiveAndEnabled)
            {
                var nativeCrashUplaoder = new NativeCrashUploader();
                nativeCrashUplaoder.SetBacktraceApi(BacktraceApi);
                StartCoroutine(nativeCrashUplaoder.SendUnhandledGameCrashesOnGameStartup(_previousSessionAttachments));
            }
        }
Пример #2
0
        public Client(INativeClient nativeClient)
        {
            MainThread          = Thread.CurrentThread;
            ForegroundStopwatch = new Stopwatch();
            BackgroundStopwatch = new Stopwatch();
            NativeClient        = nativeClient;
            User = new User {
                Id = SystemInfo.deviceUniqueIdentifier
            };
            Middleware      = new List <Middleware>();
            Metadata        = new Metadata(nativeClient);
            UniqueCounter   = new UniqueLogThrottle(Configuration);
            LogTypeCounter  = new MaximumLogTypeCounter(Configuration);
            SessionTracking = new SessionTracker(this);
            UnityMetadata.InitDefaultMetadata();
            Device.InitUnityVersion();
            NativeClient.SetMetadata(UnityMetadataKey, UnityMetadata.ForNativeClient());

            NativeClient.PopulateUser(User);

            SceneManager.sceneLoaded += SceneLoaded;
            Application.logMessageReceivedThreaded += MultiThreadedNotify;
            Application.logMessageReceived         += Notify;
            User.PropertyChanged += (obj, args) => { NativeClient.SetUser(User); };
            TimingTrackerObject   = new GameObject("Bugsnag app lifecycle tracker");
            TimingTrackerObject.AddComponent <TimingTrackerBehaviour>();
            // Run initial session check in next frame to allow potential configuration
            // changes to be completed first.
            try {
                var asyncHandler = MainThreadDispatchBehaviour.Instance();
                asyncHandler.Enqueue(RunInitialSessionCheck());
            } catch (System.Exception ex) {
                // Async behavior is not available in a test environment
            }
        }
Пример #3
0
        public Client(INativeClient nativeClient)
        {
            Stopwatch    = new Stopwatch();
            NativeClient = nativeClient;
            User         = new User {
                Id = SystemInfo.deviceUniqueIdentifier
            };
            Middleware      = new List <Middleware>();
            Metadata        = new Metadata();
            UniqueCounter   = new UniqueLogThrottle(Configuration);
            LogTypeCounter  = new MaximumLogTypeCounter(Configuration);
            SessionTracking = new SessionTracker(this);
            NativeClient.SetMetadata(UnityMetadataKey, UnityMetadata.ForNativeClient());

            NativeClient.PopulateUser(User);

            SceneManager.sceneLoaded += SceneLoaded;
            Application.logMessageReceivedThreaded += Notify;
        }
Пример #4
0
 internal Metadata(INativeClient nativeClient)
 {
     NativeClient = nativeClient;
 }
Пример #5
0
        public void Refresh()
        {
            if (Configuration == null || !Configuration.IsValid())
            {
                return;
            }

            if (Instance != null)
            {
                return;
            }

            Enabled  = true;
            _current = Thread.CurrentThread;
            CaptureUnityMessages();
            _reportLimitWatcher      = new ReportLimitWatcher(Convert.ToUInt32(Configuration.ReportPerMin));
            _clientReportAttachments = Configuration.GetAttachmentPaths();

            BacktraceApi = new BacktraceApi(
                credentials: new BacktraceCredentials(Configuration.GetValidServerUrl()),

#if UNITY_2018_4_OR_NEWER
                ignoreSslValidation: Configuration.IgnoreSslValidation
#else
                ignoreSslValidation: false
#endif
                );
            BacktraceApi.EnablePerformanceStatistics = Configuration.PerformanceStatistics;

            if (!Configuration.DestroyOnLoad)
            {
                DontDestroyOnLoad(gameObject);
                _instance = this;
            }
            var nativeAttachments = _clientReportAttachments.ToList()
                                    .Where(n => !string.IsNullOrEmpty(n))
                                    .OrderBy(System.IO.Path.GetFileName, StringComparer.InvariantCultureIgnoreCase).ToList();

            if (Configuration.Enabled)
            {
                Database = GetComponent <BacktraceDatabase>();
                if (Database != null)
                {
                    Database.Reload();
                    Database.SetApi(BacktraceApi);
                    Database.SetReportWatcher(_reportLimitWatcher);
                    if (Database.Breadcrumbs != null)
                    {
                        nativeAttachments.Add(Database.Breadcrumbs.GetBreadcrumbLogPath());
                    }
                    _nativeClient = NativeClientFactory.CreateNativeClient(Configuration, name, AttributeProvider.GenerateAttributes(false), nativeAttachments);
                    Database.EnableBreadcrumbsSupport();
                }
            }

            AttributeProvider.AddDynamicAttributeProvider(_nativeClient);

            if (Configuration.SendUnhandledGameCrashesOnGameStartup && isActiveAndEnabled)
            {
                var nativeCrashUplaoder = new NativeCrashUploader();
                nativeCrashUplaoder.SetBacktraceApi(BacktraceApi);
                StartCoroutine(nativeCrashUplaoder.SendUnhandledGameCrashesOnGameStartup());
            }
#if !UNITY_WEBGL
            EnableMetrics(false);
#endif
        }